// File: /workspace/github_cpp_makefile_star2_O3/CMU-SAFARI[P]ramulator/src/GDDR5.cpp
// Function: ramulator::GDDR5::init_speed()
void GDDR5::init_speed()
{
    const int REFIL_TABLE[int(Speed::MAX)] = {3900, 4388, 4875, 5363, 5850, 6338, 6825};
    const int REFIS_TABLE[int(Speed::MAX)] = {1900, 2138, 2375, 2613, 2850, 3088, 3325};
    const int RFC_TABLE[5][int(Speed::MAX)] = {
        // using DDR3 values
        {90, 102, 113, 124, 135, 147, 158},
        {110, 124, 138, 152, 165, 179, 193},
        {160, 180, 200, 220, 240, 260, 280},
        {260, 293, 325, 358, 390, 423, 455},
        {350, 394, 438, 482, 525, 569, 613}
    };
    int speed = 0, density = 0;
    switch (speed_entry.rate){
        case 4000: speed = 0; break;
        case 4500: speed = 1; break;
        case 5000: speed = 2; break;
        case 5500: speed = 3; break;
        case 6000: speed = 4; break;
        case 6500: speed = 5; break;
        case 7000: speed = 6; break;
        default: assert(0);
    }
    switch (org_entry.size >> 9){
        case 1: density = 0; break;
        case 2: density = 1; break;
        case 4: density = 2; break;
        case 8: density = 3; break;
        case 16: density = 4; break;
        default: assert(0);
    }
    if (org_entry.size <= 1024) speed_entry.nREFI = REFIL_TABLE[speed];
    else speed_entry.nREFI = REFIS_TABLE[speed];
    speed_entry.nRFC = RFC_TABLE[density][speed];
}

// Assembly:
pushq %rax
movl 0x3188(%rdi), %eax
cmpl $0x157b, %eax           # imm = 0x157B
jle 0x116ade
cmpl $0x1963, %eax           # imm = 0x1963
jg 0x116afe
cmpl $0x157c, %eax           # imm = 0x157C
je 0x116b22
cmpl $0x1770, %eax           # imm = 0x1770
jne 0x116bd7
movl $0x4, %eax
jmp 0x116b2e
cmpl $0xfa0, %eax            # imm = 0xFA0
je 0x116b1e
cmpl $0x1194, %eax           # imm = 0x1194
je 0x116b17
cmpl $0x1388, %eax           # imm = 0x1388
jne 0x116bd7
movl $0x2, %eax
jmp 0x116b2e
cmpl $0x1964, %eax           # imm = 0x1964
je 0x116b29
cmpl $0x1b58, %eax           # imm = 0x1B58
jne 0x116bd7
movl $0x6, %eax
jmp 0x116b2e
movl $0x1, %eax
jmp 0x116b2e
xorl %eax, %eax
jmp 0x116b2e
movl $0x3, %eax
jmp 0x116b2e
movl $0x5, %eax
movl 0x2de0(%rdi), %ecx
movl %ecx, %edx
sarl $0x9, %edx
leal -0x1(%rdx), %esi
cmpl $0x7, %esi
ja 0x116b55
leaq 0x410b8(%rip), %rdx     # 0x157c00
movslq (%rdx,%rsi,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
xorl %edx, %edx
jmp 0x116b74
cmpl $0x10, %edx
jne 0x116bb8
movl $0x4, %edx
jmp 0x116b74
movl $0x3, %edx
jmp 0x116b74
movl $0x2, %edx
jmp 0x116b74
movl $0x1, %edx
cmpl $0x401, %ecx            # imm = 0x401
leaq 0x415af(%rip), %rcx     # 0x158130
leaq 0x415c8(%rip), %rsi     # 0x158150
cmovlq %rcx, %rsi
shll $0x2, %eax
movl (%rsi,%rax), %ecx
movl %ecx, 0x31e8(%rdi)
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x415c9(%rip), %rsi     # 0x158170
addq %rdx, %rsi
addq %rcx, %rsi
movl (%rax,%rsi), %eax
movl %eax, 0x31e4(%rdi)
popq %rax
retq
leaq 0x33982(%rip), %rdi     # 0x14a541
leaq 0x41a2d(%rip), %rsi     # 0x1585f3
leaq 0x41a60(%rip), %rcx     # 0x15862d
movl $0x54, %edx
callq 0xb200
leaq 0x33963(%rip), %rdi     # 0x14a541
leaq 0x41a0e(%rip), %rsi     # 0x1585f3
leaq 0x41a41(%rip), %rcx     # 0x15862d
movl $0x4c, %edx
callq 0xb200