// File: sighingnow[P]compile-pascal/pl0_allocator.cpp
// Function: SimpleAllocator::addr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string SimpleAllocator::addr(std::string name) {
    int d = env.depth(name);
    LOC loc;
    env.find(name, true, loc);
    if (d == env.depth()) {
        if (loc.is_ref) {
            this->spill("ebx");
            out.emit("    mov ebx, dword [ebp" + loc.offset +"]");
            return "[ebx]";
        }
        else {
            return "[ebp" + loc.offset + "]";
        }
    }
    else {
        this->spill("ebx");
        out.emit("    mov ebx, dword [ebp-" + to_string(d*4) + "]");
        if (loc.is_ref) {
            out.emit("    mov ebx, dword [ebx" + loc.offset + "]");
        }
        return "[ebx" + loc.offset + "]";
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdx, -0x200(%rbp)
movq %rsi, %rax
movq -0x200(%rbp), %rsi
movq %rdi, -0x218(%rbp)
movq %rdi, %rcx
movq %rcx, -0x210(%rbp)
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x208(%rbp)
movq 0x8(%rax), %rdi
callq 0xdb350
movl %eax, -0x1c(%rbp)
leaq -0x68(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0xda9d0
movq -0x208(%rbp), %rax
movq -0x200(%rbp), %rsi
movq -0x1f8(%rbp), %rcx
movq 0x8(%rax), %rdi
movl $0x1, %edx
callq 0xdaf80
jmp 0xda285
movq -0x208(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, -0x220(%rbp)
movq 0x8(%rax), %rdi
callq 0xdb500
movl %eax, -0x21c(%rbp)
jmp 0xda2a6
movl -0x220(%rbp), %eax
movl -0x21c(%rbp), %ecx
cmpl %ecx, %eax
jne 0xda4eb
testb $0x1, -0x28(%rbp)
je 0xda47e
leaq -0x99(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x55d0
movq -0x228(%rbp), %rdx
leaq 0x175dc(%rip), %rsi     # 0xf18c1
leaq -0x98(%rbp), %rdi
callq 0x19840
jmp 0xda2f3
movq -0x208(%rbp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq -0x98(%rbp), %rsi
callq *%rax
jmp 0xda30c
leaq -0x98(%rbp), %rdi
callq 0x5200
leaq -0x99(%rbp), %rdi
callq 0x53c0
movq -0x208(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x230(%rbp)
leaq -0x48(%rbp), %rdx
leaq 0x17196(%rip), %rsi     # 0xf14d7
leaq -0xe0(%rbp), %rdi
callq 0x19ef0
jmp 0xda34f
leaq 0x17002(%rip), %rdx     # 0xf1358
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x1a380
jmp 0xda36b
movq -0x230(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xdaf40
jmp 0xda380
leaq -0xc0(%rbp), %rdi
callq 0x5200
leaq -0xe0(%rbp), %rdi
callq 0x5200
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x55d0
movq -0x218(%rbp), %rdi
movq -0x238(%rbp), %rdx
leaq 0x1712f(%rip), %rsi     # 0xf14ef
callq 0x19840
jmp 0xda3c7
leaq -0xe1(%rbp), %rdi
callq 0x53c0
movl $0x1, -0xe8(%rbp)
jmp 0xda78b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xda7a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xda419
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5200
leaq -0x99(%rbp), %rdi
callq 0x53c0
jmp 0xda7a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xda450
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x5200
leaq -0xe0(%rbp), %rdi
callq 0x5200
jmp 0xda7a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xe1(%rbp), %rdi
callq 0x53c0
jmp 0xda7a4
leaq -0x48(%rbp), %rdx
leaq 0x17061(%rip), %rsi     # 0xf14ea
leaq -0x108(%rbp), %rdi
callq 0x19ef0
jmp 0xda497
movq -0x218(%rbp), %rdi
leaq 0x16eb3(%rip), %rdx     # 0xf1358
leaq -0x108(%rbp), %rsi
callq 0x1a380
jmp 0xda4b3
leaq -0x108(%rbp), %rdi
callq 0x5200
movl $0x1, -0xe8(%rbp)
jmp 0xda78b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x5200
jmp 0xda7a4
leaq -0x129(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x55d0
movq -0x240(%rbp), %rdx
leaq 0x173b5(%rip), %rsi     # 0xf18c1
leaq -0x128(%rbp), %rdi
callq 0x19840
jmp 0xda51a
movq -0x208(%rbp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq -0x128(%rbp), %rsi
callq *%rax
jmp 0xda533
leaq -0x128(%rbp), %rdi
callq 0x5200
leaq -0x129(%rbp), %rdi
callq 0x53c0
movq -0x208(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x248(%rbp)
movl -0x1c(%rbp), %esi
shll $0x2, %esi
leaq -0x190(%rbp), %rdi
callq 0xa3920
jmp 0xda571
leaq 0x16f7d(%rip), %rsi     # 0xf14f5
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rdx
callq 0x19ad0
jmp 0xda58d
leaq 0x16dc4(%rip), %rdx     # 0xf1358
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x1a380
jmp 0xda5a9
movq -0x248(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xdaf40
jmp 0xda5be
leaq -0x150(%rbp), %rdi
callq 0x5200
leaq -0x170(%rbp), %rdi
callq 0x5200
leaq -0x190(%rbp), %rdi
callq 0x5200
testb $0x1, -0x28(%rbp)
je 0xda724
movq -0x208(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x250(%rbp)
leaq -0x48(%rbp), %rdx
leaq 0x16f05(%rip), %rsi     # 0xf150e
leaq -0x1d0(%rbp), %rdi
callq 0x19ef0
jmp 0xda617
leaq 0x16d3a(%rip), %rdx     # 0xf1358
leaq -0x1b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x1a380
jmp 0xda633
movq -0x250(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0xdaf40
jmp 0xda648
leaq -0x1b0(%rbp), %rdi
callq 0x5200
leaq -0x1d0(%rbp), %rdi
callq 0x5200
jmp 0xda724
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xda68b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x5200
leaq -0x129(%rbp), %rdi
callq 0x53c0
jmp 0xda7a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xda6dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xda6d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x5200
leaq -0x170(%rbp), %rdi
callq 0x5200
leaq -0x190(%rbp), %rdi
callq 0x5200
jmp 0xda7a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xda713
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x5200
leaq -0x1d0(%rbp), %rdi
callq 0x5200
jmp 0xda7a4
leaq -0x48(%rbp), %rdx
leaq 0x16df2(%rip), %rsi     # 0xf1521
leaq -0x1f0(%rbp), %rdi
callq 0x19ef0
jmp 0xda73d
movq -0x218(%rbp), %rdi
leaq 0x16c0d(%rip), %rdx     # 0xf1358
leaq -0x1f0(%rbp), %rsi
callq 0x1a380
jmp 0xda759
leaq -0x1f0(%rbp), %rdi
callq 0x5200
movl $0x1, -0xe8(%rbp)
jmp 0xda78b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x5200
jmp 0xda7a4
leaq -0x68(%rbp), %rdi
callq 0xdac70
movq -0x210(%rbp), %rax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0xdac70
movq -0x70(%rbp), %rdi
callq 0x55b0
nopw %cs:(%rax,%rax)