// File: Bartor[P]kompilator/middle/ast_optimizer/ASTOptimizer.cpp
// Function: ASTOptimizer::traverse(Node*, std::function<Node* (Node*)>)
bool ASTOptimizer::traverse(Node *node, Callback callback) {
    if (auto cmdList = dynamic_cast<CommandList *>(node)) {
        return traverse(*cmdList, callback);
    } else if (auto whileNode = dynamic_cast<While *>(node)) {
        return traverse(whileNode->commands, callback);
    } else if (auto forNode = dynamic_cast<For *>(node)) {
        return traverse(forNode->commands, callback);
    } else if (auto ifNode = dynamic_cast<If *>(node)) {
        return traverse(ifNode->commands, callback);
    } else if (auto ifElse = dynamic_cast<IfElse *>(node)) {
        return traverse(ifElse->commands, callback) || traverse(ifElse->elseCommands, callback);
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdx, -0x138(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
je 0x260f1
movq -0x128(%rbp), %rdi
leaq 0x19e88(%rip), %rsi     # 0x3ff60
leaq 0x1a269(%rip), %rdx     # 0x40348
xorl %eax, %eax
movl %eax, %ecx
callq 0x62f0
movq %rax, -0x140(%rbp)
jmp 0x260fc
xorl %eax, %eax
movq %rax, -0x140(%rbp)
jmp 0x260fc
movq -0x140(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x26185
movq -0x138(%rbp), %rsi
movq -0x28(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x11590
movq -0x130(%rbp), %rdi
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdx
callq 0x25f40
movb %al, -0x141(%rbp)
jmp 0x26152
movb -0x141(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x11640
jmp 0x265c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x11640
jmp 0x265d3
movq -0x18(%rbp), %rax
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
je 0x261bd
movq -0x160(%rbp), %rdi
leaq 0x19dbc(%rip), %rsi     # 0x3ff60
leaq 0x1a2bd(%rip), %rdx     # 0x40468
xorl %eax, %eax
movl %eax, %ecx
callq 0x62f0
movq %rax, -0x168(%rbp)
jmp 0x261c8
xorl %eax, %eax
movq %rax, -0x168(%rbp)
jmp 0x261c8
movq -0x168(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x26255
movq -0x138(%rbp), %rsi
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x180(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x11590
movq -0x130(%rbp), %rdi
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
callq 0x25f40
movb %al, -0x169(%rbp)
jmp 0x26222
movb -0x169(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x11640
jmp 0x265c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x11640
jmp 0x265d3
movq -0x18(%rbp), %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, %rax
je 0x2628d
movq -0x188(%rbp), %rdi
leaq 0x19cec(%rip), %rsi     # 0x3ff60
leaq 0x1a235(%rip), %rdx     # 0x404b0
xorl %eax, %eax
movl %eax, %ecx
callq 0x62f0
movq %rax, -0x190(%rbp)
jmp 0x26298
xorl %eax, %eax
movq %rax, -0x190(%rbp)
jmp 0x26298
movq -0x190(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x2633b
movq -0x138(%rbp), %rsi
movq -0x88(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x1a8(%rbp)
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x11590
movq -0x130(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
movq -0x1a0(%rbp), %rdx
callq 0x25f40
movb %al, -0x191(%rbp)
jmp 0x26302
movb -0x191(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x11640
jmp 0x265c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x11640
jmp 0x265d3
movq -0x18(%rbp), %rax
movq %rax, -0x1b0(%rbp)
cmpq $0x0, %rax
je 0x26373
movq -0x1b0(%rbp), %rdi
leaq 0x19c06(%rip), %rsi     # 0x3ff60
leaq 0x1a077(%rip), %rdx     # 0x403d8
xorl %eax, %eax
movl %eax, %ecx
callq 0x62f0
movq %rax, -0x1b8(%rbp)
jmp 0x2637e
xorl %eax, %eax
movq %rax, -0x1b8(%rbp)
jmp 0x2637e
movq -0x1b8(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x26421
movq -0x138(%rbp), %rsi
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x1d0(%rbp)
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x11590
movq -0x130(%rbp), %rdi
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
callq 0x25f40
movb %al, -0x1b9(%rbp)
jmp 0x263e8
movb -0x1b9(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x11640
jmp 0x265c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x11640
jmp 0x265d3
movq -0x18(%rbp), %rax
movq %rax, -0x1d8(%rbp)
cmpq $0x0, %rax
je 0x26459
movq -0x1d8(%rbp), %rdi
leaq 0x19b20(%rip), %rsi     # 0x3ff60
leaq 0x19fd9(%rip), %rdx     # 0x40420
xorl %eax, %eax
movl %eax, %ecx
callq 0x62f0
movq %rax, -0x1e0(%rbp)
jmp 0x26464
xorl %eax, %eax
movq %rax, -0x1e0(%rbp)
jmp 0x26464
movq -0x1e0(%rbp), %rax
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0x265b9
movq -0x138(%rbp), %rsi
movq -0xd8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x1f8(%rbp)
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x11590
movq -0x130(%rbp), %rdi
movq -0x1f8(%rbp), %rsi
movq -0x1f0(%rbp), %rdx
movb $0x0, -0x119(%rbp)
callq 0x25f40
movb %al, -0x1e1(%rbp)
jmp 0x264d5
movb -0x1e1(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1f9(%rbp)
jne 0x26548
jmp 0x264ea
movq -0x138(%rbp), %rsi
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x208(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x11590
jmp 0x26511
movq -0x208(%rbp), %rsi
movq -0x130(%rbp), %rdi
movb $0x1, -0x119(%rbp)
leaq -0x118(%rbp), %rdx
callq 0x25f40
movb %al, -0x209(%rbp)
jmp 0x2653a
movb -0x209(%rbp), %al
movb %al, -0x1f9(%rbp)
jmp 0x26548
movb -0x1f9(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
testb $0x1, -0x119(%rbp)
jne 0x2655e
jmp 0x2656a
leaq -0x118(%rbp), %rdi
callq 0x11640
leaq -0xf8(%rbp), %rdi
callq 0x11640
jmp 0x265c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x265ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0x119(%rbp)
jne 0x2659d
jmp 0x265a9
leaq -0x118(%rbp), %rdi
callq 0x11640
jmp 0x265ab
leaq -0xf8(%rbp), %rdi
callq 0x11640
jmp 0x265d3
jmp 0x265bb
jmp 0x265bd
jmp 0x265bf
jmp 0x265c1
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x64d0
nopl (%rax)