// File: Ziang95[P]Tomasulo_simulator/registor.cpp
// Function: registor::set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, memCell)
bool registor::set(string name, memCell val)
{
    int index = stoi(name.substr(1, name.size() - 1));
    if (index >= RegSize)
    {
        err_log(name + ": Reg access out of range");
        return false;
    }
    if (name[0] == 'R')
    {
        if (index == 0)
        {
            err_log("R0 can't be modified");
            return false;
        }
        intReg[index] = val.i;
    }
    else if (name[0] == 'F')
        flpReg[index] = val.f;
    else
    {
        err_log("Reg name error");
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rsi, -0xe0(%rbp)
movq %rdi, %rax
movq -0xe0(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
movl %edx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
callq 0x4270
movq -0xd0(%rbp), %rsi
movq %rax, %rcx
decq %rcx
leaq -0x40(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
movl $0x1, %edx
callq 0x4390
movq -0xc8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x15bd0
movl %eax, -0xc0(%rbp)
jmp 0x2096d
leaq -0x40(%rbp), %rdi
callq 0x4240
movl -0xc0(%rbp), %eax
movq -0xd8(%rbp), %rcx
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x10(%rcx), %eax
jl 0x20a00
movq -0xd0(%rbp), %rsi
leaq 0x2050(%rip), %rdx      # 0x229ec
leaq -0x70(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x20c40
movq -0xe8(%rbp), %rdi
callq 0x11880
jmp 0x209ba
leaq -0x70(%rbp), %rdi
callq 0x4240
movb $0x0, -0x1(%rbp)
jmp 0x20b9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x4240
jmp 0x20bad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4240
jmp 0x20bad
movq -0xd0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4690
movsbl (%rax), %eax
cmpl $0x52, %eax
jne 0x20ad4
cmpl $0x0, -0x1c(%rbp)
jne 0x20abb
leaq -0x91(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x4600
movq -0xf0(%rbp), %rdx
leaq 0x1fce(%rip), %rsi      # 0x22a15
leaq -0x90(%rbp), %rdi
callq 0x44c0
jmp 0x20a55
leaq -0x90(%rbp), %rdi
callq 0x11880
jmp 0x20a63
leaq -0x90(%rbp), %rdi
callq 0x4240
leaq -0x91(%rbp), %rdi
callq 0x43d0
movb $0x0, -0x1(%rbp)
jmp 0x20b9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20aaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4240
leaq -0x91(%rbp), %rdi
callq 0x43d0
jmp 0x20bad
movq -0xd8(%rbp), %rax
movl -0x8(%rbp), %edx
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x20b9b
movq -0xd0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4690
movsbl (%rax), %eax
cmpl $0x46, %eax
jne 0x20b0a
movq -0xd8(%rbp), %rax
movss -0x8(%rbp), %xmm0
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x20b99
leaq -0xb9(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x4600
movq -0xf8(%rbp), %rdx
leaq 0x1edb(%rip), %rsi      # 0x22a06
leaq -0xb8(%rbp), %rdi
callq 0x44c0
jmp 0x20b39
leaq -0xb8(%rbp), %rdi
callq 0x11880
jmp 0x20b47
leaq -0xb8(%rbp), %rdi
callq 0x4240
leaq -0xb9(%rbp), %rdi
callq 0x43d0
movb $0x0, -0x1(%rbp)
jmp 0x20b9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20b8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x4240
leaq -0xb9(%rbp), %rdi
callq 0x43d0
jmp 0x20bad
jmp 0x20b9b
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x45f0
nopw %cs:(%rax,%rax)