unsigned int altera_a10_cdr_lookup_lf_resistor_pd(unsigned int fvco,
                                                  unsigned int lpd) {
  if (fvco < 7000000) {
    switch (lpd) {
    case 1:
      return 2;
    case 2:
    case 4:
      return 3;
    default:
      return 0;
    }
  } else {
    switch (lpd) {
    case 1:
    case 2:
    case 4:
      return 3;
    default:
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<altera_a10_cdr_lookup_lf_resistor_pd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x6acfc0,-0x8(%rbp)
jae    1171 <altera_a10_cdr_lookup_lf_resistor_pd+0x71>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     114d <altera_a10_cdr_lookup_lf_resistor_pd+0x4d>
jmp    112b <altera_a10_cdr_lookup_lf_resistor_pd+0x2b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1159 <altera_a10_cdr_lookup_lf_resistor_pd+0x59>
jmp    113c <altera_a10_cdr_lookup_lf_resistor_pd+0x3c>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     1159 <altera_a10_cdr_lookup_lf_resistor_pd+0x59>
jmp    1165 <altera_a10_cdr_lookup_lf_resistor_pd+0x65>
movl   $0x2,-0x4(%rbp)
jmp    11ac <altera_a10_cdr_lookup_lf_resistor_pd+0xac>
movl   $0x3,-0x4(%rbp)
jmp    11ac <altera_a10_cdr_lookup_lf_resistor_pd+0xac>
movl   $0x0,-0x4(%rbp)
jmp    11ac <altera_a10_cdr_lookup_lf_resistor_pd+0xac>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     1199 <altera_a10_cdr_lookup_lf_resistor_pd+0x99>
jmp    1188 <altera_a10_cdr_lookup_lf_resistor_pd+0x88>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
jne    11a5 <altera_a10_cdr_lookup_lf_resistor_pd+0xa5>
jmp    1199 <altera_a10_cdr_lookup_lf_resistor_pd+0x99>
movl   $0x3,-0x4(%rbp)
jmp    11ac <altera_a10_cdr_lookup_lf_resistor_pd+0xac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<altera_a10_cdr_lookup_lf_resistor_pd>:
add    $0xffffffff,%esi
xor    %eax,%eax
cmp    $0x3,%esi
ja     1128 <altera_a10_cdr_lookup_lf_resistor_pd+0x28>
cmp    $0x6acfc0,%edi
lea    0xee9(%rip),%rax
lea    0xef2(%rip),%rcx
cmovb  %rax,%rcx
movslq %esi,%rax
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @altera_a10_cdr_lookup_lf_resistor_pd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp ult i32 %6, 7000000
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* %5
switch i32 %9, label %12 [
i32 1, label %10
i32 2, label %11
i32 4, label %11
]
10: ; preds = %8
store i32 2, i32* %3
br label %17
11: ; preds = %8, %8
store i32 3, i32* %3
br label %17
12: ; preds = %8
store i32 0, i32* %3
br label %17
13: ; preds = %2
%14 = load i32, i32* %5
switch i32 %14, label %16 [
i32 1, label %15
i32 2, label %15
i32 4, label %15
]
15: ; preds = %13, %13, %13
store i32 3, i32* %3
br label %17
16: ; preds = %13
store i32 0, i32* %3
br label %17
17: ; preds = %16, %15, %12, %11, %10
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
@switch.table.altera_a10_cdr_lookup_lf_resistor_pd = [4 x i32] [i32 2, i32 3, i32 0, i32 3]
@switch.table.altera_a10_cdr_lookup_lf_resistor_pd.1 = [4 x i32] [i32 3, i32 3, i32 0, i32 3]
define i32 @altera_a10_cdr_lookup_lf_resistor_pd(i32 %0, i32 %1) {
%3 = add i32 %1, -1
%4 = icmp ult i32 %3, 4
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = icmp ult i32 %0, 7000000
%7 = select i1 %6, [4 x i32]* @switch.table.altera_a10_cdr_lookup_lf_resistor_pd, [4 x i32]* @switch.table.altera_a10_cdr_lookup_lf_resistor_pd.1
%8 = sext i32 %3 to i64
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %8
%10 = load i32, i32* %9
br label %11
11: ; preds = %2, %5
%12 = phi i32 [ %10, %5 ], [ 0, %2 ]
ret i32 %12
}