// File: /workspace/github_cpp_makefile_star2_O2/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 $0xe8, %rsp
movq %rdi, %rbx
andl $0x0, 0x84(%rdi)
leaq 0x84(%rdi), %rax
movq %rax, -0x40(%rbp)
leaq 0x58(%rdi), %r14
leaq 0x1888(%rdi), %rax
movq %rax, -0x30(%rbp)
movq %rdi, -0x48(%rbp)
movq %r14, -0x50(%rbp)
movq -0x40(%rbp), %rdi
callq 0x83e0
movq %r14, %rdi
callq 0x3390
leaq 0x9b84(%rip), %rdi      # 0x16420
callq 0x3b22
movl %eax, -0x34(%rbp)
movl 0x14(%rbx), %r15d
cmpl 0x18(%rbx), %r15d
je 0xc9a2
movslq %r15d, %rax
imulq $0x18, %rax, %r12
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
cmpl %ecx, 0x4(%rax,%r12)
jne 0xc98c
leaq -0xb0(%rbp), %r13
movq %r13, %rdi
movl %r15d, %esi
callq 0x5ab8
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x2f15(%rip), %rsi      # 0xf803
movq %r13, %rdx
callq 0x5a8a
leaq -0x70(%rbp), %rdi
movq %rbx, %rsi
leaq 0x2f0f(%rip), %rdx      # 0xf813
callq 0x5bc8
leaq -0x90(%rbp), %r13
movq %r13, %rdi
movl -0x34(%rbp), %esi
callq 0x5ab8
leaq -0x110(%rbp), %r14
movq %r14, %rdi
leaq -0x70(%rbp), %rsi
movq %r13, %rdx
callq 0x5b57
movq %r14, %rdi
pushq $0x3
popq %rsi
callq 0x8343
addq -0x30(%rbp), %r12
movq %r14, %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
leaq 0xc(%r12), %rsi
leaq 0x9aa3(%rip), %rdi      # 0x16420
callq 0x3b2e
orl $-0x1, 0x4(%r12)
movq -0x48(%rbp), %rbx
incl %r15d
movl %r15d, %eax
cltd
movl $0x100, %ecx            # imm = 0x100
idivl %ecx
movl %edx, %r15d
jmp 0xc8a8
movq -0x50(%rbp), %r14
movq %r14, %rdi
callq 0x3210
movq -0x40(%rbp), %rdi
callq 0x8437
movl 0x14(%rbx), %r15d
cmpl 0x18(%rbx), %r15d
je 0xc884
movslq %r15d, %rax
imulq $0x18, %rax, %rax
movq -0x30(%rbp), %rcx
cmpl $-0x1, 0x10(%rcx,%rax)
je 0xca99
addq -0x30(%rbp), %rax
movb $0x1, 0x14(%rax)
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x5ab8
leaq -0xd0(%rbp), %r13
movq %r13, %rdi
leaq 0x2e2b(%rip), %rsi      # 0xf831
movq %rbx, %rdx
callq 0x5a8a
leaq -0x70(%rbp), %rdi
movq %r13, %rsi
leaq 0x2e27(%rip), %rdx      # 0xf843
callq 0x5bc8
movq -0x48(%rbp), %rbx
movslq 0x14(%rbx), %rax
imulq $0x18, %rax, %rax
movq -0x30(%rbp), %rcx
movl (%rcx,%rax), %esi
leaq -0x90(%rbp), %r13
movq %r13, %rdi
callq 0x5ab8
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
leaq -0x70(%rbp), %rsi
movq %r13, %rdx
callq 0x5b57
movq %r12, %rdi
pushq $0x3
popq %rsi
callq 0x8343
movq %r12, %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
callq 0x3140
leaq -0xd0(%rbp), %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
incl %r15d
movl %r15d, %eax
cltd
movl $0x100, %ecx            # imm = 0x100
idivl %ecx
movl %edx, %r15d
jmp 0xc9bb
jmp 0xcae5
jmp 0xcad4
jmp 0xcb04
jmp 0xcaea
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
jmp 0xcacd
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x3140
jmp 0xcad7
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3140
jmp 0xcaed
movq %rax, %rbx
jmp 0xcaf6
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3140
leaq -0xd0(%rbp), %rdi
callq 0x3140
jmp 0xcb07
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3440
nop