// File: /workspace/github_cpp_makefile_star2_O1/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 0x5646(%rip), %rax      # 0xa184
movl (%rax), %eax
testl %eax, %eax
je 0x4db8
xorl %ebp, %ebp
leaq 0x595f(%rip), %rbx      # 0xa4b0
leaq 0x59a8(%rip), %r14      # 0xa500
movabsq $-0x1111111111111111, %r12 # imm = 0xEEEEEEEEEEEEEEEF
movq 0x10(%rbx), %r15
movq 0x20(%rbx), %r13
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %r8
cmpq %r8, %r15
je 0x4bfb
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 0x55d1(%rip), %rsi      # 0xa194
movl (%rsi), %r10d
movq %rcx, %r11
movq %r13, %r9
movq %r15, %rsi
cmpq %rdi, %rdx
je 0x4bde
cmpl $-0x1, 0x3c(%rsi)
jne 0x4bde
movl %r10d, 0x3c(%rsi)
addq $0x78, %rsi
cmpq %r9, %rsi
jne 0x4bf6
movq 0x8(%r11), %rsi
addq $0x8, %r11
leaq 0x1e0(%rsi), %r9
cmpq %r8, %rsi
jne 0x4bcf
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, %eax
cmpq %rax, %rdx
je 0x4db8
movq 0x48(%rbx), %rax
movq %rax, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq $0x1, %rax
adcq $-0x1, %rdx
movq %r8, %rax
subq 0x38(%rbx), %rax
sarq $0x3, %rax
imulq %r12, %rax
leaq (%rax,%rdx,4), %rax
movq %r13, %rdx
subq %r15, %rdx
sarq $0x3, %rdx
movabsq $0x1111111111111111, %rsi # imm = 0x1111111111111111
imulq %rsi, %rdx
cmpq %rdx, %rax
je 0x4da5
movslq 0x18(%r15), %rax
cmpq $-0x1, %rax
je 0x4cdd
leaq 0x5706(%rip), %rdx      # 0xa3a8
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 0x4dc7
imulq $0x98, %rax, %rax
cmpb $0x1, 0x8(%rsi,%rax)
jne 0x4cdd
movl $0xffffffff, 0x18(%r15) # imm = 0xFFFFFFFF
movslq 0x20(%r15), %rax
cmpq $-0x1, %rax
je 0x4d29
leaq 0x56ba(%rip), %rdx      # 0xa3a8
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 0x4dc7
imulq $0x98, %rax, %rax
cmpb $0x1, 0x8(%rsi,%rax)
jne 0x4d29
movl $0xffffffff, 0x20(%r15) # imm = 0xFFFFFFFF
cmpq %r8, %r15
je 0x4d60
leaq 0x545f(%rip), %rax      # 0xa194
movl (%rax), %eax
movq %r15, %rdx
cmpl $-0x1, 0x3c(%rdx)
jne 0x4d43
movl %eax, 0x3c(%rdx)
addq $0x78, %rdx
cmpq %r13, %rdx
jne 0x4d5b
movq 0x8(%rcx), %rdx
addq $0x8, %rcx
leaq 0x1e0(%rdx), %r13
cmpq %r8, %rdx
jne 0x4d3a
leaq 0x542d(%rip), %rax      # 0xa194
movl (%rax), %eax
subl 0x3c(%r15), %eax
incl %eax
movl %eax, 0x40(%r15)
movq 0x40(%r14), %rax
addq $-0x78, %rax
cmpq %rax, %rdi
je 0x4d92
movl $0xf, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
addq $0x78, 0x30(%r14)
jmp 0x4d9d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4316
movq %rbx, %rdi
callq 0x46ee
incl %ebp
leaq 0x53d6(%rip), %rax      # 0xa184
movl (%rax), %eax
cmpl %eax, %ebp
jb 0x4b62
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2528(%rip), %rdi      # 0x72f6
movq %rax, %rsi
xorl %eax, %eax
callq 0x21d0