// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/backends/imgui_impl_opengl3.cpp
// Function: ImGui_ImplOpenGL3_CreateDeviceObjects()
bool    ImGui_ImplOpenGL3_CreateDeviceObjects()
{
    // Backup GL state
    GLint last_texture, last_array_buffer;
    glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
    glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
#ifndef IMGUI_IMPL_OPENGL_ES2
    GLint last_vertex_array;
    glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
#endif

    // Parse GLSL version string
    int glsl_version = 130;
    sscanf(g_GlslVersionString, "#version %d", &glsl_version);

    const GLchar* vertex_shader_glsl_120 =
        "uniform mat4 ProjMtx;\n"
        "attribute vec2 Position;\n"
        "attribute vec2 UV;\n"
        "attribute vec4 Color;\n"
        "varying vec2 Frag_UV;\n"
        "varying vec4 Frag_Color;\n"
        "void main()\n"
        "{\n"
        "    Frag_UV = UV;\n"
        "    Frag_Color = Color;\n"
        "    gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
        "}\n";

    const GLchar* vertex_shader_glsl_130 =
        "uniform mat4 ProjMtx;\n"
        "in vec2 Position;\n"
        "in vec2 UV;\n"
        "in vec4 Color;\n"
        "out vec2 Frag_UV;\n"
        "out vec4 Frag_Color;\n"
        "void main()\n"
        "{\n"
        "    Frag_UV = UV;\n"
        "    Frag_Color = Color;\n"
        "    gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
        "}\n";

    const GLchar* vertex_shader_glsl_300_es =
        "precision mediump float;\n"
        "layout (location = 0) in vec2 Position;\n"
        "layout (location = 1) in vec2 UV;\n"
        "layout (location = 2) in vec4 Color;\n"
        "uniform mat4 ProjMtx;\n"
        "out vec2 Frag_UV;\n"
        "out vec4 Frag_Color;\n"
        "void main()\n"
        "{\n"
        "    Frag_UV = UV;\n"
        "    Frag_Color = Color;\n"
        "    gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
        "}\n";

    const GLchar* vertex_shader_glsl_410_core =
        "layout (location = 0) in vec2 Position;\n"
        "layout (location = 1) in vec2 UV;\n"
        "layout (location = 2) in vec4 Color;\n"
        "uniform mat4 ProjMtx;\n"
        "out vec2 Frag_UV;\n"
        "out vec4 Frag_Color;\n"
        "void main()\n"
        "{\n"
        "    Frag_UV = UV;\n"
        "    Frag_Color = Color;\n"
        "    gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
        "}\n";

    const GLchar* fragment_shader_glsl_120 =
        "#ifdef GL_ES\n"
        "    precision mediump float;\n"
        "#endif\n"
        "uniform sampler2D Texture;\n"
        "varying vec2 Frag_UV;\n"
        "varying vec4 Frag_Color;\n"
        "void main()\n"
        "{\n"
        "    gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
        "}\n";

    const GLchar* fragment_shader_glsl_130 =
        "uniform sampler2D Texture;\n"
        "in vec2 Frag_UV;\n"
        "in vec4 Frag_Color;\n"
        "out vec4 Out_Color;\n"
        "void main()\n"
        "{\n"
        "    Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
        "}\n";

    const GLchar* fragment_shader_glsl_300_es =
        "precision mediump float;\n"
        "uniform sampler2D Texture;\n"
        "in vec2 Frag_UV;\n"
        "in vec4 Frag_Color;\n"
        "layout (location = 0) out vec4 Out_Color;\n"
        "void main()\n"
        "{\n"
        "    Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
        "}\n";

    const GLchar* fragment_shader_glsl_410_core =
        "in vec2 Frag_UV;\n"
        "in vec4 Frag_Color;\n"
        "uniform sampler2D Texture;\n"
        "layout (location = 0) out vec4 Out_Color;\n"
        "void main()\n"
        "{\n"
        "    Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
        "}\n";

    // Select shaders matching our GLSL versions
    const GLchar* vertex_shader = NULL;
    const GLchar* fragment_shader = NULL;
    if (glsl_version < 130)
    {
        vertex_shader = vertex_shader_glsl_120;
        fragment_shader = fragment_shader_glsl_120;
    }
    else if (glsl_version >= 410)
    {
        vertex_shader = vertex_shader_glsl_410_core;
        fragment_shader = fragment_shader_glsl_410_core;
    }
    else if (glsl_version == 300)
    {
        vertex_shader = vertex_shader_glsl_300_es;
        fragment_shader = fragment_shader_glsl_300_es;
    }
    else
    {
        vertex_shader = vertex_shader_glsl_130;
        fragment_shader = fragment_shader_glsl_130;
    }

    // Create shaders
    const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
    g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
    glCompileShader(g_VertHandle);
    CheckShader(g_VertHandle, "vertex shader");

    const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader };
    g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL);
    glCompileShader(g_FragHandle);
    CheckShader(g_FragHandle, "fragment shader");

    g_ShaderHandle = glCreateProgram();
    glAttachShader(g_ShaderHandle, g_VertHandle);
    glAttachShader(g_ShaderHandle, g_FragHandle);
    glLinkProgram(g_ShaderHandle);
    CheckProgram(g_ShaderHandle, "shader program");

    g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
    g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
    g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position");
    g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV");
    g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color");

    // Create buffers
    glGenBuffers(1, &g_VboHandle);
    glGenBuffers(1, &g_ElementsHandle);

    ImGui_ImplOpenGL3_CreateFontsTexture();

    // Restore modified GL state
    glBindTexture(GL_TEXTURE_2D, last_texture);
    glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
#ifndef IMGUI_IMPL_OPENGL_ES2
    glBindVertexArray(last_vertex_array);
#endif

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq -0x38(%rbp), %rsi
movl $0x8069, %edi           # imm = 0x8069
callq 0xc740
leaq -0x34(%rbp), %rsi
movl $0x8894, %edi           # imm = 0x8894
callq 0xc740
leaq -0x30(%rbp), %rsi
movl $0x85b5, %edi           # imm = 0x85B5
callq 0xc740
movl $0x82, %ebx
leaq -0x54(%rbp), %r14
movl %ebx, (%r14)
leaq 0x53c56(%rip), %r12     # 0x102860
leaq 0x24a28(%rip), %rsi     # 0xd3639
movq %r12, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xc0c0
movl (%r14), %eax
cmpl %ebx, %eax
jge 0xaec35
leaq 0x24d19(%rip), %r15     # 0xd3945
leaq 0x24a12(%rip), %rax     # 0xd3645
jmp 0xaec75
cmpl $0x199, %eax            # imm = 0x199
jbe 0xaec4c
leaq 0x24f3d(%rip), %r15     # 0xd3b80
leaq 0x24be1(%rip), %rax     # 0xd382b
jmp 0xaec75
cmpl $0x12c, %eax            # imm = 0x12C
leaq 0x24bba(%rip), %rcx     # 0xd3812
leaq 0x24adb(%rip), %rax     # 0xd373a
cmoveq %rcx, %rax
leaq 0x24e47(%rip), %rcx     # 0xd3ab1
leaq 0x24da0(%rip), %r15     # 0xd3a11
cmoveq %rcx, %r15
leaq -0x80(%rbp), %r14
movq %r12, (%r14)
movq %rax, 0x8(%r14)
movq 0x48331(%rip), %r12     # 0xf6fb8
movl $0x8b31, %edi           # imm = 0x8B31
callq *(%r12)
movl %eax, 0x53bf2(%rip)     # 0x102888
movq 0x482d3(%rip), %r13     # 0xf6f70
movl %eax, %edi
movl $0x2, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq *(%r13)
movq 0x48264(%rip), %rbx     # 0xf6f18
movl 0x53bce(%rip), %edi     # 0x102888
callq *(%rbx)
movl 0x53bc6(%rip), %edi     # 0x102888
leaq 0x24f6d(%rip), %rsi     # 0xd3c36
callq 0xaf875
leaq -0x70(%rbp), %r14
leaq 0x53b87(%rip), %rax     # 0x102860
movq %rax, (%r14)
movq %r15, 0x8(%r14)
movl $0x8b30, %edi           # imm = 0x8B30
callq *(%r12)
movl %eax, 0x53b9d(%rip)     # 0x10288c
movl %eax, %edi
movl $0x2, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq *(%r13)
movl 0x53b87(%rip), %edi     # 0x10288c
callq *(%rbx)
movl 0x53b7f(%rip), %edi     # 0x10288c
leaq 0x24f30(%rip), %rsi     # 0xd3c44
callq 0xaf875
movq 0x481d0(%rip), %rax     # 0xf6ef0
callq *(%rax)
movl %eax, 0x53b58(%rip)     # 0x102880
movq 0x48221(%rip), %rbx     # 0xf6f50
movl 0x53b53(%rip), %esi     # 0x102888
movl %eax, %edi
callq *(%rbx)
movl 0x53b41(%rip), %edi     # 0x102880
movl 0x53b47(%rip), %esi     # 0x10288c
callq *(%rbx)
movq 0x48212(%rip), %rax     # 0xf6f60
movl 0x53b2c(%rip), %edi     # 0x102880
callq *(%rax)
movl 0x53b24(%rip), %ebx     # 0x102880
leaq -0x58(%rbp), %r14
xorl %eax, %eax
movl %eax, (%r14)
leaq -0x2c(%rbp), %r15
movl %eax, (%r15)
movq 0x48145(%rip), %r12     # 0xf6eb8
movl %ebx, %edi
movl $0x8b82, %esi           # imm = 0x8B82
movq %r14, %rdx
callq *(%r12)
movl %ebx, %edi
movl $0x8b84, %esi           # imm = 0x8B84
movq %r15, %rdx
callq *(%r12)
cmpb $0x0, (%r14)
je 0xaee81
movl -0x2c(%rbp), %r12d
cmpl $0x2, %r12d
jge 0xaee8b
movq 0x480ea(%rip), %rbx     # 0xf6e98
movl 0x53acc(%rip), %edi     # 0x102880
leaq 0x24ea8(%rip), %rsi     # 0xd3c63
callq *(%rbx)
movl %eax, 0x53acd(%rip)     # 0x102890
movl 0x53ab7(%rip), %edi     # 0x102880
leaq 0x24e9b(%rip), %rsi     # 0xd3c6b
callq *(%rbx)
movl %eax, 0x53abc(%rip)     # 0x102894
movq 0x481c9(%rip), %rbx     # 0xf6fa8
movl 0x53a9b(%rip), %edi     # 0x102880
leaq 0xdcb4(%rip), %rsi      # 0xbcaa0
callq *(%rbx)
movl %eax, 0x53aa4(%rip)     # 0x102898
movl 0x53a86(%rip), %edi     # 0x102880
leaq 0x24e72(%rip), %rsi     # 0xd3c73
callq *(%rbx)
movl %eax, 0x53a93(%rip)     # 0x10289c
movl 0x53a71(%rip), %edi     # 0x102880
leaq 0x10022(%rip), %rsi     # 0xbee38
callq *(%rbx)
movl %eax, 0x53a82(%rip)     # 0x1028a0
movq 0x480a3(%rip), %rbx     # 0xf6ec8
leaq 0x53a78(%rip), %rsi     # 0x1028a4
movl $0x1, %edi
callq *(%rbx)
leaq 0x53a6e(%rip), %rsi     # 0x1028a8
movl $0x1, %edi
callq *(%rbx)
callq 0xaf72a
movl -0x38(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc960
movq 0x48036(%rip), %rax     # 0xf6e90
movl -0x34(%rbp), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x48165(%rip), %rax     # 0xf6fd0
movl -0x30(%rbp), %edi
callq *(%rax)
movb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xcebf
jmp 0xaed99
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
incl %r12d
cmpl $0x9, %r12d
movl $0x8, %r15d
cmovael %r12d, %r15d
movq %r15, %rdi
callq 0x41c63
movq %rax, %r14
movl -0x2c(%rbp), %esi
movq %rax, -0x48(%rbp)
movl %r15d, -0x4c(%rbp)
movl %r12d, -0x50(%rbp)
movq 0x48084(%rip), %rax     # 0xf6f48
movl %ebx, %edi
xorl %edx, %edx
movq %r14, %rcx
callq *(%rax)
movq 0x4803c(%rip), %rax     # 0xf6f10
movq (%rax), %rdi
leaq 0x166b3(%rip), %rsi     # 0xc5591
movq %r14, %rdx
xorl %eax, %eax
callq 0xc1a0
testq %r14, %r14
je 0xaeda7
movq %r14, %rdi
callq 0x41d3c
jmp 0xaeda7
movq %rax, %rdi
callq 0x39dbe
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x5e6f8
movq %rbx, %rdi
callq 0xc560