// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
leaq 0x10(%rbp), %r14
leaq 0xc5c6(%rip), %rax      # 0x1b368
movq (%rax), %rdi
movl (%r14), %esi
movq %rsi, -0x38(%rbp)
callq 0x7f30
movq %rax, -0x80(%rbp)
movl 0x18(%rbx), %eax
movq %rbx, -0x30(%rbp)
leaq 0x1888(%rbx), %rcx
movq %rcx, -0x60(%rbp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl 0x10(%r14), %ecx
movl %ecx, -0x74(%rbp)
movl %r15d, -0x64(%rbp)
movl %eax, %r15d
movq -0x30(%rbp), %r14
movl 0x14(%r14), %eax
cmpl %r15d, %eax
jne 0xedec
xorl %eax, %eax
jmp 0xee11
movl %r15d, %ecx
cmpl %eax, 0x18(%r14)
jge 0xee0c
xorl %ecx, %ecx
cmpl %eax, %r15d
jge 0xee09
leaq 0xc565(%rip), %rcx      # 0x1b368
movq (%rcx), %rcx
movl 0x10(%rcx), %ecx
addl %r15d, %ecx
cmpl %eax, %ecx
setg %al
testb %al, %al
je 0xef64
movl %eax, -0x70(%rbp)
leal -0x1(%r15), %eax
leal 0xfe(%r15), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
negl %ecx
addl %ecx, %r15d
decl %r15d
movslq %r15d, %rax
leaq (%rax,%rax,2), %r14
movq -0x60(%rbp), %rax
movl (%rax,%r14,8), %r13d
leaq 0xc518(%rip), %rbx      # 0x1b368
movq (%rbx), %rdi
callq 0x7fc0
movl %eax, %r12d
movq (%rbx), %rdi
callq 0x7fc8
cmpl -0x38(%rbp), %r13d
je 0xeddb
cmpl %r12d, %eax
jge 0xeea6
xorl %eax, %eax
movl $0x0, %ecx
cmpl %r12d, %r13d
jge 0xee8b
leaq 0xc4e3(%rip), %rcx      # 0x1b368
movq (%rcx), %rcx
movl 0x10(%rcx), %ecx
cmpl %r12d, -0x38(%rbp)
jge 0xee9e
leaq 0xc4d0(%rip), %rax      # 0x1b368
movq (%rax), %rax
movl 0x10(%rax), %eax
addl %ecx, %r13d
addl -0x38(%rbp), %eax
jmp 0xeeaa
movq -0x38(%rbp), %rax
cmpl %r13d, %eax
jle 0xeddb
movq -0x60(%rbp), %rax
leaq (%rax,%r14,8), %rax
movl 0x10(%rax), %ecx
cmpl $-0x1, %ecx
je 0xeee0
movl -0x64(%rbp), %edx
notl %edx
xorl -0x74(%rbp), %ecx
orl %edx, %ecx
jne 0xeddb
cmpb $0x0, 0x14(%rax)
movl %r15d, %eax
jne 0xedd4
cmpb $0x0, -0x70(%rbp)
movq -0x30(%rbp), %r14
je 0xef64
movslq 0xc(%r14), %rax
leaq (%rax,%rax,2), %rax
movl 0x88(%r14,%rax,8), %ebx
movl %ebx, %r14d
negl %r14d
cmovsl %ebx, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0xf5bd
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xf5b4
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf5ba
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf5bd
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xef22
addl $-0x3, %r15d
jmp 0xf5bd
leaq 0xcd35(%rip), %rdi      # 0x1bca0
callq 0x9674
movq -0x80(%rbp), %rcx
movl %eax, 0x58(%rcx)
movl -0x64(%rbp), %eax
testl %eax, %eax
js 0xeff3
movl %eax, %eax
leaq (%rax,%rax,2), %rbx
movl 0x1898(%r14,%rbx,8), %r13d
movl %r13d, %r14d
negl %r14d
cmovsl %r13d, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0xf06a
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xf061
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf067
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf06a
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xefb4
addl $-0x3, %r15d
jmp 0xf06a
movq -0x38(%rbp), %rax
movl %eax, %r15d
negl %r15d
cmovsl %eax, %r15d
movl $0x1, %r12d
cmpl $0xa, %r15d
jb 0xf158
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0xf14f
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf155
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf158
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xf01f
addl $-0x3, %r12d
jmp 0xf158
addl $-0x2, %r15d
jmp 0xf06a
decl %r15d
shrl $0x1f, %r13d
movl %r13d, %esi
addl %r15d, %esi
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
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 0x703e
leaq 0x6698(%rip), %rcx      # 0x1573e
movl $0x26, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0x118(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf0e5
movq %rdx, -0x128(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x118(%rbp)
jmp 0xf0ec
movups (%rcx), %xmm0
movups %xmm0, (%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 0x9f03
movq -0x128(%rbp), %rdi
cmpq %r14, %rdi
je 0xf125
callq 0x3230
movq -0x30(%rbp), %rax
leaq (%rax,%rbx,8), %rbx
addq $0x1888, %rbx           # imm = 0x1888
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf146
callq 0x3230
addq $0xc, %rbx
jmp 0xf42c
addl $-0x2, %r12d
jmp 0xf158
decl %r12d
movq -0x38(%rbp), %rbx
shrl $0x1f, %ebx
movl %ebx, %esi
addl %r12d, %esi
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x58(%rbp), %r13
movq %r13, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r13), %rdi
addq %rbx, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x703e
leaq 0x65cf(%rip), %rcx      # 0x15765
movl $0x10, %r8d
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xf8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf1d5
movq %rdx, -0x108(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xf8(%rbp)
jmp 0xf1dc
movups (%rcx), %xmm0
movups %xmm0, (%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 0x9f03
movq -0x108(%rbp), %rdi
cmpq %r14, %rdi
je 0xf215
callq 0x3230
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf227
callq 0x3230
movq -0x30(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x60(%rbp)
leaq 0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
shrl $0x1f, %eax
movq %rax, -0x70(%rbp)
xorl %ebx, %ebx
movq -0x30(%rbp), %rax
cmpb $0x1, 0x28(%rax)
jne 0xf2b9
movq -0x30(%rbp), %rax
movb $0x0, 0x28(%rax)
leaq 0xc128(%rip), %rdi      # 0x1b390
callq 0x8f88
cmpl -0x38(%rbp), %eax
je 0xf2b9
movq -0x30(%rbp), %rsi
movl 0x1c(%rsi), %edx
movq -0x38(%rbp), %rcx
cmpl %edx, 0x20(%rsi)
jge 0xf2b1
xorl %ecx, %ecx
movl $0x0, %esi
cmpl %edx, %eax
jge 0xf29a
leaq 0xc0d4(%rip), %rsi      # 0x1b368
movq (%rsi), %rsi
movl 0x10(%rsi), %esi
cmpl %edx, -0x38(%rbp)
jge 0xf2ac
leaq 0xc0c2(%rip), %rcx      # 0x1b368
movq (%rcx), %rcx
movl 0x10(%rcx), %ecx
addl %esi, %eax
addl -0x38(%rbp), %ecx
cmpl %eax, %ecx
jg 0xf5ab
leaq 0xc098(%rip), %rax      # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %eax
decl %eax
cmpl %eax, %ebx
je 0xf419
movq -0x60(%rbp), %r13
movq %r13, %rdi
callq 0xa03d
movq %r13, %rdi
callq 0x9fdf
movl $0x1, %r13d
cmpl $0xa, %r12d
jb 0xf33b
movl $0x4, %r13d
movl %r12d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0xf332
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0xf338
cmpl $0x2710, %eax           # imm = 0x2710
jb 0xf33b
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0xf302
addl $-0x3, %r13d
jmp 0xf33b
addl $-0x2, %r13d
jmp 0xf33b
decl %r13d
movl %r12d, %r14d
movq -0x70(%rbp), %r12
leal (%r12,%r13), %esi
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %r15
movq %r15, %rdi
movl $0x2d, %edx
callq 0x32b0
movq -0x58(%rbp), %rdi
addq %r12, %rdi
movl %r14d, %r12d
movl %r13d, %esi
movl %r14d, %edx
callq 0x703e
movl $0x18, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x63ee(%rip), %rcx      # 0x15776
callq 0x3280
leaq -0x90(%rbp), %r14
movq %r14, -0xa0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf3bd
movq %rdx, -0xa0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x90(%rbp)
jmp 0xf3c4
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x98(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0xa0(%rbp), %rdi
movl $0x3, %esi
callq 0x9f03
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0xf400
callq 0x3230
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf412
callq 0x3230
incl %ebx
jmp 0xf24f
leaq 0x10(%rbp), %rax
movslq 0x10(%rax), %rbx
shlq $0x2, %rbx
movq -0x30(%rbp), %rax
addq (%rax), %rbx
movl (%rbx), %eax
leaq -0xa4(%rbp), %rsi
movl %eax, (%rsi)
leaq 0x10(%rbp), %rax
movl (%rax), %r14d
leaq 0xbfd3(%rip), %rdi      # 0x1b418
movl %r14d, %edx
callq 0x3b84
movq -0x30(%rbp), %rbx
leaq 0x80(%rbx), %rdi
callq 0xa03d
movl 0xc(%rbx), %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(%rbx)
movl %r14d, %ebx
negl %ebx
cmovsl %r14d, %ebx
movl $0x1, %r15d
cmpl $0xa, %ebx
jb 0xf4da
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebx, %ecx
cmpl $0x63, %ecx
jbe 0xf4d1
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xf4d7
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xf4da
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xf49e
addl $-0x3, %r15d
jmp 0xf4da
addl $-0x2, %r15d
jmp 0xf4da
decl %r15d
shrl $0x1f, %r14d
movl %r14d, %esi
addl %r15d, %esi
leaq -0x48(%rbp), %r13
movq %r13, -0x10(%r13)
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r12), %rdi
addq %r14, %rdi
movl %r15d, %esi
movl %ebx, %edx
callq 0x703e
leaq 0x627a(%rip), %rcx      # 0x1578f
movl $0x13, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xd8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf554
movq %rdx, -0xe8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xd8(%rbp)
jmp 0xf55b
movups (%rcx), %xmm0
movups %xmm0, (%r14)
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 0x9f03
movq -0xe8(%rbp), %rdi
cmpq %r14, %rdi
je 0xf594
callq 0x3230
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0xf694
callq 0x3230
jmp 0xf694
movq -0x60(%rbp), %rdi
jmp 0xf68f
addl $-0x2, %r15d
jmp 0xf5bd
decl %r15d
shrl $0x1f, %ebx
movl %ebx, %esi
addl %r15d, %esi
leaq -0x48(%rbp), %r13
movq %r13, -0x10(%r13)
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r12), %rdi
addq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x703e
leaq 0x61ac(%rip), %rcx      # 0x157a3
movl $0x24, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xb8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xf636
movq %rdx, -0xc8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xb8(%rbp)
jmp 0xf63d
movups (%rcx), %xmm0
movups %xmm0, (%r14)
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 0x9f03
movq -0xc8(%rbp), %rdi
cmpq %r14, %rdi
je 0xf676
callq 0x3230
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
movq -0x30(%rbp), %rbx
je 0xf688
callq 0x3230
subq $-0x80, %rbx
movq %rbx, %rdi
callq 0xa03d
movb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
jmp 0xf6dc
jmp 0xf6e8
movq %rax, %rbx
movq -0x108(%rbp), %rdi
jmp 0xf705
jmp 0xf6f6
movq %rax, %rbx
movq -0x128(%rbp), %rdi
jmp 0xf705
jmp 0xf6f6
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
cmpq %r14, %rdi
je 0xf6eb
callq 0x3230
jmp 0xf6eb
movq %rax, %rbx
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
jne 0xf71c
jmp 0xf721
movq %rax, %rbx
jmp 0xf70f
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0xf70f
callq 0x3230
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xf721
callq 0x3230
movq %rbx, %rdi
callq 0x3440