// File: /workspace/github_cpp_makefile_star2_O2/Ziang95[P]Tomasulo_simulator/memory.cpp
// Function: memory::squash(int)
void memory::squash(int ROB_i)
{
    int R_f = CPU_ROB->get_front();
    int R_r = CPU_ROB->get_rear();
    pthread_mutex_lock(&LDQ_lock);
    for (int i = Lrear; ;)
    {
        int j = (i-1)%Q_LEN;
        if (j == Lfront || !is_prev_index(ROB_i, Load_Q[j].rob_i, R_f, R_r))
            break;
        Lrear = j;
        i = (--i)%Q_LEN;
    }
    pthread_mutex_unlock(&LDQ_lock);
    pthread_mutex_lock(&SDQ_lock);
    for (int i = Srear; ;)
    {
        int j = (i-1)%Q_LEN;
        if (j == Srear || !is_prev_index(ROB_i, Stor_Q[j].rob_i, R_f, R_r))
            break;
        Srear = j;
        i = (--i)%Q_LEN;
    }
    pthread_mutex_unlock(&SDQ_lock);
    msg_log("After squash, Store front = " + to_string(Sfront) + " rear = " + to_string(Srear), 3);
    squash_p.R_f = CPU_ROB->get_front();
    squash_p.R_r = CPU_ROB->get_rear();
    squash_p.ROB_i = brcUnit.squash_ROB_i();
    squash_p.flag = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %esi, -0x34(%rbp)
movq %rdi, %r14
leaq 0x9d4f(%rip), %rbx      # 0x16370
movq (%rbx), %rdi
callq 0x6cf4
movl %eax, %r15d
movq (%rbx), %rdi
callq 0x6cfc
movl %eax, %r12d
leaq 0x30(%r14), %rdi
movq %rdi, -0x40(%rbp)
callq 0x3390
movl 0xc(%r14), %ebx
movl 0x10(%r14), %r13d
movq %r14, -0x30(%rbp)
addq $0x88, %r14
decl %r13d
movl %r13d, %eax
cltd
movl $0x100, %ecx            # imm = 0x100
idivl %ecx
cmpl %ebx, %edx
je 0xc693
movl %edx, %r13d
movslq %edx, %rax
imulq $0x18, %rax, %rax
movl (%r14,%rax), %esi
movl -0x34(%rbp), %edi
movl %r15d, %edx
movl %r12d, %ecx
callq 0xc3de
testb %al, %al
je 0xc693
movq -0x30(%rbp), %rax
movl %r13d, 0x10(%rax)
jmp 0xc657
movq -0x40(%rbp), %rdi
callq 0x3210
movq -0x30(%rbp), %rbx
leaq 0x58(%rbx), %rdi
movq %rdi, -0x40(%rbp)
callq 0x3390
movl 0x18(%rbx), %ecx
addq $0x1888, %rbx           # imm = 0x1888
movl $0x100, %r14d           # imm = 0x100
leal -0x1(%rcx), %eax
cltd
idivl %r14d
cmpl %ecx, %edx
je 0xc6f4
movl %edx, %r13d
movslq %edx, %rax
imulq $0x18, %rax, %rax
movl (%rbx,%rax), %esi
movl -0x34(%rbp), %edi
movl %r15d, %edx
movl %r12d, %ecx
callq 0xc3de
testb %al, %al
je 0xc6f4
movq -0x30(%rbp), %rax
movl %r13d, 0x18(%rax)
movl %r13d, %ecx
jmp 0xc6bd
movq -0x40(%rbp), %rdi
callq 0x3210
movq -0x30(%rbp), %rax
movl 0x14(%rax), %esi
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
callq 0x5ab8
leaq 0x30c3(%rip), %rsi      # 0xf7dd
leaq -0x80(%rbp), %rdi
movq %r14, %rdx
callq 0x5a8a
leaq 0x30cd(%rip), %rdx      # 0xf7fa
leaq -0xa0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x5bc8
movq -0x30(%rbp), %rax
movl 0x18(%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x5ab8
leaq -0xc0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x5b57
leaq -0xc0(%rbp), %rdi
pushq $0x3
popq %rsi
callq 0x8343
leaq -0xc0(%rbp), %rdi
callq 0x3140
leaq -0x60(%rbp), %rdi
callq 0x3140
leaq -0xa0(%rbp), %rdi
callq 0x3140
leaq -0x80(%rbp), %rdi
callq 0x3140
leaq -0xe0(%rbp), %rdi
callq 0x3140
leaq 0x9bc0(%rip), %r14      # 0x16370
movq (%r14), %rdi
callq 0x6cf4
movq -0x30(%rbp), %rbx
movl %eax, 0x1c(%rbx)
movq (%r14), %rdi
callq 0x6cfc
movl %eax, 0x20(%rbx)
leaq 0x9bc7(%rip), %rdi      # 0x16398
callq 0x7748
movl %eax, 0x24(%rbx)
movb $0x1, 0x28(%rbx)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x3140
jmp 0xc803
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3140
jmp 0xc811
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x3140
jmp 0xc822
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x3140
jmp 0xc830
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3440