// Recovered function: KbcEmulDriverEntry
// Address: 0x43C
// Signature: __int64 EFIAPI KbcEmulDriverEntry(__int64 n33, EFI_SYSTEM_TABLE *SystemTable)

__int64 EFIAPI KbcEmulDriverEntry(__int64 n33, EFI_SYSTEM_TABLE *SystemTable)
{
  EFI_RUNTIME_SERVICES *RuntimeServices; // rax
  __int64 Status; // rbx
  __int64 EventStatus; // rax
  __int64 AssertLine; // rdx
  __int64 CreateEventStatus; // rax
  _BYTE v8[56]; // [rsp+30h] [rbp-38h] BYREF
  __int64 UsbSupportDataSize; // [rsp+70h] [rbp+8h] BYREF

  UsbSupportDataSize = n33; /*0x43c*/
  if ( SystemTable_0 ) /*0x44e*/
  {
    RuntimeServices = (EFI_RUNTIME_SERVICES *)RuntimeServices_0; /*0x46f*/
  }
  else
  {
    SystemTable_0 = (__int64)SystemTable; /*0x450*/
    BootServices_0 = (__int64)SystemTable->BootServices; /*0x45b*/
    RuntimeServices = SystemTable->RuntimeServices; /*0x462*/
    RuntimeServices_0 = (__int64)RuntimeServices; /*0x466*/
  }
  UsbSupportDataSize = 33; /*0x47b*/
  if ( ((__int64 (__fastcall *)(const __int16 *, void *, _QWORD, __int64 *, _BYTE *))RuntimeServices->GetVariable)( /*0x4b0*/
         L"UsbSupport",
         &unk_11B0,
         0,
         &UsbSupportDataSize,
         v8) < 0
    || !v8[7] )
  {
    return 0; /*0x5c6*/
  }
  Status = (*(__int64 (__fastcall **)(void *, _QWORD, __int64 *))(BootServices_0 + 320))(&unk_1190, 0, &qword_1258); /*0x4d3*/
  if ( Status >= 0 ) /*0x4d9*/
  {
    byte_11F9 = 0; /*0x4f0*/
    EventStatus = (*(__int64 (__fastcall **)(void *, void *, _QWORD, __int64 (__fastcall **)()))(BootServices_0 + 128))( /*0x505*/
           &unk_1200,
           &unk_1170,
           0,
           off_11C0);
    Status = EventStatus; /*0x50b*/
    if ( EventStatus >= 0 ) /*0x511*/
    {
      if ( byte_11F9 ) /*0x54b*/
      {
        word_11E0 = -29952; /*0x552*/
        n43 = 43; /*0x55e*/
        return Status; /*0x565*/
      }
      CreateEventStatus = (*(__int64 (__fastcall **)(__int64, __int64, __int64 (__fastcall *)()))(BootServices_0 + 368))( /*0x59a*/
             512,
             8,
             KbcEmulTimerCallback);
      Status = CreateEventStatus; /*0x5a0*/
      if ( CreateEventStatus >= 0 ) /*0x5a6*/
        return Status; /*0x5a6*/
      DebugAssertError(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", CreateEventStatus); /*0x5b7*/
      AssertLine = 162; /*0x5bc*/
    }
    else
    {
      DebugAssertError(0x80000000LL, "\nASSERT_EFI_ERROR (Status = %r)\n", EventStatus); /*0x522*/
      AssertLine = 143; /*0x527*/
    }
    DebugPrintAssert("e:\\hs\\AmiModulePkg\\KbcEmulation\\KbcEmulDxe.c", AssertLine, "!EFI_ERROR (Status)"); /*0x53a*/
  }
  return Status; /*0x5cb*/
}
