// File: /workspace/github_cpp_makefile_star2_O3/Ziang95[P]Tomasulo_simulator/memory.cpp
// Function: memory::load(LSQEntry)
bool memory::load(LSQEntry entry)
{
    ROBEntry *R = CPU_ROB->get_entry(entry.rob_i);
    int found = -1;
    bool no_blocking_SD = true;
    memCell ret;
    for (int i = Srear; is_prev_index(Sfront, i, Sfront, Srear);)
    {
        i = (--i)%Q_LEN;
        if (is_prev_index(Stor_Q[i].rob_i, entry.rob_i, CPU_ROB->get_front(), CPU_ROB->get_rear()))
        {
            if (Stor_Q[i].addr == -1)
            {
                no_blocking_SD = false;
                break;
            }
            else
            {
                if (Stor_Q[i].addr == entry.addr && found == -1)
                {
                    if (Stor_Q[i].ready)
                        found = i;
                    else
                    {
                        no_blocking_SD = false;
                        break;
                    }
                }
            }
        }
    }
    if (no_blocking_SD)
    {
        R->output.mem = sys_clk.get_prog_cyc();
        if (found >= 0)
        {
            msg_log("Forward store found, forwarding, Addr="+to_string(Stor_Q[found].addr), 3);
            ret = Stor_Q[found].val;
        }
        else
        {
            msg_log("Begin LD, ROB = " + to_string(entry.rob_i), 3);
            for (int i = 0; ; i++)
            {
                if (squash_p.flag)
                {
                    squash_p.flag = false;
                    if (is_prev_index(brcUnit.squash_ROB_i(), entry.rob_i, squash_p.R_f, squash_p.R_r))
                    {
                        at_falling_edge(mem_next_vdd);
                        return true;
                    }
                }
                if (i == CPU_cfg->ld_str->mem_time - 1)
                {
                    ret = buf[entry.addr];
                    break;
                }
                at_falling_edge(mem_next_vdd);
                at_rising_edge(mem_next_vdd);
                msg_log("Loading value from Addr="+to_string(entry.addr), 3);
            }
        }
        fCDB.enQ(&ret, entry.rob_i);
        at_falling_edge(mem_next_vdd);
        Lfront = (++Lfront)%Q_LEN;
        msg_log("Value loaded ROB = " + to_string(entry.rob_i), 2);
    }
    else
    {
        msg_log("Previous SD not ready, caller ROB = " + to_string(Load_Q[Lfront].rob_i), 3);
        at_falling_edge(mem_next_vdd);
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %r14
leaq 0x10(%rbp), %r13
leaq 0xc582(%rip), %rax      # 0x1b368
movq (%rax), %rdi
movl (%r13), %esi
movq %rsi, -0x38(%rbp)
callq 0x7f98
movl 0x14(%r14), %edx
movl 0x18(%r14), %r12d
cmpl %r12d, %edx
movq %r14, -0x30(%rbp)
jne 0xee1e
leaq 0xce92(%rip), %rdi      # 0x1bca0
movq %rax, %rbx
callq 0x96d0
movl %eax, 0x58(%rbx)
jmp 0xefe6
movq %rax, -0xa0(%rbp)
leaq 0x1888(%r14), %rax
movq %rax, -0x68(%rbp)
movl 0x10(%r13), %eax
movl %eax, -0x74(%rbp)
movl $0xffffffff, -0x60(%rbp) # imm = 0xFFFFFFFF
movl %r12d, %ecx
cmpl %edx, 0x18(%r14)
jge 0xee5e
xorl %ecx, %ecx
cmpl %edx, %r12d
jge 0xee5b
leaq 0xc513(%rip), %rcx      # 0x1b368
movq (%rcx), %rcx
movl 0x10(%rcx), %ecx
addl %r12d, %ecx
cmpl %edx, %ecx
jle 0xef51
movq %r13, %r15
leal -0x1(%r12), %eax
leal 0xfe(%r12), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
negl %ecx
addl %ecx, %r12d
decl %r12d
movslq %r12d, %rax
leaq (%rax,%rax,2), %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x70(%rbp)
movl (%rax,%rcx,8), %ebx
leaq 0xc4c6(%rip), %r13      # 0x1b368
movq (%r13), %rdi
callq 0x8028
movl %eax, %r14d
movq (%r13), %rdi
callq 0x8030
movq -0x38(%rbp), %rdx
cmpl %edx, %ebx
jne 0xeec8
movq -0x30(%rbp), %r14
movq %r15, %r13
jmp 0xef44
cmpl %r14d, %eax
jge 0xef05
xorl %eax, %eax
movl $0x0, %ecx
cmpl %r14d, %ebx
movq %r15, %r13
jge 0xeee9
leaq 0xc485(%rip), %rcx      # 0x1b368
movq (%rcx), %rcx
movl 0x10(%rcx), %ecx
cmpl %r14d, %edx
jge 0xeefb
leaq 0xc473(%rip), %rax      # 0x1b368
movq (%rax), %rax
movl 0x10(%rax), %eax
addl %ecx, %ebx
addl %edx, %eax
movq -0x30(%rbp), %r14
jmp 0xef0e
movl %edx, %eax
movq -0x30(%rbp), %r14
movq %r15, %r13
cmpl %ebx, %eax
jle 0xef44
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movl 0x10(%rax), %ecx
cmpl $-0x1, %ecx
je 0xf32a
xorl -0x74(%rbp), %ecx
movl -0x60(%rbp), %edx
notl %edx
orl %ecx, %edx
jne 0xef44
cmpb $0x1, 0x14(%rax)
movl %r12d, -0x60(%rbp)
jne 0xf32a
movl 0x14(%r14), %edx
cmpl %r12d, %edx
jne 0xee3e
leaq 0xcd48(%rip), %rdi      # 0x1bca0
callq 0x96d0
movq -0xa0(%rbp), %rcx
movl %eax, 0x58(%rcx)
movl -0x60(%rbp), %eax
testl %eax, %eax
js 0xefe6
movl %eax, %eax
leaq (%rax,%rax,2), %rbx
movl 0x1898(%r14,%rbx,8), %r13d
movl %r13d, %r15d
negl %r15d
cmovsl %r13d, %r15d
movl $0x1, %r12d
cmpl $0xa, %r15d
jb 0xf3ad
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0xf3a4
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf3aa
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf3ad
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xefa4
addl $-0x3, %r12d
jmp 0xf3ad
movq -0x38(%rbp), %rbx
movl %ebx, %r12d
negl %r12d
cmovsl %ebx, %r12d
movl $0x1, %r15d
cmpl $0xa, %r12d
jb 0xf04e
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r12d, %ecx
cmpl $0x63, %ecx
jbe 0xf045
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf04b
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf04e
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
movq -0x38(%rbp), %rbx
ja 0xf00e
addl $-0x3, %r15d
jmp 0xf04e
addl $-0x2, %r15d
jmp 0xf04e
decl %r15d
shrl $0x1f, %ebx
movl %ebx, %esi
addl %r15d, %esi
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x58(%rbp), %r14
movq %r14, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r14), %rdi
addq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x7056
leaq 0x66de(%rip), %rcx      # 0x15765
movl $0x10, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xf8(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf0c6
movq %rdx, -0x108(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xf8(%rbp)
jmp 0xf0cc
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq -0x30(%rbp), %r14
movq 0x8(%rax), %rdx
leaq -0x108(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x3, %esi
callq 0x9f0f
movq -0x108(%rbp), %rdi
cmpq %rbx, %rdi
je 0xf109
callq 0x3230
movl %r12d, -0x70(%rbp)
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf11f
callq 0x3230
leaq 0x80(%r14), %rax
movq %rax, -0x68(%rbp)
movslq 0x10(%r13), %r15
movl %r15d, %r13d
negl %r13d
cmovsl %r15d, %r13d
movq %r15, -0x60(%rbp)
shrl $0x1f, %r15d
xorl %ebx, %ebx
cmpb $0x1, 0x28(%r14)
jne 0xf1a9
movb $0x0, 0x28(%r14)
leaq 0xc23b(%rip), %rdi      # 0x1b390
callq 0x8fd4
cmpl -0x38(%rbp), %eax
je 0xf1a9
movl 0x1c(%r14), %edx
movq -0x38(%rbp), %rcx
cmpl %edx, 0x20(%r14)
jge 0xf1a1
xorl %ecx, %ecx
movl $0x0, %esi
cmpl %edx, %eax
jge 0xf185
leaq 0xc1e9(%rip), %rsi      # 0x1b368
movq (%rsi), %rsi
movl 0x10(%rsi), %esi
movq -0x38(%rbp), %rdi
cmpl %edx, %edi
movq %rdi, %rdx
jge 0xf19d
leaq 0xc1d1(%rip), %rcx      # 0x1b368
movq (%rcx), %rcx
movl 0x10(%rcx), %ecx
addl %esi, %eax
addl %edx, %ecx
cmpl %eax, %ecx
jg 0xf321
leaq 0xc1a8(%rip), %rax      # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %eax
decl %eax
cmpl %eax, %ebx
je 0xf309
movq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0xa049
movq %r14, %rdi
callq 0x9feb
movl $0x1, %r14d
cmpl $0xa, %r13d
jb 0xf22b
movl $0x4, %r14d
movl %r13d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0xf222
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0xf228
cmpl $0x2710, %eax           # imm = 0x2710
jb 0xf22b
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r14d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0xf1f2
addl $-0x3, %r14d
jmp 0xf22b
addl $-0x2, %r14d
jmp 0xf22b
decl %r14d
leal (%r14,%r15), %esi
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movl $0x2d, %edx
callq 0x32b0
movq -0x58(%rbp), %rdi
addq %r15, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x7056
movl $0x18, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x6508(%rip), %rcx      # 0x15776
callq 0x3280
leaq -0x88(%rbp), %rsi
movq %rsi, -0x98(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq -0x30(%rbp), %r14
je 0xf2a7
movq %rdx, -0x98(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x88(%rbp)
jmp 0xf2ad
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x90(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x98(%rbp), %rdi
movl $0x3, %esi
callq 0x9f0f
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xf2f0
callq 0x3230
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf302
callq 0x3230
incl %ebx
jmp 0xf142
movq -0x60(%rbp), %rbx
shlq $0x2, %rbx
addq (%r14), %rbx
movq -0x38(%rbp), %rdx
movl -0x70(%rbp), %r13d
jmp 0xf49a
movq -0x68(%rbp), %rdi
jmp 0xf6de
movslq 0xc(%r14), %rax
leaq (%rax,%rax,2), %rax
movl 0x88(%r14,%rax,8), %r13d
movl %r13d, %r14d
negl %r14d
cmovsl %r13d, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0xf60a
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xf601
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf607
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf60a
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xf362
addl $-0x3, %r15d
jmp 0xf60a
addl $-0x2, %r12d
jmp 0xf3ad
decl %r12d
shrl $0x1f, %r13d
movl %r13d, %esi
addl %r12d, %esi
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x58(%rbp), %r14
movq %r14, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r14), %rdi
addq %r13, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x7056
leaq 0x6356(%rip), %rcx      # 0x1573e
movl $0x26, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0x118(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf427
movq %rdx, -0x128(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x118(%rbp)
jmp 0xf42e
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq -0x30(%rbp), %r14
movq 0x8(%rax), %rdx
leaq -0x128(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x3, %esi
callq 0x9f0f
movq -0x128(%rbp), %rdi
cmpq %r15, %rdi
je 0xf46b
callq 0x3230
leaq (%r14,%rbx,8), %rbx
addq $0x1888, %rbx           # imm = 0x1888
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf488
callq 0x3230
addq $0xc, %rbx
movq -0x38(%rbp), %rdx
movl %edx, %r13d
negl %r13d
cmovsl %edx, %r13d
movl (%rbx), %eax
leaq -0xa4(%rbp), %rsi
movl %eax, (%rsi)
leaq 0xbf6c(%rip), %rdi      # 0x1b418
callq 0x3b84
leaq 0x80(%r14), %rdi
callq 0xa049
movl 0xc(%r14), %eax
leal 0x1(%rax), %ecx
leal 0x100(%rax), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
andl $0xffffff00, %edx       # imm = 0xFFFFFF00
negl %edx
addl %edx, %eax
incl %eax
movl %eax, 0xc(%r14)
movl $0x1, %ebx
cmpl $0xa, %r13d
jb 0xf52f
movl $0x4, %ebx
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r13d, %ecx
cmpl $0x63, %ecx
jbe 0xf528
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf52d
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf52f
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %ebx
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xf4f7
addl $-0x3, %ebx
jmp 0xf52f
addl $-0x2, %ebx
jmp 0xf52f
decl %ebx
movq -0x38(%rbp), %r12
shrl $0x1f, %r12d
movl %r12d, %esi
addl %ebx, %esi
leaq -0x48(%rbp), %r15
movq %r15, -0x10(%r15)
leaq -0x58(%rbp), %r14
movq %r14, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r14), %rdi
addq %r12, %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x7056
leaq 0x6223(%rip), %rcx      # 0x1578f
movl $0x13, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xd8(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf5ab
movq %rdx, -0xe8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xd8(%rbp)
jmp 0xf5b1
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
leaq -0xe8(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x2, %esi
callq 0x9f0f
movq -0xe8(%rbp), %rdi
cmpq %rbx, %rdi
je 0xf5ea
callq 0x3230
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0xf6e3
callq 0x3230
jmp 0xf6e3
addl $-0x2, %r15d
jmp 0xf60a
decl %r15d
shrl $0x1f, %r13d
movl %r13d, %esi
addl %r15d, %esi
leaq -0x48(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r12), %rdi
addq %r13, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x7056
leaq 0x615d(%rip), %rcx      # 0x157a3
movl $0x24, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xb8(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq -0x30(%rbp), %r14
je 0xf689
movq %rdx, -0xc8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xb8(%rbp)
jmp 0xf690
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq -0xc8(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x3, %esi
callq 0x9f0f
movq -0xc8(%rbp), %rdi
cmpq %r15, %rdi
je 0xf6c9
callq 0x3230
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0xf6d7
callq 0x3230
subq $-0x80, %r14
movq %r14, %rdi
callq 0xa049
movb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0xc8(%rbp), %rdi
cmpq %r15, %rdi
je 0xf710
callq 0x3230
jmp 0xf710
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
jne 0xf792
jmp 0xf797
movq %rax, %r14
movq -0x128(%rbp), %rdi
cmpq %r15, %rdi
jne 0xf780
jmp 0xf785
jmp 0xf765
movq %rax, %r14
movq -0x108(%rbp), %rdi
cmpq %rbx, %rdi
jne 0xf780
jmp 0xf785
jmp 0xf765
movq %rax, %r14
movq -0xe8(%rbp), %rdi
cmpq %rbx, %rdi
je 0xf75a
callq 0x3230
jmp 0xf75a
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
jne 0xf792
jmp 0xf797
movq %rax, %r14
jmp 0xf785
movq %rax, %r14
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xf785
callq 0x3230
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf797
callq 0x3230
movq %r14, %rdi
callq 0x3440