// File: /workspace/github_cpp_makefile_star2_O2/johan-bjareholt[P]lua-compiler/src/ir.cc
// Function: emitPass(Expression*, std::map<Expression*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<Expression*>, std::allocator<std::pair<Expression* const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&, BBlock*)
void emitPass(Expression *tree, map<Expression*,string> &nameMap, BBlock *out)
{
    if (tree->kind == 'N'){
        emitPass(tree->left, nameMap, out);
        emitPass(tree->right, nameMap, out);
	    ThreeAd* ta = new ThreeAd(
            nameMap[tree],
	        tree->op, nameMap[tree->left],
	        nameMap[tree->right]
        );
        out->instructions.push_back(*ta);
    }
    else if (tree->kind == 'f' && tree->op == 'f'){
        for (Expression* exp : tree->subexp){
            emitPass(exp, nameMap, out);
        }
	    ThreeAd* ta = new ThreeAd(
            nameMap[tree],
	        tree->op, 
            tree->name, nameMap[tree->subexp.front()]
        );
        out->instructions.push_back(*ta);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rdi, -0x30(%rbp)
movzbl 0x28(%rdi), %eax
cmpl $0x66, %eax
je 0x5ba4
cmpl $0x4e, %eax
jne 0x5c6f
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5ac6
movq 0x8(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5ac6
pushq $0x68
popq %rdi
callq 0x3200
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rsi
movq %r15, %rdi
callq 0x6b52
leaq -0xf8(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x32f0
movq -0x30(%rbp), %rsi
movb 0x29(%rsi), %bl
movq %r15, %rdi
callq 0x6b52
leaq -0xd8(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x32f0
movq -0x30(%rbp), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x6b52
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x32f0
movsbl %bl, %edx
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq %r15, %r8
callq 0x4818
jmp 0x5c4c
cmpb $0x66, 0x29(%rbx)
jne 0x5c6f
addq $0x10, %rbx
movq %rbx, %r12
movq (%r12), %r12
cmpq %rbx, %r12
je 0x5bd0
movq 0x10(%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5ac6
jmp 0x5bb5
pushq $0x68
popq %rdi
callq 0x3200
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rsi
movq %r15, %rdi
callq 0x6b52
leaq -0x98(%rbp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x32f0
movq -0x30(%rbp), %rsi
movb 0x29(%rsi), %bl
addq $0x30, %rsi
leaq -0x78(%rbp), %r13
movq %r13, %rdi
callq 0x32f0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
addq $0x10, %rsi
movq %r15, %rdi
callq 0x6b52
leaq -0x58(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x32f0
movsbl %bl, %edx
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq %r15, %r8
callq 0x4818
movq %r15, %rdi
callq 0x3448
movq %r13, %rdi
callq 0x3448
movq %r12, %rdi
callq 0x3448
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6ba4
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x3448
jmp 0x5ca8
movq %rax, %r14
jmp 0x5cb1
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
callq 0x3448
jmp 0x5cbf
movq %rax, %r14
leaq -0x78(%rbp), %rdi
callq 0x3448
leaq -0x98(%rbp), %rdi
jmp 0x5cd7
jmp 0x5cde
movq %rax, %r14
leaq -0xd8(%rbp), %rdi
callq 0x3448
jmp 0x5cd0
movq %rax, %r14
leaq -0xf8(%rbp), %rdi
callq 0x3448
jmp 0x5ce1
movq %rax, %r14
movq -0x38(%rbp), %rdi
callq 0x31e0
movq %r14, %rdi
callq 0x33f0