// File: /workspace/github_c_makefile_star2_O0/FredTheDino[P]Fog/src/engine/renderer/opengl_renderer.cpp
// Function: Renderer::Impl::RenderQueue<Renderer::Impl::Vertex>::expand()
void RenderQueue<T>::expand() {
    ASSERT(gl_draw_hint, "Trying to use uninitalized render queue");
    arena->clear();
    u32 to_copy = num_buffers;
    num_buffers += GROW_BY;
    GLBuffer *new_buffers = arena->push<GLBuffer>(num_buffers);
    if (new_buffers != vertex_buffers) {
        for (u32 i = 0; i < to_copy; i++) {
            new_buffers[i] = vertex_buffers[i];
        }
        vertex_buffers = new_buffers;
    }

    u32 vaos[GROW_BY];
    glGenVertexArrays(GROW_BY, vaos);
    u32 buffers[GROW_BY];
    glGenBuffers(GROW_BY, buffers);
    for (u32 i = 0; i < GROW_BY; i++) {
        vertex_buffers[to_copy + i] = {0, buffers[i], vaos[i]};
        vertex_buffers[to_copy + i].bind();
        glBufferData(GL_ARRAY_BUFFER, buffer_size * sizeof(T), NULL,
                     GL_STREAM_DRAW);
        enable_attrib_pointer();
    }
    glBindVertexArray(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, 0x4(%rax)
setne %al
andb $0x1, %al
leaq 0x23b1(%rip), %rdi      # 0x46045
movl $0x88, %esi
leaq 0x16cd0(%rip), %rdx     # 0x5a970
movzbl %al, %ecx
callq 0xb210
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x109d0
movq -0x50(%rbp), %rax
movl 0xc(%rax), %ecx
movl %ecx, -0xc(%rbp)
movl 0xc(%rax), %ecx
addl $0x3, %ecx
movl %ecx, 0xc(%rax)
movq 0x18(%rax), %rdi
movl 0xc(%rax), %eax
movl %eax, %esi
callq 0x43b40
movq -0x50(%rbp), %rcx
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq 0x10(%rcx), %rax
je 0x43d3a
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x43d2e
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x1c(%rbp), %eax
imulq $0xc, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x43cef
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x3b2af(%rip), %rax     # 0x7eff0
movq (%rax), %rax
leaq -0x28(%rbp), %rsi
movl $0x3, %edi
callq *%rax
leaq 0x3b26a(%rip), %rax     # 0x7efc0
movq (%rax), %rax
leaq -0x34(%rbp), %rsi
movl $0x3, %edi
callq *%rax
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jae 0x43e07
movq -0x50(%rbp), %rax
movl $0x0, -0x44(%rbp)
movl -0x38(%rbp), %ecx
movl -0x34(%rbp,%rcx,4), %ecx
movl %ecx, -0x40(%rbp)
movl -0x38(%rbp), %ecx
movl -0x28(%rbp,%rcx,4), %ecx
movl %ecx, -0x3c(%rbp)
movq 0x10(%rax), %rcx
movl -0xc(%rbp), %edx
addl -0x38(%rbp), %edx
movl %edx, %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movq -0x44(%rbp), %rdx
movq %rdx, (%rcx)
movl -0x3c(%rbp), %edx
movl %edx, 0x8(%rcx)
movq 0x10(%rax), %rdi
movl -0xc(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, %eax
imulq $0xc, %rax, %rax
addq %rax, %rdi
callq 0x43e20
movq -0x50(%rbp), %rcx
leaq 0x3ad51(%rip), %rax     # 0x7eb28
movq (%rax), %rax
movl (%rcx), %ecx
imulq $0x24, %rcx, %rsi
movl $0x8892, %edi           # imm = 0x8892
xorl %ecx, %ecx
movl %ecx, %edx
movl $0x88e0, %ecx           # imm = 0x88E0
callq *%rax
movq -0x50(%rbp), %rdi
callq 0x2b440
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x43d6b
xorl %edi, %edi
leaq 0x3acd8(%rip), %rax     # 0x7eae8
callq *(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)