// File: Ciaxur[P]yagb-emu/include/imgui/backends/imgui_impl_opengl3.cpp
// Function: ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*)
void    ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
{
    // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
    int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
    int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
    if (fb_width <= 0 || fb_height <= 0)
        return;

    // Backup GL state
    GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
    glActiveTexture(GL_TEXTURE0);
    GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
    GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
    GLuint last_sampler; if (g_GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; }
#endif
    GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
#ifndef IMGUI_IMPL_OPENGL_ES2
    GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
#endif
#ifdef GL_POLYGON_MODE
    GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
#endif
    GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
    GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
    GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
    GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
    GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
    GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
    GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
    GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
    GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
    GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
    GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
    GLboolean last_enable_stencil_test = glIsEnabled(GL_STENCIL_TEST);
    GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
    GLboolean last_enable_primitive_restart = (g_GlVersion >= 310) ? glIsEnabled(GL_PRIMITIVE_RESTART) : GL_FALSE;
#endif

    // Setup desired GL state
    // Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
    // The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
    GLuint vertex_array_object = 0;
#ifndef IMGUI_IMPL_OPENGL_ES2
    glGenVertexArrays(1, &vertex_array_object);
#endif
    ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);

    // Will project scissor/clipping rectangles into framebuffer space
    ImVec2 clip_off = draw_data->DisplayPos;         // (0,0) unless using multi-viewports
    ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)

    // Render command lists
    for (int n = 0; n < draw_data->CmdListsCount; n++)
    {
        const ImDrawList* cmd_list = draw_data->CmdLists[n];

        // Upload vertex/index buffers
        glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);

        for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
        {
            const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
            if (pcmd->UserCallback != NULL)
            {
                // User callback, registered via ImDrawList::AddCallback()
                // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
                if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
                    ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
                else
                    pcmd->UserCallback(cmd_list, pcmd);
            }
            else
            {
                // Project scissor/clipping rectangles into framebuffer space
                ImVec4 clip_rect;
                clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
                clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
                clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
                clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;

                if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
                {
                    // Apply scissor/clipping rectangle
                    glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));

                    // Bind texture, Draw
                    glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
                    if (g_GlVersion >= 320)
                        glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
                    else
#endif
                    glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
                }
            }
        }
    }

    // Destroy the temporary VAO
#ifndef IMGUI_IMPL_OPENGL_ES2
    glDeleteVertexArrays(1, &vertex_array_object);
#endif

    // Restore modified GL state
    glUseProgram(last_program);
    glBindTexture(GL_TEXTURE_2D, last_texture);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
    if (g_GlVersion >= 330)
        glBindSampler(0, last_sampler);
#endif
    glActiveTexture(last_active_texture);
#ifndef IMGUI_IMPL_OPENGL_ES2
    glBindVertexArray(last_vertex_array_object);
#endif
    glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
    glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
    glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
    if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
    if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
    if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
    if (last_enable_stencil_test) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST);
    if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
    if (g_GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
#endif

#ifdef GL_POLYGON_MODE
    glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
#endif
    glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
    glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movss 0x24(%rax), %xmm0
movq -0x8(%rbp), %rax
mulss 0x2c(%rax), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movss 0x28(%rax), %xmm0
movq -0x8(%rbp), %rax
mulss 0x30(%rax), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0xc(%rbp)
jle 0x1695dd
cmpl $0x0, -0x10(%rbp)
jg 0x1695e2
jmp 0x169c1a
movl $0x84e0, %edi           # imm = 0x84E0
leaq -0x14(%rbp), %rsi
callq 0xd800
movl $0x84c0, %edi           # imm = 0x84C0
movq 0xa49dc(%rip), %rax     # 0x20dfd8
callq *(%rax)
movl $0x8b8d, %edi           # imm = 0x8B8D
leaq -0x18(%rbp), %rsi
callq 0xd800
movl $0x8069, %edi           # imm = 0x8069
leaq -0x1c(%rbp), %rsi
callq 0xd800
cmpl $0x14a, 0xb064c(%rip)   # imm = 0x14A
jb 0x169636
movl $0x8919, %edi           # imm = 0x8919
leaq -0x20(%rbp), %rsi
callq 0xd800
jmp 0x16963d
movl $0x0, -0x20(%rbp)
movl $0x8894, %edi           # imm = 0x8894
leaq -0x24(%rbp), %rsi
callq 0xd800
movl $0x85b5, %edi           # imm = 0x85B5
leaq -0x28(%rbp), %rsi
callq 0xd800
leaq -0x30(%rbp), %rsi
movl $0xb40, %edi            # imm = 0xB40
callq 0xd800
leaq -0x40(%rbp), %rsi
movl $0xba2, %edi            # imm = 0xBA2
callq 0xd800
leaq -0x50(%rbp), %rsi
movl $0xc10, %edi            # imm = 0xC10
callq 0xd800
movl $0x80c9, %edi           # imm = 0x80C9
leaq -0x54(%rbp), %rsi
callq 0xd800
movl $0x80c8, %edi           # imm = 0x80C8
leaq -0x58(%rbp), %rsi
callq 0xd800
movl $0x80cb, %edi           # imm = 0x80CB
leaq -0x5c(%rbp), %rsi
callq 0xd800
movl $0x80ca, %edi           # imm = 0x80CA
leaq -0x60(%rbp), %rsi
callq 0xd800
movl $0x8009, %edi           # imm = 0x8009
leaq -0x64(%rbp), %rsi
callq 0xd800
movl $0x883d, %edi           # imm = 0x883D
leaq -0x68(%rbp), %rsi
callq 0xd800
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xd340
movb %al, -0x69(%rbp)
movl $0xb44, %edi            # imm = 0xB44
callq 0xd340
movb %al, -0x6a(%rbp)
movl $0xb71, %edi            # imm = 0xB71
callq 0xd340
movb %al, -0x6b(%rbp)
movl $0xb90, %edi            # imm = 0xB90
callq 0xd340
movb %al, -0x6c(%rbp)
movl $0xc11, %edi            # imm = 0xC11
callq 0xd340
movb %al, -0x6d(%rbp)
cmpl $0x136, 0xb054e(%rip)   # imm = 0x136
jb 0x169739
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xd340
movzbl %al, %eax
movl %eax, -0xb4(%rbp)
jmp 0x169743
xorl %eax, %eax
movl %eax, -0xb4(%rbp)
jmp 0x169743
movl -0xb4(%rbp), %eax
movb %al, -0x6e(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x1, %edi
leaq -0x74(%rbp), %rsi
movq 0xa47f5(%rip), %rax     # 0x20df58
callq *(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x74(%rbp), %ecx
callq 0x169c30
movq -0x8(%rbp), %rax
movq 0x1c(%rax), %rax
movq %rax, -0x7c(%rbp)
movq -0x8(%rbp), %rax
movq 0x2c(%rax), %rax
movq %rax, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x169a8e
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x90(%rbp)
movq 0xa4700(%rip), %rax     # 0x20ded0
movq (%rax), %rax
movq -0x90(%rbp), %rcx
movslq 0x20(%rcx), %rcx
imulq $0x14, %rcx, %rsi
movq -0x90(%rbp), %rcx
movq 0x28(%rcx), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e0, %ecx           # imm = 0x88E0
callq *%rax
movq 0xa46d0(%rip), %rax     # 0x20ded0
movq (%rax), %rax
movq -0x90(%rbp), %rcx
movslq 0x10(%rcx), %rsi
shlq %rsi
movq -0x90(%rbp), %rcx
movq 0x18(%rcx), %rdx
movl $0x8893, %edi           # imm = 0x8893
movl $0x88e0, %ecx           # imm = 0x88E0
callq *%rax
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
movq -0x90(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x169a78
movq -0x90(%rbp), %rdi
movl -0x94(%rbp), %esi
callq 0x16a380
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x1698b6
movq -0xa0(%rbp), %rax
movq $-0x1, %rcx
cmpq %rcx, 0x28(%rax)
jne 0x169896
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x74(%rbp), %ecx
callq 0x169c30
jmp 0x1698b1
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x90(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq *%rax
jmp 0x169a62
leaq -0xb0(%rbp), %rdi
callq 0xe7e00
movq -0xa0(%rbp), %rax
movss (%rax), %xmm0
subss -0x7c(%rbp), %xmm0
mulss -0x84(%rbp), %xmm0
movss %xmm0, -0xb0(%rbp)
movq -0xa0(%rbp), %rax
movss 0x4(%rax), %xmm0
subss -0x78(%rbp), %xmm0
mulss -0x80(%rbp), %xmm0
movss %xmm0, -0xac(%rbp)
movq -0xa0(%rbp), %rax
movss 0x8(%rax), %xmm0
subss -0x7c(%rbp), %xmm0
mulss -0x84(%rbp), %xmm0
movss %xmm0, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movss 0xc(%rax), %xmm0
subss -0x78(%rbp), %xmm0
mulss -0x80(%rbp), %xmm0
movss %xmm0, -0xa4(%rbp)
movss -0xb0(%rbp), %xmm1
cvtsi2ssl -0xc(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x169a60
movss -0xac(%rbp), %xmm1
cvtsi2ssl -0x10(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x169a60
movss -0xa8(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x169a60
movss -0xa4(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x169a60
cvttss2si -0xb0(%rbp), %edi
cvtsi2ssl -0x10(%rbp), %xmm0
subss -0xa4(%rbp), %xmm0
cvttss2si %xmm0, %esi
movss -0xa8(%rbp), %xmm0
subss -0xb0(%rbp), %xmm0
cvttss2si %xmm0, %edx
movss -0xa4(%rbp), %xmm0
subss -0xac(%rbp), %xmm0
cvttss2si %xmm0, %ecx
callq 0xd5e0
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xdab0
cmpl $0x140, 0xb0276(%rip)   # imm = 0x140
jb 0x169a36
movq 0xa4595(%rip), %rax     # 0x20df98
movq (%rax), %rax
movq -0xa0(%rbp), %rcx
movl 0x20(%rcx), %esi
movq -0xa0(%rbp), %rcx
movl 0x1c(%rcx), %ecx
shlq %rcx
movq -0xa0(%rbp), %rdx
movl 0x18(%rdx), %r8d
movl $0x4, %edi
movl $0x1403, %edx           # imm = 0x1403
callq *%rax
jmp 0x169a5e
movq -0xa0(%rbp), %rax
movl 0x20(%rax), %esi
movq -0xa0(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, %ecx
shlq %rcx
movl $0x4, %edi
movl $0x1403, %edx           # imm = 0x1403
callq 0xd240
jmp 0x169a60
jmp 0x169a62
jmp 0x169a64
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x169832
jmp 0x169a7a
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x16979c
movl $0x1, %edi
leaq -0x74(%rbp), %rsi
movq 0xa44ca(%rip), %rax     # 0x20df68
callq *(%rax)
movq 0xa4539(%rip), %rax     # 0x20dfe0
movq (%rax), %rax
movl -0x18(%rbp), %edi
callq *%rax
movl -0x1c(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xdab0
cmpl $0x14a, 0xb01aa(%rip)   # imm = 0x14A
jb 0x169ad9
movq 0xa44b1(%rip), %rax     # 0x20df80
movq (%rax), %rax
movl -0x20(%rbp), %esi
xorl %edi, %edi
callq *%rax
movq 0xa44f8(%rip), %rax     # 0x20dfd8
movq (%rax), %rax
movl -0x14(%rbp), %edi
callq *%rax
movq 0xa44e1(%rip), %rax     # 0x20dfd0
movq (%rax), %rax
movl -0x28(%rbp), %edi
callq *%rax
movq 0xa43a2(%rip), %rax     # 0x20dea0
movq (%rax), %rax
movl -0x24(%rbp), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movq 0xa4426(%rip), %rax     # 0x20df38
movq (%rax), %rax
movl -0x64(%rbp), %edi
movl -0x68(%rbp), %esi
callq *%rax
movq 0xa44c4(%rip), %rax     # 0x20dfe8
movq (%rax), %rax
movl -0x54(%rbp), %edi
movl -0x58(%rbp), %esi
movl -0x5c(%rbp), %edx
movl -0x60(%rbp), %ecx
callq *%rax
cmpb $0x0, -0x69(%rbp)
je 0x169b47
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xd5a0
jmp 0x169b51
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xd8c0
cmpb $0x0, -0x6a(%rbp)
je 0x169b63
movl $0xb44, %edi            # imm = 0xB44
callq 0xd5a0
jmp 0x169b6d
movl $0xb44, %edi            # imm = 0xB44
callq 0xd8c0
cmpb $0x0, -0x6b(%rbp)
je 0x169b7f
movl $0xb71, %edi            # imm = 0xB71
callq 0xd5a0
jmp 0x169b89
movl $0xb71, %edi            # imm = 0xB71
callq 0xd8c0
cmpb $0x0, -0x6c(%rbp)
je 0x169b9b
movl $0xb90, %edi            # imm = 0xB90
callq 0xd5a0
jmp 0x169ba5
movl $0xb90, %edi            # imm = 0xB90
callq 0xd8c0
cmpb $0x0, -0x6d(%rbp)
je 0x169bb7
movl $0xc11, %edi            # imm = 0xC11
callq 0xd5a0
jmp 0x169bc1
movl $0xc11, %edi            # imm = 0xC11
callq 0xd8c0
cmpl $0x136, 0xb00a5(%rip)   # imm = 0x136
jb 0x169beb
cmpb $0x0, -0x6e(%rbp)
je 0x169bdf
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xd5a0
jmp 0x169be9
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xd8c0
jmp 0x169beb
movl -0x30(%rbp), %esi
movl $0x408, %edi            # imm = 0x408
callq 0xd3f0
movl -0x40(%rbp), %edi
movl -0x3c(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x34(%rbp), %ecx
callq 0xd440
movl -0x50(%rbp), %edi
movl -0x4c(%rbp), %esi
movl -0x48(%rbp), %edx
movl -0x44(%rbp), %ecx
callq 0xd5e0
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)