// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/backends/imgui_impl_opengl3.cpp
// Function: ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int)
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
{
    // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
    glEnable(GL_BLEND);
    glBlendEquation(GL_FUNC_ADD);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glDisable(GL_CULL_FACE);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_STENCIL_TEST);
    glEnable(GL_SCISSOR_TEST);
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
    if (g_GlVersion >= 310)
        glDisable(GL_PRIMITIVE_RESTART);
#endif
#ifdef GL_POLYGON_MODE
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
#endif

    // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
    bool clip_origin_lower_left = true;
    GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&current_clip_origin);
    if (current_clip_origin == GL_UPPER_LEFT)
        clip_origin_lower_left = false;
#endif

    // Setup viewport, orthographic projection matrix
    // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
    glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
    float L = draw_data->DisplayPos.x;
    float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
    float T = draw_data->DisplayPos.y;
    float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
    if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
#endif
    const float ortho_projection[4][4] =
    {
        { 2.0f/(R-L),   0.0f,         0.0f,   0.0f },
        { 0.0f,         2.0f/(T-B),   0.0f,   0.0f },
        { 0.0f,         0.0f,        -1.0f,   0.0f },
        { (R+L)/(L-R),  (T+B)/(B-T),  0.0f,   1.0f },
    };
    glUseProgram(g_ShaderHandle);
    glUniform1i(g_AttribLocationTex, 0);
    glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);

#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
    if (g_GlVersion >= 330)
        glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
#endif

    (void)vertex_array_object;
#ifndef IMGUI_IMPL_OPENGL_ES2
    glBindVertexArray(vertex_array_object);
#endif

    // Bind vertex/index buffers and setup attributes for ImDrawVert
    glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
    glEnableVertexAttribArray(g_AttribLocationVtxPos);
    glEnableVertexAttribArray(g_AttribLocationVtxUV);
    glEnableVertexAttribArray(g_AttribLocationVtxColor);
    glVertexAttribPointer(g_AttribLocationVtxPos,   2, GL_FLOAT,         GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
    glVertexAttribPointer(g_AttribLocationVtxUV,    2, GL_FLOAT,         GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
    glVertexAttribPointer(g_AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE,  sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebx
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %r14
movl $0xbe2, %edi            # imm = 0xBE2
callq 0xc500
movq 0x48865(%rip), %rax     # 0xdefb8
movl $0x8006, %edi           # imm = 0x8006
callq *(%rax)
movl $0x302, %edi            # imm = 0x302
movl $0x303, %esi            # imm = 0x303
callq 0xc970
movl $0xb44, %edi            # imm = 0xB44
callq 0xc820
movl $0xb71, %edi            # imm = 0xB71
callq 0xc820
movl $0xb90, %edi            # imm = 0xB90
callq 0xc820
movl $0xc11, %edi            # imm = 0xC11
callq 0xc500
cmpl $0x136, 0x540c5(%rip)   # imm = 0x136
jb 0x967a7
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc820
movl $0x408, %edi            # imm = 0x408
movl $0x1b02, %esi           # imm = 0x1B02
callq 0xc350
leaq -0x2c(%rbp), %r13
andl $0x0, (%r13)
movl $0x935c, %edi           # imm = 0x935C
movq %r13, %rsi
callq 0xc780
movl (%r13), %r13d
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq 0xc3b0
movss 0x1c(%r14), %xmm1
movss 0x20(%r14), %xmm0
movss 0x24(%r14), %xmm3
addss %xmm1, %xmm3
movss 0x28(%r14), %xmm2
addss %xmm0, %xmm2
movaps %xmm2, %xmm4
movaps %xmm0, %xmm5
cmpl $0x8ca2, %r13d          # imm = 0x8CA2
je 0x96814
movaps %xmm0, %xmm4
movaps %xmm2, %xmm5
movaps %xmm3, %xmm6
subss %xmm1, %xmm6
movss 0x6071(%rip), %xmm7     # 0x9c894
movaps %xmm7, %xmm8
divss %xmm6, %xmm8
leaq -0x70(%rbp), %r14
movss %xmm8, (%r14)
movaps %xmm4, %xmm6
subss %xmm5, %xmm6
divss %xmm6, %xmm7
xorps %xmm6, %xmm6
movups %xmm6, 0x4(%r14)
movss %xmm7, 0x14(%r14)
movups %xmm6, 0x18(%r14)
movl $0xbf800000, %eax       # imm = 0xBF800000
movq %rax, 0x28(%r14)
movaps %xmm1, %xmm6
addss %xmm3, %xmm6
subss %xmm3, %xmm1
divss %xmm1, %xmm6
movss %xmm6, 0x30(%r14)
addss %xmm2, %xmm0
subss %xmm4, %xmm5
divss %xmm5, %xmm0
movss %xmm0, 0x34(%r14)
movabsq $0x3f80000000000000, %rax # imm = 0x3F80000000000000
movq %rax, 0x38(%r14)
movq 0x48750(%rip), %rax     # 0xdefe8
movl 0x53ff2(%rip), %edi     # 0xea890
callq *(%rax)
movq 0x486a9(%rip), %rax     # 0xdef50
movl 0x53ff3(%rip), %edi     # 0xea8a0
xorl %esi, %esi
callq *(%rax)
movq 0x48638(%rip), %rax     # 0xdeef0
movl 0x53fe6(%rip), %edi     # 0xea8a4
pushq $0x1
popq %rsi
xorl %edx, %edx
movq %r14, %rcx
callq *(%rax)
cmpl $0x14a, 0x53f8e(%rip)   # imm = 0x14A
jb 0x968e1
movq 0x486b5(%rip), %rax     # 0xdef90
xorl %edi, %edi
xorl %esi, %esi
callq *(%rax)
movq 0x486f0(%rip), %rax     # 0xdefd8
movl %ebx, %edi
callq *(%rax)
movq 0x485bd(%rip), %rbx     # 0xdeeb0
movl 0x53fbb(%rip), %esi     # 0xea8b4
movl $0x8892, %edi           # imm = 0x8892
callq *(%rbx)
movl 0x53fb2(%rip), %esi     # 0xea8b8
movl $0x8893, %edi           # imm = 0x8893
callq *(%rbx)
movq 0x48694(%rip), %rbx     # 0xdefa8
movl 0x53f8e(%rip), %edi     # 0xea8a8
callq *(%rbx)
movl 0x53f8a(%rip), %edi     # 0xea8ac
callq *(%rbx)
movl 0x53f86(%rip), %edi     # 0xea8b0
callq *(%rbx)
movq 0x48695(%rip), %r15     # 0xdefc8
movl 0x53f6f(%rip), %edi     # 0xea8a8
pushq $0x2
popq %r14
pushq $0x14
popq %rbx
movl %r14d, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
callq *(%r15)
movl 0x53f53(%rip), %edi     # 0xea8ac
pushq $0x8
popq %r9
movl %r14d, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl %ebx, %r8d
callq *(%r15)
movl 0x53f3d(%rip), %edi     # 0xea8b0
pushq $0x4
popq %rsi
pushq $0x1
popq %rcx
pushq $0x10
popq %r9
movl $0x1401, %edx           # imm = 0x1401
movl %ebx, %r8d
callq *(%r15)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq