// File: /workspace/github_cpp_makefile_star2_O3/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 -0x88(%rbp), %r15
movq 0xd632(%rip), %r14      # 0x26fc8
leaq 0x5e7c(%rip), %r12      # 0x1f819
movq (%rbx), %rax
movq 0x8(%rax), %rsi
movq $0x0, -0x80(%rbp)
movq %rbx, -0x88(%rbp)
leaq 0x57a(%rip), %rax       # 0x19f34
movq %rax, -0x70(%rbp)
leaq 0x57d(%rip), %rax       # 0x19f42
movq %rax, -0x78(%rbp)
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18a94
movl %eax, %r13d
movq -0x78(%rbp), %rax
testq %rax, %rax
je 0x199ed
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
testb %r13b, %r13b
je 0x19a2e
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 0x1999d
leaq 0x547(%rip), %r12       # 0x19f7c
leaq -0x68(%rbp), %r15
movq (%rbx), %rax
movq 0x8(%rax), %rsi
movq $0x0, -0x60(%rbp)
movq %rbx, -0x68(%rbp)
leaq 0x519(%rip), %rax       # 0x19f6c
movq %rax, -0x50(%rbp)
movq %r12, -0x58(%rbp)
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18a94
movl %eax, %r13d
movq -0x58(%rbp), %rax
testq %rax, %rax
je 0x19a7f
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
testb %r13b, %r13b
je 0x19ac4
movl $0x1f, %edx
movq %r14, %rdi
leaq 0x5db0(%rip), %rsi      # 0x1f843
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 0x19a39
leaq 0x4eb(%rip), %r12       # 0x19fb6
leaq -0x48(%rbp), %r15
movq (%rbx), %rax
movq 0x8(%rax), %rsi
movq $0x0, -0x40(%rbp)
movq %rbx, -0x48(%rbp)
leaq 0x4bd(%rip), %rax       # 0x19fa6
movq %rax, -0x30(%rbp)
movq %r12, -0x38(%rbp)
movq %rbx, %rdi
movq %r15, %rdx
callq 0x18a94
movl %eax, %r13d
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0x19b15
movq %r15, %rdi
movq %r15, %rsi
movl $0x3, %edx
callq *%rax
testb %r13b, %r13b
je 0x19b5a
movl $0x25, %edx
movq %r14, %rdi
leaq 0x5d3a(%rip), %rsi      # 0x1f863
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 0x19acf
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x19bd0
jmp 0x19bd0
jmp 0x19bd0
movq %rax, %rbx
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0x19bc8
leaq -0x48(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x19bc8
jmp 0x19bd0
movq %rax, %rbx
movq -0x58(%rbp), %rax
testq %rax, %rax
je 0x19bc8
leaq -0x68(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x19bc8
jmp 0x19bd0
movq %rax, %rbx
movq -0x78(%rbp), %rax
testq %rax, %rax
je 0x19bc8
leaq -0x88(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbx, %rdi
callq 0x53d0
movq %rax, %rdi
callq 0xeb19