// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movss 0x24(%rdi), %xmm0
movss 0x28(%rdi), %xmm1
mulss 0x2c(%rdi), %xmm0
cvttss2si %xmm0, %eax
mulss 0x30(%rdi), %xmm1
cvttss2si %xmm1, %r15d
movl %eax, -0x40(%rbp)
testl %eax, %eax
setle %al
testl %r15d, %r15d
setle %cl
orb %al, %cl
jne 0x96714
movq %rdi, %rbx
leaq -0x80(%rbp), %rsi
movl $0x84e0, %edi           # imm = 0x84E0
callq 0xc780
movq 0x48db3(%rip), %rax     # 0xdefe0
movl $0x84c0, %edi           # imm = 0x84C0
callq *(%rax)
leaq -0x7c(%rbp), %rsi
movl $0x8b8d, %edi           # imm = 0x8B8D
callq 0xc780
leaq -0x78(%rbp), %rsi
movl $0x8069, %edi           # imm = 0x8069
callq 0xc780
cmpl $0x14a, 0x54606(%rip)   # imm = 0x14A
jb 0x9626c
leaq -0x50(%rbp), %rsi
movl $0x8919, %edi           # imm = 0x8919
callq 0xc780
jmp 0x96270
andl $0x0, -0x50(%rbp)
leaq -0x74(%rbp), %rsi
movl $0x8894, %edi           # imm = 0x8894
callq 0xc780
leaq -0x70(%rbp), %rsi
movl $0x85b5, %edi           # imm = 0x85B5
callq 0xc780
leaq -0xb0(%rbp), %rsi
movl $0xb40, %edi            # imm = 0xB40
callq 0xc780
leaq -0xa0(%rbp), %rsi
movl $0xba2, %edi            # imm = 0xBA2
callq 0xc780
leaq -0x90(%rbp), %rsi
movl $0xc10, %edi            # imm = 0xC10
callq 0xc780
leaq -0x6c(%rbp), %rsi
movl $0x80c9, %edi           # imm = 0x80C9
callq 0xc780
leaq -0x68(%rbp), %rsi
movl $0x80c8, %edi           # imm = 0x80C8
callq 0xc780
leaq -0x64(%rbp), %rsi
movl $0x80cb, %edi           # imm = 0x80CB
callq 0xc780
leaq -0x60(%rbp), %rsi
movl $0x80ca, %edi           # imm = 0x80CA
callq 0xc780
leaq -0x5c(%rbp), %rsi
movl $0x8009, %edi           # imm = 0x8009
callq 0xc780
leaq -0x58(%rbp), %rsi
movl $0x883d, %edi           # imm = 0x883D
callq 0xc780
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc2b0
movb %al, -0x2a(%rbp)
movl $0xb44, %edi            # imm = 0xB44
callq 0xc2b0
movb %al, -0x2b(%rbp)
movl $0xb71, %edi            # imm = 0xB71
callq 0xc2b0
movb %al, -0x2c(%rbp)
movl $0xb90, %edi            # imm = 0xB90
callq 0xc2b0
movb %al, -0x2d(%rbp)
movl $0xc11, %edi            # imm = 0xC11
callq 0xc2b0
movb %al, -0x2e(%rbp)
movb $0x1, -0x29(%rbp)
cmpl $0x136, 0x544fe(%rip)   # imm = 0x136
jb 0x96374
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc2b0
testb %al, %al
sete -0x29(%rbp)
leaq -0x4c(%rbp), %r14
andl $0x0, (%r14)
movq 0x48be5(%rip), %rax     # 0xdef68
pushq $0x1
popq %rdi
movq %r14, %rsi
callq *(%rax)
movl (%r14), %ecx
movq %rbx, %rdi
movl -0x40(%rbp), %r14d
movl %r14d, %esi
movl %r15d, %edx
callq 0x96726
movss 0x1c(%rbx), %xmm0
movss %xmm0, -0x48(%rbp)
movss 0x20(%rbx), %xmm0
movss %xmm0, -0x3c(%rbp)
movss 0x2c(%rbx), %xmm0
movss %xmm0, -0x44(%rbp)
movss 0x30(%rbx), %xmm0
movss %xmm0, -0x38(%rbp)
cvtsi2ss %r14d, %xmm0
movss %xmm0, -0x54(%rbp)
cvtsi2ss %r15d, %xmm0
movss %xmm0, -0x34(%rbp)
xorl %ecx, %ecx
movslq 0x10(%rbx), %rax
cmpq %rax, %rcx
jge 0x96586
movq 0x8(%rbx), %rax
movq %rcx, -0xa8(%rbp)
movq (%rax,%rcx,8), %r12
movslq 0x20(%r12), %rax
imulq $0x14, %rax, %rsi
movq 0x28(%r12), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e0, %ecx           # imm = 0x88E0
movq 0x48ac7(%rip), %r14     # 0xdeee0
callq *(%r14)
movslq 0x10(%r12), %rsi
addq %rsi, %rsi
movq 0x18(%r12), %rdx
movl $0x8893, %edi           # imm = 0x8893
movl $0x88e0, %ecx           # imm = 0x88E0
callq *(%r14)
xorl %r13d, %r13d
cmpl (%r12), %r13d
jge 0x96577
movq %r12, %rdi
movl %r13d, %esi
callq 0x96bbe
movq %rax, %r14
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x9647a
cmpq $-0x1, %rax
jne 0x9654d
movl -0x4c(%rbp), %ecx
movq %rbx, %rdi
movl -0x40(%rbp), %esi
movl %r15d, %edx
callq 0x96726
jmp 0x96555
movss (%r14), %xmm0
subss -0x48(%rbp), %xmm0
mulss -0x44(%rbp), %xmm0
movss -0x54(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x96555
movss 0x4(%r14), %xmm1
subss -0x3c(%rbp), %xmm1
mulss -0x38(%rbp), %xmm1
movss -0x34(%rbp), %xmm2
ucomiss %xmm1, %xmm2
jbe 0x96555
movss 0x8(%r14), %xmm2
subss -0x48(%rbp), %xmm2
mulss -0x44(%rbp), %xmm2
ucomiss 0x63f8(%rip), %xmm2     # 0x9c8c4
jb 0x96555
movss 0xc(%r14), %xmm3
subss -0x3c(%rbp), %xmm3
mulss -0x38(%rbp), %xmm3
ucomiss 0x63db(%rip), %xmm3     # 0x9c8c4
jb 0x96555
cvttss2si %xmm0, %edi
movss -0x34(%rbp), %xmm4
subss %xmm3, %xmm4
cvttss2si %xmm4, %esi
subss %xmm0, %xmm2
cvttss2si %xmm2, %edx
subss %xmm1, %xmm3
cvttss2si %xmm3, %ecx
callq 0xc540
movl 0x10(%r14), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc990
cmpl $0x140, 0x54337(%rip)   # imm = 0x140
jb 0x9655d
movl 0x20(%r14), %esi
movl 0x18(%r14), %r8d
movl 0x1c(%r14), %ecx
addq %rcx, %rcx
pushq $0x4
popq %rdi
movl $0x1403, %edx           # imm = 0x1403
movq 0x48a57(%rip), %rax     # 0xdefa0
callq *(%rax)
jmp 0x96555
movq %r12, %rdi
movq %r14, %rsi
callq *%rax
incl %r13d
jmp 0x96439
movl 0x1c(%r14), %ecx
movl 0x20(%r14), %esi
addq %rcx, %rcx
pushq $0x4
popq %rdi
movl $0x1403, %edx           # imm = 0x1403
callq 0xc1e0
jmp 0x96555
movq -0xa8(%rbp), %rcx
incq %rcx
jmp 0x963de
movq 0x489eb(%rip), %rax     # 0xdef78
pushq $0x1
popq %rdi
leaq -0x4c(%rbp), %rsi
callq *(%rax)
movq 0x48a4b(%rip), %rax     # 0xdefe8
movl -0x7c(%rbp), %edi
callq *(%rax)
movl -0x78(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc990
cmpl $0x149, 0x542a7(%rip)   # imm = 0x149
jbe 0x965c9
movq 0x489ce(%rip), %rax     # 0xdef90
movl -0x50(%rbp), %esi
xorl %edi, %edi
callq *(%rax)
movl -0x80(%rbp), %edi
movq 0x48a0d(%rip), %rax     # 0xdefe0
callq *(%rax)
movq 0x489fc(%rip), %rax     # 0xdefd8
movl -0x70(%rbp), %edi
callq *(%rax)
movq 0x488c8(%rip), %rax     # 0xdeeb0
movl -0x74(%rbp), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x4894f(%rip), %rax     # 0xdef48
movl -0x5c(%rbp), %edi
movl -0x58(%rbp), %esi
callq *(%rax)
movq 0x489e8(%rip), %rax     # 0xdeff0
movl -0x6c(%rbp), %edi
movl -0x68(%rbp), %esi
movl -0x64(%rbp), %edx
movl -0x60(%rbp), %ecx
callq *(%rax)
cmpb $0x0, -0x2a(%rbp)
je 0x96628
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc500
jmp 0x96632
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc820
cmpb $0x0, -0x2b(%rbp)
je 0x96644
movl $0xb44, %edi            # imm = 0xB44
callq 0xc500
jmp 0x9664e
movl $0xb44, %edi            # imm = 0xB44
callq 0xc820
cmpb $0x0, -0x2c(%rbp)
je 0x96660
movl $0xb71, %edi            # imm = 0xB71
callq 0xc500
jmp 0x9666a
movl $0xb71, %edi            # imm = 0xB71
callq 0xc820
cmpb $0x0, -0x2d(%rbp)
je 0x9667c
movl $0xb90, %edi            # imm = 0xB90
callq 0xc500
jmp 0x96686
movl $0xb90, %edi            # imm = 0xB90
callq 0xc820
cmpb $0x0, -0x2e(%rbp)
je 0x96698
movl $0xc11, %edi            # imm = 0xC11
callq 0xc500
jmp 0x966a2
movl $0xc11, %edi            # imm = 0xC11
callq 0xc820
cmpl $0x136, 0x541b4(%rip)   # imm = 0x136
jb 0x966ca
cmpb $0x0, -0x29(%rbp)
je 0x966c0
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc820
jmp 0x966ca
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc500
movl -0xb0(%rbp), %esi
movl $0x408, %edi            # imm = 0x408
callq 0xc350
movl -0xa0(%rbp), %edi
movl -0x9c(%rbp), %esi
movl -0x98(%rbp), %edx
movl -0x94(%rbp), %ecx
callq 0xc3b0
movl -0x90(%rbp), %edi
movl -0x8c(%rbp), %esi
movl -0x88(%rbp), %edx
movl -0x84(%rbp), %ecx
callq 0xc540
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq