// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %rsp
movss 0x24(%rdi), %xmm0
movss 0x28(%rdi), %xmm1
mulss 0x2c(%rdi), %xmm0
cvttss2si %xmm0, %eax
mulss 0x30(%rdi), %xmm1
cvttss2si %xmm1, %ecx
movl %eax, -0x38(%rbp)
testl %eax, %eax
setle %al
movl %ecx, -0x34(%rbp)
testl %ecx, %ecx
setle %cl
orb %al, %cl
jne 0xaf497
movq %rdi, %rbx
leaq -0x84(%rbp), %rsi
movl $0x84e0, %edi           # imm = 0x84E0
callq 0xc740
movq 0x4805b(%rip), %rax     # 0xf6fd8
movl $0x84c0, %edi           # imm = 0x84C0
callq *(%rax)
leaq -0x80(%rbp), %rsi
movl $0x8b8d, %edi           # imm = 0x8B8D
callq 0xc740
leaq -0x7c(%rbp), %rsi
movl $0x8069, %edi           # imm = 0x8069
callq 0xc740
cmpl $0x14a, 0x538a6(%rip)   # imm = 0x14A
jb 0xaefbc
leaq -0x54(%rbp), %rsi
movl $0x8919, %edi           # imm = 0x8919
callq 0xc740
jmp 0xaefc3
movl $0x0, -0x54(%rbp)
leaq -0x78(%rbp), %rsi
movl $0x8894, %edi           # imm = 0x8894
callq 0xc740
leaq -0x74(%rbp), %rsi
movl $0x85b5, %edi           # imm = 0x85B5
callq 0xc740
leaq -0xc0(%rbp), %rsi
movl $0xb40, %edi            # imm = 0xB40
callq 0xc740
leaq -0xb0(%rbp), %rsi
movl $0xba2, %edi            # imm = 0xBA2
callq 0xc740
leaq -0xa0(%rbp), %rsi
movl $0xc10, %edi            # imm = 0xC10
callq 0xc740
leaq -0x70(%rbp), %rsi
movl $0x80c9, %edi           # imm = 0x80C9
callq 0xc740
leaq -0x6c(%rbp), %rsi
movl $0x80c8, %edi           # imm = 0x80C8
callq 0xc740
leaq -0x68(%rbp), %rsi
movl $0x80cb, %edi           # imm = 0x80CB
callq 0xc740
leaq -0x64(%rbp), %rsi
movl $0x80ca, %edi           # imm = 0x80CA
callq 0xc740
leaq -0x60(%rbp), %rsi
movl $0x8009, %edi           # imm = 0x8009
callq 0xc740
leaq -0x5c(%rbp), %rsi
movl $0x883d, %edi           # imm = 0x883D
callq 0xc740
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc290
movb %al, -0x2a(%rbp)
movl $0xb44, %edi            # imm = 0xB44
callq 0xc290
movb %al, -0x2b(%rbp)
movl $0xb71, %edi            # imm = 0xB71
callq 0xc290
movb %al, -0x2c(%rbp)
movl $0xb90, %edi            # imm = 0xB90
callq 0xc290
movb %al, -0x2d(%rbp)
movl $0xc11, %edi            # imm = 0xC11
callq 0xc290
movb %al, -0x2e(%rbp)
movb $0x1, -0x29(%rbp)
cmpl $0x136, 0x5379b(%rip)   # imm = 0x136
jb 0xaf0c7
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc290
testb %al, %al
sete -0x29(%rbp)
leaq -0x50(%rbp), %r12
movl $0x0, (%r12)
movq 0x47e7e(%rip), %rax     # 0xf6f58
movl $0x1, %edi
movq %r12, %rsi
callq *(%rax)
movl (%r12), %ecx
movq %rbx, %rdi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0xaf4a9
cmpl $0x0, 0x10(%rbx)
jle 0xaf304
movss 0x1c(%rbx), %xmm0
movss %xmm0, -0x4c(%rbp)
movss 0x20(%rbx), %xmm0
movss %xmm0, -0x44(%rbp)
movss 0x2c(%rbx), %xmm0
movss %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
cvtsi2ssl -0x38(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movss 0x30(%rbx), %xmm0
movss %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtsi2ssl -0x34(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
xorl %ecx, %ecx
movq %rbx, %r14
movq 0x8(%rbx), %rax
movq %rcx, -0xb8(%rbp)
movq (%rax,%rcx,8), %r13
movslq 0x20(%r13), %rax
shlq $0x2, %rax
leaq (%rax,%rax,4), %rsi
movq 0x28(%r13), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e0, %ecx           # imm = 0x88E0
movq 0x47d49(%rip), %rbx     # 0xf6ec0
callq *(%rbx)
movslq 0x10(%r13), %rsi
addq %rsi, %rsi
movq 0x18(%r13), %rdx
movl $0x8893, %edi           # imm = 0x8893
movl $0x88e0, %ecx           # imm = 0x88E0
callq *(%rbx)
cmpl $0x0, (%r13)
jle 0xaf2ea
xorl %r15d, %r15d
xorl %ebx, %ebx
movq 0x8(%r13), %r12
movq 0x28(%r12,%r15), %rax
testq %rax, %rax
je 0xaf1ce
cmpq $-0x1, %rax
jne 0xaf2ab
movl -0x50(%rbp), %ecx
movq %r14, %rdi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0xaf4a9
jmp 0xaf2b6
movss (%r12,%r15), %xmm0
subss -0x4c(%rbp), %xmm0
mulss -0x48(%rbp), %xmm0
movss -0x58(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0xaf2b6
movss 0x4(%r12,%r15), %xmm1
subss -0x44(%rbp), %xmm1
mulss -0x40(%rbp), %xmm1
movss -0x3c(%rbp), %xmm2
ucomiss %xmm1, %xmm2
jbe 0xaf2b6
movss 0x8(%r12,%r15), %xmm2
subss -0x4c(%rbp), %xmm2
mulss -0x48(%rbp), %xmm2
ucomiss 0x6621(%rip), %xmm2     # 0xb5844
jb 0xaf2b6
movss 0xc(%r12,%r15), %xmm3
subss -0x44(%rbp), %xmm3
mulss -0x40(%rbp), %xmm3
ucomiss 0x6603(%rip), %xmm3     # 0xb5844
jb 0xaf2b6
cvttss2si %xmm0, %edi
movss -0x3c(%rbp), %xmm4
subss %xmm3, %xmm4
cvttss2si %xmm4, %esi
subss %xmm0, %xmm2
cvttss2si %xmm2, %edx
subss %xmm1, %xmm3
cvttss2si %xmm3, %ecx
callq 0xc510
movl 0x10(%r12,%r15), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc960
cmpl $0x140, 0x535ce(%rip)   # imm = 0x140
jb 0xaf2cc
movl 0x20(%r12,%r15), %esi
movl 0x18(%r12,%r15), %r8d
movl 0x1c(%r12,%r15), %ecx
addq %rcx, %rcx
movl $0x4, %edi
movl $0x1403, %edx           # imm = 0x1403
movq 0x47cf1(%rip), %rax     # 0xf6f98
callq *(%rax)
jmp 0xaf2b6
addq %r15, %r12
movq %r13, %rdi
movq %r12, %rsi
callq *%rax
incq %rbx
movslq (%r13), %rax
addq $0x38, %r15
cmpq %rax, %rbx
jl 0xaf1a0
jmp 0xaf2ea
movl 0x1c(%r12,%r15), %ecx
movl 0x20(%r12,%r15), %esi
addq %rcx, %rcx
movl $0x4, %edi
movl $0x1403, %edx           # imm = 0x1403
callq 0xc1e0
jmp 0xaf2b6
movq -0xb8(%rbp), %rcx
incq %rcx
movq %r14, %rbx
movslq 0x10(%r14), %rax
cmpq %rax, %rcx
jl 0xaf144
movq 0x47c5d(%rip), %rax     # 0xf6f68
leaq -0x50(%rbp), %rsi
movl $0x1, %edi
callq *(%rax)
movq 0x47cc3(%rip), %rax     # 0xf6fe0
movl -0x80(%rbp), %edi
callq *(%rax)
movl -0x7c(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc960
cmpl $0x149, 0x53517(%rip)   # imm = 0x149
jbe 0xaf349
movq 0x47c46(%rip), %rax     # 0xf6f88
movl -0x54(%rbp), %esi
xorl %edi, %edi
callq *(%rax)
movl -0x84(%rbp), %edi
movq 0x47c82(%rip), %rax     # 0xf6fd8
callq *(%rax)
movq 0x47c71(%rip), %rax     # 0xf6fd0
movl -0x74(%rbp), %edi
callq *(%rax)
movq 0x47b25(%rip), %rax     # 0xf6e90
movl -0x78(%rbp), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x47bbc(%rip), %rax     # 0xf6f38
movl -0x60(%rbp), %edi
movl -0x5c(%rbp), %esi
callq *(%rax)
movq 0x47c5d(%rip), %rax     # 0xf6fe8
movl -0x70(%rbp), %edi
movl -0x6c(%rbp), %esi
movl -0x68(%rbp), %edx
movl -0x64(%rbp), %ecx
callq *(%rax)
cmpb $0x0, -0x2a(%rbp)
je 0xaf3ab
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc4e0
jmp 0xaf3b5
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc7d0
cmpb $0x0, -0x2b(%rbp)
je 0xaf3c7
movl $0xb44, %edi            # imm = 0xB44
callq 0xc4e0
jmp 0xaf3d1
movl $0xb44, %edi            # imm = 0xB44
callq 0xc7d0
cmpb $0x0, -0x2c(%rbp)
je 0xaf3e3
movl $0xb71, %edi            # imm = 0xB71
callq 0xc4e0
jmp 0xaf3ed
movl $0xb71, %edi            # imm = 0xB71
callq 0xc7d0
cmpb $0x0, -0x2d(%rbp)
je 0xaf3ff
movl $0xb90, %edi            # imm = 0xB90
callq 0xc4e0
jmp 0xaf409
movl $0xb90, %edi            # imm = 0xB90
callq 0xc7d0
cmpb $0x0, -0x2e(%rbp)
je 0xaf41b
movl $0xc11, %edi            # imm = 0xC11
callq 0xc4e0
jmp 0xaf425
movl $0xc11, %edi            # imm = 0xC11
callq 0xc7d0
cmpl $0x136, 0x53421(%rip)   # imm = 0x136
jb 0xaf44d
cmpb $0x0, -0x29(%rbp)
je 0xaf443
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc7d0
jmp 0xaf44d
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc4e0
movl -0xc0(%rbp), %esi
movl $0x408, %edi            # imm = 0x408
callq 0xc320
movl -0xb0(%rbp), %edi
movl -0xac(%rbp), %esi
movl -0xa8(%rbp), %edx
movl -0xa4(%rbp), %ecx
callq 0xc370
movl -0xa0(%rbp), %edi
movl -0x9c(%rbp), %esi
movl -0x98(%rbp), %edx
movl -0x94(%rbp), %ecx
callq 0xc510
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq