// File: /workspace/github_c_makefile_star2_O1/FredTheDino[P]Fog/src/engine/renderer/opengl_renderer.cpp
// Function: Renderer::Impl::blit()
void blit() {
    glBindBuffer(GL_UNIFORM_BUFFER, ubo_global);
    glBufferSubData(GL_UNIFORM_BUFFER, 0, ubo_global_size, &_fog_global_window_state);
    glBindBuffer(GL_UNIFORM_BUFFER, 0);

    for (u32 cam = 0; cam < OPENGL_NUM_CAMERAS; cam++) {
        glBindFramebuffer(GL_FRAMEBUFFER, screen_fbos[cam]);
        glClearColor(0.1f, 0.2f, 0.3f, 1.0f);
        clear();
        u32 bit = (cam == 0) ? 1 : (1 << cam);
        if (!(_fog_active_cameras & bit)) continue;

        master_shader_program.bind();
        glUniform1ui(master_shader_current_cam_loc, cam);
        for (u32 layer = 0; layer < OPENGL_NUM_LAYERS; layer++)
            sprite_render_queues[layer].draw();

        font_shader_program.bind();
        // TODO(ed): Some way to do camera specific text or rendering
        // would probably be good.
        glUniform1ui(master_shader_current_cam_loc, cam);
        font_render_queue.draw();
    }

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glClearColor(0.1f, 0.3f, 0.2f, 1.0f);
    clear();
    render_post_processing();
    // TODO(ed): This is where screen space reflections can be rendered.
    // TODO(ed): Passing values is kinda tricky right now, might need some
    // way to pass uniforms to the shader...

    SDL_GL_SwapWindow(window);

    font_render_queue.clear();
    for (u32 layer = 0; layer < OPENGL_NUM_LAYERS; layer++)
        sprite_render_queues[layer].clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x435bc(%rip), %rbx     # 0x64a80
movl 0x49dd6(%rip), %esi     # 0x6b2a0
movl $0x8a11, %edi           # imm = 0x8A11
callq *(%rbx)
leaq 0x43628(%rip), %rax     # 0x64b00
leaq 0x49d71(%rip), %rcx     # 0x6b250
xorl %r14d, %r14d
movl $0x50, %edx
movl $0x8a11, %edi           # imm = 0x8A11
xorl %esi, %esi
callq *(%rax)
movl $0x8a11, %edi           # imm = 0x8A11
xorl %esi, %esi
callq *(%rbx)
leaq 0x49acc(%rip), %r13     # 0x6afcc
leaq 0x49ad9(%rip), %r15     # 0x6afe0
leaq 0x49cd2(%rip), %r12     # 0x6b1e0
leaq 0x49cef(%rip), %rax     # 0x6b204
movl (%rax,%r14,4), %esi
movl $0x8d40, %edi           # imm = 0x8D40
leaq 0x4357b(%rip), %rax     # 0x64aa0
callq *(%rax)
movss 0xecfd(%rip), %xmm0     # 0x3022c
movss 0xead5(%rip), %xmm1     # 0x3000c
movss 0xecfd(%rip), %xmm2     # 0x3023c
movss 0xeabd(%rip), %xmm3     # 0x30004
leaq 0x4360a(%rip), %rax     # 0x64b58
callq *(%rax)
movl $0x4100, %edi           # imm = 0x4100
leaq 0x435cc(%rip), %rax     # 0x64b28
callq *(%rax)
leaq 0x2f3b3(%rip), %rax     # 0x50918
movl (%rax), %eax
btl %r14d, %eax
jae 0x215d1
leaq 0x49a54(%rip), %rax     # 0x6afc8
movl (%rax), %edi
leaq 0x44643(%rip), %rax     # 0x65bc0
callq *(%rax)
movl (%r13), %edi
movl %r14d, %esi
leaq 0x4453b(%rip), %rax     # 0x65ac8
callq *(%rax)
xorl %ebx, %ebx
leaq (%rbx,%r15), %rdi
callq 0x2e2ba
addq $0x20, %rbx
cmpq $0x200, %rbx            # imm = 0x200
jne 0x21591
leaq 0x49a22(%rip), %rax     # 0x6afd0
movl (%rax), %edi
leaq 0x44609(%rip), %rax     # 0x65bc0
callq *(%rax)
movl (%r13), %edi
movl %r14d, %esi
leaq 0x44501(%rip), %rax     # 0x65ac8
callq *(%rax)
movq %r12, %rdi
callq 0x2e374
leaq 0x1(%r14), %rax
testq %r14, %r14
movq %rax, %r14
je 0x2150e
movl $0x8d40, %edi           # imm = 0x8D40
xorl %esi, %esi
leaq 0x434b1(%rip), %rax     # 0x64aa0
callq *(%rax)
movss 0xec33(%rip), %xmm0     # 0x3022c
movss 0xec3b(%rip), %xmm1     # 0x3023c
movss 0xea03(%rip), %xmm2     # 0x3000c
movss 0xe9f3(%rip), %xmm3     # 0x30004
leaq 0x43540(%rip), %rax     # 0x64b58
callq *(%rax)
movl $0x4100, %edi           # imm = 0x4100
leaq 0x43502(%rip), %rax     # 0x64b28
callq *(%rax)
callq 0x20528
leaq 0x49bfc(%rip), %rax     # 0x6b230
movq (%rax), %rdi
callq 0x21f0
movl $0x0, 0x8(%r12)
movl 0xc(%r12), %ecx
testq %rcx, %rcx
je 0x2166e
movq 0x10(%r12), %rax
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
movl $0x0, (%rax,%rdx)
addq $0xc, %rdx
cmpq %rdx, %rcx
jne 0x2165e
xorl %eax, %eax
movq %rax, %rcx
shlq $0x5, %rcx
movl $0x0, 0x8(%r15,%rcx)
movl 0xc(%r15,%rcx), %edx
testq %rdx, %rdx
je 0x216ab
addq %r15, %rcx
movq 0x10(%rcx), %rcx
shlq $0x2, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
movl $0x0, (%rcx,%rsi)
addq $0xc, %rsi
cmpq %rsi, %rdx
jne 0x2169b
incq %rax
cmpq $0x10, %rax
jne 0x21670
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq