// File: /workspace/github_cpp_makefile_star2_O3/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 0x444d
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x794a
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %rcx
movl (%rcx), %eax
cmpl $0xb, %eax
jle 0x4361
cmpl $0x19, %eax
je 0x4385
cmpl $0x16, %eax
je 0x439c
cmpl $0xc, %eax
jne 0x43e4
movl $0x1, (%rbx)
movq %r14, %rdi
callq 0x3e68
movq %rax, 0x10(%rbx)
movq %rdx, 0x18(%rbx)
jmp 0x4425
cmpl $0x1, %eax
je 0x43b3
cmpl $0x8, %eax
jne 0x43e4
movl $0x0, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x448c
jmp 0x4425
movl $0x5, (%rbx)
movq %r14, %rdi
callq 0x4276
movq %rax, 0x10(%rbx)
jmp 0x4425
movl $0x2, (%rbx)
movq %rbx, %rdi
addq $0x10, %rdi
movq %r14, %rsi
callq 0x3c62
jmp 0x4425
cmpq $0x1, 0x8(%r14)
jbe 0x446c
movl 0x18(%rcx), %eax
leaq 0x10(%rbx), %rdi
cmpl $0x11, %eax
je 0x443d
cmpl $0x10, %eax
je 0x442d
cmpl $0x9, %eax
jne 0x43e4
movl $0x3, (%rbx)
movq %r14, %rsi
callq 0x3f9e
jmp 0x4425
movl $0x4, (%rbx)
movq %r14, %rdi
callq 0x3d52
movq %rax, 0x10(%rbx)
movq %r14, %rdi
movl $0x13, %esi
callq 0x78c4
movq 0x8(%r14), %rax
testq %rax, %rax
movl $0x18, %ecx
cmoveq %rax, %rcx
xorl %edx, %edx
subq $0x1, %rax
cmovaeq %rax, %rdx
addq %rcx, 0x10(%r14)
movq %rdx, 0x8(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
movl $0x3, (%rbx)
movq %r14, %rsi
callq 0x416c
jmp 0x4425
movl $0x3, (%rbx)
movq %r14, %rsi
callq 0x4062
jmp 0x4425
leaq 0x5610(%rip), %rdi      # 0x9a64
leaq 0x561a(%rip), %rsi      # 0x9a75
leaq 0x5628(%rip), %rcx      # 0x9a8a
movl $0x18d, %edx            # imm = 0x18D
callq 0x1090
leaq 0x563b(%rip), %rdi      # 0x9aae
leaq 0x55fb(%rip), %rsi      # 0x9a75
leaq 0x5609(%rip), %rcx      # 0x9a8a
movl $0x19e, %edx            # imm = 0x19E
callq 0x1090
nop