// File: /workspace/github_cpp_makefile_star2_O1/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 $0xc8, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rdi, -0x30(%rbp)
movzbl 0x28(%rdi), %eax
cmpl $0x66, %eax
je 0x6aa9
cmpl $0x4e, %eax
jne 0x6bd2
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x696b
leaq -0x30(%rbp), %r12
movq (%r12), %rax
movq 0x8(%rax), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x696b
movl $0x68, %edi
callq 0x3260
movq %rax, %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x7e80
leaq -0x60(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x70(%rbp), %rdi
callq 0x4baa
movq -0x30(%rbp), %rsi
movb 0x29(%rsi), %r12b
movq %r15, %rdi
callq 0x7e80
leaq -0xe0(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x4baa
movq -0x30(%rbp), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x7e80
leaq -0xc0(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x4baa
movsbl %r12b, %edx
leaq -0x70(%rbp), %rsi
leaq -0xf0(%rbp), %rcx
leaq -0xd0(%rbp), %r8
movq %rbx, %rdi
callq 0x4c90
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x6a8b
callq 0x3230
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6a9c
callq 0x3230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
jmp 0x6bae
cmpb $0x66, 0x29(%rbx)
jne 0x6bd2
movq 0x10(%rbx), %r12
addq $0x10, %rbx
cmpq %rbx, %r12
je 0x6ad6
movq 0x10(%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x696b
movq (%r12), %r12
jmp 0x6abb
movl $0x68, %edi
callq 0x3260
movq %rax, %rbx
leaq -0x30(%rbp), %rsi
movq %r15, %rdi
callq 0x7e80
leaq -0x40(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x50(%rbp), %rdi
callq 0x4baa
movq -0x30(%rbp), %rax
movb 0x29(%rax), %r12b
leaq -0xa0(%rbp), %r13
movq %r13, -0x10(%r13)
movq 0x30(%rax), %rsi
movq 0x38(%rax), %rdx
addq %rsi, %rdx
leaq -0xb0(%rbp), %rdi
callq 0x4baa
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
addq $0x10, %rsi
movq %r15, %rdi
callq 0x7e80
leaq -0x80(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x90(%rbp), %rdi
callq 0x4baa
movsbl %r12b, %edx
leaq -0x50(%rbp), %rsi
leaq -0xb0(%rbp), %rcx
leaq -0x90(%rbp), %r8
movq %rbx, %rdi
callq 0x4c90
movq -0x90(%rbp), %rdi
cmpq %r15, %rdi
je 0x6b95
callq 0x3230
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6ba6
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6bb8
callq 0x3230
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8b78
movq %rax, %rdi
movq %r14, %rsi
callq 0x3060
incq 0x10(%r14)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x90(%rbp), %rdi
cmpq %r15, %rdi
je 0x6c18
callq 0x3230
jmp 0x6c18
movq %rax, %r14
jmp 0x6c29
movq %rax, %r14
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x6c38
callq 0x3230
jmp 0x6c38
movq %rax, %r14
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6c29
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
jmp 0x6c56
jmp 0x6c62
movq %rax, %r14
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6c4e
callq 0x3230
jmp 0x6c4e
movq %rax, %r14
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x6c65
callq 0x3230
jmp 0x6c65
movq %rax, %r14
movq %rbx, %rdi
callq 0x3230
movq %r14, %rdi
callq 0x3470