// File: /workspace/github_cpp_makefile_star2_O1/Bartor[P]kompilator/middle/ast_optimizer/ASTOptimizer.cpp
// Function: ASTOptimizer::optimize(bool)
void ASTOptimizer::optimize(bool verbose) {
    while (traverse(originalProgram->commands, [this](Node *node) -> Node * { return constantConditionRemover(node); })) {
        std::cout << "   [i] flattening always true expressions" << std::endl;
    }

    while (traverse(originalProgram->commands, [this](Node *node) -> Node * { return constantLoopUnroller(node); })) {
        std::cout << "   [i] unrolling constant loops" << std::endl;
    }
    while (traverse(originalProgram->commands, [this](Node *node) -> Node * { return constantExpressionOptimizer(node); })) {
        std::cout << "   [i] Replacing constant expressions" << std::endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
leaq -0x90(%rbp), %r15
movq 0xe36a(%rip), %r14      # 0x27fc8
leaq 0x6bd4(%rip), %r12      # 0x20839
movq (%rbx), %rax
movq 0x8(%rax), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x80(%rbp)
movq %rbx, -0x90(%rbp)
leaq 0x5be(%rip), %rax       # 0x1a246
movq %rax, -0x78(%rbp)
leaq 0x5c1(%rip), %rax       # 0x1a254
movq %rax, -0x80(%rbp)
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18d22
movl %eax, %r13d
movq -0x80(%rbp), %rax
testq %rax, %rax
je 0x19cbb
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
testb %r13b, %r13b
je 0x19cfc
movl $0x29, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x5250
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x51d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5140
jmp 0x19c65
leaq 0x58b(%rip), %r12       # 0x1a28e
leaq -0x70(%rbp), %r15
movq (%rbx), %rax
movq 0x8(%rax), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x60(%rbp)
movq %rbx, -0x70(%rbp)
leaq 0x55a(%rip), %rax       # 0x1a27e
movq %rax, -0x58(%rbp)
movq %r12, -0x60(%rbp)
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18d22
movl %eax, %r13d
movq -0x60(%rbp), %rax
testq %rax, %rax
je 0x19d50
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
testb %r13b, %r13b
je 0x19d95
movl $0x1f, %edx
movq %r14, %rdi
leaq 0x6aff(%rip), %rsi      # 0x20863
callq 0x5250
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x51d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5140
jmp 0x19d07
leaq 0x52c(%rip), %r12       # 0x1a2c8
leaq -0x50(%rbp), %r15
movq (%rbx), %rax
movq 0x8(%rax), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x40(%rbp)
movq %rbx, -0x50(%rbp)
leaq 0x4fb(%rip), %rax       # 0x1a2b8
movq %rax, -0x38(%rbp)
movq %r12, -0x40(%rbp)
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18d22
movl %eax, %r13d
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x19de9
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
testb %r13b, %r13b
je 0x19e2e
movl $0x25, %edx
movq %r14, %rdi
leaq 0x6a86(%rip), %rsi      # 0x20883
callq 0x5250
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x51d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5140
jmp 0x19da0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x19ea4
jmp 0x19ea4
jmp 0x19ea4
movq %rax, %rbx
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x19e9c
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x19e9c
jmp 0x19ea4
movq %rax, %rbx
movq -0x60(%rbp), %rax
testq %rax, %rax
je 0x19e9c
leaq -0x70(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x19e9c
jmp 0x19ea4
movq %rax, %rbx
movq -0x80(%rbp), %rax
testq %rax, %rax
je 0x19e9c
leaq -0x90(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbx, %rdi
callq 0x53d0
movq %rax, %rdi
callq 0xec29