// File: Ciaxur[P]yagb-emu/include/imgui/backends/imgui_impl_sdl.cpp
// Function: ImGui_ImplSDL2_Init(SDL_Window*)
static bool ImGui_ImplSDL2_Init(SDL_Window* window)
{
    g_Window = window;

    // Setup backend capabilities flags
    ImGuiIO& io = ImGui::GetIO();
    io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors;       // We can honor GetMouseCursor() values (optional)
    io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos;        // We can honor io.WantSetMousePos requests (optional, rarely used)
    io.BackendPlatformName = "imgui_impl_sdl";

    // Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
    io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB;
    io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
    io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT;
    io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP;
    io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN;
    io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP;
    io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN;
    io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME;
    io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END;
    io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT;
    io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE;
    io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
    io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
    io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
    io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
    io.KeyMap[ImGuiKey_KeyPadEnter] = SDL_SCANCODE_KP_ENTER;
    io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
    io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
    io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V;
    io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X;
    io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
    io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;

    io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
    io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
    io.ClipboardUserData = NULL;

    // Load mouse cursors
    g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
    g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
    g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
    g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
    g_MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
    g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
    g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
    g_MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
    g_MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);

    // Check and store if we are on Wayland
    g_MouseCanUseGlobalState = strncmp(SDL_GetCurrentVideoDriver(), "wayland", 7) != 0;

#ifdef _WIN32
    SDL_SysWMinfo wmInfo;
    SDL_VERSION(&wmInfo.version);
    SDL_GetWindowWMInfo(window, &wmInfo);
    io.ImeWindowHandle = wmInfo.info.win.window;
#else
    (void)window;
#endif

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, 0xb1a51(%rip)     # 0x219bf8
callq 0xcb1a0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
leaq 0x28a9b(%rip), %rcx     # 0x190c70
movq %rcx, 0xd0(%rax)
movq -0x10(%rbp), %rax
movl $0x2b, 0x34(%rax)
movq -0x10(%rbp), %rax
movl $0x50, 0x38(%rax)
movq -0x10(%rbp), %rax
movl $0x4f, 0x3c(%rax)
movq -0x10(%rbp), %rax
movl $0x52, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x51, 0x44(%rax)
movq -0x10(%rbp), %rax
movl $0x4b, 0x48(%rax)
movq -0x10(%rbp), %rax
movl $0x4e, 0x4c(%rax)
movq -0x10(%rbp), %rax
movl $0x4a, 0x50(%rax)
movq -0x10(%rbp), %rax
movl $0x4d, 0x54(%rax)
movq -0x10(%rbp), %rax
movl $0x49, 0x58(%rax)
movq -0x10(%rbp), %rax
movl $0x4c, 0x5c(%rax)
movq -0x10(%rbp), %rax
movl $0x2a, 0x60(%rax)
movq -0x10(%rbp), %rax
movl $0x2c, 0x64(%rax)
movq -0x10(%rbp), %rax
movl $0x28, 0x68(%rax)
movq -0x10(%rbp), %rax
movl $0x29, 0x6c(%rax)
movq -0x10(%rbp), %rax
movl $0x58, 0x70(%rax)
movq -0x10(%rbp), %rax
movl $0x4, 0x74(%rax)
movq -0x10(%rbp), %rax
movl $0x6, 0x78(%rax)
movq -0x10(%rbp), %rax
movl $0x19, 0x7c(%rax)
movq -0x10(%rbp), %rax
movl $0x1b, 0x80(%rax)
movq -0x10(%rbp), %rax
movl $0x1c, 0x84(%rax)
movq -0x10(%rbp), %rax
movl $0x1d, 0x88(%rax)
movq -0x10(%rbp), %rax
leaq 0xbfe(%rip), %rcx       # 0x168ee0
movq %rcx, 0x100(%rax)
movq -0x10(%rbp), %rax
leaq 0xc0c(%rip), %rcx       # 0x168f00
movq %rcx, 0xf8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x108(%rax)
xorl %edi, %edi
callq 0xd670
movq %rax, 0xb18f8(%rip)     # 0x219c10
movl $0x1, %edi
callq 0xd670
movq %rax, 0xb18ef(%rip)     # 0x219c18
movl $0x9, %edi
callq 0xd670
movq %rax, 0xb18e6(%rip)     # 0x219c20
movl $0x8, %edi
callq 0xd670
movq %rax, 0xb18dd(%rip)     # 0x219c28
movl $0x7, %edi
callq 0xd670
movq %rax, 0xb18d4(%rip)     # 0x219c30
movl $0x6, %edi
callq 0xd670
movq %rax, 0xb18cb(%rip)     # 0x219c38
movl $0x5, %edi
callq 0xd670
movq %rax, 0xb18c2(%rip)     # 0x219c40
movl $0xb, %edi
callq 0xd670
movq %rax, 0xb18b9(%rip)     # 0x219c48
movl $0xa, %edi
callq 0xd670
movq %rax, 0xb18b0(%rip)     # 0x219c50
callq 0xd8e0
movq %rax, %rdi
leaq 0x288d0(%rip), %rsi     # 0x190c7f
movl $0x7, %edx
callq 0xd220
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0xaa9db(%rip)      # 0x212da2
movb $0x1, %al
andb $0x1, %al
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)