// File: /workspace/github_cpp_makefile_star2_O1/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 0x483cb(%rip), %rax     # 0xf8fb0
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, 0x53c23(%rip)   # imm = 0x136
jb 0xb0c39
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 0xb0ca9
movaps %xmm0, %xmm4
movaps %xmm2, %xmm5
movaps %xmm3, %xmm6
subss %xmm1, %xmm6
movss 0x6bb0(%rip), %xmm7     # 0xb7868
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 0x482b3(%rip), %rax     # 0xf8fe0
movl 0x53b4d(%rip), %edi     # 0x104880
callq *(%rax)
movq 0x48204(%rip), %rax     # 0xf8f40
movl 0x53b4e(%rip), %edi     # 0x104890
xorl %esi, %esi
callq *(%rax)
movq 0x48183(%rip), %rax     # 0xf8ed0
movl 0x53b41(%rip), %edi     # 0x104894
movl $0x1, %esi
xorl %edx, %edx
movq %r14, %rcx
callq *(%rax)
cmpl $0x14a, 0x53ae7(%rip)   # imm = 0x14A
jb 0xb0d78
movq 0x48216(%rip), %rax     # 0xf8f88
xorl %edi, %edi
xorl %esi, %esi
callq *(%rax)
movq 0x48251(%rip), %rax     # 0xf8fd0
movl %ebx, %edi
callq *(%rax)
movq 0x48106(%rip), %rbx     # 0xf8e90
movl 0x53b14(%rip), %esi     # 0x1048a4
movl $0x8892, %edi           # imm = 0x8892
callq *(%rbx)
movl 0x53b0b(%rip), %esi     # 0x1048a8
movl $0x8893, %edi           # imm = 0x8893
callq *(%rbx)
movq 0x481f5(%rip), %rbx     # 0xf8fa0
movl 0x53ae7(%rip), %edi     # 0x104898
callq *(%rbx)
movl 0x53ae3(%rip), %edi     # 0x10489c
callq *(%rbx)
movl 0x53adf(%rip), %edi     # 0x1048a0
callq *(%rbx)
movq 0x481f6(%rip), %rbx     # 0xf8fc0
movl 0x53ac8(%rip), %edi     # 0x104898
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
xorl %r9d, %r9d
callq *(%rbx)
movl 0x53aaf(%rip), %edi     # 0x10489c
movl $0x8, %r9d
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x14, %r8d
callq *(%rbx)
movl 0x53a93(%rip), %edi     # 0x1048a0
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