// File: /workspace/github_c_makefile_star2_O2/nkanaev[P]tipsy/src/tigr.c
// Function: tigrGAPICreate
void tigrGAPICreate(Tigr* bmp) {
    TigrInternal* win = tigrInternal(bmp);
    GLStuff* gl = &win->gl;
    GLuint VBO;
    GLfloat vertices[] = { // pos      uv
                           0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
                           0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f
    };

#ifdef _WIN32
    if (tigrGL11Init(bmp))
        return;
    tigrGL33Init(bmp);
#endif

    if (!gl->gl_legacy) {
        // create vao
        glGenVertexArrays(1, &gl->vao);
        glGenBuffers(1, &VBO);
        glBindBuffer(GL_ARRAY_BUFFER, VBO);
        glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
        glBindVertexArray(gl->vao);
        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);
        glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), NULL);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), NULL);

        // create program
        tigrCreateShaderProgram(gl, tigr_default_fx_gl_fs, tigr_default_fx_gl_fs_size);
    }

    // create textures
    if (gl->gl_legacy) {
        glEnable(GL_TEXTURE_2D);
    }
    glGenTextures(2, gl->tex);
    for (int i = 0; i < 2; ++i) {
        glBindTexture(GL_TEXTURE_2D, gl->tex[i]);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl->gl_legacy ? GL_NEAREST : GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl->gl_legacy ? GL_NEAREST : GL_LINEAR);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    }

    tigrCheckGLError("initialization");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
callq 0x5e9d
movq %rax, %rbx
leaq 0x8(%rax), %r14
leaq 0x515a(%rip), %rsi      # 0xb6a0
pushq $0xc
popq %rcx
leaq 0x10(%rsp), %rdi
rep  movsq (%rsi), %es:(%rdi)
cmpl $0x0, 0x24(%rax)
jne 0x6605
movq %rbx, %rsi
addq $0x10, %rsi
pushq $0x1
popq %rbp
movl %ebp, %edi
callq 0x3400
leaq 0xc(%rsp), %r15
movl %ebp, %edi
movq %r15, %rsi
callq 0x3170
movl (%r15), %esi
movl $0x8892, %edi           # imm = 0x8892
callq 0x3070
pushq $0x60
popq %rsi
leaq 0x10(%rsp), %rdx
movl $0x8892, %edi           # imm = 0x8892
movl $0x88e4, %ecx           # imm = 0x88E4
callq 0x3490
movl 0x10(%rbx), %edi
callq 0x36b0
xorl %edi, %edi
callq 0x3090
movl %ebp, %edi
callq 0x3090
pushq $0x2
popq %r15
pushq $0x10
popq %r12
xorl %edi, %edi
movl %r15d, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl %r12d, %r8d
xorl %r9d, %r9d
callq 0x3720
movl %ebp, %edi
movl %r15d, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl %r12d, %r8d
xorl %r9d, %r9d
callq 0x3720
leaq 0x3e1e(%rip), %rsi      # 0xa410
movq %r14, %rdi
movl $0x16f, %edx            # imm = 0x16F
callq 0x724a
cmpl $0x0, 0x24(%rbx)
je 0x660f
movl $0xde1, %edi            # imm = 0xDE1
callq 0x3340
pushq $0x2
popq %rdi
movq %r14, %rsi
callq 0x35a0
xorl %r14d, %r14d
pushq $0x1
popq %rbp
cmpq $0x2, %r14
je 0x668e
movl 0x8(%rbx,%r14,4), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq 0x3480
cmpl $0x1, 0x24(%rbx)
movl $0x0, %edx
adcl $0x2600, %edx           # imm = 0x2600
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
callq 0x3550
cmpl $0x1, 0x24(%rbx)
movl $0x0, %edx
adcl $0x2600, %edx           # imm = 0x2600
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
callq 0x3550
movl $0xcf2, %edi            # imm = 0xCF2
xorl %esi, %esi
callq 0x3190
movl $0xcf5, %edi            # imm = 0xCF5
movl %ebp, %esi
callq 0x3190
incq %r14
jmp 0x6620
leaq 0x5482(%rip), %rdi      # 0xbb17
callq 0x717c
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq