// File: /workspace/github_cpp_makefile_star2_O2/Ziang95[P]Tomasulo_simulator/memory.cpp
// Function: memory::store(LSQEntry)
bool memory::store(LSQEntry entry)
{
    ROBEntry *R = CPU_ROB->get_entry(entry.rob_i);
    R->output.commit = R->output.mem = sys_clk.get_prog_cyc();
    instr_timeline_output(R);
    msg_log("Begin to store value to Addr="+to_string(entry.addr), 3);
    for (int i = 0; ; i++)
    {
        msg_log("Storing value to Addr="+to_string(entry.addr), 3);
        if (i == CPU_cfg->ld_str->mem_time - 1)
            break;
        at_falling_edge(mem_next_vdd);
        if (i == 0)
            CPU_ROB->ptr_advance();
        at_rising_edge(mem_next_vdd);
    }
    buf[entry.addr] = entry.val;
    at_falling_edge(mem_next_vdd);
    if (CPU_cfg->ld_str->mem_time == 1) //In this case the ROB pointer was not advanced in the loop
        CPU_ROB->ptr_advance();
    Sfront = (++Sfront)%Q_LEN;
    msg_log("Value stored ROB = " + to_string(entry.rob_i), 2);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r12
leaq 0xa56a(%rip), %rax      # 0x16370
movq (%rax), %rdi
movl 0x10(%rbp), %r14d
movl %r14d, %esi
callq 0x6c7e
movq %rax, %rbx
leaq 0xae89(%rip), %rdi      # 0x16ca8
callq 0x7e24
movl %eax, 0x58(%rbx)
movl %eax, 0x60(%rbx)
movq %rbx, %rdi
callq 0xd090
movl 0x20(%rbp), %r15d
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x5ab8
leaq 0x38a9(%rip), %rsi      # 0xf6f5
leaq -0xa0(%rbp), %rdi
movq %rbx, %rdx
callq 0x5a8a
movl %r14d, -0x2c(%rbp)
leaq -0xa0(%rbp), %rdi
pushq $0x3
popq %rsi
callq 0x8343
movslq %r15d, %rax
movq %rax, -0x40(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3140
leaq -0x60(%rbp), %r13
movq %r13, %rdi
callq 0x3140
movq %r12, -0x38(%rbp)
addq $0x80, %r12
xorl %ebx, %ebx
leaq -0xc0(%rbp), %r14
movq %r13, %rdi
movl %r15d, %esi
callq 0x5ab8
movq %r14, %rdi
leaq 0x385d(%rip), %rsi      # 0xf713
movq %r13, %rdx
callq 0x5a8a
movq %r14, %rdi
pushq $0x3
popq %rsi
callq 0x8343
movq %r14, %rdi
callq 0x3140
movq %r13, %rdi
callq 0x3140
leaq 0xa480(%rip), %rax      # 0x16360
movq (%rax), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %eax
decl %eax
cmpl %eax, %ebx
je 0xbf17
movq %r12, %rdi
callq 0x8437
testl %ebx, %ebx
jne 0xbf0b
leaq 0xa46d(%rip), %rax      # 0x16370
movq (%rax), %rdi
callq 0x6ce4
movq %r12, %rdi
callq 0x83e0
incl %ebx
jmp 0xbea1
movq -0x38(%rbp), %rax
movq (%rax), %rax
leaq 0x10(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq -0x40(%rbp), %rdx
movl %ecx, (%rax,%rdx,4)
movq %r12, %rdi
callq 0x8437
leaq 0xa425(%rip), %rax      # 0x16360
movq (%rax), %rax
movq 0x20(%rax), %rax
cmpl $0x1, 0x8(%rax)
jne 0xbf57
leaq 0xa421(%rip), %rax      # 0x16370
movq (%rax), %rdi
callq 0x6ce4
movq -0x38(%rbp), %rsi
movl 0x14(%rsi), %eax
incl %eax
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movl %edx, 0x14(%rsi)
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0x5ab8
leaq 0x37a9(%rip), %rsi      # 0xf72a
leaq -0x80(%rbp), %rdi
movq %rbx, %rdx
callq 0x5a8a
leaq -0x80(%rbp), %rdi
pushq $0x2
popq %rsi
callq 0x8343
leaq -0x80(%rbp), %rdi
callq 0x3140
leaq -0x60(%rbp), %rdi
callq 0x3140
movb $0x1, %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
jmp 0xbfe7
jmp 0xbfd8
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
jmp 0xbfe7
jmp 0xbfd8
movq %rax, %rbx
jmp 0xbfec
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x3140
leaq -0x60(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3440
nop