// File: Ciaxur[P]yagb-emu/include/imgui/backends/imgui_impl_sdl.cpp
// Function: ImGui_ImplSDL2_NewFrame(SDL_Window*)
void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
{
    ImGuiIO& io = ImGui::GetIO();
    IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer backend. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");

    // Setup display size (every frame to accommodate for window resizing)
    int w, h;
    int display_w, display_h;
    SDL_GetWindowSize(window, &w, &h);
    if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)
        w = h = 0;
    SDL_GL_GetDrawableSize(window, &display_w, &display_h);
    io.DisplaySize = ImVec2((float)w, (float)h);
    if (w > 0 && h > 0)
        io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);

    // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
    static Uint64 frequency = SDL_GetPerformanceFrequency();
    Uint64 current_time = SDL_GetPerformanceCounter();
    io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
    g_Time = current_time;

    ImGui_ImplSDL2_UpdateMousePosAndButtons();
    ImGui_ImplSDL2_UpdateMouseCursor();

    // Update game controllers (if enabled and available)
    ImGui_ImplSDL2_UpdateGamepads();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
callq 0xcb1a0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0x168f40
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x49(%rbp)
jne 0x168503
jmp 0x16850a
movb $0x1, %al
movb %al, -0x49(%rbp)
jmp 0x16850a
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x168513
jmp 0x168515
jmp 0x168534
leaq 0x28679(%rip), %rdi     # 0x190b95
leaq 0x2853d(%rip), %rsi     # 0x190a60
movl $0x15a, %edx            # imm = 0x15A
leaq 0x28716(%rip), %rcx     # 0x190c45
callq 0xd180
movq -0x8(%rbp), %rdi
leaq -0x14(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0xd7b0
movq -0x8(%rbp), %rdi
callq 0xd850
andl $0x40, %eax
cmpl $0x0, %eax
je 0x168564
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0xd8a0
cvtsi2ssl -0x14(%rbp), %xmm0
cvtsi2ssl -0x18(%rbp), %xmm1
leaq -0x28(%rbp), %rdi
callq 0xbf4c0
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0x8(%rax)
cmpl $0x0, -0x14(%rbp)
jle 0x1685d4
cmpl $0x0, -0x18(%rbp)
jle 0x1685d4
cvtsi2ssl -0x1c(%rbp), %xmm0
cvtsi2ssl -0x14(%rbp), %xmm1
divss %xmm1, %xmm0
cvtsi2ssl -0x20(%rbp), %xmm1
cvtsi2ssl -0x18(%rbp), %xmm2
divss %xmm2, %xmm1
leaq -0x30(%rbp), %rdi
callq 0xbf4c0
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0xb8(%rax)
cmpb $0x0, 0xb1685(%rip)     # 0x219c60
jne 0x168610
leaq 0xb167c(%rip), %rdi     # 0x219c60
callq 0xd380
cmpl $0x0, %eax
je 0x168610
callq 0xda70
movq %rax, -0x58(%rbp)
jmp 0x1685f9
movq -0x58(%rbp), %rax
movq %rax, 0xb1654(%rip)     # 0x219c58
leaq 0xb1655(%rip), %rdi     # 0x219c60
callq 0xd580
callq 0xd270
movq %rax, -0x48(%rbp)
cmpq $0x0, 0xb1647(%rip)     # 0x219c68
jbe 0x168682
movq -0x48(%rbp), %rax
movq 0xb163a(%rip), %rcx     # 0x219c68
subq %rcx, %rax
movq %rax, %xmm0
movaps 0x25c03(%rip), %xmm3    # 0x18e240
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x25c07(%rip), %xmm2    # 0x18e250
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0xb15f8(%rip), %xmm1    # 0x219c58
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x5c(%rbp)
jmp 0x168691
movss 0xa0ca(%rip), %xmm0     # 0x172754
movss %xmm0, -0x5c(%rbp)
jmp 0x168691
movss -0x5c(%rbp), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x10(%rax)
movq -0x48(%rbp), %rax
movq %rax, 0xb15be(%rip)     # 0x219c68
callq 0x1686e0
callq 0x168890
callq 0x168920
addq $0x60, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq 0xb158e(%rip), %rdi     # 0x219c60
callq 0xd460
movq -0x38(%rbp), %rdi
callq 0xd620