// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rdi, %r13
movq %rsi, 0x28(%rsp)
movq (%rsi), %r12
cmpq $0x2c, (%r12)
jne 0xe658
movq 0x20(%r13), %rdi
movl $0x20, %esi
callq 0x962b
movl $0x1, (%rax)
movl 0x7c17(%rip), %edx      # 0x15b78
leal 0x1(%rdx), %ecx
movl %ecx, 0x7c0e(%rip)      # 0x15b78
movl %edx, 0x4(%rax)
movq 0x8(%r12), %rcx
movq %rax, 0x60(%rsp)
movq %rcx, 0x8(%rax)
addq $0x20, %r12
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r13, 0x10(%rsp)
movq (%r12), %rax
cmpq $0x2d, %rax
je 0xe672
movq %r12, 0x8(%rsp)
movl 0x8(%r12), %ecx
movl %ecx, 0x18(%rsp)
movl 0xc(%r12), %ecx
movl %ecx, 0x1c(%rsp)
cmpq $0x1b, %rax
jg 0xe05d
testq %rax, %rax
je 0xe09a
cmpq $0xc, %rax
je 0xe196
cmpq $0xd, %rax
jne 0xe13f
addq $0x20, %r12
movq %r12, 0x8(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %r14
testq %rax, %rax
je 0xe701
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xdf23
movq %rax, %r12
testq %rax, %rax
je 0xe701
movq 0x8(%rsp), %rax
cmpq $0x7, (%rax)
jne 0xe31f
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xdf23
movq %rax, %r13
testq %rax, %rax
jne 0xe322
jmp 0xe701
cmpq $0x1c, %rax
je 0xe0cd
cmpq $0x1e, %rax
je 0xe1d8
cmpq $0x2c, %rax
jne 0xe13f
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0xdf23
movq %rax, %rbx
movq 0x8(%rsp), %r12
testq %rax, %rax
jne 0xe18c
jmp 0xe706
movq 0x20(%r12), %rax
addq $-0x22, %rax
cmpq $0x2, %rax
ja 0xe258
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x9369
movq %rax, %rbx
testq %rax, %rax
jne 0xe187
jmp 0xe701
leaq 0x20(%r12), %rax
movq %rax, 0x8(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %r14
testq %rax, %rax
je 0xe701
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x20, %esi
callq 0x962b
movq %rax, %rbx
movl $0x6, (%rax)
movl 0x7a61(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x7a58(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rbx)
movq $0x0, 0x10(%rbx)
movq %r14, 0x18(%rbx)
jmp 0xe15d
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %rbx
testq %rax, %rax
je 0xe701
movq 0x8(%rsp), %rdx
cmpq $0x21, (%rdx)
jne 0xe173
addq $0x20, %rdx
movq %rdx, 0x8(%rsp)
jmp 0xe187
movq 0x10(%rsp), %rdi
movq %r12, %rsi
leaq 0x3acf(%rip), %rcx      # 0x11c51
callq 0x9208
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r13
jmp 0xe5c5
leaq 0x20(%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%r12), %rbx
movq %rbx, %rcx
movq %rax, %r14
cmpq $0x36, %rbx
jne 0xe1c0
leaq 0x40(%r12), %r14
movq %r14, 0x8(%rsp)
movq 0x40(%r12), %rcx
testq %rcx, %rcx
movq %rbx, 0x20(%rsp)
je 0xe36f
xorl %r15d, %r15d
xorl %ebp, %ebp
jmp 0xe47b
addq $0x20, %r12
movq %r12, 0x8(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %r14
testq %rax, %rax
je 0xe701
movq 0x10(%rsp), %r13
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0xdf23
movq %rax, %r12
movq 0x20(%r13), %rdi
movl $0x20, %esi
callq 0x962b
movq %rax, %rbx
movl $0x2, (%rax)
movl 0x7947(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x793e(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rbx)
movq %r14, 0x10(%rbx)
movq %r12, 0x18(%rbx)
jmp 0xe5c0
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %rbx
testq %rax, %rax
je 0xe701
movq 0x8(%rsp), %rax
movq (%rax), %rcx
leaq -0x3b(%rcx), %rdx
cmpq $0x5, %rdx
ja 0xe15d
movl $0x3d, %esi
btl %edx, %esi
jae 0xe15d
leaq 0x2897(%rip), %rdx      # 0x10b38
movq -0x1d8(%rdx,%rcx,8), %r13
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %r14
testq %rax, %rax
je 0xe701
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x28, %esi
callq 0x962b
movl $0x5, (%rax)
movl 0x7887(%rip), %ecx      # 0x15b78
leal 0x1(%rcx), %edx
movl %edx, 0x787e(%rip)      # 0x15b78
movl %ecx, 0x4(%rax)
movl 0x18(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0x1c(%rsp), %ecx
movl %ecx, 0xc(%rax)
movq %r13, 0x10(%rax)
movq %rbx, 0x18(%rax)
movq %r14, 0x20(%rax)
movq %rax, %rbx
jmp 0xe15d
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x28, %esi
callq 0x962b
movq %rax, %rbx
movl $0x4, (%rax)
movl 0x7834(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x782b(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rbx)
movq %r14, 0x10(%rbx)
movq %r12, 0x18(%rbx)
movq %r13, 0x20(%rbx)
jmp 0xe5bb
movq 0x20(%r14), %rcx
cmpq $0x22, %rcx
je 0xe3b1
cmpq $0x20, %rcx
jne 0xe469
leaq 0x40(%r14), %rbx
movq %rbx, 0x8(%rsp)
cmpq $0x0, 0x40(%r14)
jne 0xe6e3
leaq 0x60(%r14), %rdx
movq %rdx, 0x8(%rsp)
movl $0x60, %eax
cmpq $0x22, 0x60(%r14)
je 0xe3b8
jmp 0xe6ef
movl $0x20, %eax
xorl %ebx, %ebx
addq %r14, %rax
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq 0x20(%r13), %rdi
movl $0x40, %esi
callq 0x962b
movq %rax, %rbp
movq 0x8(%r14), %rax
movups 0x10(%r14), %xmm0
movaps %xmm0, 0x50(%rsp)
movl 0x778f(%rip), %ecx      # 0x15b78
leal 0x1(%rcx), %edx
movl %edx, 0x7786(%rip)      # 0x15b78
movl $0x7, (%rbp)
movl %ecx, 0x4(%rbp)
movq %rax, 0x8(%rbp)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%rbp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, 0x20(%rbp)
movups %xmm1, 0x30(%rbp)
testq %rbx, %rbx
je 0xe473
movq 0x20(%r13), %rdi
movl $0x40, %esi
callq 0x962b
movq %rax, %r15
movq 0x8(%rbx), %rsi
movups 0x10(%rbx), %xmm0
movaps %xmm0, 0x50(%rsp)
movl 0x773b(%rip), %ecx      # 0x15b78
leal 0x1(%rcx), %edx
movl %edx, 0x7732(%rip)      # 0x15b78
movl $0x7, (%rax)
movl %ecx, 0x4(%rax)
movq %rsi, 0x8(%rax)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%rax)
movaps 0x50(%rsp), %xmm0
movups %xmm0, 0x20(%rax)
movups %xmm1, 0x30(%rax)
jmp 0xe476
movq %rax, 0x8(%rsp)
jmp 0xe1ce
xorl %r15d, %r15d
movq 0x20(%rsp), %rbx
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %r14
testq %rax, %rax
je 0xe701
movq 0x8(%rsp), %rdx
cmpq $0x26, (%rdx)
jne 0xe4e4
movq %r15, %rax
testq %r15, %r15
jne 0xe6bf
cmpq $0x36, %rbx
je 0xe6bf
addq $0x20, %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x7, %edx
callq 0xcbd8
movq %rax, %r12
testq %rax, %rax
jne 0xe4e7
jmp 0xe701
xorl %r12d, %r12d
movq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xdf23
movq %rax, %r13
testq %rax, %rax
je 0xe701
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x30, %esi
callq 0x962b
movq %rax, %rbx
movl $0x3, (%rax)
movl 0x7654(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x764b(%rip)      # 0x15b78
movl %eax, 0x4(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x8(%rbx)
movl 0x1c(%rsp), %eax
movl %eax, 0xc(%rbx)
cmpq $0x36, 0x20(%rsp)
jne 0xe54c
movw $0x4, 0x2(%rbx)
testq %rbp, %rbp
jne 0xe5a6
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movl $0x40, %esi
callq 0x962b
movq %rax, %rbp
movw $0x7, (%rax)
movl 0x7606(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x75fd(%rip)      # 0x15b78
movl %eax, 0x4(%rbp)
movq $0x0, 0x8(%rbp)
movw $0x1, 0x2(%rbp)
movq $0x2, 0x20(%rbp)
leaq 0x39ee(%rip), %rax      # 0x11f89
movq %rax, 0x28(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbp)
movq %rbp, 0x10(%rbx)
movq %r13, 0x28(%rbx)
testq %r12, %r12
je 0xe5e5
movq %r14, 0x18(%rbx)
movq %r12, 0x20(%rbx)
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r12
movq 0x759c(%rip), %rdx      # 0x15b68
movq 0x759d(%rip), %rcx      # 0x15b70
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0xedd2
jmp 0xdf97
testq %r15, %r15
movq 0x10(%rsp), %r13
jne 0xe647
movq 0x20(%r13), %rdi
movl $0x40, %esi
callq 0x962b
movq %rax, %r15
movw $0x7, (%rax)
movl 0x756d(%rip), %eax      # 0x15b78
leal 0x1(%rax), %ecx
movl %ecx, 0x7564(%rip)      # 0x15b78
movl %eax, 0x4(%r15)
movq $0x0, 0x8(%r15)
movw $0x1, 0x2(%r15)
movq $0x8, 0x20(%r15)
leaq 0x3956(%rip), %rax      # 0x11f8c
movq %rax, 0x28(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
movq 0x10(%rsp), %r13
orb $0x8, 0x2(%rbx)
movq %r15, 0x18(%rbx)
movq %r14, 0x20(%rbx)
jmp 0xe5c0
leaq 0x381f(%rip), %rcx      # 0x11e7e
movq %r13, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x9208
jmp 0xe706
addq $0x20, %r12
movq 0x30(%rsp), %rsi
movq 0x60(%rsp), %rbx
movq %rsi, 0x10(%rbx)
movq 0x20(%r13), %rdi
shlq $0x3, %rsi
callq 0x962b
movq %rax, 0x18(%rbx)
cmpq $0x0, 0x30(%rsp)
movq %rbx, %rsi
je 0xe708
xorl %eax, %eax
movq 0x38(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x18(%rsi), %rdx
movq %rcx, (%rdx,%rax,8)
incq %rax
cmpq 0x30(%rsp), %rax
jb 0xe6a2
jmp 0xe708
testq %rax, %rax
leaq 0x3844(%rip), %rax      # 0x11f0d
leaq 0x388a(%rip), %rcx      # 0x11f5a
cmovneq %rax, %rcx
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x9208
jmp 0xe701
movq %rbx, %rdx
leaq 0x37b7(%rip), %rcx      # 0x11ea4
jmp 0xe6f6
leaq 0x37d9(%rip), %rcx      # 0x11ecf
movq %r13, %rdi
movq %r12, %rsi
callq 0x9208
movq 0x8(%rsp), %r12
xorl %esi, %esi
movq 0x28(%rsp), %rax
movq %r12, (%rax)
movq %rsi, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe755
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe74e
jmp 0xe755
jmp 0xe74e
jmp 0xe74e
movq 0x8(%rsp), %r12
jmp 0xe755
movq 0x28(%rsp), %rcx
movq %r12, (%rcx)
movq %rax, %rdi
callq 0x3100