// File: /workspace/github_cpp_makefile_star2_O3/donfreiday[P]gb/./imgui/imgui_impl_sdl.cpp
// Function: ImGui_ImplSdl_CreateDeviceObjects()
bool ImGui_ImplSdl_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);

    const GLchar *vertex_shader =
        "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* fragment_shader =
#ifdef __EMSCRIPTEN__
        // WebGL requires precision specifiers but OpenGL 2.1 disallows
        // them, so I define the shader without it and then add it here.
        "precision mediump float;\n"
#endif
        "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);\n"
        "}\n";

    g_ShaderHandle = glCreateProgram();
    g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
    g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(g_VertHandle, 1, &vertex_shader, 0);
    glShaderSource(g_FragHandle, 1, &fragment_shader, 0);
    glCompileShader(g_VertHandle);
    glCompileShader(g_FragHandle);
    glAttachShader(g_ShaderHandle, g_VertHandle);
    glAttachShader(g_ShaderHandle, g_FragHandle);
    glLinkProgram(g_ShaderHandle);
    
    g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
    g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
    g_AttribLocationPosition = glGetAttribLocation(g_ShaderHandle, "Position");
    g_AttribLocationUV = glGetAttribLocation(g_ShaderHandle, "UV");
    g_AttribLocationColor = glGetAttribLocation(g_ShaderHandle, "Color");

    glGenBuffers(1, &g_VboHandle);
    glGenBuffers(1, &g_ElementsHandle);

    ImGuiIO& io = ImGui::GetIO();

    // Build texture
    unsigned char* pixels;
    int width, height;
    io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);   // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.

    // Create OpenGL texture
    glGenTextures(1, &g_FontTexture);
    glBindTexture(GL_TEXTURE_2D, g_FontTexture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

    // Store our identifier
    io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;

    // Cleanup (don't clear the input data if you want to append new fonts later)
    io.Fonts->ClearInputData();
    io.Fonts->ClearTexData();

    // Restore modified GL state
    glBindTexture(GL_TEXTURE_2D, last_texture);
    glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq -0x2c(%rbp), %rsi
movl $0x8069, %edi           # imm = 0x8069
callq 0x7650
leaq -0x38(%rbp), %r14
movl $0x8894, %edi           # imm = 0x8894
movq %r14, %rsi
callq 0x7650
leaq 0x10e42(%rip), %rax     # 0x47f48
leaq -0x50(%rbp), %r15
movq %rax, (%r15)
leaq 0x10f20(%rip), %rax     # 0x48034
leaq -0x48(%rbp), %rbx
movq %rax, (%rbx)
callq 0x7780
movl %eax, 0x28c82(%rip)     # 0x5fda8
movl $0x8b31, %edi           # imm = 0x8B31
callq 0x71b0
movl %eax, 0x28c9a(%rip)     # 0x5fdd0
movl $0x8b30, %edi           # imm = 0x8B30
callq 0x71b0
movl %eax, 0x28c8e(%rip)     # 0x5fdd4
movl 0x28c84(%rip), %edi     # 0x5fdd0
movl $0x1, %esi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x7680
movl 0x28c73(%rip), %edi     # 0x5fdd4
movl $0x1, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x7680
movl 0x28c5a(%rip), %edi     # 0x5fdd0
callq 0x7090
movl 0x28c53(%rip), %edi     # 0x5fdd4
callq 0x7090
movl 0x28c1c(%rip), %edi     # 0x5fda8
movl 0x28c3e(%rip), %esi     # 0x5fdd0
callq 0x7540
movl 0x28c0b(%rip), %edi     # 0x5fda8
movl 0x28c31(%rip), %esi     # 0x5fdd4
callq 0x7540
movl 0x28bfa(%rip), %edi     # 0x5fda8
callq 0x7800
movl 0x28bef(%rip), %edi     # 0x5fda8
leaq 0x10f09(%rip), %rsi     # 0x480c9
callq 0x7280
movl %eax, 0x28be1(%rip)     # 0x5fdac
movl 0x28bd7(%rip), %edi     # 0x5fda8
leaq 0x10ef9(%rip), %rsi     # 0x480d1
callq 0x7280
movl %eax, 0x28bcd(%rip)     # 0x5fdb0
movl 0x28bbf(%rip), %edi     # 0x5fda8
leaq 0x10ee9(%rip), %rsi     # 0x480d9
callq 0x7700
movl %eax, 0x28bbd(%rip)     # 0x5fdb8
movl 0x28ba7(%rip), %edi     # 0x5fda8
leaq 0x10eda(%rip), %rsi     # 0x480e2
callq 0x7700
movl %eax, 0x28ba9(%rip)     # 0x5fdbc
movl 0x28b8f(%rip), %edi     # 0x5fda8
leaq 0x10ec5(%rip), %rsi     # 0x480e5
callq 0x7700
movl %eax, 0x28b95(%rip)     # 0x5fdc0
leaq 0x28b82(%rip), %rsi     # 0x5fdb4
movl $0x1, %edi
callq 0x7160
leaq 0x28b81(%rip), %rsi     # 0x5fdc4
movl $0x1, %edi
callq 0x7160
callq 0xb0ca
movq %rax, %r15
movq 0x88(%rax), %rdi
leaq -0x40(%rbp), %r12
leaq -0x34(%rbp), %r13
leaq -0x30(%rbp), %rbx
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x33c04
leaq 0x28b58(%rip), %rsi     # 0x5fdd8
movl $0x1, %edi
callq 0x72c0
movl 0x28b48(%rip), %esi     # 0x5fdd8
movl $0xde1, %edi            # imm = 0xDE1
callq 0x7890
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2601, %edx           # imm = 0x2601
callq 0x7580
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2601, %edx           # imm = 0x2601
callq 0x7580
movl (%r13), %ecx
movl (%rbx), %r8d
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
movl $0x1908, %edx           # imm = 0x1908
xorl %r9d, %r9d
pushq (%r12)
pushq $0x1401                 # imm = 0x1401
pushq $0x1908                 # imm = 0x1908
callq 0x77f0
addq $0x20, %rsp
movl 0x28adf(%rip), %eax     # 0x5fdd8
movq 0x88(%r15), %rdi
movq %rax, (%rdi)
callq 0x30d34
movq 0x88(%r15), %rdi
callq 0x30e20
leaq -0x2c(%rbp), %rax
movl (%rax), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0x7890
movl (%r14), %esi
movl $0x8892, %edi           # imm = 0x8892
callq 0x75a0
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq