// File: /workspace/github_cpp_makefile_star2_O1/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 0x2d6a(%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 0x2b3a(%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 0x6992
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10bda
movq %rax, %r14
movq %r13, -0x30(%rbp)
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0xfc97
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 0x6992
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10bda
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 0xfce6
callq 0x3250
testl %r14d, %r14d
je 0xfd35
cmpl $0x1, %r14d
jne 0xfe7c
testl %r13d, %r13d
je 0xfd8d
leaq 0x2c7f(%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 0x10ee0
jmp 0xfdbf
testl %r13d, %r13d
je 0xfe04
cmpl $0x3, %r13d
movq -0x38(%rbp), %r14
je 0xfdd0
cmpl $0x1, %r13d
jne 0xfe3f
leaq 0x2c38(%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 0x10a02
jmp 0xfe71
leaq 0x2bdf(%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 0x10da2
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x10e44
jmp 0xfe7c
leaq 0x2be1(%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 0x10fd0
jmp 0xfe71
leaq 0x2b9c(%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 0x10da2
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
jmp 0xfe77
leaq 0x2b83(%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 0x10ee0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x10f2e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x58(%rbp), %rdi
jmp 0xfe9b
movq %rax, %rbx
movq -0x78(%rbp), %rdi
cmpq %r15, %rdi
je 0xfea5
callq 0x3250
movq %rbx, %rdi
callq 0x3420
nop