// File: Ciaxur[P]yagb-emu/include/imgui/backends/imgui_impl_sdl.cpp
// Function: ImGui_ImplSDL2_UpdateGamepads()
static void ImGui_ImplSDL2_UpdateGamepads()
{
    ImGuiIO& io = ImGui::GetIO();
    memset(io.NavInputs, 0, sizeof(io.NavInputs));
    if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
        return;

    // Get gamepad
    SDL_GameController* game_controller = SDL_GameControllerOpen(0);
    if (!game_controller)
    {
        io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
        return;
    }

    // Update gamepad inputs
    #define MAP_BUTTON(NAV_NO, BUTTON_NO)       { io.NavInputs[NAV_NO] = (SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0) ? 1.0f : 0.0f; }
    #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
    const int thumb_dead_zone = 8000;           // SDL_gamecontroller.h suggests using this value.
    MAP_BUTTON(ImGuiNavInput_Activate,      SDL_CONTROLLER_BUTTON_A);               // Cross / A
    MAP_BUTTON(ImGuiNavInput_Cancel,        SDL_CONTROLLER_BUTTON_B);               // Circle / B
    MAP_BUTTON(ImGuiNavInput_Menu,          SDL_CONTROLLER_BUTTON_X);               // Square / X
    MAP_BUTTON(ImGuiNavInput_Input,         SDL_CONTROLLER_BUTTON_Y);               // Triangle / Y
    MAP_BUTTON(ImGuiNavInput_DpadLeft,      SDL_CONTROLLER_BUTTON_DPAD_LEFT);       // D-Pad Left
    MAP_BUTTON(ImGuiNavInput_DpadRight,     SDL_CONTROLLER_BUTTON_DPAD_RIGHT);      // D-Pad Right
    MAP_BUTTON(ImGuiNavInput_DpadUp,        SDL_CONTROLLER_BUTTON_DPAD_UP);         // D-Pad Up
    MAP_BUTTON(ImGuiNavInput_DpadDown,      SDL_CONTROLLER_BUTTON_DPAD_DOWN);       // D-Pad Down
    MAP_BUTTON(ImGuiNavInput_FocusPrev,     SDL_CONTROLLER_BUTTON_LEFTSHOULDER);    // L1 / LB
    MAP_BUTTON(ImGuiNavInput_FocusNext,     SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);   // R1 / RB
    MAP_BUTTON(ImGuiNavInput_TweakSlow,     SDL_CONTROLLER_BUTTON_LEFTSHOULDER);    // L1 / LB
    MAP_BUTTON(ImGuiNavInput_TweakFast,     SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);   // R1 / RB
    MAP_ANALOG(ImGuiNavInput_LStickLeft,    SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
    MAP_ANALOG(ImGuiNavInput_LStickRight,   SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
    MAP_ANALOG(ImGuiNavInput_LStickUp,      SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32767);
    MAP_ANALOG(ImGuiNavInput_LStickDown,    SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);

    io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
    #undef MAP_BUTTON
    #undef MAP_ANALOG
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
callq 0xcb1a0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x33c, %rdi            # imm = 0x33C
xorl %esi, %esi
movl $0x54, %edx
callq 0xd2f0
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x16895e
jmp 0x168ecb
xorl %edi, %edi
callq 0xd720
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x168982
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
andl $-0x2, %ecx
movl %ecx, 0x4(%rax)
jmp 0x168ecb
movl $0x1f40, -0x14(%rbp)    # imm = 0x1F40
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0xd810
movzbl %al, %eax
movss 0x829d(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x2c(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x28(%rbp)
jne 0x1689bb
movss -0x2c(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x28(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x33c(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xd810
movzbl %al, %eax
movss 0x8257(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x34(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x30(%rbp)
jne 0x168a01
movss -0x34(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x340(%rax)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0xd810
movzbl %al, %eax
movss 0x8211(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x3c(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x38(%rbp)
jne 0x168a47
movss -0x3c(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x348(%rax)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0xd810
movzbl %al, %eax
movss 0x81cb(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x44(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x40(%rbp)
jne 0x168a8d
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x344(%rax)
movq -0x10(%rbp), %rdi
movl $0xd, %esi
callq 0xd810
movzbl %al, %eax
movss 0x8185(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x4c(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x48(%rbp)
jne 0x168ad3
movss -0x4c(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x48(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x34c(%rax)
movq -0x10(%rbp), %rdi
movl $0xe, %esi
callq 0xd810
movzbl %al, %eax
movss 0x813f(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x54(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x50(%rbp)
jne 0x168b19
movss -0x54(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x50(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x350(%rax)
movq -0x10(%rbp), %rdi
movl $0xb, %esi
callq 0xd810
movzbl %al, %eax
movss 0x80f9(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x5c(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x58(%rbp)
jne 0x168b5f
movss -0x5c(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x354(%rax)
movq -0x10(%rbp), %rdi
movl $0xc, %esi
callq 0xd810
movzbl %al, %eax
movss 0x80b3(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x64(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x60(%rbp)
jne 0x168ba5
movss -0x64(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x60(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x358(%rax)
movq -0x10(%rbp), %rdi
movl $0x9, %esi
callq 0xd810
movzbl %al, %eax
movss 0x806d(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x6c(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x68(%rbp)
jne 0x168beb
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x68(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x36c(%rax)
movq -0x10(%rbp), %rdi
movl $0xa, %esi
callq 0xd810
movzbl %al, %eax
movss 0x8027(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x74(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x70(%rbp)
jne 0x168c31
movss -0x74(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x70(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x370(%rax)
movq -0x10(%rbp), %rdi
movl $0x9, %esi
callq 0xd810
movzbl %al, %eax
movss 0x7fe1(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x7c(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x78(%rbp)
jne 0x168c77
movss -0x7c(%rbp), %xmm0
movss %xmm0, -0x78(%rbp)
movss -0x78(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x374(%rax)
movq -0x10(%rbp), %rdi
movl $0xa, %esi
callq 0xd810
movzbl %al, %eax
movss 0x7f9b(%rip), %xmm0     # 0x170c3c
xorps %xmm1, %xmm1
movss %xmm1, -0x84(%rbp)
cmpl $0x0, %eax
movss %xmm0, -0x80(%rbp)
jne 0x168cc3
movss -0x84(%rbp), %xmm0
movss %xmm0, -0x80(%rbp)
movss -0x80(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x378(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0xd1c0
cwtl
subl $0xffffe0c0, %eax       # imm = 0xFFFFE0C0
cvtsi2ss %eax, %xmm0
movss 0x27d1b(%rip), %xmm1    # 0x190a0c
divss %xmm1, %xmm0
movss %xmm0, -0x18(%rbp)
movss -0x18(%rbp), %xmm0
movss 0x7f35(%rip), %xmm1     # 0x170c3c
ucomiss %xmm1, %xmm0
jbe 0x168d19
movss 0x7f28(%rip), %xmm0     # 0x170c3c
movss %xmm0, -0x18(%rbp)
movss -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x168d4d
movq -0x8(%rbp), %rax
movss 0x35c(%rax), %xmm1
movss -0x18(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x168d4d
movss -0x18(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x35c(%rax)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0xd1c0
cwtl
subl $0x1f40, %eax           # imm = 0x1F40
cvtsi2ss %eax, %xmm0
movss 0x27ca6(%rip), %xmm1    # 0x190a10
divss %xmm1, %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
movss 0x7ebc(%rip), %xmm1     # 0x170c3c
ucomiss %xmm1, %xmm0
jbe 0x168d92
movss 0x7eaf(%rip), %xmm0     # 0x170c3c
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x168dc6
movq -0x8(%rbp), %rax
movss 0x360(%rax), %xmm1
movss -0x1c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x168dc6
movss -0x1c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x360(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xd1c0
cwtl
subl $0xffffe0c0, %eax       # imm = 0xFFFFE0C0
cvtsi2ss %eax, %xmm0
movss 0x27c2e(%rip), %xmm1    # 0x190a14
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
movss 0x7e40(%rip), %xmm1     # 0x170c3c
ucomiss %xmm1, %xmm0
jbe 0x168e0e
movss 0x7e33(%rip), %xmm0     # 0x170c3c
movss %xmm0, -0x20(%rbp)
movss -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x168e42
movq -0x8(%rbp), %rax
movss 0x364(%rax), %xmm1
movss -0x20(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x168e42
movss -0x20(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x364(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xd1c0
cwtl
subl $0x1f40, %eax           # imm = 0x1F40
cvtsi2ss %eax, %xmm0
movss 0x27bae(%rip), %xmm1    # 0x190a10
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
movss 0x7dc4(%rip), %xmm1     # 0x170c3c
ucomiss %xmm1, %xmm0
jbe 0x168e8a
movss 0x7db7(%rip), %xmm0     # 0x170c3c
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x168ebe
movq -0x8(%rbp), %rax
movss 0x368(%rax), %xmm1
movss -0x24(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x168ebe
movss -0x24(%rbp), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x368(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x4(%rax)
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)