// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rdi, 0x553d4(%rip)     # 0xea7e8
callq 0x37e82
orb $0x6, 0x4(%rax)
leaq 0x254bd(%rip), %rcx     # 0xba8e1
movq %rcx, 0xd0(%rax)
movaps 0x2529e(%rip), %xmm0    # 0xba6d0
movups %xmm0, 0x34(%rax)
movaps 0x252a3(%rip), %xmm0    # 0xba6e0
movups %xmm0, 0x44(%rax)
movaps 0x252a8(%rip), %xmm0    # 0xba6f0
movups %xmm0, 0x54(%rax)
movaps 0x252ad(%rip), %xmm0    # 0xba700
movups %xmm0, 0x64(%rax)
movaps 0x252b2(%rip), %xmm0    # 0xba710
movups %xmm0, 0x74(%rax)
movabsq $0x1d0000001c, %rcx     # imm = 0x1D0000001C
movq %rcx, 0x84(%rax)
leaq 0x78a(%rip), %rcx       # 0x95c04
movq %rcx, 0x100(%rax)
leaq 0x789(%rip), %rcx       # 0x95c11
movq %rcx, 0xf8(%rax)
andq $0x0, 0x108(%rax)
xorl %edi, %edi
callq 0xc5e0
movq %rax, 0x5535b(%rip)     # 0xea800
pushq $0x1
popq %rdi
callq 0xc5e0
movq %rax, 0x55354(%rip)     # 0xea808
pushq $0x9
popq %rdi
callq 0xc5e0
movq %rax, 0x5534d(%rip)     # 0xea810
pushq $0x8
popq %rdi
callq 0xc5e0
movq %rax, 0x55346(%rip)     # 0xea818
pushq $0x7
popq %rdi
callq 0xc5e0
movq %rax, 0x5533f(%rip)     # 0xea820
pushq $0x6
popq %rdi
callq 0xc5e0
movq %rax, 0x55338(%rip)     # 0xea828
pushq $0x5
popq %rdi
callq 0xc5e0
movq %rax, 0x55331(%rip)     # 0xea830
pushq $0xb
popq %rdi
callq 0xc5e0
movq %rax, 0x5532a(%rip)     # 0xea838
pushq $0xa
popq %rdi
callq 0xc5e0
movq %rax, 0x55323(%rip)     # 0xea840
callq 0xc840
leaq 0x253c7(%rip), %rsi     # 0xba8f0
pushq $0x7
popq %rdx
movq %rax, %rdi
callq 0xc1d0
testl %eax, %eax
setne 0x4e603(%rip)           # 0xe3b40
popq %rbp
retq