bsearch_s

void *__cdecl bsearch_s(
        const void *Key,
        const void *Base,
        rsize_t NumOfElements,
        rsize_t SizeOfElements,
        int (__cdecl *PtFuncCompare)(void *, const void *, const void *),
        void *Context){
  __int64 v6; 
  unsigned __int64 v7; 
  char *v8; 
  char *v9; 
  unsigned __int64 v11; 
  bool v12; 
  char *v13; 
  int v14; 

  v6 = *(_QWORD *)&SizeOfElements;
  v7 = *(_QWORD *)&NumOfElements;
  v8 = (char *)Base + *(_QWORD *)&SizeOfElements * (*(_QWORD *)&NumOfElements - 1i64);
  v9 = (char *)Base;
  if( (Base || !*(_QWORD *)&NumOfElements) && *(_QWORD *)&SizeOfElements && PtFuncCompare )
  {
    while( v9 <= v8 )
    {
      v11 = v7 >> 1;
      if( !(v7 >> 1) )
      {
        if( !v7 )
          return 0i64;
        if( ((unsigned int(__fastcall *)(void *, const void *, char *))PtFuncCompare)(Context, Key, v9) )
          return 0i64;
        return v9;
      }
      v12 = (v7 & 1) == 0;
      v7 = v11 - 1;
      if( !v12 )
        v7 = v11;
      v13 = &v9[v6 * v7];
      v14 = ((__int64(__fastcall *)(void *, const void *, char *))PtFuncCompare)(Context, Key, v13);
      if( !v14 )
        return &v9[v6 * v7];
      if( v14 >= 0 )
      {
        v9 = &v13[v6];
        v7 = v11;
      }
      else
      {
        v8 = &v13[-v6];
      }
    }
  }
  else
  {
    xHalTimerWatchdogStop(0i64, 0i64);
  }
  return 0i64;
}

Referenced by:

RtlGuardCheckExceptionHandler
RtlGuardCheckLongJumpTarget
RtlVerifyUserUnwindTarget
SeQuerySecureBootPlatformManifest