// File: /workspace/github_cpp_makefile_star2_O2/philpoore[P]Math/./src/Interp.cpp
// Function: Interp::execStmt(AstStmt*)
void Interp::execStmt(AstStmt* stmt) {
    if (stmt->expr->type == AST_TYPE_ASSIGN) {
        AstAssign* assign = (AstAssign*)stmt->expr;
        double value = eval(assign->expr);
        string name = assign->name;
#ifdef DEBUG
        cerr << "--> setting variable: " + name + " to " + to_string(value)
             << endl;
#endif
        variables[name] = value;
    } else if (stmt->expr->type == AST_TYPE_BLOCK) {
        AstBlock* block = (AstBlock*)stmt->expr;
        for (auto stmt : block->stmts) {
            execStmt(stmt);
        }
    } else if (stmt->expr->type == AST_TYPE_IF) {
        AstIf* ast = (AstIf*)stmt->expr;
        double a = eval(ast->expr);
        if (a) {
            if (ast->if_branch) {
                for (auto stmt : ast->if_branch->stmts) {
                    execStmt(stmt);
                }
            }
        } else {
            if (ast->else_branch) {
                for (auto stmt : ast->else_branch->stmts) {
                    execStmt(stmt);
                }
            }
        }
    } else {
        double value = eval(stmt->expr);
        cout << setprecision(16) << value << endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
movq 0x8(%rsi), %r14
movl (%r14), %eax
cmpl $0x9, %eax
je 0x54d7
cmpl $0x8, %eax
je 0x54b9
cmpl $0x1, %eax
jne 0x5516
movq 0x28(%r14), %rsi
movq %rbx, %rdi
callq 0x51b6
movsd %xmm0, -0x20(%rbp)
addq $0x8, %r14
leaq -0xc0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3290
leaq 0x4f5b(%rip), %rsi      # 0xa35e
leaq -0x60(%rbp), %rdi
movq %r15, %rdx
callq 0x761c
leaq 0x4f5f(%rip), %rdx      # 0xa375
leaq -0x80(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x7442
leaq -0x40(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
callq 0x75ef
leaq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x746b
movq 0x9ba4(%rip), %rdi      # 0xeff0
leaq -0xa0(%rbp), %rsi
callq 0x31e0
movq %rax, %rdi
callq 0x3120
leaq -0xa0(%rbp), %rdi
callq 0x3110
leaq -0x40(%rbp), %rdi
callq 0x3110
leaq -0x80(%rbp), %rdi
callq 0x3110
leaq -0x60(%rbp), %rdi
callq 0x3110
leaq -0xc0(%rbp), %rsi
movq %rbx, %rdi
callq 0x7ae6
movsd -0x20(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0xc0(%rbp), %rdi
callq 0x3110
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r14), %r15
movq 0x10(%r14), %r14
cmpq %r14, %r15
je 0x54ab
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x53a0
addq $0x8, %r15
jmp 0x54c1
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0x51b6
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x54ef
jnp 0x5552
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x54ab
movq 0x8(%rax), %r14
movq 0x10(%rax), %r15
cmpq %r15, %r14
je 0x54ab
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x53a0
addq $0x8, %r14
jmp 0x5500
movq %rbx, %rdi
movq %r14, %rsi
callq 0x51b6
movq 0x9a48(%rip), %rdi      # 0xef70
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq $0x10, 0x8(%rdi,%rax)
callq 0x3310
movq %rax, %rdi
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3120
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x54ab
movq 0x8(%rax), %r14
movq 0x10(%rax), %r15
cmpq %r15, %r14
je 0x54ab
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x53a0
addq $0x8, %r14
jmp 0x5567
jmp 0x5592
movq %rax, %rbx
jmp 0x55a6
movq %rax, %rbx
jmp 0x55af
movq %rax, %rbx
jmp 0x55b8
movq %rax, %rbx
jmp 0x55c1
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x3110
leaq -0x40(%rbp), %rdi
callq 0x3110
leaq -0x80(%rbp), %rdi
callq 0x3110
leaq -0x60(%rbp), %rdi
callq 0x3110
leaq -0xc0(%rbp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3370
nop