// File: /workspace/github_cpp_makefile_star2_O1/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 0xcab5(%rip), %rax      # 0x1b368
movq (%rax), %rdi
movl 0x10(%rbp), %r12d
movl %r12d, %esi
callq 0x7f30
movq %rax, %rbx
leaq 0xd3d4(%rip), %rdi      # 0x1bca0
callq 0x9674
movl %eax, 0x58(%rbx)
movl %eax, 0x60(%rbx)
movq %rbx, %rdi
callq 0x10ebc
movl 0x20(%rbp), %esi
movl %esi, %r15d
negl %r15d
cmovsl %esi, %r15d
movl $0x1, %ebx
cmpl $0xa, %r15d
jb 0xe93c
movl $0x4, %ebx
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0xe935
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xe93a
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xe93c
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %ebx
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xe904
addl $-0x3, %ebx
jmp 0xe93c
addl $-0x2, %ebx
jmp 0xe93c
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 0x703e
leaq 0x6d76(%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 0xe9be
movq %rdx, -0xd0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xc0(%rbp)
jmp 0xe9c4
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 0x9f03
movq -0xd0(%rbp), %rdi
cmpq %rbx, %rdi
je 0xe9fd
callq 0x3230
movq %r12, -0x58(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xea13
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 0xea76
movl $0x4, %r14d
movl %r15d, %eax
cmpl $0x63, %eax
jbe 0xea6d
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0xea73
cmpl $0x2710, %eax           # imm = 0x2710
jb 0xea76
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r14d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0xea3d
addl $-0x3, %r14d
jmp 0xea76
addl $-0x2, %r14d
jmp 0xea76
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 0x703e
movl $0x16, %r8d
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x6c50(%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 0xeaf6
movq %rdx, -0x90(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x80(%rbp)
jmp 0xeafe
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 0x9f03
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0xeb3a
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xeb4c
callq 0x3230
leaq 0xc805(%rip), %rax      # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
movl 0x8(%rax), %eax
decl %eax
cmpl %eax, %ebx
je 0xeb8d
movq %r14, %rdi
callq 0xa03d
testl %ebx, %ebx
jne 0xeb7e
leaq 0xc7f2(%rip), %rax      # 0x1b368
movq (%rax), %rdi
callq 0x7fb0
movq %r14, %rdi
callq 0x9fdf
incl %ebx
jmp 0xea23
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 0xa03d
leaq 0xc7a7(%rip), %rax      # 0x1b358
movq (%rax), %rax
movq 0x20(%rax), %rax
cmpl $0x1, 0x8(%rax)
jne 0xebcd
leaq 0xc7a3(%rip), %rax      # 0x1b368
movq (%rax), %rdi
callq 0x7fb0
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 0xec4e
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebx, %ecx
cmpl $0x63, %ecx
jbe 0xec45
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xec4b
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xec4e
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xec12
addl $-0x3, %r14d
jmp 0xec4e
addl $-0x2, %r14d
jmp 0xec4e
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 0x703e
leaq 0x6aa3(%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 0xecc6
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0xeccc
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 0x9f03
movq -0xb0(%rbp), %rdi
cmpq %rbx, %rdi
je 0xed05
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xed17
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 0xed43
jmp 0xed4c
movq %rax, %r14
movq -0xd0(%rbp), %rdi
cmpq %rbx, %rdi
jne 0xed60
jmp 0xed65
jmp 0xed4c
movq %rax, %r14
jmp 0xed65
movq %rax, %r14
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0xed65
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xed77
callq 0x3230
movq %r14, %rdi
callq 0x3440
nop