// File: /workspace/github_cpp_makefile_star2_O2/Ziang95[P]Tomasulo_simulator/reserv_station.cpp
// Function: resStation::reserv_automat()
void resStation::reserv_automat()
{
    next_vdd = 0;
    while (true)
    {
        at_rising_edge(next_vdd);
        if (busy)
        {
            if (fCDB.get_source() == dest)
            {
                msg_log("WriteBack to ROB = " + to_string(dest), 2);
                ROBEntry *R = CPU_ROB->get_entry(dest);
                fCDB.get_val(&R->value);
                R->wrtnBack = true;
                R->output.wBack = sys_clk.get_prog_cyc();
                at_falling_edge(next_vdd);
                R->finished = true;
                at_rising_edge(next_vdd);
                busy = false;
                at_falling_edge(next_vdd);
                continue;
            }
            else if (!Rj || !Rk)
            {
                if (fCDB.get_source() == Qj)
                {
                    fCDB.get_val(&Vj);
                    Rj = true;
                }
                if (fCDB.get_source() == Qk)
                {
                    fCDB.get_val(&Vk);
                    Rk = true;
                }
            }
        }
        at_falling_edge(next_vdd);
        if (!Rj || !Rk)
        {
            msg_log("ROB = " + to_string(dest) + " waiting for operands" + (Rj?"":(" Qj = "+to_string(Qj))) + (Rk?"":(" Qk = "+to_string(Qk))), 3);
        }
        if (busy && to_start && Rj && Rk)
        {
            msg_log("Operands ready, sending to FU, dest ROB = " + to_string(dest), 2);
            to_start = false;
            if (type == FLTP)
                Vk.f = sub? -Vk.f : Vk.f;
            else
                Vk.i = sub? -Vk.i : Vk.i;
            prnt_Q->enQ(code, dest, &rest, &Vj, &Vk, lsqE, offset, &busy);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, %rbx
andl $0x0, 0x40(%rdi)
leaq 0x40(%rdi), %r14
leaq 0x14(%rdi), %rax
movq %rax, -0x40(%rbp)
leaq 0x18(%rdi), %rax
movq %rax, -0x38(%rbp)
leaq 0x10(%rdi), %rax
movq %rax, -0x48(%rbp)
leaq -0x110(%rbp), %r15
leaq -0x70(%rbp), %r12
leaq -0x90(%rbp), %r13
movq %r14, -0x50(%rbp)
movq %r14, %rdi
callq 0x83e0
cmpb $0x1, (%rbx)
jne 0xeb02
leaq 0x7a2b(%rip), %rdi      # 0x16420
callq 0x3b22
cmpl 0x4(%rbx), %eax
jne 0xeaa7
movq %r15, %rdi
movl %eax, %esi
callq 0x5ab8
movq %r12, %rdi
leaq 0x106f(%rip), %rsi      # 0xfa86
movq %r15, %rdx
callq 0x5a8a
movq %r12, %rdi
pushq $0x2
popq %rsi
callq 0x8343
movq %r12, %rdi
callq 0x3140
movq %r15, %rdi
callq 0x3140
leaq 0x792f(%rip), %rax      # 0x16370
movq (%rax), %rdi
movl 0x4(%rbx), %esi
callq 0x6c7e
movq %rax, %r12
leaq 0x48(%rax), %rsi
leaq 0x79c6(%rip), %rdi      # 0x16420
callq 0x3b2e
movb $0x1, %r13b
movb %r13b, 0x1(%r12)
leaq 0x823a(%rip), %rdi      # 0x16ca8
callq 0x7e24
movl %eax, 0x5c(%r12)
movq %r14, %rdi
callq 0x8437
movb %r13b, (%r12)
leaq -0x90(%rbp), %r13
leaq -0x70(%rbp), %r12
movq %r14, %rdi
callq 0x83e0
movb $0x0, (%rbx)
movq %r14, %rdi
callq 0x8437
jmp 0xe9dd
cmpb $0x1, 0x2c(%rbx)
jne 0xeab3
cmpb $0x0, 0x2d(%rbx)
jne 0xeb02
movq %r13, %r12
leaq 0x7963(%rip), %r13      # 0x16420
movq %r13, %rdi
callq 0x3b22
cmpl 0x8(%rbx), %eax
jne 0xeada
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x3b2e
movb $0x1, 0x2c(%rbx)
movq %r13, %rdi
callq 0x3b22
cmpl 0xc(%rbx), %eax
movq %r12, %r13
leaq -0x70(%rbp), %r12
jne 0xeb02
leaq 0x792b(%rip), %rdi      # 0x16420
movq -0x38(%rbp), %rsi
callq 0x3b2e
movb $0x1, 0x2d(%rbx)
movq %r14, %rdi
callq 0x8437
cmpb $0x1, 0x2c(%rbx)
jne 0xeb1a
cmpb $0x0, 0x2d(%rbx)
jne 0xecad
movl 0x4(%rbx), %esi
leaq -0x170(%rbp), %r12
movq %r12, %rdi
callq 0x5ab8
leaq -0x190(%rbp), %r13
movq %r13, %rdi
leaq 0xc32(%rip), %rsi       # 0xf76f
movq %r12, %rdx
callq 0x5a8a
leaq -0xf0(%rbp), %rdi
movq %r13, %rsi
leaq 0xf44(%rip), %rdx       # 0xfa9a
callq 0x5bc8
movb 0x2c(%rbx), %al
movb %al, -0x29(%rbp)
cmpb $0x1, %al
jne 0xeb81
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
leaq 0xe24(%rip), %rsi       # 0xf99a
leaq -0x2b(%rbp), %rdx
callq 0x3100
jmp 0xebac
movl 0x8(%rbx), %esi
leaq -0x150(%rbp), %r13
movq %r13, %rdi
callq 0x5ab8
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
leaq 0xf0c(%rip), %rsi       # 0xfab0
movq %r13, %rdx
callq 0x5a8a
movq %r15, %rdi
leaq -0xf0(%rbp), %rsi
movq %r12, %rdx
callq 0x5b57
movb 0x2d(%rbx), %r13b
cmpb $0x1, %r13b
jne 0xebe4
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
leaq 0xdc1(%rip), %rsi       # 0xf99a
leaq -0x2a(%rbp), %rdx
callq 0x3100
jmp 0xec0f
movl 0xc(%rbx), %esi
leaq -0x130(%rbp), %r14
movq %r14, %rdi
callq 0x5ab8
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
leaq 0xeb0(%rip), %rsi       # 0xfab7
movq %r14, %rdx
callq 0x5a8a
leaq -0x1b0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x5b57
movq %r14, %rdi
pushq $0x3
popq %rsi
callq 0x8343
movq %r14, %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
testb %r13b, %r13b
jne 0xec54
leaq -0x130(%rbp), %rdi
callq 0x3140
leaq -0x90(%rbp), %r13
movq %r15, %rdi
callq 0x3140
leaq -0xd0(%rbp), %rdi
callq 0x3140
cmpb $0x0, -0x29(%rbp)
movq -0x50(%rbp), %r14
jne 0xec85
leaq -0x150(%rbp), %rdi
callq 0x3140
leaq -0x70(%rbp), %r12
leaq -0xf0(%rbp), %rdi
callq 0x3140
leaq -0x190(%rbp), %rdi
callq 0x3140
leaq -0x170(%rbp), %rdi
callq 0x3140
cmpb $0x1, (%rbx)
jne 0xe9dd
cmpb $0x1, 0x1(%rbx)
jne 0xe9dd
cmpb $0x1, 0x2c(%rbx)
jne 0xe9dd
cmpb $0x1, 0x2d(%rbx)
jne 0xe9dd
movl 0x4(%rbx), %esi
movq %r15, %rdi
callq 0x5ab8
movq %r13, %rdi
leaq 0xd57(%rip), %rsi       # 0xfa40
movq %r15, %rdx
callq 0x5a8a
movq %r13, %rdi
pushq $0x2
popq %rsi
callq 0x8343
movq %r13, %rdi
callq 0x3140
movq %r15, %rdi
callq 0x3140
movb $0x0, 0x1(%rbx)
cmpl $0x1, 0x34(%rbx)
movb 0x2e(%rbx), %cl
jne 0xed34
movq -0x38(%rbp), %r9
movd (%r9), %xmm0
testb %cl, %cl
je 0xed2e
pxor 0xd02(%rip), %xmm0      # 0xfa30
movd %xmm0, %eax
jmp 0xed44
movq -0x38(%rbp), %r9
movl (%r9), %edx
movl %edx, %eax
negl %eax
testb %cl, %cl
cmovel %edx, %eax
movl %eax, 0x18(%rbx)
movq 0x48(%rbx), %rdi
movl 0x30(%rbx), %esi
movl 0x4(%rbx), %edx
movl 0x28(%rbx), %eax
subq $0x8, %rsp
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
pushq %rbx
pushq %rax
pushq 0x20(%rbx)
callq 0x3d74
addq $0x20, %rsp
jmp 0xe9dd
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3140
jmp 0xed9a
movq %rax, %rbx
jmp 0xed9a
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3140
jmp 0xed9a
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
jmp 0xee3d
movq %rax, %rbx
jmp 0xede3
jmp 0xedad
movq %rax, %rbx
jmp 0xedef
movq %rax, %rbx
jmp 0xee12
jmp 0xedb9
movq %rax, %rbx
jmp 0xee1e
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x3140
jmp 0xedd2
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x3140
testb %r13b, %r13b
jne 0xedef
leaq -0x130(%rbp), %rdi
callq 0x3140
leaq -0x110(%rbp), %rdi
callq 0x3140
jmp 0xee00
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x3140
cmpb $0x0, -0x29(%rbp)
jne 0xee1e
leaq -0x150(%rbp), %rdi
callq 0x3140
leaq -0xf0(%rbp), %rdi
callq 0x3140
leaq -0x190(%rbp), %rdi
callq 0x3140
leaq -0x170(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3440
movq %rax, %rbx
jmp 0xee2a
movq %rax, %rbx
jmp 0xee36