// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x80(%rdi), %r13
leaq 0x2ece(%rip), %rsi      # 0x12969
movl $0x9, %edx
movq %r13, %rdi
callq 0x32d0
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
movq %r13, %rdi
callq 0x32d0
movq %rax, %r14
leaq 0x2c9e(%rip), %rsi      # 0x12762
movl $0x4, %edx
movq %rax, %rdi
callq 0x32d0
movq 0x28(%r12), %rsi
movq 0x30(%r12), %rdx
movq %r14, %rdi
callq 0x32d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %rax, %rdi
callq 0x32d0
leaq -0x68(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r14
movq %r14, %rdi
callq 0x6906
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10a76
movq %rax, %r14
movq %r13, -0x30(%rbp)
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0xfb33
callq 0x3250
leaq -0x48(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x28(%r12), %rsi
movq 0x30(%r12), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %r12
movq %r12, %rdi
callq 0x6906
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10a76
movq %rax, %r13
movq %r14, %rax
shrq $0x20, %rax
movq %rax, -0x38(%rbp)
movq %r13, %r12
shrq $0x20, %r12
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0xfb82
callq 0x3250
testl %r14d, %r14d
je 0xfbd1
cmpl $0x1, %r14d
jne 0xfd18
testl %r13d, %r13d
je 0xfc29
leaq 0x2de3(%rip), %rsi      # 0x12984
movl $0x10, %edx
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x32d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x10d7c
jmp 0xfc5b
testl %r13d, %r13d
je 0xfca0
cmpl $0x3, %r13d
movq -0x38(%rbp), %r14
je 0xfc6c
cmpl $0x1, %r13d
jne 0xfcdb
leaq 0x2d9c(%rip), %rsi      # 0x12995
movl $0x11, %edx
movq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x32d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x32d0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1089e
jmp 0xfd0d
leaq 0x2d43(%rip), %rsi      # 0x12973
movl $0x10, %edx
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x32d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x10c3e
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x10ce0
jmp 0xfd18
leaq 0x2d45(%rip), %rsi      # 0x129b8
movl $0x10, %edx
movq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x32d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x32d0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x10e6c
jmp 0xfd0d
leaq 0x2d00(%rip), %rsi      # 0x129a7
movl $0x10, %edx
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x32d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x10c3e
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
jmp 0xfd13
leaq 0x2ce7(%rip), %rsi      # 0x129c9
movl $0x10, %edx
movq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x32d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x32d0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x10d7c
movq %rbx, %rdi
movl %r14d, %esi
callq 0x10dca
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x58(%rbp), %rdi
jmp 0xfd37
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0xfd41
callq 0x3250
movq %rbx, %rdi
callq 0x3420
nop