HalpLbrInitialize

CHAR __stdcall HalpLbrInitialize(){
  INT64(__fastcall *v0)(INT64); 
  unsigned __int64 v1; 
  int v2; 
  int v3; 
  UINT8 v5; 
  CHAR v6; 
  char v7[6]; 
  INT32 v8[4]; 
  LOBYTE(v0) = HalpFeatureBits;
  v6 = 0;
  v7[0] = 0;
  v5 = 0;
  HalpLbrIsInitialized = 0;
  *(_OWORD *)v8 = 0i64;
  if( (HalpFeatureBits & 1) == 0 )
    return(char)v0;
  if( (unsigned __int8)HalpIsHvPresent() )
  {
    LOBYTE(v0) = HviGetHypervisorFeatures(v8);
    if( (v8[3] & 0x4000000) == 0 )
      return(char)v0;
  }
  LOBYTE(v0) = HalpGetCpuInfo(&v6, 0i64, (UINT8 *)v7, &v5);
  if( !(_BYTE)v0 || v5 != 2 )
    return(char)v0;
  if( v6 != 6 )
    goto LABEL_28;
  LOBYTE(v0) = v7[0];
  if( (unsigned __int8)v7[0] <= 0x56u )
  {
    if( v7[0] == 86 || v7[0] == 60 || v7[0] == 61 || v7[0] == 63 )
      goto LABEL_9;
    if( (unsigned __int8)v7[0] <= 0x44u )
      goto LABEL_28;
    if( (unsigned __int8)v7[0] <= 0x46u || v7[0] == 71 )
      goto LABEL_9;
    if( v7[0] != 78 )
    {
      if( v7[0] != 79 )
      {
        if( v7[0] != 85 )
          goto LABEL_28;
        goto LABEL_27;
      }
LABEL_9:
      HalpLbrStackSize = 16;
      goto LABEL_10;
    }
LABEL_27:
    HalpLbrStackSize = 32;
    goto LABEL_28;
  }
  if( v7[0] == 94 )
    goto LABEL_27;
  if( (unsigned __int8)v7[0] > 0x65u )
  {
    if( (unsigned __int8)v7[0] <= 0x67u )
      goto LABEL_39;
    if( (unsigned __int8)v7[0] > 0x7Cu )
    {
      if( (unsigned __int8)v7[0] <= 0x7Eu )
        goto LABEL_39;
      switch( (unsigned __int8)v7[0] )
      {
        case 0x8Eu:
          goto LABEL_27;
        case 0x9Du:
          goto LABEL_39;
        case 0x9Eu:
          goto LABEL_27;
        case 0x9Fu:
LABEL_39:
          HalpLbrStackSize = 32;
          goto LABEL_10;
      }
    }
  }
LABEL_28:
  if( !HalpLbrStackSize )
    return(char)v0;
LABEL_10:
  LOBYTE(v0) = EAX(__cpuid(10, 0));
  if( (_BYTE)v0 )
  {
    HalpLbrIsFreezeLegacy = (unsigned __int8)v0 <= 3u;
    if( (ECX(__cpuid(1, 0)) & 0x8000) != 0 )
    {
      v1 = __readmsr(0x345u);
      v2 = (v1 & 0x3F) - 3;
      if( v2 )
      {
        v3 = v2 - 1;
        if( !v3 )
        {
          HalpLbrMostSignificantFromAddrBit = 60;
          goto LABEL_15;
        }
        if( v3 != 2 )
          goto LABEL_15;
        HalpLbrMostSignificantToAddrBit = 47;
      }
      HalpLbrMostSignificantFromAddrBit = 62;
    }
LABEL_15:
    HalpLbrIsInitialized = 1;
    off_140C00988[0] = (__int64(__fastcall *)())HalpLbrCaptureStack;
    off_140C00990[0] = (__int64(__fastcall *)())HalpLbrClearStack;
    off_140C00998[0] = (__int64(__fastcall *)())HalpLbrConfigureRecording;
    off_140C009A0[0] = (__int64(__fastcall *)())HalpLbrGetInformation;
    off_140C009A8[0] = (__int64(__fastcall *)())HalpLbrResumeRecording;
    off_140C009B0[0] = (__int64(__fastcall *)())HalpLbrStartRecording;
    v0 = HalpLbrStopRecording;
    off_140C009B8[0] = (__int64(__fastcall *)())HalpLbrStopRecording;
  }
  return(char)v0;
}

Referenced by:

HalpInitializeProfiling