// File: /workspace/github_cpp_makefile_star2_O1/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 -0x50(%rbp), %rsi
movl $0x8069, %edi           # imm = 0x8069
callq 0xc740
leaq -0x4c(%rbp), %rsi
movl $0x8894, %edi           # imm = 0x8894
callq 0xc740
leaq -0x48(%rbp), %rsi
movl $0x85b5, %edi           # imm = 0x85B5
callq 0xc740
movl $0x82, %ebx
leaq -0x54(%rbp), %r14
movl %ebx, (%r14)
leaq 0x54586(%rip), %r12     # 0x104860
leaq 0x254a8(%rip), %rsi     # 0xd5789
movq %r12, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xc0c0
movl (%r14), %eax
cmpl %ebx, %eax
jge 0xb0305
leaq 0x25799(%rip), %r15     # 0xd5a95
leaq 0x25492(%rip), %rax     # 0xd5795
jmp 0xb0345
cmpl $0x199, %eax            # imm = 0x199
jle 0xb031c
leaq 0x259bd(%rip), %r15     # 0xd5cd0
leaq 0x25661(%rip), %rax     # 0xd597b
jmp 0xb0345
cmpl $0x12c, %eax            # imm = 0x12C
leaq 0x2563a(%rip), %rcx     # 0xd5962
leaq 0x2555b(%rip), %rax     # 0xd588a
cmoveq %rcx, %rax
leaq 0x258c7(%rip), %rcx     # 0xd5c01
leaq 0x25820(%rip), %r15     # 0xd5b61
cmoveq %rcx, %r15
leaq -0x80(%rbp), %r14
movq %r12, (%r14)
movq %rax, 0x8(%r14)
movq 0x48c61(%rip), %r12     # 0xf8fb8
movl $0x8b31, %edi           # imm = 0x8B31
callq *(%r12)
movl %eax, 0x54522(%rip)     # 0x104888
movq 0x48c03(%rip), %r13     # 0xf8f70
movl %eax, %edi
movl $0x2, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq *(%r13)
movq 0x48b94(%rip), %rbx     # 0xf8f18
movl 0x544fe(%rip), %edi     # 0x104888
callq *(%rbx)
movl 0x544f6(%rip), %edi     # 0x104888
leaq 0x259ed(%rip), %rsi     # 0xd5d86
callq 0xb0f84
leaq -0x70(%rbp), %r14
leaq 0x544b7(%rip), %rax     # 0x104860
movq %rax, (%r14)
movq %r15, 0x8(%r14)
movl $0x8b30, %edi           # imm = 0x8B30
callq *(%r12)
movl %eax, 0x544cd(%rip)     # 0x10488c
movl %eax, %edi
movl $0x2, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq *(%r13)
movl 0x544b7(%rip), %edi     # 0x10488c
callq *(%rbx)
movl 0x544af(%rip), %edi     # 0x10488c
leaq 0x259b0(%rip), %rsi     # 0xd5d94
callq 0xb0f84
movq 0x48b00(%rip), %rax     # 0xf8ef0
callq *(%rax)
movl %eax, 0x54488(%rip)     # 0x104880
movq 0x48b51(%rip), %rbx     # 0xf8f50
movl 0x54483(%rip), %esi     # 0x104888
movl %eax, %edi
callq *(%rbx)
movl 0x54471(%rip), %edi     # 0x104880
movl 0x54477(%rip), %esi     # 0x10488c
callq *(%rbx)
movq 0x48b42(%rip), %rax     # 0xf8f60
movl 0x5445c(%rip), %edi     # 0x104880
callq *(%rax)
movl 0x54454(%rip), %ebx     # 0x104880
leaq -0x58(%rbp), %r14
xorl %eax, %eax
movl %eax, (%r14)
leaq -0x44(%rbp), %r15
movl %eax, (%r15)
movq 0x48a75(%rip), %r12     # 0xf8eb8
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 0xb054f
movl -0x44(%rbp), %ecx
cmpl $0x2, %ecx
jge 0xb0559
movq 0x48a1c(%rip), %rbx     # 0xf8e98
movl 0x543fe(%rip), %edi     # 0x104880
leaq 0x2592a(%rip), %rsi     # 0xd5db3
callq *(%rbx)
movl %eax, 0x543ff(%rip)     # 0x104890
movl 0x543e9(%rip), %edi     # 0x104880
leaq 0x2591d(%rip), %rsi     # 0xd5dbb
callq *(%rbx)
movl %eax, 0x543ee(%rip)     # 0x104894
movq 0x48afb(%rip), %rbx     # 0xf8fa8
movl 0x543cd(%rip), %edi     # 0x104880
leaq 0xe616(%rip), %rsi      # 0xbead0
callq *(%rbx)
movl %eax, 0x543d6(%rip)     # 0x104898
movl 0x543b8(%rip), %edi     # 0x104880
leaq 0x258f4(%rip), %rsi     # 0xd5dc3
callq *(%rbx)
movl %eax, 0x543c5(%rip)     # 0x10489c
movl 0x543a3(%rip), %edi     # 0x104880
leaq 0x10984(%rip), %rsi     # 0xc0e68
callq *(%rbx)
movl %eax, 0x543b4(%rip)     # 0x1048a0
movq 0x489d5(%rip), %rbx     # 0xf8ec8
leaq 0x543aa(%rip), %rsi     # 0x1048a4
movl $0x1, %edi
callq *(%rbx)
leaq 0x543a0(%rip), %rsi     # 0x1048a8
movl $0x1, %edi
callq *(%rbx)
callq 0xb0e39
movl -0x50(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0xc960
movq 0x48968(%rip), %rax     # 0xf8e90
movl -0x4c(%rbp), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
movq 0x48a97(%rip), %rax     # 0xf8fd0
movl -0x48(%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 0xb0469
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leal 0x1(%rcx), %r15d
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jg 0xb05c2
movl $0x8, %r12d
testl %eax, %eax
je 0xb0585
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
addl %eax, %r12d
cmpl %r15d, %r12d
cmovlel %r15d, %r12d
cmpl %r12d, %eax
jge 0xb05c2
movl %r12d, %edi
callq 0x424fb
movq %rax, %r14
movq -0x38(%rbp), %rsi
testq %rsi, %rsi
je 0xb05ba
movslq -0x40(%rbp), %rdx
movq %r14, %rdi
callq 0xc080
movq -0x38(%rbp), %rdi
callq 0x425d4
movq %r14, -0x38(%rbp)
movl %r12d, -0x3c(%rbp)
movl %r15d, -0x40(%rbp)
movq 0x4897b(%rip), %rax     # 0xf8f48
movl -0x44(%rbp), %esi
movq -0x38(%rbp), %rcx
movl %ebx, %edi
xorl %edx, %edx
callq *(%rax)
movq 0x4892f(%rip), %rax     # 0xf8f10
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x16fd2(%rip), %rsi     # 0xc75c1
xorl %eax, %eax
callq 0xc1a0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0xb0475
callq 0x425d4
jmp 0xb0475
movq %rax, %rdi
callq 0x3a5b4
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x5f8d6
movq %rbx, %rdi
callq 0xc560