// File: /workspace/github_cpp_makefile_star2_O1/cphinton42[P]hinton-language/src/parse.cpp
// Function: parse_statement_block(Parsing_Context*, Token**)
internal Block_AST *parse_statement_block(Parsing_Context *ctx, Token **current_ptr)
{
    Token *current = *current_ptr;
    Token *start_section = current;
    Block_AST *result = nullptr;
    defer {
        *current_ptr = current;
    };
    
    if(current->type == Token_Type::open_brace)
    {
        result = construct_ast(ctx->ast_pool, Block_AST, current->line_number, current->line_offset);
        ++current;
        
        // TODO: memory leak
        Dynamic_Array<AST*> statements = {0};
        
        while(true)
        {
            if(current->type == Token_Type::close_brace)
            {
                ++current;
                
                result->statements.count = statements.count;
                result->statements.data = pool_alloc(AST*, statements.count, ctx->ast_pool);
                
                for(u64 i = 0; i < statements.count; ++i)
                {
                    result->statements[i] = statements[i];
                }
                break;
            }
            else
            {
                AST *stmt = parse_statement(ctx, &current);
                if(stmt)
                {
                    array_add(&statements, stmt);
                }
                else
                {
                    return nullptr;
                }
            }
        }
    }
    else
    {
        report_error(ctx, start_section, current, "Expected '{' to begin statement block");
    }
    
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %r15
movq %rsi, 0x38(%rsp)
movq (%rsi), %r14
cmpq $0x2c, (%r14)
jne 0xeaaf
movq 0x20(%r15), %rdi
movl $0x20, %esi
callq 0x95e6
movq 0x8(%r14), %rsi
movl $0x1, (%rax)
movl 0x78c3(%rip), %ecx      # 0x15b78
leal 0x1(%rcx), %edx
movl %edx, 0x78ba(%rip)      # 0x15b78
movl %ecx, 0x4(%rax)
movq %rsi, 0x8(%rax)
addq $0x20, %r14
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rcx
movaps %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
movq %r15, 0x10(%rsp)
movq %rax, 0x70(%rsp)
cmpq $0x2d, (%r14)
je 0xeae0
movq %r14, 0x8(%rsp)
movl 0x8(%r14), %ebp
movl 0xc(%r14), %r12d
movq (%r14), %rax
cmpq $0x1b, %rax
jg 0xe3a2
testq %rax, %rax
je 0xe3d3
cmpq $0xc, %rax
je 0xe4db
cmpq $0xd, %rax
jne 0xe482
movl %r12d, 0x18(%rsp)
leaq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, %r13
testq %rax, %rax
je 0xe59f
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xe274
movq %rax, %r12
testq %rax, %rax
je 0xe59f
movq 0x8(%rsp), %rax
cmpq $0x7, (%rax)
jne 0xe6e5
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xe274
movq %rax, %r15
testq %rax, %rax
jne 0xe6e8
jmp 0xe9c1
cmpq $0x1c, %rax
je 0xe417
cmpq $0x1e, %rax
je 0xe51b
cmpq $0x2c, %rax
jne 0xe482
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xe274
movq %rax, %rbx
xorl %eax, %eax
jmp 0xe4a3
leaq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%r14), %rax
addq $-0x22, %rax
movq %r14, 0x8(%rsp)
cmpq $0x2, %rax
ja 0xe5a8
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x9318
movq %rax, %rbx
xorl %eax, %eax
testq %rbx, %rbx
je 0xeaa8
movb $0x1, %cl
jmp 0xe9cc
leaq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movq %r15, %r13
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, %r15
testq %rax, %rax
je 0xe6b4
movq 0x20(%r13), %rdi
movl $0x20, %esi
callq 0x95e6
movq %rax, %rbx
movl $0x6, (%rax)
movl 0x771a(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x7711(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl %ebp, 0x8(%rbx)
movl %r12d, 0xc(%rbx)
movq $0x0, 0x10(%rbx)
movq %r15, 0x18(%rbx)
jmp 0xe6b6
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, %rbx
testq %rax, %rax
setne %al
je 0xe9d4
testb %al, %al
je 0xe9d6
movq 0x8(%rsp), %rdx
cmpq $0x21, (%rdx)
jne 0xe4c4
addq $0x20, %rdx
movq %rdx, 0x8(%rsp)
jmp 0xe9d6
movq %r15, %rdi
movq %r14, %rsi
leaq 0x3805(%rip), %rcx      # 0x11cd6
callq 0x91b7
jmp 0xe9d6
movq %r15, %rdi
movl %ebp, 0x2c(%rsp)
movl %r12d, 0x18(%rsp)
leaq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%r14), %r12
cmpq $0x36, %r12
jne 0xe503
leaq 0x40(%r14), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%rsp), %r15
cmpq $0x0, (%r15)
je 0xe67a
xorl %ebx, %ebx
xorl %ebp, %ebp
jmp 0xe844
movl %r12d, %r13d
leaq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movq %r15, %r12
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, %r15
testq %rax, %rax
je 0xe6c9
movq %r12, %rbx
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0xe274
movq %rax, 0x18(%rsp)
movq 0x20(%rbx), %rdi
movl $0x20, %esi
callq 0x95e6
movq %rax, %rbx
movl $0x2, (%rax)
movl 0x75fe(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x75f5(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl %ebp, 0x8(%rbx)
movl %r13d, 0xc(%rbx)
movq %r15, 0x10(%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x18(%rbx)
jmp 0xe6cb
xorl %ecx, %ecx
xorl %ebx, %ebx
jmp 0xe9ca
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, %rbx
testq %rax, %rax
je 0xe737
movq 0x8(%rsp), %rax
movq (%rax), %rcx
leaq -0x3b(%rcx), %rdx
movb $0x1, %r13b
cmpq $0x5, %rdx
ja 0xe6de
movb $0x1, %r13b
movl $0x3d, %esi
btl %edx, %esi
jae 0xe6de
leaq 0x2541(%rip), %rdx      # 0x10b38
movq -0x1d8(%rdx,%rcx,8), %rcx
movq %rcx, 0x18(%rsp)
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, %r15
testq %rax, %rax
setne %r13b
je 0xea92
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x28, %esi
callq 0x95e6
movl $0x5, (%rax)
movl 0x752a(%rip), %ecx      # 0x15b78
leal 0x1(%rcx), %edx
movl %edx, 0x7521(%rip)      # 0x15b78
movl %ecx, 0x4(%rax)
movl %ebp, 0x8(%rax)
movl %r12d, 0xc(%rax)
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %rbx, 0x18(%rax)
movq %r15, 0x20(%rax)
movq %rax, %rbx
jmp 0xea94
leaq 0x20(%r15), %rcx
movq %rcx, 0x8(%rsp)
movq 0x20(%r15), %rsi
cmpq $0x20, %rsi
jne 0xe733
leaq 0x40(%r15), %rbx
movq %rbx, 0x8(%rsp)
cmpq $0x0, 0x40(%r15)
je 0xe743
movq %rbx, %rdx
leaq 0x387a(%rip), %rcx      # 0x11f29
jmp 0xe822
xorl %ebx, %ebx
movb $0x1, %al
testq %r15, %r15
movq %r13, %r15
jne 0xe4a3
jmp 0xe9d4
xorl %ebx, %ebx
xorl %eax, %eax
testq %r15, %r15
movq %r12, %r15
jne 0xe4a3
jmp 0xe9d4
movb $0x1, %al
jmp 0xea9f
xorl %r15d, %r15d
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x28, %esi
callq 0x95e6
movq %rax, %rbx
movl $0x4, (%rax)
movl 0x746e(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x7465(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl %ebp, 0x8(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0xc(%rbx)
movq %r13, 0x10(%rbx)
movq %r12, 0x18(%rbx)
movq %r15, 0x20(%rbx)
movb $0x1, %cl
jmp 0xe9c5
xorl %ebx, %ebx
jmp 0xe74c
xorl %r13d, %r13d
xorl %eax, %eax
xorl %ebx, %ebx
jmp 0xea9f
leaq 0x60(%r15), %rcx
movq %rcx, 0x8(%rsp)
movq 0x8(%rsp), %rdx
cmpq $0x22, (%rdx)
jne 0xe815
addq $0x20, %rdx
movq %rdx, 0x8(%rsp)
movq 0x20(%rdi), %rdi
movl $0x40, %esi
callq 0x95e6
movq %rax, %rbp
movq 0x8(%r15), %rax
movups 0x10(%r15), %xmm0
movaps %xmm0, 0x60(%rsp)
movl 0x73ef(%rip), %ecx      # 0x15b78
leal 0x1(%rcx), %edx
movl %edx, 0x73e6(%rip)      # 0x15b78
movl $0x7, (%rbp)
movl %ecx, 0x4(%rbp)
movq %rax, 0x8(%rbp)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%rbp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, 0x20(%rbp)
movups %xmm1, 0x30(%rbp)
movb $0x1, %r15b
testq %rbx, %rbx
je 0xea8b
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x40, %esi
callq 0x95e6
movq 0x8(%rbx), %rsi
movups 0x10(%rbx), %xmm0
movaps %xmm0, 0x60(%rsp)
movl 0x7392(%rip), %ecx      # 0x15b78
leal 0x1(%rcx), %edx
movl %edx, 0x7389(%rip)      # 0x15b78
movl $0x7, (%rax)
movl %ecx, 0x4(%rax)
movq %rsi, 0x8(%rax)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%rax)
movaps 0x60(%rsp), %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm1, 0x30(%rax)
movq %rax, %rbx
jmp 0xe83b
leaq 0x3738(%rip), %rcx      # 0x11f54
cmpq $0x20, %rsi
jne 0xe82f
movq %r14, %rsi
callq 0x91b7
xorl %r15d, %r15d
jmp 0xe837
movq %rax, 0x8(%rsp)
movb $0x1, %r15b
xorl %ebx, %ebx
xorl %ebp, %ebp
testb %r15b, %r15b
je 0xe9c1
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, %r13
testq %rax, %rax
je 0xe9c1
movq 0x8(%rsp), %rdx
cmpq $0x26, (%rdx)
jne 0xe8ae
testq %rbx, %rbx
jne 0xe99f
cmpq $0x36, %r12
je 0xe99f
addq $0x20, %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcd76
movq %rax, 0x30(%rsp)
testq %rax, %rax
jne 0xe8b7
jmp 0xe9c1
movq $0x0, 0x30(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xe274
movq %rax, %r15
testq %rax, %rax
setne %cl
je 0xe9c3
movq %rbx, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x30, %esi
callq 0x95e6
movq %rax, %rbx
movl $0x3, (%rax)
movl 0x727c(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x7273(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl 0x2c(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0xc(%rbx)
cmpq $0x36, %r12
jne 0xe922
movw $0x4, 0x2(%rbx)
testq %rbp, %rbp
jne 0xe97d
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x40, %esi
callq 0x95e6
movq %rax, %rbp
movl $0x7, (%rax)
movl 0x722f(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x7226(%rip)      # 0x15b78
movl %eax, 0x4(%rbp)
movq $0x0, 0x8(%rbp)
movw $0x1, 0x2(%rbp)
movq $0x2, 0x20(%rbp)
leaq 0x369c(%rip), %rax      # 0x1200e
movq %rax, 0x28(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbp)
movq %rbp, 0x10(%rbx)
movq %r15, 0x28(%rbx)
movq 0x30(%rsp), %rcx
testq %rcx, %rcx
je 0xea09
movq %r13, %rax
movq %rcx, %r13
movq 0x10(%rsp), %r15
jmp 0xea7c
testq %rbx, %rbx
leaq 0x3636(%rip), %rcx      # 0x11fdf
leaq 0x35e2(%rip), %rax      # 0x11f92
cmovneq %rax, %rcx
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x91b7
xorl %ecx, %ecx
xorl %ebx, %ebx
movq 0x10(%rsp), %r15
xorl %eax, %eax
testb %cl, %cl
jne 0xe4a3
xorl %ebx, %ebx
movq 0x8(%rsp), %r14
testq %rbx, %rbx
je 0xeac4
movq 0x717d(%rip), %rdx      # 0x15b68
movq 0x717e(%rip), %rcx      # 0x15b70
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0xf208
movq 0x70(%rsp), %rax
jmp 0xe2e6
cmpq $0x0, 0x20(%rsp)
jne 0xea6e
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x40, %esi
callq 0x95e6
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdx
movl $0x7, (%rdx)
movl 0x713e(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x7135(%rip)      # 0x15b78
movl %eax, 0x4(%rdx)
movq $0x0, 0x8(%rdx)
movw $0x1, 0x2(%rdx)
movq $0x8, 0x20(%rdx)
leaq 0x35ae(%rip), %rax      # 0x12011
movq %rax, 0x28(%rdx)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdx)
orb $0x8, 0x2(%rbx)
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rbx)
movq %r13, 0x20(%rbx)
movb $0x1, %cl
jmp 0xe9ca
xorl %ebx, %ebx
jmp 0xe83b
xorl %ebx, %ebx
testq %r15, %r15
setne %al
movq 0x10(%rsp), %r15
testb %r13b, %r13b
jne 0xe410
xorl %ecx, %ecx
jmp 0xe9cc
leaq 0x344d(%rip), %rcx      # 0x11f03
movq %r15, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x91b7
xorl %ecx, %ecx
movq 0x38(%rsp), %rax
movq %r14, (%rax)
movq %rcx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x20, %r14
movq 0x40(%rsp), %rsi
movq %rsi, 0x10(%rax)
movq 0x20(%r15), %rdi
shlq $0x3, %rsi
movq %rax, %rbx
callq 0x95e6
movq %rax, 0x18(%rbx)
cmpq $0x0, 0x40(%rsp)
movq %rbx, %rcx
je 0xeac6
movq %rcx, %rsi
xorl %eax, %eax
movq 0x48(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x18(%rsi), %rdx
movq %rcx, (%rdx,%rax,8)
incq %rax
cmpq 0x40(%rsp), %rax
jb 0xeb11
movq %rsi, %rcx
jmp 0xeac6
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb60
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb60
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
jmp 0xeb59
movq 0x8(%rsp), %r14
jmp 0xeb60
movq 0x38(%rsp), %rcx
movq %r14, (%rcx)
movq %rax, %rdi
callq 0x3100