// File: /workspace/github_cpp_makefile_star2_O1/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 0xb0ba6
movq %rdi, %rbx
leaq -0x84(%rbp), %rsi
movl $0x84e0, %edi           # imm = 0x84E0
callq 0xc740
movq 0x4894c(%rip), %rax     # 0xf8fd8
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, 0x54197(%rip)   # imm = 0x14A
jb 0xb06cb
leaq -0x54(%rbp), %rsi
movl $0x8919, %edi           # imm = 0x8919
callq 0xc740
jmp 0xb06d2
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, 0x5408c(%rip)   # imm = 0x136
jb 0xb07d6
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc290
testb %al, %al
sete -0x29(%rbp)
leaq -0x50(%rbp), %r12
movl $0x0, (%r12)
movq 0x4876f(%rip), %rax     # 0xf8f58
movl $0x1, %edi
movq %r12, %rsi
callq *(%rax)
movl (%r12), %ecx
movq %rbx, %rdi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0xb0bb8
cmpl $0x0, 0x10(%rbx)
jle 0xb0a13
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 0x4863a(%rip), %rbx     # 0xf8ec0
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 0xb09f9
xorl %r15d, %r15d
xorl %ebx, %ebx
movq 0x8(%r13), %r12
movq 0x28(%r12,%r15), %rax
testq %rax, %rax
je 0xb08dd
cmpq $-0x1, %rax
jne 0xb09ba
movl -0x50(%rbp), %ecx
movq %r14, %rdi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0xb0bb8
jmp 0xb09c5
movss (%r12,%r15), %xmm0
subss -0x4c(%rbp), %xmm0
mulss -0x48(%rbp), %xmm0
movss -0x58(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0xb09c5
movss 0x4(%r12,%r15), %xmm1
subss -0x44(%rbp), %xmm1
mulss -0x40(%rbp), %xmm1
movss -0x3c(%rbp), %xmm2
ucomiss %xmm1, %xmm2
jbe 0xb09c5
movss 0x8(%r12,%r15), %xmm2
subss -0x4c(%rbp), %xmm2
mulss -0x48(%rbp), %xmm2
ucomiss 0x6f12(%rip), %xmm2     # 0xb7844
jb 0xb09c5
movss 0xc(%r12,%r15), %xmm3
subss -0x44(%rbp), %xmm3
mulss -0x40(%rbp), %xmm3
ucomiss 0x6ef4(%rip), %xmm3     # 0xb7844
jb 0xb09c5
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, 0x53ebf(%rip)   # imm = 0x140
jb 0xb09db
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 0x485e2(%rip), %rax     # 0xf8f98
callq *(%rax)
jmp 0xb09c5
addq %r15, %r12
movq %r13, %rdi
movq %r12, %rsi
callq *%rax
incq %rbx
movslq (%r13), %rax
addq $0x38, %r15
cmpq %rax, %rbx
jl 0xb08af
jmp 0xb09f9
movl 0x1c(%r12,%r15), %ecx
movl 0x20(%r12,%r15), %esi
addq %rcx, %rcx
movl $0x4, %edi
movl $0x1403, %edx           # imm = 0x1403
callq 0xc1e0
jmp 0xb09c5
movq -0xb8(%rbp), %rcx
incq %rcx
movq %r14, %rbx
movslq 0x10(%r14), %rax
cmpq %rax, %rcx
jl 0xb0853
movq 0x4854e(%rip), %rax     # 0xf8f68
leaq -0x50(%rbp), %rsi
movl $0x1, %edi
callq *(%rax)
movq 0x485b4(%rip), %rax     # 0xf8fe0
movl -0x80(%rbp), %edi
callq *(%rax)
movl -0x7c(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc960
cmpl $0x149, 0x53e08(%rip)   # imm = 0x149
jbe 0xb0a58
movq 0x48537(%rip), %rax     # 0xf8f88
movl -0x54(%rbp), %esi
xorl %edi, %edi
callq *(%rax)
movl -0x84(%rbp), %edi
movq 0x48573(%rip), %rax     # 0xf8fd8
callq *(%rax)
movq 0x48562(%rip), %rax     # 0xf8fd0
movl -0x74(%rbp), %edi
callq *(%rax)
movq 0x48416(%rip), %rax     # 0xf8e90
movl -0x78(%rbp), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x484ad(%rip), %rax     # 0xf8f38
movl -0x60(%rbp), %edi
movl -0x5c(%rbp), %esi
callq *(%rax)
movq 0x4854e(%rip), %rax     # 0xf8fe8
movl -0x70(%rbp), %edi
movl -0x6c(%rbp), %esi
movl -0x68(%rbp), %edx
movl -0x64(%rbp), %ecx
callq *(%rax)
cmpb $0x0, -0x2a(%rbp)
je 0xb0aba
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc4e0
jmp 0xb0ac4
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc7d0
cmpb $0x0, -0x2b(%rbp)
je 0xb0ad6
movl $0xb44, %edi            # imm = 0xB44
callq 0xc4e0
jmp 0xb0ae0
movl $0xb44, %edi            # imm = 0xB44
callq 0xc7d0
cmpb $0x0, -0x2c(%rbp)
je 0xb0af2
movl $0xb71, %edi            # imm = 0xB71
callq 0xc4e0
jmp 0xb0afc
movl $0xb71, %edi            # imm = 0xB71
callq 0xc7d0
cmpb $0x0, -0x2d(%rbp)
je 0xb0b0e
movl $0xb90, %edi            # imm = 0xB90
callq 0xc4e0
jmp 0xb0b18
movl $0xb90, %edi            # imm = 0xB90
callq 0xc7d0
cmpb $0x0, -0x2e(%rbp)
je 0xb0b2a
movl $0xc11, %edi            # imm = 0xC11
callq 0xc4e0
jmp 0xb0b34
movl $0xc11, %edi            # imm = 0xC11
callq 0xc7d0
cmpl $0x136, 0x53d12(%rip)   # imm = 0x136
jb 0xb0b5c
cmpb $0x0, -0x29(%rbp)
je 0xb0b52
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc7d0
jmp 0xb0b5c
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