// File: /workspace/github_cpp_makefile_star2_O1/philpoore[P]Math/./src/Parser.cpp
// Function: Parser::parseStatement()
AstStmt* Parser::parseStatement() {
    consumeWhiteSpace();
    AstExpr* expr = nullptr;

    Token t = peek();
    // Assignment statement
    if (t.type == TOKEN_IF) {
        expr = (AstExpr*)parseIf();
    } else if (t.type == TOKEN_IDENT) {
        if (peekNonWhitespace(1).type == TOKEN_EQ) {
            // parse assignment statement
            Token t_ident = expect(TOKEN_IDENT);
            consumeWhiteSpace();

            expect(TOKEN_EQ);
            AstAssign* ast = new AstAssign();
            ast->name = t_ident.source;
            ast->expr = parseExpr();
            expr = (AstExpr*)ast;
        }
    } else if (peek().type == TOKEN_LCURLY) {
        // Block statement
        consume();
        expr = (AstExpr*)parseBlock();
        expect(TOKEN_RCURLY, "Unmatched curly brace, missing closing bracket.");
    }

    // default to parsing expressions.
    if (expr == nullptr) {
        expr = parseExpr();
    }

    if (expr == nullptr) {
        return nullptr;
    }

    consumeWhiteSpace();
    if (expr->type != AST_TYPE_BLOCK && expr->type != AST_TYPE_IF &&
        peek().type != TOKEN_EOF) {
        expect(TOKEN_SEMI, "Missing semi colon");
    }

    AstStmt* stmt = new AstStmt();
    stmt->expr = expr;
    return stmt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %rbx
callq 0x8970
movslq 0x1c(%rbx), %rax
movq (%rbx), %r14
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
movl (%r14,%r15), %eax
leaq -0x100(%rbp), %rdi
movl %eax, -0x8(%rdi)
leaq -0xf0(%rbp), %r13
movq %r13, -0x10(%r13)
movq 0x8(%r14,%r15), %rsi
movq 0x10(%r14,%r15), %rdx
addq %rsi, %rdx
callq 0xb374
movq 0x28(%r14,%r15), %rax
movq %rax, 0x10(%r13)
movl -0x18(%r13), %eax
cmpl $0x101, %eax            # imm = 0x101
je 0x8cc1
cmpl $0x10e, %eax            # imm = 0x10E
jne 0x8e2c
movq %rbx, %rdi
callq 0x91a4
movq %rax, %r14
jmp 0x8f85
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x81b2
leaq -0x40(%rbp), %r12
movl -0x18(%r12), %r14d
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x8cf1
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3240
cmpl $0x103, %r14d           # imm = 0x103
jne 0x8f82
leaq -0xc8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x479d(%rip), %rdx      # 0xd4ad
leaq -0xd8(%rbp), %rdi
movq %rdx, %rsi
callq 0xb59a
leaq -0x58(%rbp), %rdi
leaq -0xd8(%rbp), %rcx
movq %rbx, %rsi
movl $0x101, %edx            # imm = 0x101
callq 0x8468
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x8d52
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x3240
movq %rbx, %rdi
callq 0x8970
leaq -0xa8(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x4741(%rip), %rdx      # 0xd4ad
leaq -0xb8(%rbp), %rdi
movq %rdx, %rsi
callq 0xb59a
leaq -0x1c8(%rbp), %rdi
leaq -0xb8(%rbp), %rcx
movq %rbx, %rsi
movl $0x103, %edx            # imm = 0x103
callq 0x8468
leaq -0x1b0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8db5
movq -0x1b0(%rbp), %rsi
incq %rsi
callq 0x3240
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0x8dd0
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x3240
movl $0x30, %edi
callq 0x3230
movq %rax, %r14
movl $0x1, (%rax)
leaq 0x8(%rax), %rdi
addq $0x18, %rax
movq %rax, 0x8(%r14)
movq $0x0, 0x10(%r14)
movb $0x0, 0x18(%r14)
leaq -0x50(%rbp), %rsi
callq 0x3150
movq %rbx, %rdi
movl $0xffffd8f1, %esi       # imm = 0xFFFFD8F1
callq 0x9644
movq %rax, 0x28(%r14)
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x8f85
movq -0x40(%rbp), %rsi
jmp 0x8f78
movslq 0x1c(%rbx), %rax
movq (%rbx), %r14
leaq (%rax,%rax,2), %r12
shlq $0x4, %r12
movl (%r14,%r12), %eax
leaq -0x50(%rbp), %rdi
movl %eax, -0x8(%rdi)
leaq -0x40(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14,%r12), %rsi
movq 0x10(%r14,%r12), %rdx
addq %rsi, %rdx
callq 0xb374
addq %r12, %r14
movq 0x28(%r14), %rax
movq %rax, -0x30(%rbp)
movl -0x58(%rbp), %r14d
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x8e84
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3240
cmpl $0x10c, %r14d           # imm = 0x10C
jne 0x8f82
movslq 0x1c(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x1c(%rbx)
movq (%rbx), %r14
leaq (%rax,%rax,2), %r12
shlq $0x4, %r12
movl (%r14,%r12), %eax
leaq -0x130(%rbp), %rdi
movl %eax, -0x8(%rdi)
leaq -0x120(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14,%r12), %rsi
movq 0x10(%r14,%r12), %rdx
addq %rsi, %rdx
callq 0xb374
addq %r12, %r14
movq 0x28(%r14), %rax
movq %rax, -0x110(%rbp)
movq -0x130(%rbp), %rdi
cmpq %r15, %rdi
je 0x8efa
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x3240
movq %rbx, %rdi
callq 0x99c4
movq %rax, %r14
leaq -0x88(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x445f(%rip), %rsi      # 0xd377
leaq 0x4487(%rip), %rdx      # 0xd3a6
leaq -0x98(%rbp), %rdi
callq 0xb59a
leaq -0x198(%rbp), %rdi
leaq -0x98(%rbp), %rcx
movq %rbx, %rsi
movl $0x10d, %edx            # imm = 0x10D
callq 0x8468
leaq -0x180(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8f65
movq -0x180(%rbp), %rsi
incq %rsi
callq 0x3240
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0x8f85
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x3240
jmp 0x8f85
xorl %r14d, %r14d
testq %r14, %r14
jne 0x8f9a
movq %rbx, %rdi
movl $0xffffd8f1, %esi       # imm = 0xFFFFD8F1
callq 0x9644
movq %rax, %r14
testq %r14, %r14
je 0x8fb9
movq %rbx, %rdi
callq 0x8970
movl (%r14), %r12d
andl $-0x2, %r12d
cmpl $0x8, %r12d
jne 0x8fc0
xorl %r13d, %r13d
jmp 0x900b
xorl %ebx, %ebx
jmp 0x90b9
movslq 0x1c(%rbx), %rax
movq (%rbx), %r13
leaq (%rax,%rax,2), %r15
shlq $0x4, %r15
movl (%r13,%r15), %eax
leaq -0x50(%rbp), %rdi
movl %eax, -0x8(%rdi)
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x8(%r13,%r15), %rsi
movq 0x10(%r13,%r15), %rdx
addq %rsi, %rdx
callq 0xb374
addq %r15, %r13
movq 0x28(%r13), %rax
movq %rax, -0x30(%rbp)
cmpl $0x112, -0x58(%rbp)     # imm = 0x112
setne %r13b
cmpl $0x8, %r12d
je 0x902a
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x902a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3240
testb %r13b, %r13b
leaq -0xf0(%rbp), %r13
je 0x90a2
leaq -0x68(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x4361(%rip), %rsi      # 0xd3a7
leaq 0x436c(%rip), %rdx      # 0xd3b9
leaq -0x78(%rbp), %rdi
callq 0xb59a
leaq -0x168(%rbp), %rdi
leaq -0x78(%rbp), %rcx
movq %rbx, %rsi
movl $0x110, %edx            # imm = 0x110
callq 0x8468
leaq -0x150(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x908d
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x3240
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x90a2
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3240
movl $0x10, %edi
callq 0x3230
movq %rax, %rbx
movl $0x0, (%rax)
movq %r14, 0x8(%rax)
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x90d4
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x3240
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0x915e
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x3240
jmp 0x915e
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0x917a
movq -0x88(%rbp), %rsi
jmp 0x916b
jmp 0x915b
jmp 0x9177
jmp 0x915b
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x917a
movq -0xc8(%rbp), %rsi
jmp 0x916b
jmp 0x9177
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x917a
movq -0x68(%rbp), %rsi
jmp 0x916b
jmp 0x9177
jmp 0x9177
jmp 0x9177
jmp 0x9177
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x917a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3240
jmp 0x917a
jmp 0x9177
movq %rax, %rbx
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x919c
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x3240
movq %rbx, %rdi
callq 0x3370