// File: /workspace/github_cpp_makefile_star2_O3/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 0x6a6f
cmpl $0x4e, %eax
jne 0x6b98
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6938
movq 0x8(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6938
movl $0x68, %edi
callq 0x3260
movq %rax, %rbx
leaq -0x30(%rbp), %rsi
movq %r15, %rdi
callq 0x7e5e
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 0x7e5e
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 0x7e5e
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 0x4c94
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x6a51
callq 0x3230
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6a62
callq 0x3230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
jmp 0x6b74
cmpb $0x66, 0x29(%rbx)
jne 0x6b98
movq 0x10(%rbx), %r12
addq $0x10, %rbx
cmpq %rbx, %r12
je 0x6a9c
movq 0x10(%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x6938
movq (%r12), %r12
jmp 0x6a81
movl $0x68, %edi
callq 0x3260
movq %rax, %rbx
leaq -0x30(%rbp), %rsi
movq %r15, %rdi
callq 0x7e5e
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 0x7e5e
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 0x4c94
movq -0x90(%rbp), %rdi
cmpq %r15, %rdi
je 0x6b5b
callq 0x3230
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6b6c
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6b7e
callq 0x3230
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8b44
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 0x6bde
callq 0x3230
jmp 0x6bde
movq %rax, %r14
jmp 0x6bef
movq %rax, %r14
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x6bfe
callq 0x3230
jmp 0x6bfe
movq %rax, %r14
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6bef
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
jmp 0x6c1c
jmp 0x6c28
movq %rax, %r14
movq -0xf0(%rbp), %rdi
cmpq %r13, %rdi
je 0x6c14
callq 0x3230
jmp 0x6c14
movq %rax, %r14
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x6c2b
callq 0x3230
jmp 0x6c2b
movq %rax, %r14
movq %rbx, %rdi
callq 0x3230
movq %r14, %rdi
callq 0x3470