// File: taurheim[P]AgNES/codeGenerator.cpp
// Function: CodeGenerator::lookup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
CodeVar CodeGenerator::lookup(std::string varName) {
    if (isNumber(varName)) {
        int value = std::stoi(varName);
        return {CVT_CONST, value};  
    }
    if (currentParamMap.find(varName) != currentParamMap.end()) {
        return {CVT_PARAM, currentParamMap[varName]};
    }
    if (globalToAddressMap.find(varName) != globalToAddressMap.end()) {
        return {CVT_GLOBAL, globalToAddressMap[varName]};
    }
    if (localToOffsetMap.find(varName) != localToOffsetMap.end()) {
        return {CVT_LOCAL, localToOffsetMap[varName]};
    }
    localToOffsetMap[varName] = currentLocalOffset;
    currentLocalOffset++;
    return {CVT_LOCAL, localToOffsetMap[varName]};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rsi, -0x98(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x3140
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x21aa0
movb %al, -0x79(%rbp)
jmp 0x2129d
leaq -0x38(%rbp), %rdi
callq 0x31d0
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x212af
jmp 0x212f3
movq -0x98(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x21c70
movl %eax, -0x48(%rbp)
movl $0x2, -0x8(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x214ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31d0
jmp 0x214b9
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
addq $0x258, %rdi            # imm = 0x258
callq 0x21e50
movq -0x90(%rbp), %rdi
movq %rax, -0x50(%rbp)
addq $0x258, %rdi            # imm = 0x258
callq 0x21e80
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x21e20
testb $0x1, %al
jne 0x2133b
jmp 0x21366
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdi
movl $0x3, -0x8(%rbp)
addq $0x258, %rdi            # imm = 0x258
callq 0x21b90
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x214ac
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
addq $0x1f8, %rdi            # imm = 0x1F8
callq 0x21e50
movq -0x90(%rbp), %rdi
movq %rax, -0x60(%rbp)
addq $0x1f8, %rdi            # imm = 0x1F8
callq 0x21e80
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x21e20
testb $0x1, %al
jne 0x213ae
jmp 0x213d9
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdi
movl $0x1, -0x8(%rbp)
addq $0x1f8, %rdi            # imm = 0x1F8
callq 0x21b90
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x214ac
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
addq $0x228, %rdi            # imm = 0x228
callq 0x21e50
movq -0x90(%rbp), %rdi
movq %rax, -0x70(%rbp)
addq $0x228, %rdi            # imm = 0x228
callq 0x21e80
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x21e20
testb $0x1, %al
jne 0x21421
jmp 0x21449
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdi
movl $0x0, -0x8(%rbp)
addq $0x228, %rdi            # imm = 0x228
callq 0x21b90
movl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x214ac
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdi
movl 0x298(%rdi), %eax
movl %eax, -0x9c(%rbp)
addq $0x228, %rdi            # imm = 0x228
callq 0x21b90
movl -0x9c(%rbp), %ecx
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
movl %ecx, (%rax)
movl 0x298(%rdi), %eax
addl $0x1, %eax
movl %eax, 0x298(%rdi)
movl $0x0, -0x8(%rbp)
addq $0x228, %rdi            # imm = 0x228
callq 0x21b90
movl (%rax), %eax
movl %eax, -0x4(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3520
nopw %cs:(%rax,%rax)