SdbpBinarySearchFirst

INT64 __fastcall SdbpBinarySearchFirst(INT64 a1, UINT64 a2, UINT64 a3, INT64 *a4){
  int v4; 
  unsigned int v5; 
  int v6; 
  int v7; 
  *(_DWORD *)a4 = -1;
  v4 = a2 - 1;
  v5 = 0;
  v6 = 0;
  if( (int)a2 - 1 >= 0 )
  {
    while( 1 )
    {
      v7 = (v4 + v6) / 2;
      if( v7 < 0 || v7 >= (unsigned int)a2 )
        break;
      if( a3 == *(_QWORD *)(a1 + 12i64 * v7) )
      {
        if( !v7 || (v4 = v7 - 1, *(_QWORD *)(a1 + 12i64 * v7 - 12) != a3) )
        {
          v5 = 1;
          *(_DWORD *)a4 = v7;
          return v5;
        }
      }
      else if( a3 >= *(_QWORD *)(a1 + 12i64 * v7) )
      {
        v6 = v7 + 1;
      }
      else
      {
        v4 = v7 - 1;
      }
      if( v4 < v6 )
        return v5;
    }
  }
  return 0i64;
}

Referenced by:

SdbpGetFirstIndexedRecord