// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rsi), %rdi
movq %rdx, %rsi
callq 0x4f4e2
movl %eax, %ebp
leaq 0xe8(%rsp), %r12
movq %r12, %rdi
callq 0x4f086
movq 0x8(%r14), %rdi
pushq $0x1
popq %rdx
movq %r15, %rsi
movq %r12, %rcx
callq 0x4f2e2
movq 0x8(%r14), %rax
movq 0x20(%rax), %rcx
subq 0x18(%rax), %rcx
shrq $0x2, %rcx
decl %ecx
cmpl %ecx, %ebp
jne 0x4eda9
cmpb $0x1, 0x128(%rsp)
jne 0x4eed7
leaq 0xc4c6(%rip), %rsi      # 0x5b1c9
leaq 0xc8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xfa26
movq (%r14), %rax
leaq 0xc8(%rsp), %rsi
movq %r14, %rdi
callq *0x28(%rax)
leaq 0xc8(%rsp), %rdi
callq 0x5120
movq 0x10(%r14), %r14
leaq 0x108(%rsp), %rdx
leaq 0xc099(%rip), %rsi      # 0x5addf
leaq 0x8(%rsp), %rdi
callq 0xfbb3
leaq 0xbef1(%rip), %rdx      # 0x5ac48
leaq 0xa8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xfd14
leaq 0xa8(%rsp), %rsi
movq %r14, %rdi
callq 0x4f2cc
leaq 0xa8(%rsp), %rdi
callq 0x5120
leaq 0x8(%rsp), %rdi
callq 0x5120
leaq 0xc060(%rip), %rsi      # 0x5adf7
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0xfa26
jmp 0x4ef0e
leaq 0xc419(%rip), %rsi      # 0x5b1c9
leaq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xfa26
movq (%r14), %rax
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq *0x28(%rax)
leaq 0x88(%rsp), %rdi
callq 0x5120
movq 0x10(%r14), %r15
shll $0x2, %ebp
leaq 0x48(%rsp), %rdi
movl %ebp, %esi
callq 0x3cc01
leaq 0xc003(%rip), %rsi      # 0x5adfd
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0xfac0
leaq 0xbe38(%rip), %rdx      # 0x5ac48
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xfd14
leaq 0x68(%rsp), %rsi
movq %r15, %rdi
callq 0x4f2cc
leaq 0x68(%rsp), %rdi
callq 0x5120
leaq 0x8(%rsp), %rdi
callq 0x5120
leaq 0x48(%rsp), %rdi
callq 0x5120
cmpb $0x1, 0x128(%rsp)
jne 0x4eea8
movq 0x10(%r14), %r14
leaq 0x108(%rsp), %rdx
leaq 0xbfaf(%rip), %rsi      # 0x5ae16
leaq 0x8(%rsp), %rdi
callq 0xfbb3
leaq 0xbdd0(%rip), %rdx      # 0x5ac48
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xfd14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x4f2cc
leaq 0x28(%rsp), %rdi
callq 0x5120
leaq 0x8(%rsp), %rdi
callq 0x5120
leaq 0x108(%rsp), %rdx
leaq 0xbf72(%rip), %rsi      # 0x5ae29
leaq 0x8(%rsp), %rdi
callq 0xfbb3
leaq 0xbd80(%rip), %rdx      # 0x5ac48
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xfd14
jmp 0x4ef04
leaq 0x108(%rsp), %rdx
leaq 0xbf0c(%rip), %rsi      # 0x5adf2
leaq 0x8(%rsp), %rdi
callq 0xfbb3
leaq 0xbd51(%rip), %rdx      # 0x5ac48
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xfd14
leaq 0x8(%rsp), %rdi
callq 0x5120
leaq 0xe8(%rsp), %rdi
callq 0x4f1b6
movq %rbx, %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x4ef49
jmp 0x4ef67
jmp 0x4efb1
jmp 0x4efb1
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x5120
jmp 0x4ef6a
jmp 0x4ef67
jmp 0x4efb1
jmp 0x4ef67
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
jmp 0x4efa8
jmp 0x4efb1
jmp 0x4efb1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x4efa8
jmp 0x4efb1
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x5120
jmp 0x4ef85
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5120
jmp 0x4ef94
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x4efa8
jmp 0x4efb1
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x5120
jmp 0x4efb4
jmp 0x4efb1
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x4f1b6
movq %rbx, %rdi
callq 0x53f0
nop