// File: /workspace/github_c_makefile_star2_O0/FredTheDino[P]Fog/src/engine/renderer/opengl_renderer.cpp
// Function: Renderer::Impl::RenderQueue<Renderer::Impl::Vertex>::push(unsigned int, Renderer::Impl::Vertex*)
void RenderQueue<T>::push(u32 num_new_verticies, T *new_verticies) {
    ASSERT(gl_draw_hint, "Trying to use uninitalized render queue.");
    ASSERT(gl_draw_hint == GL_TRIANGLES, "Push code assumes triangles.");

    while (num_new_verticies) {
        for (u32 i = next_free; num_new_verticies; i++) {
            next_free = i;
            if (next_free == num_buffers) expand();
            GLBuffer *buffer = vertex_buffers + next_free;
            u32 free = buffer_size - buffer->draw_length;
            if (free == 0) continue;
            u32 to_push = MIN(num_new_verticies, (u32) free);

            buffer->bind();
            glBufferSubData(GL_ARRAY_BUFFER,
                            buffer->draw_length * sizeof(T),
                            to_push * sizeof(T), new_verticies);

            buffer->draw_length += to_push;
            num_new_verticies -= to_push;
            new_verticies += to_push;
        }
    }
    glBindVertexArray(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, 0x4(%rax)
setne %al
andb $0x1, %al
leaq 0x449a(%rip), %rdi      # 0x46045
movl $0x6c, %esi
leaq 0x18def(%rip), %rdx     # 0x5a9a6
movzbl %al, %ecx
callq 0xb210
movq -0x38(%rbp), %rax
cmpl $0x4, 0x4(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
leaq 0x4467(%rip), %rdi      # 0x46045
movl $0x6d, %esi
leaq 0x18df3(%rip), %rdx     # 0x5a9dd
movzbl %al, %ecx
callq 0xb210
cmpl $0x0, -0xc(%rbp)
je 0x41cdc
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x41cd7
movq -0x38(%rbp), %rcx
movl -0x1c(%rbp), %eax
movl %eax, 0x8(%rcx)
movl 0x8(%rcx), %eax
cmpl 0xc(%rcx), %eax
jne 0x41c2b
movq -0x38(%rbp), %rdi
callq 0x43c70
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rcx
movl 0x8(%rax), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movq %rcx, -0x28(%rbp)
movl (%rax), %eax
movq -0x28(%rbp), %rcx
subl (%rcx), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x41c54
jmp 0x41cc9
movl -0xc(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x41c64
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x41c6a
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x43e20
leaq 0x3ceb0(%rip), %rax     # 0x7eb30
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movl (%rcx), %ecx
imulq $0x24, %rcx, %rsi
movl -0x30(%rbp), %ecx
imulq $0x24, %rcx, %rdx
movq -0x18(%rbp), %rcx
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x30(%rbp), %ecx
movl -0xc(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xc(%rbp)
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x41c06
jmp 0x41bf2
xorl %edi, %edi
leaq 0x3ce03(%rip), %rax     # 0x7eae8
callq *(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)