// File: /workspace/github_cpp_makefile_star2_O2/taurheim[P]AgNES/codeGenerator.cpp
// Function: CodeGenerator::generateAssign(TAC)
void CodeGenerator::generateAssign(TAC tac) {
    code << "; assign " << tac.first <<" := " << tac.second << nl;
    CodeVar left = lookup(tac.first);
    CodeVar right = lookup(tac.second);
    if (left.type == CVT_GLOBAL) {
        if (right.type == CVT_LOCAL) {
            // GLOBAL = LOCAL
            code << "; global = local" << nl;
            loadLocalIntoA(right.value);
            storeAIntoGlobal(left.value);
        }
        else {
            // GLOBAL = CONST
            code << "; global = const" << nl;
            loadConstIntoA(right.value);
            storeAIntoGlobal(left.value);
        }
    }
    else if (left.type == CVT_LOCAL) {
        if (right.type == CVT_GLOBAL) {
            // LOCAL = GLOBAL
            code << "; local := global" << nl;
            loadGlobalIntoA(right.value);
            storeAIntoLocal(left.value);
        }
        else if (right.type == CVT_LOCAL) {
            // LOCAL = LOCAL
            code << "; local := local" << nl;
            loadLocalIntoA(right.value);
            storeAIntoLocal(left.value);
        }
        else if (right.type == CVT_PARAM) {
            code << "; local := param" << nl;
            loadParamIntoA(right.value);
            storeAIntoLocal(left.value);
        }
        else {
            // LOCAL = CONST
            code << "; local := const" << nl;
            loadConstIntoA(right.value);
            storeAIntoLocal(left.value);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
addq $0x80, %rdi
leaq 0x2e84(%rip), %rsi      # 0x10971
movq %rdi, -0x30(%rbp)
callq 0x3230
leaq 0x8(%r14), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x3210
leaq 0x2c5e(%rip), %rsi      # 0x1076a
movq %rax, %rdi
callq 0x3230
addq $0x28, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x3210
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
leaq -0x70(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x32e0
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe668
movq %rax, %r13
leaq -0x70(%rbp), %rdi
callq 0x3140
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x32e0
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe668
movq %rax, %r15
movq %r13, %r14
shrq $0x20, %r14
movq %rax, %r12
shrq $0x20, %r12
leaq -0x50(%rbp), %rdi
callq 0x3140
testl %r13d, %r13d
je 0xdbc4
cmpl $0x1, %r13d
jne 0xdcbf
testl %r15d, %r15d
je 0xdc08
leaq 0x2de9(%rip), %rsi      # 0x1098c
movq -0x30(%rbp), %rdi
callq 0x3230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
movq %rbx, %rdi
movl %r12d, %esi
callq 0xe86c
jmp 0xdc2e
testl %r15d, %r15d
je 0xdc66
cmpl $0x3, %r15d
je 0xdc3e
cmpl $0x1, %r15d
jne 0xdc8e
leaq 0x2db9(%rip), %rsi      # 0x1099d
movq -0x30(%rbp), %rdi
callq 0x3230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
movq %rbx, %rdi
movl %r12d, %esi
callq 0xe4e2
jmp 0xdcb4
leaq 0x2d6c(%rip), %rsi      # 0x1097b
movq -0x30(%rbp), %rdi
callq 0x3230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
movq %rbx, %rdi
movl %r12d, %esi
callq 0xe76e
movq %rbx, %rdi
movl %r14d, %esi
callq 0xe7f2
jmp 0xdcbf
leaq 0x2d7b(%rip), %rsi      # 0x109c0
movq -0x30(%rbp), %rdi
callq 0x3230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
movq %rbx, %rdi
movl %r12d, %esi
callq 0xe928
jmp 0xdcb4
leaq 0x2d42(%rip), %rsi      # 0x109af
movq -0x30(%rbp), %rdi
callq 0x3230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
movq %rbx, %rdi
movl %r12d, %esi
callq 0xe76e
jmp 0xdcb4
leaq 0x2d3c(%rip), %rsi      # 0x109d1
movq -0x30(%rbp), %rdi
callq 0x3230
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3210
movq %rbx, %rdi
movl %r12d, %esi
callq 0xe86c
movq %rbx, %rdi
movl %r14d, %esi
callq 0xe8a4
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdcd0
movq %rax, %rbx
movq %r12, %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x33e0
nop