// File: /workspace/github_cpp_makefile_star2_O2/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 0xc780
leaq -0x34(%rbp), %rsi
movl $0x8894, %edi           # imm = 0x8894
callq 0xc780
leaq -0x30(%rbp), %rsi
movl $0x85b5, %edi           # imm = 0x85B5
callq 0xc780
movl $0x82, %ebx
leaq -0x54(%rbp), %r14
movl %ebx, (%r14)
leaq 0x549ae(%rip), %r13     # 0xea870
leaq 0x24b00(%rip), %rsi     # 0xba9c9
movq %r13, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xc0c0
movl (%r14), %eax
cmpl %ebx, %eax
jge 0x95eed
leaq 0x24df1(%rip), %r12     # 0xbacd5
leaq 0x24aea(%rip), %rax     # 0xba9d5
jmp 0x95f2d
cmpl $0x199, %eax            # imm = 0x199
jbe 0x95f04
leaq 0x25015(%rip), %r12     # 0xbaf10
leaq 0x24cb9(%rip), %rax     # 0xbabbb
jmp 0x95f2d
cmpl $0x12c, %eax            # imm = 0x12C
leaq 0x24c92(%rip), %rcx     # 0xbaba2
leaq 0x24bb3(%rip), %rax     # 0xbaaca
cmoveq %rcx, %rax
leaq 0x24f1f(%rip), %rcx     # 0xbae41
leaq 0x24e78(%rip), %r12     # 0xbada1
cmoveq %rcx, %r12
leaq -0x80(%rbp), %r15
movq %r13, (%r15)
movq %rax, 0x8(%r15)
movq 0x49081(%rip), %rax     # 0xdefc0
movl $0x8b31, %edi           # imm = 0x8B31
callq *(%rax)
movl %eax, 0x5494c(%rip)     # 0xea898
movq 0x4902d(%rip), %r8      # 0xdef80
pushq $0x2
popq %r14
movl %eax, %edi
movl %r14d, %esi
movq %r15, %rdx
xorl %ecx, %ecx
callq *(%r8)
movq %r13, %rbx
movq 0x48fc2(%rip), %r13     # 0xdef30
movl 0x54924(%rip), %edi     # 0xea898
callq *(%r13)
movl 0x5491a(%rip), %edi     # 0xea898
leaq 0x25041(%rip), %rsi     # 0xbafc6
callq 0x96ad8
leaq -0x70(%rbp), %r15
movq %rbx, (%r15)
movq %r12, 0x8(%r15)
movl $0x8b30, %edi           # imm = 0x8B30
movq 0x4901f(%rip), %rax     # 0xdefc0
callq *(%rax)
movl %eax, 0x548f3(%rip)     # 0xea89c
movl %eax, %edi
movl %r14d, %esi
movq %r15, %rdx
xorl %ecx, %ecx
movq 0x48fc6(%rip), %rax     # 0xdef80
callq *(%rax)
movl 0x548da(%rip), %edi     # 0xea89c
callq *(%r13)
movl 0x548d0(%rip), %edi     # 0xea89c
leaq 0x25001(%rip), %rsi     # 0xbafd4
callq 0x96ad8
movq 0x48f29(%rip), %rax     # 0xdef08
callq *(%rax)
movl %eax, 0x548a9(%rip)     # 0xea890
movq 0x48f72(%rip), %rbx     # 0xdef60
movl 0x548a4(%rip), %esi     # 0xea898
movl %eax, %edi
callq *(%rbx)
movl 0x54892(%rip), %edi     # 0xea890
movl 0x54898(%rip), %esi     # 0xea89c
callq *(%rbx)
movq 0x48f63(%rip), %rax     # 0xdef70
movl 0x5487d(%rip), %edi     # 0xea890
callq *(%rax)
movl 0x54875(%rip), %ebx     # 0xea890
leaq -0x58(%rbp), %r14
andl $0x0, (%r14)
leaq -0x2c(%rbp), %r15
andl $0x0, (%r15)
movq 0x48ea6(%rip), %r12     # 0xdeed8
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 0x9613d
movl -0x2c(%rbp), %esi
cmpl $0x2, %esi
jge 0x96168
movq 0x48e4d(%rip), %rbx     # 0xdeeb8
movl 0x5481f(%rip), %edi     # 0xea890
leaq 0x24f7b(%rip), %rsi     # 0xbaff3
callq *(%rbx)
movl %eax, 0x54820(%rip)     # 0xea8a0
movl 0x5480a(%rip), %edi     # 0xea890
leaq 0x24f6e(%rip), %rsi     # 0xbaffb
callq *(%rbx)
movl %eax, 0x5480f(%rip)     # 0xea8a4
movq 0x48f14(%rip), %rbx     # 0xdefb0
movl 0x547ee(%rip), %edi     # 0xea890
leaq 0xdd27(%rip), %rsi      # 0xa3dd0
callq *(%rbx)
movl %eax, 0x547f7(%rip)     # 0xea8a8
movl 0x547d9(%rip), %edi     # 0xea890
leaq 0x24f45(%rip), %rsi     # 0xbb003
callq *(%rbx)
movl %eax, 0x547e6(%rip)     # 0xea8ac
movl 0x547c4(%rip), %edi     # 0xea890
leaq 0x10095(%rip), %rsi     # 0xa6168
callq *(%rbx)
movl %eax, 0x547d5(%rip)     # 0xea8b0
movq 0x48e06(%rip), %r14     # 0xdeee8
leaq 0x547cb(%rip), %rsi     # 0xea8b4
pushq $0x1
popq %rbx
movl %ebx, %edi
callq *(%r14)
leaq 0x547c0(%rip), %rsi     # 0xea8b8
movl %ebx, %edi
callq *(%r14)
callq 0x96997
movl -0x38(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc990
movq 0x48d9a(%rip), %rax     # 0xdeeb0
movl -0x34(%rbp), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x48eb1(%rip), %rax     # 0xdefd8
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
movq 0x48de4(%rip), %rax     # 0xdef28
movq (%rax), %rdi
leaq 0x24efd(%rip), %rsi     # 0xbb04b
leaq 0x24e8f(%rip), %rdx     # 0xbafe4
leaq 0x54714(%rip), %rcx     # 0xea870
xorl %eax, %eax
callq 0xc1a0
jmp 0x96058
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rdi
movaps %xmm0, (%rdi)
incl %esi
callq 0x49cb6
movq 0x48dd8(%rip), %rax     # 0xdef58
movl -0x2c(%rbp), %esi
movq -0x48(%rbp), %rcx
movl %ebx, %edi
xorl %edx, %edx
callq *(%rax)
movq 0x48d94(%rip), %rax     # 0xdef28
movq (%rax), %rdi
leaq -0x50(%rbp), %rbx
movq 0x8(%rbx), %rdx
leaq 0x1675d(%rip), %rsi     # 0xac903
xorl %eax, %eax
callq 0xc1a0
movq %rbx, %rdi
callq 0x4be3a
jmp 0x96064
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x4be3a
movq %rbx, %rdi
callq 0xc580