// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movl %esi, %r14d
movq %rdi, %rbx
leaq 0xb9bb(%rip), %r13      # 0x1b368
movq (%r13), %rdi
callq 0x7fc0
movl %eax, %r15d
movq (%r13), %rdi
callq 0x7fc8
movl %eax, %r12d
leaq 0x30(%rbx), %rdi
movq %rdi, -0x90(%rbp)
callq 0x3380
movl 0xc(%rbx), %eax
movl 0x10(%rbx), %esi
leaq 0x88(%rbx), %rcx
movq (%r13), %rdx
leal -0x1(%rsi), %edi
leal 0xfe(%rsi), %r8d
testl %edi, %edi
cmovnsl %edi, %r8d
andl $0xffffff00, %r8d       # imm = 0xFFFFFF00
negl %r8d
leal (%rsi,%r8), %edi
decl %edi
cmpl %eax, %edi
je 0xfa54
movslq %edi, %r8
leaq (%r8,%r8,2), %r8
movl (%rcx,%r8,8), %r8d
cmpl %r14d, %r8d
je 0xfa54
cmpl %r15d, %r12d
jge 0xfa42
xorl %r10d, %r10d
movl $0x0, %r9d
cmpl %r14d, %r15d
jle 0xfa31
movl 0x10(%rdx), %r9d
cmpl %r15d, %r8d
jge 0xfa3a
movl 0x10(%rdx), %r10d
addl %r14d, %r9d
addl %r10d, %r8d
jmp 0xfa45
movl %r14d, %r9d
cmpl %r9d, %r8d
jle 0xfa54
movl %edi, 0x10(%rbx)
movb $0x1, %r8b
movl %edi, %esi
jmp 0xfa57
xorl %r8d, %r8d
testb %r8b, %r8b
jne 0xf9e6
movq -0x90(%rbp), %rdi
callq 0x31e0
leaq 0x58(%rbx), %r13
movq %r13, %rdi
callq 0x3380
movl 0x18(%rbx), %edx
leaq 0x1888(%rbx), %rax
leaq 0xb8e3(%rip), %rcx      # 0x1b368
movq (%rcx), %rcx
movl %edx, %esi
leal -0x1(%rsi), %edi
leal 0xfe(%rsi), %r8d
testl %edi, %edi
cmovnsl %edi, %r8d
andl $0xffffff00, %r8d       # imm = 0xFFFFFF00
negl %r8d
leal (%rsi,%r8), %edi
decl %edi
cmpl %edx, %edi
je 0xfafa
movslq %edi, %r8
leaq (%r8,%r8,2), %r8
movl (%rax,%r8,8), %r8d
cmpl %r14d, %r8d
je 0xfafa
cmpl %r15d, %r12d
jge 0xfae6
xorl %r10d, %r10d
movl $0x0, %r9d
cmpl %r14d, %r15d
jle 0xfad5
movl 0x10(%rcx), %r9d
cmpl %r15d, %r8d
jge 0xfade
movl 0x10(%rcx), %r10d
addl %r14d, %r9d
addl %r10d, %r8d
jmp 0xfae9
movl %r14d, %r9d
cmpl %r9d, %r8d
jle 0xfafa
movl %edi, 0x18(%rbx)
movb $0x1, %r8b
movl %edi, %edx
movl %edi, %esi
jmp 0xfafd
xorl %r8d, %r8d
testb %r8b, %r8b
jne 0xfa8a
movq %r13, %rdi
callq 0x31e0
movl 0x14(%rbx), %r13d
movl %r13d, %r14d
negl %r14d
cmovsl %r13d, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0xfb6e
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xfb65
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xfb6b
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xfb6e
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xfb32
addl $-0x3, %r15d
jmp 0xfb6e
addl $-0x2, %r15d
jmp 0xfb6e
decl %r15d
shrl $0x1f, %r13d
movl %r13d, %esi
addl %r15d, %esi
leaq -0xc0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0xd0(%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 0x5c2d(%rip), %rcx      # 0x157dd
movl $0x1c, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0xa0(%rbp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xfbef
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0xfbf5
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq -0xb0(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x5be0(%rip), %rsi      # 0x157fa
callq 0x34a0
leaq -0x78(%rbp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xfc49
movq %rsi, %r13
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0xfc52
movups (%rcx), %xmm0
movq %rsi, %r13
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x80(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl 0x18(%rbx), %r14d
movl %r14d, %r15d
negl %r15d
cmovsl %r14d, %r15d
movl $0x1, %r12d
cmpl $0xa, %r15d
jb 0xfccd
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0xfcc4
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xfcca
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xfccd
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xfc91
addl $-0x3, %r12d
jmp 0xfccd
addl $-0x2, %r12d
jmp 0xfccd
decl %r12d
shrl $0x1f, %r14d
leal (%r12,%r14), %esi
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x48(%rbp), %rdi
movl $0x2d, %edx
callq 0x32b0
addq -0x48(%rbp), %r14
movq %r14, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x703e
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
movq -0x40(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0xfd1e
movq -0x78(%rbp), %rsi
cmpq %rsi, %rax
leaq -0x38(%rbp), %r14
jbe 0xfd3b
movl $0xf, %esi
cmpq %r14, -0x48(%rbp)
je 0xfd36
movq -0x38(%rbp), %rsi
cmpq %rsi, %rax
jbe 0xfd4d
movq -0x48(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x30d0
jmp 0xfd5a
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0x58(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0xfd7b
movq %rsi, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0xfd81
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0x68(%rbp), %rdi
movl $0x3, %esi
callq 0x9f03
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfdbd
callq 0x3230
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0xfdcb
callq 0x3230
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0xfddc
callq 0x3230
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0xfdf4
callq 0x3230
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0xfe0c
callq 0x3230
leaq 0xb555(%rip), %r14      # 0x1b368
movq (%r14), %rdi
callq 0x7fc0
movl %eax, 0x1c(%rbx)
movq (%r14), %rdi
callq 0x7fc8
movl %eax, 0x20(%rbx)
leaq 0xb560(%rip), %rdi      # 0x1b390
callq 0x8f88
movl %eax, 0x24(%rbx)
movb $0x1, 0x28(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfe68
callq 0x3230
jmp 0xfe68
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xfe7f
callq 0x3230
jmp 0xfe7f
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0xfe95
callq 0x3230
jmp 0xfe95
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0xfeb2
callq 0x3230
jmp 0xfeb2
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0xfeca
callq 0x3230
movq %rbx, %rdi
callq 0x3440