// File: /workspace/github_cpp_makefile_star2_O3/dsesami[P]superscalar-processor-model/regRead.cc
// Function: regRead()
void regRead(){
    for(u_int i=0; i<WIDTH; i++) {

        // set first cycle and duration of this instruction.
        for(deque<bundle>::iterator it = RR_register.begin(); it != RR_register.end(); it++) {
            if(RR_register.size() && it->regRead_first == -1)
                it->regRead_first = cycles;
        }

        // If the dispatch register is full, do nothing.
        if(DI_register.size() == WIDTH) {
            return;
        }
        // Otherwise check if values in the rob are ready, and if so, and move things forward.
        else if(RR_register.size()) {
            // Wake appropriate dependents! Since we do not have actual register values,
            // simply indicate that we have "ready" sources by indicating that they are not renamed.
            // Wake source 1:
            if(RR_register.front().rn_src_1 != -1) {
                if(ROB.at(RR_register.front().rn_src_1).ready) {
                    RR_register.front().rn_src_1 = -1;
                }
            }
            // Wake source 2:
            if(RR_register.front().rn_src_2 != -1) {
                if(ROB.at(RR_register.front().rn_src_2).ready) {
                    RR_register.front().rn_src_2 = -1;
                }
            }
        for(deque<bundle>::iterator it = RR_register.begin(); it != RR_register.end(); it++) {
            if(RR_register.size() && it->regRead_first == -1)
                it->regRead_first = cycles;
        }

            // Finally, move this bundle to the DI register.
            RR_register.front().regRead_time = cycles - RR_register.front().regRead_first+1;
            DI_register.push_back(RR_register.front());
            RR_register.pop_front();
        }
    }
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x5bce(%rip), %rax      # 0xb184
movl (%rax), %eax
testl %eax, %eax
je 0x5837
leaq 0x5ee9(%rip), %rbx      # 0xb4b0
movq 0x10(%rbx), %r15
movq 0x20(%rbx), %r13
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %r8
xorl %ebp, %ebp
leaq 0x5f20(%rip), %r14      # 0xb500
movabsq $-0x1111111111111111, %r12 # imm = 0xEEEEEEEEEEEEEEEF
cmpq %r8, %r15
je 0x5673
movq 0x48(%rbx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
cmpq $0x1, %rdx
adcq $-0x1, %rsi
movq %r8, %rdx
subq 0x38(%rbx), %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
leaq (%rdx,%rsi,4), %rdx
movq %r13, %rdi
subq %r15, %rdi
sarq $0x3, %rdi
movabsq $0x1111111111111111, %rsi # imm = 0x1111111111111111
imulq %rsi, %rdi
leaq 0x5b59(%rip), %rsi      # 0xb194
movl (%rsi), %r10d
movq %rcx, %r11
movq %r13, %r9
movq %r15, %rsi
cmpq %rdi, %rdx
je 0x5656
cmpl $-0x1, 0x3c(%rsi)
jne 0x5656
movl %r10d, 0x3c(%rsi)
addq $0x78, %rsi
cmpq %r9, %rsi
jne 0x566e
movq 0x8(%r11), %rsi
addq $0x8, %r11
leaq 0x1e0(%rsi), %r9
cmpq %r8, %rsi
jne 0x5647
movq 0x48(%r14), %rdx
movq %rdx, %rsi
subq 0x28(%r14), %rsi
sarq $0x3, %rsi
cmpq $0x1, %rdx
adcq $-0x1, %rsi
movq 0x20(%r14), %rdx
movq 0x30(%r14), %rdi
movq %rdi, %r9
subq 0x38(%r14), %r9
sarq $0x3, %r9
imulq %r12, %r9
leaq (%r9,%rsi,4), %rsi
subq 0x10(%r14), %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
addq %rsi, %rdx
movl %eax, %esi
cmpq %rsi, %rdx
je 0x5837
movq 0x48(%rbx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
cmpq $0x1, %rdx
adcq $-0x1, %rsi
movq %r8, %rdx
subq 0x38(%rbx), %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
leaq (%rdx,%rsi,4), %rdx
movq %r13, %rsi
subq %r15, %rsi
sarq $0x3, %rsi
movabsq $0x1111111111111111, %r9 # imm = 0x1111111111111111
imulq %r9, %rsi
cmpq %rsi, %rdx
je 0x582d
movslq 0x18(%r15), %rax
cmpq $-0x1, %rax
je 0x5755
leaq 0x5c8e(%rip), %rdx      # 0xb3a8
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %r9 # imm = 0x86BCA1AF286BCA1B
imulq %r9, %rdx
cmpq %rax, %rdx
jbe 0x5846
imulq $0x98, %rax, %rax
cmpb $0x1, 0x8(%rsi,%rax)
jne 0x5755
movl $0xffffffff, 0x18(%r15) # imm = 0xFFFFFFFF
movslq 0x20(%r15), %rax
cmpq $-0x1, %rax
je 0x57a1
leaq 0x5c42(%rip), %rdx      # 0xb3a8
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
subq %rsi, %rdx
sarq $0x3, %rdx
movabsq $-0x79435e50d79435e5, %r9 # imm = 0x86BCA1AF286BCA1B
imulq %r9, %rdx
cmpq %rax, %rdx
jbe 0x5846
imulq $0x98, %rax, %rax
cmpb $0x1, 0x8(%rsi,%rax)
jne 0x57a1
movl $0xffffffff, 0x20(%r15) # imm = 0xFFFFFFFF
leaq 0x59ec(%rip), %rax      # 0xb194
movl (%rax), %eax
movq %r15, %rdx
cmpq %r8, %r15
je 0x57d8
cmpl $-0x1, 0x3c(%rdx)
jne 0x57bb
movl %eax, 0x3c(%rdx)
addq $0x78, %rdx
cmpq %r13, %rdx
jne 0x57d3
movq 0x8(%rcx), %rdx
addq $0x8, %rcx
leaq 0x1e0(%rdx), %r13
cmpq %r8, %rdx
jne 0x57b2
subl 0x3c(%r15), %eax
incl %eax
movl %eax, 0x40(%r15)
movq 0x40(%r14), %rax
addq $-0x78, %rax
cmpq %rax, %rdi
je 0x5801
movl $0xf, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
addq $0x78, 0x30(%r14)
jmp 0x580c
movq %r14, %rdi
movq %r15, %rsi
callq 0x4d4e
movq %rbx, %rdi
callq 0x514c
movq 0x10(%rbx), %r15
movq 0x20(%rbx), %r13
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %r8
leaq 0x5959(%rip), %rax      # 0xb184
movl (%rax), %eax
incl %ebp
cmpl %eax, %ebp
jb 0x55ea
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b08(%rip), %rdi      # 0x8355
movq %rax, %rsi
xorl %eax, %eax
callq 0x21d0
nop