// File: /workspace/github_cpp_makefile_star2_O3/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 0xc4e0
movq 0x47ada(%rip), %rax     # 0xf6fb0
movl $0x8006, %edi           # imm = 0x8006
callq *(%rax)
movl $0x302, %edi            # imm = 0x302
movl $0x303, %esi            # imm = 0x303
callq 0xc940
movl $0xb44, %edi            # imm = 0xB44
callq 0xc7d0
movl $0xb71, %edi            # imm = 0xB71
callq 0xc7d0
movl $0xb90, %edi            # imm = 0xB90
callq 0xc7d0
movl $0xc11, %edi            # imm = 0xC11
callq 0xc4e0
cmpl $0x136, 0x53332(%rip)   # imm = 0x136
jb 0xaf52a
movl $0x8f9d, %edi           # imm = 0x8F9D
callq 0xc7d0
movl $0x408, %edi            # imm = 0x408
movl $0x1b02, %esi           # imm = 0x1B02
callq 0xc320
leaq -0x2c(%rbp), %r13
movl $0x0, (%r13)
movl $0x935c, %edi           # imm = 0x935C
movq %r13, %rsi
callq 0xc740
movl (%r13), %r13d
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %edx
movl %r15d, %ecx
callq 0xc370
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 0xaf59a
movaps %xmm0, %xmm4
movaps %xmm2, %xmm5
movaps %xmm3, %xmm6
subss %xmm1, %xmm6
movss 0x62bf(%rip), %xmm7     # 0xb5868
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 0x479c2(%rip), %rax     # 0xf6fe0
movl 0x5325c(%rip), %edi     # 0x102880
callq *(%rax)
movq 0x47913(%rip), %rax     # 0xf6f40
movl 0x5325d(%rip), %edi     # 0x102890
xorl %esi, %esi
callq *(%rax)
movq 0x47892(%rip), %rax     # 0xf6ed0
movl 0x53250(%rip), %edi     # 0x102894
movl $0x1, %esi
xorl %edx, %edx
movq %r14, %rcx
callq *(%rax)
cmpl $0x14a, 0x531f6(%rip)   # imm = 0x14A
jb 0xaf669
movq 0x47925(%rip), %rax     # 0xf6f88
xorl %edi, %edi
xorl %esi, %esi
callq *(%rax)
movq 0x47960(%rip), %rax     # 0xf6fd0
movl %ebx, %edi
callq *(%rax)
movq 0x47815(%rip), %rbx     # 0xf6e90
movl 0x53223(%rip), %esi     # 0x1028a4
movl $0x8892, %edi           # imm = 0x8892
callq *(%rbx)
movl 0x5321a(%rip), %esi     # 0x1028a8
movl $0x8893, %edi           # imm = 0x8893
callq *(%rbx)
movq 0x47904(%rip), %rbx     # 0xf6fa0
movl 0x531f6(%rip), %edi     # 0x102898
callq *(%rbx)
movl 0x531f2(%rip), %edi     # 0x10289c
callq *(%rbx)
movl 0x531ee(%rip), %edi     # 0x1028a0
callq *(%rbx)
movq 0x47905(%rip), %rbx     # 0xf6fc0
movl 0x531d7(%rip), %edi     # 0x102898
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
xorl %r9d, %r9d
callq *(%rbx)
movl 0x531be(%rip), %edi     # 0x10289c
movl $0x8, %r9d
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
callq *(%rbx)
movl 0x531a2(%rip), %edi     # 0x1028a0
movl $0x10, %r9d
movl $0x4, %esi
movl $0x1401, %edx           # imm = 0x1401
movl $0x1, %ecx
movl $0x14, %r8d
callq *(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq