// File: /workspace/github_cpp_makefile_star2_O1/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 0x119b54
cmpl $0x1963, %eax           # imm = 0x1963
jg 0x119b74
cmpl $0x157c, %eax           # imm = 0x157C
je 0x119b98
cmpl $0x1770, %eax           # imm = 0x1770
jne 0x119c4d
movl $0x4, %eax
jmp 0x119ba4
cmpl $0xfa0, %eax            # imm = 0xFA0
je 0x119b94
cmpl $0x1194, %eax           # imm = 0x1194
je 0x119b8d
cmpl $0x1388, %eax           # imm = 0x1388
jne 0x119c4d
movl $0x2, %eax
jmp 0x119ba4
cmpl $0x1964, %eax           # imm = 0x1964
je 0x119b9f
cmpl $0x1b58, %eax           # imm = 0x1B58
jne 0x119c4d
movl $0x6, %eax
jmp 0x119ba4
movl $0x1, %eax
jmp 0x119ba4
xorl %eax, %eax
jmp 0x119ba4
movl $0x3, %eax
jmp 0x119ba4
movl $0x5, %eax
movl 0x2de0(%rdi), %ecx
movl %ecx, %edx
sarl $0x9, %edx
leal -0x1(%rdx), %esi
cmpl $0x7, %esi
ja 0x119bcb
leaq 0x40fe2(%rip), %rdx     # 0x15aba0
movslq (%rdx,%rsi,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
xorl %edx, %edx
jmp 0x119bea
cmpl $0x10, %edx
jne 0x119c2e
movl $0x4, %edx
jmp 0x119bea
movl $0x3, %edx
jmp 0x119bea
movl $0x2, %edx
jmp 0x119bea
movl $0x1, %edx
cmpl $0x401, %ecx            # imm = 0x401
leaq 0x414d9(%rip), %rcx     # 0x15b0d0
leaq 0x414f2(%rip), %rsi     # 0x15b0f0
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 0x414f3(%rip), %rsi     # 0x15b110
addq %rdx, %rsi
addq %rcx, %rsi
movl (%rax,%rsi), %eax
movl %eax, 0x31e4(%rdi)
popq %rax
retq
leaq 0x338cc(%rip), %rdi     # 0x14d501
leaq 0x41957(%rip), %rsi     # 0x15b593
leaq 0x4198a(%rip), %rcx     # 0x15b5cd
movl $0x54, %edx
callq 0xb200
leaq 0x338ad(%rip), %rdi     # 0x14d501
leaq 0x41938(%rip), %rsi     # 0x15b593
leaq 0x4196b(%rip), %rcx     # 0x15b5cd
movl $0x4c, %edx
callq 0xb200