// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq %rsi, 0x20(%rsp)
movq (%rsi), %rbx
cmpq $0x2c, (%rbx)
jne 0xc9df
movq 0x20(%r15), %rdi
pushq $0x20
popq %rsi
callq 0x7fa2
movl $0x1, (%rax)
movl 0x8872(%rip), %edx      # 0x14b78
leal 0x1(%rdx), %ecx
movl %ecx, 0x8869(%rip)      # 0x14b78
movl %edx, 0x4(%rax)
movq 0x8(%rbx), %rcx
movq %rax, 0x48(%rsp)
movq %rcx, 0x8(%rax)
addq $0x20, %rbx
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq (%rbx), %rax
cmpq $0x2d, %rax
je 0xc9f9
movq %rbx, 0x8(%rsp)
movl 0x8(%rbx), %ecx
movl %ecx, 0x10(%rsp)
movl 0xc(%rbx), %ecx
movl %ecx, 0x14(%rsp)
testq %rax, %rax
je 0xc601
cmpq $0x2c, %rax
je 0xc5de
cmpq $0xd, %rax
je 0xc432
cmpq $0x1c, %rax
je 0xc525
cmpq $0x1e, %rax
je 0xc4a6
cmpq $0xc, %rax
jne 0xc592
leaq 0x20(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rbx), %rdx
movq %rdx, %rcx
movq %rax, %r12
movq %rdx, 0x28(%rsp)
cmpq $0x36, %rdx
jne 0xc3b9
leaq 0x40(%rbx), %r12
movq %r12, 0x8(%rsp)
movq 0x40(%rbx), %rcx
testq %rcx, %rcx
je 0xc827
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %r14
testq %rax, %rax
je 0xca7e
movq 0x8(%rsp), %rdx
cmpq $0x26, (%rdx)
jne 0xc6e7
testq %r12, %r12
jne 0xca3e
cmpq $0x36, 0x28(%rsp)
je 0xca3e
addq $0x20, %rdx
movq %rdx, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %rbx
testq %rax, %rax
jne 0xc6e9
jmp 0xca7e
addq $0x20, %rbx
movq %rbx, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %rbx
testq %rax, %rax
je 0xca7e
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xc2cb
movq %rax, %r14
testq %rax, %rax
je 0xca7e
movq 0x8(%rsp), %rax
cmpq $0x7, (%rax)
jne 0xc7d5
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xc2cb
movq %rax, %r13
testq %rax, %rax
jne 0xc7d8
jmp 0xca7e
addq $0x20, %rbx
movq %rbx, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %rbx
testq %rax, %rax
je 0xca7e
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xc2cb
movq %rax, %r14
movq 0x20(%r15), %rdi
pushq $0x20
popq %rsi
callq 0x7fa2
movq %rax, %r12
movl $0x2, (%rax)
movl 0x8682(%rip), %eax      # 0x14b78
leal 0x1(%rax), %ecx
movl %ecx, 0x8679(%rip)      # 0x14b78
movl %eax, 0x4(%r12)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%r12)
movl 0x14(%rsp), %eax
movl %eax, 0xc(%r12)
movq %rbx, 0x10(%r12)
movq %r14, 0x18(%r12)
jmp 0xc8df
leaq 0x20(%rbx), %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %r14
testq %rax, %rax
je 0xca7e
movq 0x20(%r15), %rdi
pushq $0x20
popq %rsi
callq 0x7fa2
movq %rax, %r12
movl $0x6, (%rax)
movl 0x8613(%rip), %eax      # 0x14b78
leal 0x1(%rax), %ecx
movl %ecx, 0x860a(%rip)      # 0x14b78
movl %eax, 0x4(%r12)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%r12)
movl 0x14(%rsp), %eax
movl %eax, 0xc(%r12)
andq $0x0, 0x10(%r12)
movq %r14, 0x18(%r12)
jmp 0xc5ae
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %r12
testq %rax, %rax
je 0xca7e
movq 0x8(%rsp), %rdx
cmpq $0x21, (%rdx)
jne 0xc5c7
addq $0x20, %rdx
movq %rdx, 0x8(%rsp)
jmp 0xc8df
movq %r15, %rdi
movq %rbx, %rsi
leaq 0x364d(%rip), %rcx      # 0xfc21
callq 0x7bb9
jmp 0xc8df
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xc2cb
movq %rax, %r12
movq 0x8(%rsp), %rbx
testq %rax, %rax
jne 0xc8e4
jmp 0xca83
movq 0x20(%rbx), %rax
addq $-0x22, %rax
cmpq $0x2, %rax
ja 0xc62f
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x7cf1
movq %rax, %r12
testq %rax, %rax
jne 0xc8df
jmp 0xca7e
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %r12
testq %rax, %rax
je 0xca7e
movq 0x8(%rsp), %rax
movq (%rax), %rcx
leaq -0x3b(%rcx), %rdx
cmpq $0x5, %rdx
ja 0xc5ae
pushq $0x3d
popq %rsi
btl %edx, %esi
jae 0xc5ae
leaq 0x24a4(%rip), %rdx      # 0xeb18
movq -0x1d8(%rdx,%rcx,8), %r13
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x7
popq %rdx
callq 0xb0d1
movq %rax, %r14
testq %rax, %rax
je 0xca7e
movq 0x20(%r15), %rdi
pushq $0x28
popq %rsi
callq 0x7fa2
movl $0x5, (%rax)
movl 0x84bf(%rip), %ecx      # 0x14b78
leal 0x1(%rcx), %edx
movl %edx, 0x84b6(%rip)      # 0x14b78
movl %ecx, 0x4(%rax)
movl 0x10(%rsp), %ecx
movl %ecx, 0x8(%rax)
movl 0x14(%rsp), %ecx
movl %ecx, 0xc(%rax)
movq %r13, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %r14, 0x20(%rax)
movq %rax, %r12
jmp 0xc5ae
xorl %ebx, %ebx
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xc2cb
movq %rax, %rbp
testq %rax, %rax
je 0xca7e
movq %r14, 0x18(%rsp)
movq %r15, %rax
movq %r12, %r15
movq %rax, %r14
movq 0x20(%rax), %rdi
pushq $0x30
popq %rsi
callq 0x7fa2
movq %rax, %r12
movl $0x3, (%rax)
movl 0x844d(%rip), %eax      # 0x14b78
leal 0x1(%rax), %ecx
movl %ecx, 0x8444(%rip)      # 0x14b78
movl %eax, 0x4(%r12)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%r12)
movl 0x14(%rsp), %eax
movl %eax, 0xc(%r12)
cmpq $0x36, 0x28(%rsp)
jne 0xc75b
movw $0x4, 0x2(%r12)
testq %r13, %r13
jne 0xc7ae
movq 0x20(%r14), %rdi
pushq $0x40
popq %rsi
callq 0x7fa2
movq %rax, %r13
movw $0x7, (%rax)
movl 0x83fe(%rip), %eax      # 0x14b78
leal 0x1(%rax), %ecx
movl %ecx, 0x83f5(%rip)      # 0x14b78
movl %eax, 0x4(%r13)
andq $0x0, 0x8(%r13)
movw $0x1, 0x2(%r13)
movq $0x2, 0x20(%r13)
leaq 0x37b7(%rip), %rax      # 0xff59
movq %rax, 0x28(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r13)
movq %r13, 0x10(%r12)
movq %rbp, 0x28(%r12)
testq %rbx, %rbx
je 0xc874
movq 0x18(%rsp), %rax
movq %rax, 0x18(%r12)
movq %rbx, 0x20(%r12)
jmp 0xc8dc
xorl %r13d, %r13d
movq 0x20(%r15), %rdi
pushq $0x28
popq %rsi
callq 0x7fa2
movq %rax, %r12
movl $0x4, (%rax)
movl 0x8385(%rip), %eax      # 0x14b78
leal 0x1(%rax), %ecx
movl %ecx, 0x837c(%rip)      # 0x14b78
movl %eax, 0x4(%r12)
movl 0x10(%rsp), %eax
movl %eax, 0x8(%r12)
movl 0x14(%rsp), %eax
movl %eax, 0xc(%r12)
movq %rbx, 0x10(%r12)
movq %r14, 0x18(%r12)
movq %r13, 0x20(%r12)
jmp 0xc8df
movq 0x20(%r12), %rcx
cmpq $0x22, %rcx
je 0xc904
cmpq $0x20, %rcx
jne 0xc9cd
leaq 0x40(%r12), %r14
movq %r14, 0x8(%rsp)
cmpq $0x0, 0x40(%r12)
jne 0xca60
leaq 0x60(%r12), %rdx
movq %rdx, 0x8(%rsp)
cmpq $0x22, 0x60(%r12)
pushq $0x60
popq %rax
je 0xc90a
jmp 0xca6c
testq %r15, %r15
jne 0xc8c7
movq 0x20(%r14), %rdi
pushq $0x40
popq %rsi
callq 0x7fa2
movq %rax, %r15
movw $0x7, (%rax)
movl 0x82e5(%rip), %eax      # 0x14b78
leal 0x1(%rax), %ecx
movl %ecx, 0x82dc(%rip)      # 0x14b78
movl %eax, 0x4(%r15)
andq $0x0, 0x8(%r15)
movw $0x1, 0x2(%r15)
movq $0x8, 0x20(%r15)
leaq 0x36a1(%rip), %rax      # 0xff5c
movq %rax, 0x28(%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r15)
orb $0x8, 0x2(%r12)
movq %r15, 0x18(%r12)
movq 0x18(%rsp), %rax
movq %rax, 0x20(%r12)
movq %r14, %r15
movq 0x8(%rsp), %rbx
movq 0x827d(%rip), %rdx      # 0x14b68
movq 0x827e(%rip), %rcx      # 0x14b70
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0xd1f6
jmp 0xc333
pushq $0x20
popq %rax
xorl %r14d, %r14d
addq %r12, %rax
addq $0x20, %rax
movq %rax, 0x8(%rsp)
movq 0x20(%r15), %rdi
pushq $0x40
popq %rsi
callq 0x7fa2
movq %rax, %r13
movq 0x8(%r12), %rax
movups 0x10(%r12), %xmm0
movaps %xmm0, 0x30(%rsp)
movl 0x823d(%rip), %ecx      # 0x14b78
leal 0x1(%rcx), %edx
movl %edx, 0x8234(%rip)      # 0x14b78
movl $0x7, (%r13)
movl %ecx, 0x4(%r13)
movq %rax, 0x8(%r13)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%r13)
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x20(%r13)
movups %xmm1, 0x30(%r13)
testq %r14, %r14
je 0xc9d7
movq 0x20(%r15), %rdi
pushq $0x40
popq %rsi
callq 0x7fa2
movq %rax, %r12
movq 0x8(%r14), %rax
movups 0x10(%r14), %xmm0
movaps %xmm0, 0x30(%rsp)
movl 0x81e5(%rip), %ecx      # 0x14b78
leal 0x1(%rcx), %edx
movl %edx, 0x81dc(%rip)      # 0x14b78
movl $0x7, (%r12)
movl %ecx, 0x4(%r12)
movq %rax, 0x8(%r12)
xorps %xmm1, %xmm1
movups %xmm1, 0x10(%r12)
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x20(%r12)
movups %xmm1, 0x30(%r12)
jmp 0xc3c8
movq %rax, 0x8(%rsp)
jmp 0xc3c2
xorl %r12d, %r12d
jmp 0xc3c8
leaq 0x3468(%rip), %rcx      # 0xfe4e
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x7bb9
jmp 0xca83
addq $0x20, %rbx
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %r14
movq %rsi, 0x10(%r14)
movq 0x20(%r15), %rdi
shlq $0x3, %rsi
callq 0x7fa2
movq %rax, 0x18(%r14)
xorl %eax, %eax
movq %r14, %rsi
cmpq 0x50(%rsp), %rax
jae 0xca85
movq 0x58(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movq 0x18(%rsi), %rdx
movq %rcx, (%rdx,%rax,8)
incq %rax
jmp 0xca21
testq %r12, %r12
leaq 0x3495(%rip), %rax      # 0xfedd
leaq 0x34db(%rip), %rcx      # 0xff2a
cmovneq %rax, %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7bb9
jmp 0xca7e
movq %r14, %rdx
leaq 0x340a(%rip), %rcx      # 0xfe74
jmp 0xca73
leaq 0x342c(%rip), %rcx      # 0xfe9f
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7bb9
movq 0x8(%rsp), %rbx
xorl %esi, %esi
movq 0x20(%rsp), %rax
movq %rbx, (%rax)
movq %rsi, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcad2
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcacb
jmp 0xcad2
jmp 0xcacb
jmp 0xcacb
movq 0x8(%rsp), %rbx
jmp 0xcad2
movq 0x20(%rsp), %rcx
movq %rbx, (%rcx)
movq %rax, %rdi
callq 0x3100