/*
 * File: binsearch_u32u8.c
 *
 * Code generated for Simulink model 'COMR_RtcCalc'.
 *
 * Model version                  : A1.0F_0
 * Simulink Coder version         : 8.11F (R2016b) 25-Aug-2016
 * C/C++ source code generated on : Fri May 24 10:20:56 2019
 */

#include "rtwtypes.h"
#include "binsearch_u32u8.h"

uint32_T binsearch_u32u8(uint8_T u, const uint8_T bp[], uint32_T startIndex,
  uint32_T maxIndex)
{
  uint32_T bpIndex;
  uint32_T iRght;
  uint32_T bpIdx;

  /* Binary Search */
  bpIdx = startIndex;
  bpIndex = 0U;
  iRght = maxIndex;
  while (iRght - bpIndex > 1U) {
    if (u < bp[bpIdx]) {
      iRght = bpIdx;
    } else {
      bpIndex = bpIdx;
    }

    bpIdx = (iRght + bpIndex) >> 1U;
  }

  return bpIndex;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
