// File: /workspace/github_cpp_makefile_star2_O3/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 0xb945(%rip), %r12      # 0x1b368
movq (%r12), %rdi
callq 0x8028
movl %eax, %r15d
movq (%r12), %rdi
callq 0x8030
movl %eax, %r12d
leaq 0x30(%rbx), %r13
movq %r13, %rdi
callq 0x3380
movl 0xc(%rbx), %eax
movl 0x10(%rbx), %ecx
leal -0x1(%rcx), %edx
leal 0xfe(%rcx), %esi
testl %edx, %edx
cmovnsl %edx, %esi
andl $0xffffff00, %esi       # imm = 0xFFFFFF00
negl %esi
addl %esi, %ecx
decl %ecx
cmpl %eax, %ecx
je 0xfae1
leaq 0x88(%rbx), %rdx
leaq 0xb8ef(%rip), %rsi      # 0x1b368
movq (%rsi), %rsi
movslq %ecx, %rdi
leaq (%rdi,%rdi,2), %rdi
movl (%rdx,%rdi,8), %edi
cmpl %r14d, %edi
je 0xfae1
cmpl %r15d, %r12d
jge 0xfab3
xorl %r9d, %r9d
movl $0x0, %r8d
cmpl %r14d, %r15d
jle 0xfaa2
movl 0x10(%rsi), %r8d
cmpl %r15d, %edi
jge 0xfaab
movl 0x10(%rsi), %r9d
addl %r14d, %r8d
addl %r9d, %edi
jmp 0xfab6
movl %r14d, %r8d
cmpl %r8d, %edi
jle 0xfae1
movl %ecx, 0x10(%rbx)
leal -0x1(%rcx), %edi
leal 0xfe(%rcx), %r8d
testl %edi, %edi
cmovnsl %edi, %r8d
andl $0xffffff00, %r8d       # imm = 0xFFFFFF00
negl %r8d
addl %r8d, %ecx
decl %ecx
cmpl %eax, %ecx
jne 0xfa7c
movq %r13, %rdi
callq 0x31e0
leaq 0x58(%rbx), %r13
movq %r13, %rdi
callq 0x3380
movl 0x18(%rbx), %ecx
leal -0x1(%rcx), %eax
leal 0xfe(%rcx), %edx
testl %eax, %eax
cmovnsl %eax, %edx
andl $0xffffff00, %edx       # imm = 0xFFFFFF00
negl %edx
leal (%rcx,%rdx), %eax
decl %eax
cmpl %ecx, %eax
je 0xfb88
leaq 0x1888(%rbx), %rcx
leaq 0xb843(%rip), %rdx      # 0x1b368
movq (%rdx), %rdx
movslq %eax, %rsi
leaq (%rsi,%rsi,2), %rsi
movl (%rcx,%rsi,8), %esi
cmpl %r14d, %esi
je 0xfb88
cmpl %r15d, %r12d
jge 0xfb5d
xorl %r8d, %r8d
movl $0x0, %edi
cmpl %r14d, %r15d
jle 0xfb4c
movl 0x10(%rdx), %edi
cmpl %r15d, %esi
jge 0xfb55
movl 0x10(%rdx), %r8d
addl %r14d, %edi
addl %r8d, %esi
jmp 0xfb60
movl %r14d, %edi
cmpl %edi, %esi
jle 0xfb88
movl %eax, 0x18(%rbx)
leal -0x1(%rax), %esi
leal 0xfe(%rax), %edi
testl %esi, %esi
cmovnsl %esi, %edi
andl $0xffffff00, %edi       # imm = 0xFFFFFF00
negl %edi
leal (%rax,%rdi), %esi
decl %esi
cmpl %eax, %esi
movl %esi, %eax
jne 0xfb28
movq %r13, %rdi
callq 0x31e0
movl 0x14(%rbx), %r13d
movl %r13d, %r14d
negl %r14d
cmovsl %r13d, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0xfbf4
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xfbeb
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xfbf1
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xfbf4
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xfbb8
addl $-0x3, %r15d
jmp 0xfbf4
addl $-0x2, %r15d
jmp 0xfbf4
decl %r15d
shrl $0x1f, %r13d
movl %r13d, %esi
addl %r15d, %esi
leaq -0xb8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0xc8(%rbp), %r12
movq %r12, %rdi
movl $0x2d, %edx
callq 0x32b0
movq (%r12), %rdi
addq %r13, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x7056
leaq 0x5ba7(%rip), %rcx      # 0x157dd
movl $0x1c, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
leaq -0x98(%rbp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xfc75
movq %rdx, -0xa8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x98(%rbp)
jmp 0xfc7b
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq -0xa8(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x5b5a(%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 0xfccf
movq %rsi, %r13
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0xfcd8
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 0xfd53
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0xfd4a
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xfd50
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xfd53
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xfd17
addl $-0x3, %r12d
jmp 0xfd53
addl $-0x2, %r12d
jmp 0xfd53
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 0x7056
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
movq -0x40(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r13, %rcx
je 0xfda4
movq -0x78(%rbp), %rdi
movq -0x48(%rbp), %rsi
cmpq %rdi, %rax
leaq -0x38(%rbp), %r14
jbe 0xfdc4
movl $0xf, %edi
cmpq %r14, %rsi
je 0xfdbf
movq -0x38(%rbp), %rdi
cmpq %rdi, %rax
jbe 0xfdd2
leaq -0x88(%rbp), %rdi
callq 0x30d0
jmp 0xfddf
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 0xfe00
movq %rsi, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0xfe06
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 0x9f0f
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfe42
callq 0x3230
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0xfe50
callq 0x3230
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0xfe61
callq 0x3230
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xfe79
callq 0x3230
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xfe91
callq 0x3230
leaq 0xb4d0(%rip), %r14      # 0x1b368
movq (%r14), %rdi
callq 0x8028
movl %eax, 0x1c(%rbx)
movq (%r14), %rdi
callq 0x8030
movl %eax, 0x20(%rbx)
leaq 0xb4db(%rip), %rdi      # 0x1b390
callq 0x8fd4
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 0xfeed
callq 0x3230
jmp 0xfeed
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xff04
callq 0x3230
jmp 0xff04
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0xff1a
callq 0x3230
jmp 0xff1a
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0xff37
callq 0x3230
jmp 0xff37
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0xff4f
callq 0x3230
movq %rbx, %rdi
callq 0x3440
nop