// File: /workspace/github_cpp_makefile_star2_O1/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, -0x118(%rbp)
movl $0x0, 0x84(%rdi)
leaq 0x58(%rdi), %rax
movq %rax, -0x110(%rbp)
movq %rdi, -0x78(%rbp)
leaq 0x1888(%rdi), %r14
movq %r14, -0x80(%rbp)
movq -0x118(%rbp), %rdi
callq 0x9fdf
movq -0x110(%rbp), %rdi
callq 0x3380
leaq 0xb4e1(%rip), %rdi      # 0x1b418
callq 0x3d06
movl $0xd1b71759, %edx       # imm = 0xD1B71759
movl %eax, %esi
movq -0x78(%rbp), %rax
movl 0x14(%rax), %r15d
cmpl 0x18(%rax), %r15d
je 0x102e4
movl %esi, %eax
negl %eax
cmovsl %esi, %eax
movl %eax, -0x2c(%rbp)
movl %esi, %edi
shrl $0x1f, %edi
movl %esi, -0xc4(%rbp)
movq %rdi, -0x120(%rbp)
movslq %r15d, %rax
leaq (%rax,%rax,2), %rax
cmpl %esi, 0x4(%r14,%rax,8)
jne 0x102b8
movq %rax, -0x128(%rbp)
movl %r15d, %r14d
negl %r14d
cmovsl %r15d, %r14d
movl $0x1, %r13d
cmpl $0xa, %r14d
jb 0xffe2
movl $0x4, %r13d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0xffd9
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0xffdf
cmpl $0x2710, %eax           # imm = 0x2710
jb 0xffe2
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0xffa9
addl $-0x3, %r13d
jmp 0xffe2
addl $-0x2, %r13d
jmp 0xffe2
decl %r13d
movl %r15d, %r12d
shrl $0x1f, %r12d
leal (%r12,%r13), %esi
leaq -0xb0(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
movl $0x2d, %edx
callq 0x32b0
addq -0xc0(%rbp), %r12
movq %r12, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x703e
movl $0xf, %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x57cb(%rip), %rcx      # 0x15803
callq 0x3280
leaq -0x90(%rbp), %r12
movq %r12, -0xa0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x1006d
movq %rdx, -0xa0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x90(%rbp)
jmp 0x10075
movups (%rcx), %xmm0
movups %xmm0, (%r12)
leaq -0xf8(%rbp), %r13
movq -0x120(%rbp), %rbx
movq 0x8(%rax), %rdx
movq %rdx, -0x98(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0xa0(%rbp), %rdi
leaq 0x5768(%rip), %rsi      # 0x15813
callq 0x34a0
leaq -0x60(%rbp), %rsi
movq %rsi, -0x70(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x100d4
movq %rdx, -0x70(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x60(%rbp)
jmp 0x100da
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x1, %r14d
cmpl $0xa, -0x2c(%rbp)
jb 0x10144
movl $0x4, %r14d
movl -0x2c(%rbp), %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x1013b
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x10141
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x10144
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r14d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x1010b
addl $-0x3, %r14d
jmp 0x10144
addl $-0x2, %r14d
jmp 0x10144
decl %r14d
leal (%rbx,%r14), %esi
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
movl $0x2d, %edx
callq 0x32b0
movq -0x50(%rbp), %rdi
addq %rbx, %rdi
movl %r14d, %esi
movl -0x2c(%rbp), %edx
callq 0x703e
movq -0x70(%rbp), %rcx
movl $0xf, %esi
leaq -0x60(%rbp), %rax
cmpq %rax, %rcx
je 0x10186
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %r8
movq -0x48(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
movq -0x80(%rbp), %r14
jbe 0x101b3
movl $0xf, %esi
leaq -0x40(%rbp), %rdi
cmpq %rdi, -0x50(%rbp)
je 0x101ae
movq -0x40(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x101c2
movq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x30d0
jmp 0x101cf
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
movq %r13, -0x108(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x101f5
movq %rdx, -0x108(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xf8(%rbp)
jmp 0x101fd
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x100(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0x108(%rbp), %rdi
movl $0x3, %esi
callq 0x9f03
movq -0x108(%rbp), %rdi
cmpq %r13, %rdi
je 0x1023e
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x10250
callq 0x3230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x10262
callq 0x3230
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
je 0x10273
callq 0x3230
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x1028b
callq 0x3230
movq -0x128(%rbp), %rax
leaq (%r14,%rax,8), %rbx
leaq 0xc(%rbx), %rsi
leaq 0xb177(%rip), %rdi      # 0x1b418
callq 0x3d12
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
movl $0xd1b71759, %edx       # imm = 0xD1B71759
movl -0xc4(%rbp), %esi
leal 0x1(%r15), %eax
leal 0x100(%r15), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
negl %ecx
addl %ecx, %r15d
incl %r15d
movq -0x78(%rbp), %rax
cmpl 0x18(%rax), %r15d
jne 0xff71
movq -0x110(%rbp), %rdi
callq 0x31e0
movq -0x118(%rbp), %rdi
callq 0xa03d
movl $0xd1b71759, %edx       # imm = 0xD1B71759
movq -0x78(%rbp), %rax
movl 0x14(%rax), %r13d
cmpl 0x18(%rax), %r13d
je 0xff18
movslq %r13d, %rax
leaq (%rax,%rax,2), %rax
cmpl $-0x1, 0x10(%r14,%rax,8)
je 0x1064f
leaq (%r14,%rax,8), %rax
movb $0x1, 0x14(%rax)
movl %r13d, %r14d
negl %r14d
cmovsl %r13d, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0x10386
movl $0x4, %r15d
movl %r14d, %eax
cmpl $0x63, %eax
jbe 0x1037d
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x10383
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x10386
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r15d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x1034d
addl $-0x3, %r15d
jmp 0x10386
addl $-0x2, %r15d
jmp 0x10386
decl %r15d
movl %r13d, %r12d
shrl $0x1f, %r12d
leal (%r15,%r12), %esi
leaq -0xb0(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
movl $0x2d, %edx
callq 0x32b0
addq -0xc0(%rbp), %r12
movq %r12, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x703e
movl $0x11, %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x5455(%rip), %rcx      # 0x15831
callq 0x3280
leaq -0x90(%rbp), %r14
movq %r14, -0xa0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq -0x60(%rbp), %rbx
je 0x10415
movq %rdx, -0xa0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x90(%rbp)
jmp 0x1041c
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x98(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0xa0(%rbp), %rdi
leaq 0x53ff(%rip), %rsi      # 0x15843
callq 0x34a0
movq %rbx, -0x70(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x10469
movq %rdx, -0x70(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x60(%rbp)
jmp 0x1046f
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq -0x80(%rbp), %rsi
leaq -0xd8(%rbp), %rbx
movq 0x8(%rax), %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x78(%rbp), %rax
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rax
movl (%rsi,%rax,8), %r15d
movl %r15d, %r12d
negl %r12d
cmovsl %r15d, %r12d
movl $0x1, %r14d
cmpl $0xa, %r12d
jb 0x104fe
movl $0x4, %r14d
movl %r12d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x104f5
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x104fb
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x104fe
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r14d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x104c5
addl $-0x3, %r14d
jmp 0x104fe
addl $-0x2, %r14d
jmp 0x104fe
decl %r14d
shrl $0x1f, %r15d
leal (%r14,%r15), %esi
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
movl $0x2d, %edx
callq 0x32b0
addq -0x50(%rbp), %r15
movq %r15, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x703e
movq -0x70(%rbp), %rcx
movl $0xf, %esi
leaq -0x60(%rbp), %r15
cmpq %r15, %rcx
je 0x10544
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %r8
movq -0x48(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq -0x90(%rbp), %r14
jbe 0x10574
movl $0xf, %esi
leaq -0x40(%rbp), %rdi
cmpq %rdi, -0x50(%rbp)
je 0x1056f
movq -0x40(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x10583
movq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x30d0
jmp 0x10590
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3280
movq %rbx, -0xe8(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x105b6
movq %rdx, -0xe8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xd8(%rbp)
jmp 0x105bc
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0xe0(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0xe8(%rbp), %rdi
movl $0x3, %esi
callq 0x9f03
movq -0xe8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x105fd
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x1060f
callq 0x3230
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0x1061d
callq 0x3230
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x1062e
callq 0x3230
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
movq -0x80(%rbp), %r14
je 0x1064a
callq 0x3230
movl $0xd1b71759, %edx       # imm = 0xD1B71759
leal 0x1(%r13), %eax
leal 0x100(%r13), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
negl %ecx
addl %ecx, %r13d
incl %r13d
movq -0x78(%rbp), %rax
jmp 0x10309
movq %rax, %rbx
jmp 0x106c2
movq %rax, %rbx
jmp 0x1069e
jmp 0x10734
movq %rax, %rbx
jmp 0x106b0
movq %rax, %rbx
movq -0x108(%rbp), %rdi
cmpq %r13, %rdi
je 0x1069e
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x106b0
callq 0x3230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x106c2
callq 0x3230
movq -0xa0(%rbp), %rdi
cmpq %r12, %rdi
jne 0x1072d
jmp 0x10737
movq %rbx, %rcx
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
cmpq %rcx, %rdi
je 0x106ec
callq 0x3230
jmp 0x106ec
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x10713
callq 0x3230
jmp 0x10713
movq %rax, %rbx
jmp 0x10721
movq %rax, %rbx
leaq -0x90(%rbp), %r14
leaq -0x60(%rbp), %r15
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0x10721
callq 0x3230
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x10737
callq 0x3230
jmp 0x10737
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x1074f
callq 0x3230
movq %rbx, %rdi
callq 0x3440
nop