// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
pushq %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
cmpq $0x0, 0x8(%rsi)
je 0x3afb
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsi), %r15
movq %rsi, %rdi
callq 0x6528
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %rcx
movl (%rcx), %eax
cmpl $0x1, %eax
je 0x3a75
cmpl $0x8, %eax
je 0x3a33
cmpl $0x19, %eax
je 0x3a61
cmpl $0x16, %eax
je 0x3a4a
cmpl $0xc, %eax
jne 0x3aa5
movl $0x1, (%rbx)
movq %r14, %rdi
callq 0x368a
movq %rax, 0x10(%rbx)
movq %rdx, 0x18(%rbx)
jmp 0x3acd
andl $0x0, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x3b3a
jmp 0x3acd
movl $0x2, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x34f8
jmp 0x3acd
movl $0x5, (%rbx)
movq %r14, %rdi
callq 0x3966
movq %rax, 0x10(%rbx)
jmp 0x3acd
cmpq $0x1, (%r15)
jbe 0x3b1a
movl 0x18(%rcx), %eax
leaq 0x10(%rbx), %rdi
cmpl $0x11, %eax
je 0x3aeb
cmpl $0x10, %eax
je 0x3adb
cmpl $0x9, %eax
jne 0x3aa5
movl $0x3, (%rbx)
movq %r14, %rsi
callq 0x3768
jmp 0x3acd
movl $0x4, (%rbx)
movq %r14, %rdi
callq 0x35a2
movq %rax, 0x10(%rbx)
pushq $0x13
popq %rsi
movq %r14, %rdi
callq 0x6470
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x64f6
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x3, (%rbx)
movq %r14, %rsi
callq 0x38a6
jmp 0x3acd
movl $0x3, (%rbx)
movq %r14, %rsi
callq 0x37e6
jmp 0x3acd
leaq 0x4f56(%rip), %rdi      # 0x8a58
leaq 0x4f60(%rip), %rsi      # 0x8a69
leaq 0x4f6e(%rip), %rcx      # 0x8a7e
movl $0x18d, %edx            # imm = 0x18D
callq 0x1090
leaq 0x4f81(%rip), %rdi      # 0x8aa2
leaq 0x4f41(%rip), %rsi      # 0x8a69
leaq 0x4f4f(%rip), %rcx      # 0x8a7e
movl $0x19e, %edx            # imm = 0x19E
callq 0x1090
nop