// File: /workspace/github_cpp_makefile_star2_O3/Ziang95[P]Tomasulo_simulator/memory.cpp
// Function: memory::SD_Q_automat()
void memory::SD_Q_automat()
{
    SDQ_next_vdd = 0;
    while (true)
    {
        at_rising_edge(SDQ_next_vdd);
        pthread_mutex_lock(&SDQ_lock);
        int CDB_i = fCDB.get_source();
        for (int i = Sfront; i != Srear;)
        {
            if (Stor_Q[i].SD_source == CDB_i)
            {
                msg_log("SD queue entry " + to_string(i) + " got the value, source ROB = " + to_string(CDB_i), 3);
                fCDB.get_val(&Stor_Q[i].val);
                Stor_Q[i].SD_source = -1;
            }
            i = (++i)%Q_LEN;
        }
        pthread_mutex_unlock(&SDQ_lock);
        at_falling_edge(SDQ_next_vdd);
        for (int i = Sfront; i != Srear;)
        {
            if (Stor_Q[i].addr != -1)
            {
                Stor_Q[i].ready = true;
                msg_log("Stor_Q entry i = " + to_string(i) + " ready, ROB = " + to_string(Stor_Q[Sfront].rob_i), 3);
            }
            i = (++i)%Q_LEN;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0x84(%rdi), %rax
movq %rax, -0xf0(%rbp)
movl $0x0, 0x84(%rdi)
leaq 0x58(%rdi), %rax
movq %rax, -0xe8(%rbp)
movq %rdi, -0x70(%rbp)
leaq 0x1888(%rdi), %rbx
movq %rbx, -0x78(%rbp)
movq -0xf0(%rbp), %rdi
callq 0x9feb
movq -0xe8(%rbp), %rdi
callq 0x3380
leaq 0xb45b(%rip), %rdi      # 0x1b418
callq 0x3d08
movq -0x70(%rbp), %rcx
movl 0x14(%rcx), %edi
movl 0x18(%rcx), %esi
cmpl %esi, %edi
je 0x1037f
movl %eax, %r15d
negl %r15d
cmovsl %eax, %r15d
movl %eax, %r12d
shrl $0x1f, %r12d
movl %eax, -0xbc(%rbp)
movq %r12, -0x118(%rbp)
movslq %edi, %rcx
leaq (%rcx,%rcx,2), %rcx
cmpl %eax, 0x4(%rbx,%rcx,8)
jne 0x1035d
movq %rcx, -0x120(%rbp)
movl %edi, %r14d
negl %r14d
cmovsl %edi, %r14d
movl $0x1, %r13d
cmpl $0xa, %r14d
jb 0x1006a
movl $0x4, %r13d
movl %r14d, %esi
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %esi
jbe 0x10061
cmpl $0x3e7, %esi            # imm = 0x3E7
jbe 0x10067
cmpl $0x2710, %esi           # imm = 0x2710
jb 0x1006a
movl %esi, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %esi          # imm = 0x1869F
movl %ecx, %esi
ja 0x1002e
addl $-0x3, %r13d
jmp 0x1006a
addl $-0x2, %r13d
jmp 0x1006a
decl %r13d
movl %r15d, %r12d
movq %rdi, -0x128(%rbp)
movl %edi, %ebx
shrl $0x1f, %ebx
leal (%rbx,%r13), %esi
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
movl $0x2d, %edx
callq 0x32b0
addq -0xb8(%rbp), %rbx
movq %rbx, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x7056
movl $0xf, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x573b(%rip), %rcx      # 0x15803
callq 0x3280
leaq -0x88(%rbp), %r14
movq %r14, -0x98(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x100fd
movq %rdx, -0x98(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x88(%rbp)
jmp 0x10104
movups (%rcx), %xmm0
movups %xmm0, (%r14)
leaq -0xd0(%rbp), %r13
movl %r12d, %r15d
movq 0x8(%rax), %rdx
movq %rdx, -0x90(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x98(%rbp), %rdi
leaq 0x56dd(%rip), %rsi      # 0x15813
callq 0x34a0
movq -0x118(%rbp), %r12
leaq -0x38(%rbp), %rsi
movq %rsi, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x10166
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x1016c
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x1, %r14d
cmpl $0xa, %r15d
jb 0x101d6
movl $0x4, %r14d
movl %r15d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x101cd
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x101d3
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x101d6
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r14d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x1019d
addl $-0x3, %r14d
jmp 0x101d6
addl $-0x2, %r14d
jmp 0x101d6
decl %r14d
leal (%r12,%r14), %esi
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
movl $0x2d, %edx
callq 0x32b0
movq -0x68(%rbp), %rdi
addq %r12, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x7056
movq -0x48(%rbp), %rcx
movl $0xf, %edi
leaq -0x38(%rbp), %rax
cmpq %rax, %rcx
je 0x10218
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %r8
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
leaq -0x88(%rbp), %r14
jbe 0x1024b
movl $0xf, %edi
leaq -0x58(%rbp), %r9
cmpq %r9, %rsi
je 0x10246
movq -0x58(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x10256
leaq -0x48(%rbp), %rdi
callq 0x30d0
jmp 0x10263
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
movq %r13, -0xe0(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x10289
movq %rdx, -0xe0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xd0(%rbp)
jmp 0x10291
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0xd8(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0xe0(%rbp), %rdi
movl $0x3, %esi
callq 0x9f0f
movq -0xe0(%rbp), %rdi
cmpq %r13, %rdi
je 0x102d2
callq 0x3230
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x102e4
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x102f6
callq 0x3230
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0x10307
callq 0x3230
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x1031f
callq 0x3230
movq -0x78(%rbp), %rax
movq -0x120(%rbp), %rcx
leaq (%rax,%rcx,8), %rbx
leaq 0xc(%rbx), %rsi
leaq 0xb0df(%rip), %rdi      # 0x1b418
callq 0x3d14
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
movq -0x78(%rbp), %rbx
movq -0x70(%rbp), %rax
movl 0x18(%rax), %esi
movl -0xbc(%rbp), %eax
movq -0x128(%rbp), %rdi
leal 0x1(%rdi), %ecx
leal 0x100(%rdi), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
andl $0xffffff00, %edx       # imm = 0xFFFFFF00
negl %edx
addl %edx, %edi
incl %edi
cmpl %esi, %edi
jne 0xfff2
movq -0xe8(%rbp), %rdi
callq 0x31e0
movq -0xf0(%rbp), %rdi
callq 0xa049
movq -0x70(%rbp), %rax
movl 0x14(%rax), %r13d
movl 0x18(%rax), %eax
cmpl %eax, %r13d
je 0xff9e
movslq %r13d, %rcx
leaq (%rcx,%rcx,2), %rcx
cmpl $-0x1, 0x10(%rbx,%rcx,8)
je 0x106ec
leaq (%rbx,%rcx,8), %rax
movb $0x1, 0x14(%rax)
movl %r13d, %r14d
negl %r14d
cmovsl %r13d, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0x10422
movl $0x4, %r15d
movl %r14d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x10419
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x1041f
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x10422
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r15d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x103e9
addl $-0x3, %r15d
jmp 0x10422
addl $-0x2, %r15d
jmp 0x10422
decl %r15d
movl %r13d, %ebx
shrl $0x1f, %ebx
leal (%r15,%rbx), %esi
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %r12
movq %r12, %rdi
movl $0x2d, %edx
callq 0x32b0
addq -0xb8(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x7056
movl $0x11, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x53ba(%rip), %rcx      # 0x15831
callq 0x3280
leaq -0x88(%rbp), %r14
movq %r14, -0x98(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x104ac
movq %rdx, -0x98(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x88(%rbp)
jmp 0x104b3
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq -0x78(%rbp), %rbx
movq 0x8(%rax), %rdx
movq %rdx, -0x90(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x98(%rbp), %rdi
leaq 0x5364(%rip), %rsi      # 0x15843
callq 0x34a0
leaq -0x38(%rbp), %rsi
movq %rsi, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x10508
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x1050e
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x70(%rbp), %rax
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rax
movl (%rbx,%rax,8), %r15d
movl %r15d, %r12d
negl %r12d
cmovsl %r15d, %r12d
movl $0x1, %r14d
cmpl $0xa, %r12d
jb 0x10592
movl $0x4, %r14d
movl %r12d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x10589
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x1058f
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x10592
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r14d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x10559
addl $-0x3, %r14d
jmp 0x10592
addl $-0x2, %r14d
jmp 0x10592
decl %r14d
shrl $0x1f, %r15d
leal (%r14,%r15), %esi
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
movl $0x2d, %edx
callq 0x32b0
addq -0x68(%rbp), %r15
movq %r15, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x7056
movq -0x48(%rbp), %rcx
movl $0xf, %edi
leaq -0x38(%rbp), %rax
cmpq %rax, %rcx
je 0x105d8
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %r8
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
leaq -0x88(%rbp), %r14
leaq -0x100(%rbp), %r15
jbe 0x10612
movl $0xf, %edi
leaq -0x58(%rbp), %r9
cmpq %r9, %rsi
je 0x1060d
movq -0x58(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x1061d
leaq -0x48(%rbp), %rdi
callq 0x30d0
jmp 0x1062a
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
movq %r15, -0x110(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x10650
movq %rdx, -0x110(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x100(%rbp)
jmp 0x10657
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x108(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0x110(%rbp), %rdi
movl $0x3, %esi
callq 0x9f0f
movq -0x110(%rbp), %rdi
cmpq %r15, %rdi
je 0x10698
callq 0x3230
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x106aa
callq 0x3230
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x106bc
callq 0x3230
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0x106cd
callq 0x3230
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x106e5
callq 0x3230
movq -0x70(%rbp), %rax
movl 0x18(%rax), %eax
leal 0x1(%r13), %ecx
leal 0x100(%r13), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
andl $0xffffff00, %edx       # imm = 0xFFFFFF00
negl %edx
addl %edx, %r13d
incl %r13d
jmp 0x103a2
jmp 0x10755
jmp 0x1073e
jmp 0x10789
jmp 0x1075a
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r13, %rdi
jne 0x10737
jmp 0x10741
movq %rax, %rbx
movq -0x110(%rbp), %rdi
cmpq %r15, %rdi
je 0x10741
callq 0x3230
jmp 0x10741
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x10764
callq 0x3230
jmp 0x10764
movq %rax, %rbx
jmp 0x10776
movq %rax, %rbx
leaq -0x88(%rbp), %r14
leaq -0x38(%rbp), %rax
movq -0x48(%rbp), %rdi
cmpq %rax, %rdi
je 0x10776
callq 0x3230
movq -0x98(%rbp), %rdi
cmpq %r14, %rdi
je 0x1078c
callq 0x3230
jmp 0x1078c
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x107a4
callq 0x3230
movq %rbx, %rdi
callq 0x3440