// File: /workspace/github_cpp_makefile_star2_O2/sighingnow[P]compile-pascal/pl0_allocator.cpp
// Function: SimpleAllocator::alloc(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
string SimpleAllocator::alloc(std::string name, bool is_ref) {
    string res;
    if ((res = exist(name)).length() != 0) {
        return res;
    }
    LOC loc;
    for (auto && r: regs) {
        if (!used[r] || record[r] == name) {
            if (is_ref && r == "ebx") {
                continue; // don't map ebx to a variable with reference type.
            }
            used[r] = true;
            this->record[r] = name;
            return r; // found free register, or this variable already mapped to register.
        }
    }
    std::string r = regs[this->random()];
    if (is_ref && r == "ebx") {
        r = "ecx";  // don't map ebx to a variable with reference type.
    }
    this->spill(r);
    this->used[r] = true;
    this->record[r] = name;
    return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %ecx, %ebp
movq %rsi, %r15
movq %rdi, %r13
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
andq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq 0x60(%rsp), %rdi
movq %rdx, 0x10(%rsp)
movq %rdx, %rsi
callq 0x5340
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r15, %rsi
callq 0x4f010
leaq 0x18(%rsp), %rdi
leaq 0x80(%rsp), %rbx
movq %rbx, %rsi
callq 0x52f0
movq 0x8(%rax), %r14
movq %rbx, %rdi
callq 0x5120
leaq 0x60(%rsp), %rdi
callq 0x5120
testq %r14, %r14
je 0x4db9b
leaq 0x10(%r13), %rax
movq %rax, (%r13)
movq 0x18(%rsp), %rcx
cmpq %r12, %rcx
je 0x4dc2c
movq %rcx, (%r13)
movq 0x28(%rsp), %rax
movq %rax, 0x10(%r13)
jmp 0x4dc34
movq %r13, (%rsp)
leaq 0x80(%rsp), %rdi
callq 0x4f086
leaq 0x20(%r15), %rax
movq %rax, 0x38(%rsp)
leaq 0xc0(%r15), %r13
leaq 0xf0(%r15), %rax
movq %rax, 0x8(%rsp)
pushq $0x20
popq %r14
leaq 0xd5f6(%rip), %r12      # 0x5b1c9
cmpq $0xc0, %r14
je 0x4dc8b
leaq (%r15,%r14), %rbx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4f0cc
cmpb $0x1, (%rax)
jne 0x4dc12
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x4f132
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0xfb78
testb %al, %al
je 0x4dc26
testb %bpl, %bpl
je 0x4dc52
movq %rbx, %rdi
movq %r12, %rsi
callq 0x15c52
testb %al, %al
je 0x4dc52
addq $0x20, %r14
jmp 0x4dbd3
movups (%r12), %xmm0
movups %xmm0, (%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%r13)
movq %r12, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
jmp 0x4dd34
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4f0cc
movb $0x1, (%rax)
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x4f132
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x5160
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x5340
jmp 0x4dd23
movq %r15, %rdi
callq 0x4f198
cltq
shlq $0x5, %rax
movq 0x38(%rsp), %rsi
addq %rax, %rsi
movq (%rsp), %rdi
callq 0x5340
testb %bpl, %bpl
je 0x4dcd3
leaq 0xd513(%rip), %rsi      # 0x5b1c9
movq (%rsp), %rdi
callq 0x15c52
testb %al, %al
je 0x4dcd3
leaq 0xd096(%rip), %rsi      # 0x5ad60
movq (%rsp), %rdi
callq 0x5450
leaq 0x40(%rsp), %rdi
movq (%rsp), %rsi
callq 0x5340
movq (%r15), %rax
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
callq *0x28(%rax)
leaq 0x40(%rsp), %rdi
callq 0x5120
movq %r13, %rdi
movq (%rsp), %rsi
callq 0x4f0cc
movb $0x1, (%rax)
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x4f132
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x5160
leaq 0x80(%rsp), %rdi
callq 0x4f1b6
movq (%rsp), %r13
leaq 0x18(%rsp), %rdi
callq 0x5120
movq %r13, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x5120
jmp 0x4dd69
jmp 0x4dd8a
jmp 0x4dd85
movq %rax, %rbx
movq (%rsp), %rdi
callq 0x5120
jmp 0x4dd8d
jmp 0x4dd8a
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x5120
jmp 0x4dd9a
movq %rax, %rbx
jmp 0x4dd9a
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x4f1b6
leaq 0x18(%rsp), %rdi
callq 0x5120
movq %rbx, %rdi
callq 0x53f0