// File: /workspace/github_c_makefile_star2_O2/nkanaev[P]tipsy/src/tigr.c
// Function: tigrGAPIPresent
void tigrGAPIPresent(Tigr* bmp, int w, int h) {
    TigrInternal* win = tigrInternal(bmp);
    GLStuff* gl = &win->gl;

    glViewport(0, 0, w, h);
    if (!gl->gl_user_opengl_rendering) {
        glClearColor(0, 0, 0, 1);
        glClear(GL_COLOR_BUFFER_BIT);
    }

    if (!gl->gl_legacy) {
        float projection[16] = { 2.0f / w, 0.0f, 0.0f, 0.0f, 0.0f,  -2.0f / h, 0.0f, 0.0f,
                                 0.0f,     0.0f, 1.0f, 0.0f, -1.0f, 1.0f,      0.0f, 1.0f };

        glActiveTexture(GL_TEXTURE0);
        glBindVertexArray(gl->vao);
        glUseProgram(gl->program);
        glUniformMatrix4fv(gl->uniform_projection, 1, GL_FALSE, projection);
        glUniform4f(gl->uniform_parameters, win->p1, win->p2, win->p3, win->p4);
    } else {
#if !(__APPLE__ || __ANDROID__)
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, w, h, 0, -1.0f, 1.0f);
        glEnable(GL_TEXTURE_2D);
#else
        assert(0);
#endif
    }

    if (gl->gl_user_opengl_rendering) {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    } else {
        glDisable(GL_BLEND);
    }
    tigrGAPIDraw(gl->gl_legacy, gl->uniform_model, gl->tex[0], bmp, win->pos[0], win->pos[1], win->pos[2], win->pos[3]);

    if (win->widgetsScale > 0) {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        tigrGAPIDraw(gl->gl_legacy, gl->uniform_model, gl->tex[1], win->widgets,
                     (int)(w - win->widgets->w * win->widgetsScale), 0, w, (int)(win->widgets->h * win->widgetsScale));
    }

    tigrCheckGLError("present");

    gl->gl_user_opengl_rendering = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %r15
callq 0x5e9d
movq %rax, %rbx
xorl %edi, %edi
xorl %esi, %esi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x30d0
cmpl $0x0, 0x28(%rbx)
jne 0x6e30
movss 0x31ec(%rip), %xmm3     # 0xa004
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x3610
movl $0x4000, %edi           # imm = 0x4000
callq 0x30b0
cmpl $0x0, 0x24(%rbx)
cvtsi2ss %r14d, %xmm1
movss %xmm1, 0xc(%rsp)
je 0x6e83
movl $0x1701, %edi           # imm = 0x1701
callq 0x3560
callq 0x34e0
cvtsi2sd %r14d, %xmm1
cvtsi2sd %ebp, %xmm2
movsd 0x4b5f(%rip), %xmm4     # 0xb9c0
movsd 0x4b5f(%rip), %xmm5     # 0xb9c8
xorps %xmm0, %xmm0
xorps %xmm3, %xmm3
callq 0x3780
movl $0xde1, %edi            # imm = 0xDE1
callq 0x3340
jmp 0x6f22
movss 0x3181(%rip), %xmm0     # 0xa00c
divss %xmm1, %xmm0
cvtsi2ss %ebp, %xmm1
leaq 0x10(%rsp), %r12
movss %xmm0, (%r12)
movss 0x316a(%rip), %xmm0     # 0xa010
divss %xmm1, %xmm0
xorps %xmm1, %xmm1
movups %xmm1, 0x4(%r12)
movss %xmm0, 0x14(%r12)
movups %xmm1, 0x18(%r12)
movaps 0x4ad9(%rip), %xmm0     # 0xb9a0
movups %xmm0, 0x28(%r12)
movsd 0x4adb(%rip), %xmm0     # 0xb9b0
movsd %xmm0, 0x38(%r12)
movl $0x84c0, %edi           # imm = 0x84C0
callq 0x31f0
movl 0x10(%rbx), %edi
callq 0x36b0
movl 0x14(%rbx), %edi
callq 0x3500
movl 0x18(%rbx), %edi
pushq $0x1
popq %rsi
xorl %edx, %edx
movq %r12, %rcx
callq 0x3600
movl 0x20(%rbx), %edi
movss 0x64(%rbx), %xmm0
movss 0x68(%rbx), %xmm1
movss 0x6c(%rbx), %xmm2
movss 0x70(%rbx), %xmm3
callq 0x3200
cmpl $0x0, 0x28(%rbx)
je 0x6f43
movl $0xbe2, %edi            # imm = 0xBE2
callq 0x3340
movl $0x302, %edi            # imm = 0x302
movl $0x303, %esi            # imm = 0x303
callq 0x32c0
jmp 0x6f4d
movl $0xbe2, %edi            # imm = 0xBE2
callq 0x30c0
movl 0x24(%rbx), %edi
movl 0x8(%rbx), %edx
movl 0x1c(%rbx), %esi
movl 0x7c(%rbx), %r8d
movl 0x80(%rbx), %r9d
movl 0x84(%rbx), %eax
movl 0x88(%rbx), %r10d
movq %r15, %rcx
pushq %r10
pushq %rax
callq 0x73db
popq %rax
popq %rcx
movss 0x60(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x6fe5
movl $0xbe2, %edi            # imm = 0xBE2
callq 0x3340
movl $0x302, %edi            # imm = 0x302
movl $0x303, %esi            # imm = 0x303
callq 0x32c0
movl 0x24(%rbx), %edi
movq 0x50(%rbx), %rcx
cvtsi2ssl (%rcx), %xmm0
movss 0x60(%rbx), %xmm1
mulss %xmm1, %xmm0
movss 0xc(%rsp), %xmm2
subss %xmm0, %xmm2
cvttss2si %xmm2, %r8d
movl 0xc(%rbx), %edx
cvtsi2ssl 0x4(%rcx), %xmm0
movl 0x1c(%rbx), %esi
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
xorl %r9d, %r9d
pushq %rax
pushq %r14
callq 0x73db
popq %rax
popq %rcx
leaq 0x4b86(%rip), %rdi      # 0xbb72
callq 0x717c
andl $0x0, 0x28(%rbx)
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq