// File: /workspace/github_cpp_makefile_star2_O2/taurheim[P]AgNES/irGenerator.cpp
// Function: IRGenerator::genTACExpression[abi:cxx11](ASTNode*)
std::string IRGenerator::genTACExpression(ASTNode * expr) {
    TAC code = TAC();
    if (expr->children.size() == 1) {
        ASTNode * onlyChild = expr->children[0];
        if(onlyChild->nodeType == AST_NUMBER) {
            // Case 1: cgen(k) where k is a constant
            code.op = IR_ASSIGN;
            code.first = genAddress();
            code.second = std::to_string(((NumberNode *)onlyChild)->value);
            intermediateCode.push_back(code);
        } else if (onlyChild->nodeType == AST_IDENTIFIER) {
            // Case 2: cgen(id) where id is an identifier
            code.op = IR_ASSIGN;
            code.first = genAddress();
            code.second = ((IdentifierNode *)onlyChild)->name;
            intermediateCode.push_back(code);
        }
    } else {
        ASTNode * secondChild = expr->children[1];
        //Check if binary op
        if (secondChild->nodeType == AST_OPERATOR) {
            code.second = genTACExpression(expr->children[0]);
            code.third = genTACExpression(expr->children[2]);
            OpNode * opNode = (OpNode *)expr->children[1];
            code.op = opStringToEnum[opNode->operation];
            code.first = genAddress();
            intermediateCode.push_back(code);
        }
        //Could be unary op, function, etc..
    }
    return code.first;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq -0xa8(%rbp), %r14
movaps %xmm0, -0x8(%r14)
movaps %xmm0, 0x8(%r14)
movaps %xmm0, 0x18(%r14)
movaps %xmm0, 0x28(%r14)
movaps %xmm0, 0x38(%r14)
andq $0x0, 0x58(%r14)
movaps %xmm0, 0x48(%r14)
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
movb %cl, (%rax)
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
movb %cl, (%rax)
movq 0x8(%rdx), %rax
movq 0x10(%rdx), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
jne 0xbf3c
movq (%rax), %r13
movl (%r13), %eax
cmpl $0x4, %eax
je 0xbff2
cmpl $0x5, %eax
jne 0xc045
movl $0x2, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0xcc56
leaq -0x48(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x32a0
movq %r12, %rdi
callq 0x3140
movl 0x20(%r13), %esi
leaq -0x48(%rbp), %rdi
callq 0x9afb
leaq -0x88(%rbp), %rdi
movq %r12, %rsi
callq 0x32a0
movq %r12, %rdi
callq 0x3140
jmp 0xc032
movq 0x8(%rax), %rcx
cmpl $0xd, (%rcx)
jne 0xc045
movq %rdx, %r13
movq (%rax), %rdx
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0xbe52
leaq -0x48(%rbp), %r12
leaq -0x88(%rbp), %rdi
movq %r12, %rsi
callq 0x32a0
movq %r12, %rdi
callq 0x3140
movq 0x8(%r13), %rax
movq 0x10(%rax), %rdx
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0xbe52
leaq -0x68(%rbp), %rdi
movq %r12, %rsi
callq 0x32a0
movq %r12, %rdi
callq 0x3140
movq 0x8(%r13), %rax
movq 0x8(%rax), %rsi
addq $0x20, %rsi
leaq 0xc567(%rip), %rdi      # 0x18518
callq 0xccf8
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0xcc56
movq %r14, %rdi
movq %r12, %rsi
callq 0x32a0
movq %r12, %rdi
callq 0x3140
addq $0x10, %r15
leaq -0xb0(%rbp), %rsi
movq %r15, %rdi
callq 0xcce8
jmp 0xc045
movl $0x2, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
movq %r15, %rsi
callq 0xcc56
leaq -0x48(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x32a0
movq %r12, %rdi
callq 0x3140
addq $0x20, %r13
leaq -0x88(%rbp), %rdi
movq %r13, %rsi
callq 0x3180
addq $0x10, %r15
leaq -0xb0(%rbp), %rsi
movq %r15, %rdi
callq 0xcce8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32e0
leaq -0xb0(%rbp), %rdi
callq 0x6104
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc081
jmp 0xc081
jmp 0xc081
jmp 0xc081
jmp 0xc081
jmp 0xc081
jmp 0xc081
jmp 0xc081
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x6104
movq %rbx, %rdi
callq 0x33e0