// File: /workspace/github_cpp_makefile_star2_O3/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 $0xa8, %rsp
movq %rdi, -0x50(%rbp)
leaq 0xca71(%rip), %rax      # 0x1b368
movq (%rax), %rdi
movl 0x10(%rbp), %r12d
movl %r12d, %esi
callq 0x7f98
movq %rax, %rbx
leaq 0xd390(%rip), %rdi      # 0x1bca0
callq 0x96d0
movl %eax, 0x58(%rbx)
movl %eax, 0x60(%rbx)
movq %rbx, %rdi
callq 0x10f1c
movl 0x20(%rbp), %esi
movl %esi, %r15d
negl %r15d
cmovsl %esi, %r15d
movl $0x1, %ebx
cmpl $0xa, %r15d
jb 0xe980
movl $0x4, %ebx
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0xe979
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xe97e
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xe980
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %ebx
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xe948
addl $-0x3, %ebx
jmp 0xe980
addl $-0x2, %ebx
jmp 0xe980
decl %ebx
movq %rsi, -0x60(%rbp)
movl %esi, %r13d
shrl $0x1f, %r13d
leal (%rbx,%r13), %esi
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x48(%rbp), %r14
movq %r14, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r14), %rdi
movq %r13, -0x70(%rbp)
addq %r13, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0x7056
leaq 0x6d32(%rip), %rcx      # 0x156f5
movl $0x1d, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xc0(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xea02
movq %rdx, -0xd0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xc0(%rbp)
jmp 0xea08
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
leaq -0xd0(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x3, %esi
callq 0x9f0f
movq -0xd0(%rbp), %rdi
cmpq %rbx, %rdi
je 0xea41
callq 0x3230
movq %r12, -0x58(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xea57
callq 0x3230
movq -0x50(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x68(%rbp)
xorl %ebx, %ebx
movl $0xd1b71759, %edx       # imm = 0xD1B71759
movl $0x1, %r14d
cmpl $0xa, %r15d
jb 0xeaba
movl $0x4, %r14d
movl %r15d, %eax
cmpl $0x63, %eax
jbe 0xeab1
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0xeab7
cmpl $0x2710, %eax           # imm = 0x2710
jb 0xeaba
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r14d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0xea81
addl $-0x3, %r14d
jmp 0xeaba
addl $-0x2, %r14d
jmp 0xeaba
decl %r14d
movl %r15d, %r12d
movq -0x70(%rbp), %r15
leal (%r14,%r15), %esi
leaq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %r13
movq %r13, %rdi
movl $0x2d, %edx
callq 0x32b0
movq -0x48(%rbp), %rdi
addq %r15, %rdi
movl %r12d, %r15d
movl %r14d, %esi
movl %r12d, %edx
callq 0x7056
movl $0x16, %r8d
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x6c0c(%rip), %rcx      # 0x15713
callq 0x3280
leaq -0x80(%rbp), %r12
movq %r12, -0x90(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq -0x68(%rbp), %r14
je 0xeb3a
movq %rdx, -0x90(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x80(%rbp)
jmp 0xeb42
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x88(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x90(%rbp), %rdi
movl $0x3, %esi
callq 0x9f0f
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0xeb7e
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xeb90
callq 0x3230
leaq 0xc7c1(%rip), %rax      # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %eax
decl %eax
cmpl %eax, %ebx
je 0xebd1
movq %r14, %rdi
callq 0xa049
testl %ebx, %ebx
jne 0xebc2
leaq 0xc7ae(%rip), %rax      # 0x1b368
movq (%rax), %rdi
callq 0x8018
movq %r14, %rdi
callq 0x9feb
incl %ebx
jmp 0xea67
movq -0x50(%rbp), %rbx
movq (%rbx), %rax
movslq -0x60(%rbp), %rcx
leaq 0x10(%rbp), %rdx
movl 0xc(%rdx), %edx
movl %edx, (%rax,%rcx,4)
movq %r14, %rdi
callq 0xa049
leaq 0xc763(%rip), %rax      # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
cmpl $0x1, 0x8(%rax)
jne 0xec11
leaq 0xc75f(%rip), %rax      # 0x1b368
movq (%rax), %rdi
callq 0x8018
movl 0x14(%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, 0x14(%rbx)
movq -0x58(%rbp), %r12
movl %r12d, %ebx
negl %ebx
cmovsl %r12d, %ebx
movl $0x1, %r14d
cmpl $0xa, %ebx
jb 0xec92
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebx, %ecx
cmpl $0x63, %ecx
jbe 0xec89
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xec8f
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xec92
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xec56
addl $-0x3, %r14d
jmp 0xec92
addl $-0x2, %r14d
jmp 0xec92
decl %r14d
shrl $0x1f, %r12d
movl %r12d, %esi
addl %r14d, %esi
leaq -0x48(%rbp), %r15
leaq -0x38(%rbp), %rax
movq %rax, (%r15)
movq %r15, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r15), %rdi
addq %r12, %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x7056
leaq 0x6a5f(%rip), %rcx      # 0x1572a
movl $0x13, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xa0(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xed0a
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0xed10
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
leaq -0xb0(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x2, %esi
callq 0x9f0f
movq -0xb0(%rbp), %rdi
cmpq %rbx, %rdi
je 0xed49
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xed5b
callq 0x3230
movb $0x1, %al
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0xb0(%rbp), %rdi
jmp 0xed87
jmp 0xed90
movq %rax, %r14
movq -0xd0(%rbp), %rdi
cmpq %rbx, %rdi
jne 0xeda4
jmp 0xeda9
jmp 0xed90
movq %rax, %r14
jmp 0xeda9
movq %rax, %r14
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0xeda9
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xedbb
callq 0x3230
movq %r14, %rdi
callq 0x3440
nop