RtlpGetRetpolineStubsFunctionTable

INT64 __fastcall RtlpGetRetpolineStubsFunctionTable(VOID *a1, INT64 a2, INT64 a3, UINT64 a4, INT64 *a5){
  __int64 v6; 
  __int64 v8; 
  __int64 v9; 
  unsigned __int64 v10; 
  unsigned __int64 v11; 
  unsigned __int64 v12; 
  int v13; 
  unsigned __int64 v14; 
  int v15; 
  __int64 v16; 
  unsigned __int64 v17; 
  unsigned __int64 v18; 
  INT64 result; 
  unsigned int *v20; 
  __int64 v21; 
  int v22; 
  int v23; 
  INT64 v24; 
  unsigned int *v25; 
  int v26[6]; 
  v26[0] = 0;
  v6 = (unsigned int)a4;
  LODWORD(v8) = RtlImageDirectoryEntryToData(a1, 1u, 3u, (UINT64 *)v26);
  v9 = v8;
  if( !v8 )
    return 0i64;
  if( !v26[0] )
    return 0i64;
  v10 = (unsigned int)v26[0] / 0xCui64;
  v11 = (unsigned int)v26[0] % 0xCui64;
  if( v11 )
    return 0i64;
  v12 = a3 - a2;
  v13 = v10 - 1;
  v14 = v12 + v6;
  if( (int)v10 - 1 < 0 )
    return 0i64;
  while( 1 )
  {
    v15 = ((int)v11 + v13) >> 1;
    v16 = v15;
    v17 = *(unsigned int *)(v9 + 12i64 * v15);
    if( v14 > v17 )
      break;
    v13 = v15 - 1;
LABEL_9:
    if( v13 < (int)v11 )
      return 0i64;
  }
  v18 = *(unsigned int *)(v9 + 12i64 * v15 + 4);
  if( v12 >= v18 )
  {
    LODWORD(v11) = v15 + 1;
    goto LABEL_9;
  }
  if( v12 > v17 || v14 < v18 )
    return 0i64;
  if( v15 > 0 )
  {
    v20 = (unsigned int *)(v9 - 12 + 12i64 * v15);
    do
    {
      if( *v20 < v12 )
        break;
      --v15;
      --v16;
      v20 -= 3;
    }
    while( v16 > 0 );
  }
  v21 = v15;
  v22 = 1;
  v23 = v15 + 1;
  v24 = v9 + 12 * v21;
  if( v23 < v10 )
  {
    v25 = (unsigned int *)(v24 + 16);
    do
    {
      if( *v25 > v14 )
        break;
      ++v23;
      ++v22;
      v25 += 3;
    }
    while( v23 < v10 );
  }
  result = v24;
  *(_DWORD *)a5 = v22;
  return result;
}

Referenced by:

RtlCopyRetpolineStubsUnwindInfo
RtlCreateRetpolineStubsFunctionTable