// File: /workspace/github_cpp_makefile_star2_O1/tsoding[P]wcc/src/./wcc_parser.cpp
// Function: Parser::parse_statement()
Statement Parser::parse_statement()
{
    Statement result = {};

    assert(tokens.count > 0);
    result.offset = current_offset();

    switch (tokens.items->type) {
    case Token_Type::While:
        result.kind = Statement_Kind::While;
        result.hwile = parse_while();
        break;
    case Token_Type::If:
        result.kind = Statement_Kind::If;
        result.iph = parse_if();
        break;
    case Token_Type::Local:
        result.kind = Statement_Kind::Local_Var_Def;
        result.local_var_def = parse_local_var_def();
        break;
    case Token_Type::Symbol:
        assert(tokens.count > 1);
        switch (tokens.items[1].type) {
        case Token_Type::Equals:
            result.kind = Statement_Kind::Assignment;
            result.assignment = parse_assignment();
            break;
        case Token_Type::Minus_Equals:
            result.kind = Statement_Kind::Assignment;
            result.assignment = parse_subtract_assignment();
            break;
        case Token_Type::Plus_Equals:
            result.kind = Statement_Kind::Assignment;
            result.assignment = parse_add_assignment();
            break;
        default:
            result.kind = Statement_Kind::Expression;
            result.expression = parse_expression();
            expect_token_type(Token_Type::Semicolon);
            tokens.chop(1);
        }
        break;
    case Token_Type::Return:
        result.kind = Statement_Kind::Return;
        result.reeturn = parse_return();
        break;
    default:
        result.kind = Statement_Kind::Expression;
        result.expression = parse_expression();
        expect_token_type(Token_Type::Semicolon);
        tokens.chop(1);
    }

    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
cmpq $0x0, 0x8(%rsi)
je 0x4619
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x7be6
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %rcx
movl (%rcx), %eax
cmpl $0xb, %eax
jle 0x4507
cmpl $0x19, %eax
je 0x452f
cmpl $0x16, %eax
je 0x4546
cmpl $0xc, %eax
jne 0x4598
movl $0x1, (%rbx)
movq %r14, %rdi
callq 0x3f8c
movq %rax, 0x10(%rbx)
movq %rdx, 0x18(%rbx)
jmp 0x45e3
cmpl $0x1, %eax
je 0x4560
cmpl $0x8, %eax
jne 0x4598
movl $0x0, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x4658
jmp 0x45e3
movl $0x5, (%rbx)
movq %r14, %rdi
callq 0x4410
movq %rax, 0x10(%rbx)
jmp 0x45e3
movl $0x2, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x3d42
jmp 0x45e3
cmpq $0x1, 0x8(%r14)
jbe 0x4638
movl 0x18(%rcx), %eax
cmpl $0x11, %eax
je 0x4602
cmpl $0x10, %eax
je 0x45eb
cmpl $0x9, %eax
jne 0x4598
movl $0x3, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x40e4
jmp 0x45e3
movl $0x4, (%rbx)
movq %r14, %rdi
callq 0x3e52
movq %rax, 0x10(%rbx)
movq %r14, %rdi
movl $0x13, %esi
callq 0x7b60
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
testq %rax, %rax
je 0x45d1
addq $0x18, %rcx
movq %rcx, 0x10(%r14)
decq %rax
jmp 0x45df
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
movq %rax, 0x10(%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
movl $0x3, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x42ea
jmp 0x45e3
movl $0x3, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x41c4
jmp 0x45e3
leaq 0x6424(%rip), %rdi      # 0xaa44
leaq 0x642e(%rip), %rsi      # 0xaa55
leaq 0x643c(%rip), %rcx      # 0xaa6a
movl $0x18d, %edx            # imm = 0x18D
callq 0x1090
leaq 0x644f(%rip), %rdi      # 0xaa8e
leaq 0x640f(%rip), %rsi      # 0xaa55
leaq 0x641d(%rip), %rcx      # 0xaa6a
movl $0x19e, %edx            # imm = 0x19E
callq 0x1090
nop