// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!!

#include <r3/binders/auto.h>
#include <r3/binders/stub.h>
#include <gh_global.h>
#include <spdlog/spdlog.h>

extern "C" {
undefined4 crt_createProgramHeap(undefined4 param_1) {
  return gh_stub_impl_cdecl<undefined4>((void *)0x00404902, param_1);
}
undefined4 ioinit(void) {
  return gh_stub_impl_cdecl<undefined4>((void *)0x004046bf);
}
void crt_initConsole(void) {
  return gh_stub_impl_cdecl<void>((void *)0x00404503);
}
LPSTR crt_setupEnv(void) {
  return gh_stub_impl_cdecl<LPSTR>((void *)0x004043d1);
}
undefined4 crt_main2(void) {
  return gh_stub_impl_cdecl<undefined4>((void *)0x00404184);
}
undefined4 crt_main1(void) {
  return gh_stub_impl_cdecl<undefined4>((void *)0x004040cb);
}
void c_static_init(void) {
  return gh_stub_impl_cdecl<void>((void *)0x004027be);
}

char* crt_0(void) {
  return gh_stub_impl_cdecl<char*>((void *)0x00404073);
}

void gh_pre_main(void) {
  DWORD DVar1;
  int iVar2;
  LPSTR *cmdline;
  uint showCmd;
  HMODULE hInstance;
  HINSTANCE hPrevInstance;
  _STARTUPINFOA local_60;
  undefined1 *local_1c;
  void *pvStack_14;
  undefined1 *puStack_10;
  undefined *puStack_c;
  undefined4 local_8;

  local_8 = 0xffffffff;
  // This sets up the unhandled exception handler i think?
  // puStack_c = &DAT_00597ca0;
  // puStack_10 = &LAB_00404a58;
  // pvStack_14 = ExceptionList;
  // local_1c = &stack0xffffff88;
  // ExceptionList = &pvStack_14;
  DVar1 = GetVersion();
  DWORD_005cf980 = DVar1 >> 8 & 0xff;
  DWORD_005cf97c = DVar1 & 0xff;
  DWORD_005cf978 = DWORD_005cf97c * 0x100 + DWORD_005cf980;
  DWORD_005cf974 = DVar1 >> 0x10;
  iVar2 = crt_createProgramHeap(1);
  if (iVar2 == 0) {
    SPDLOG_ERROR("crt_createProgramHeap failed");
    exit(0);
  }
  iVar2 = ioinit();
  if (iVar2 == 0) {
    SPDLOG_ERROR("_ioinit failed");
    exit(0);
  }
  local_8 = 0;
  crt_initConsole();
  g_crt_cmdLine = GetCommandLineA();
  PTR_005cf9b4 = crt_setupEnv();
  crt_main2();
  crt_main1();
  c_static_init();
  local_60.dwFlags = 0;
  GetStartupInfoA(&local_60);
  cmdline = (LPSTR *)crt_0();
  if ((local_60.dwFlags & 1) == 0) {
    showCmd = 10;
  } else {
    showCmd = (uint)local_60.wShowWindow;
  }
  hPrevInstance = (HINSTANCE)0x0;
  hInstance = GetModuleHandleA((LPCSTR)0x0);
}
}