int liberty_hash_get_next_higher_prime(int prime) {
  if (prime < 20)
    return 53;
  if (prime < 60)
    return 409;
  if (prime < 400)
    return 1019;
  if (prime < 1020)
    return 5009;
  if (prime < 5010)
    return 20011;
  return 99529;
}


x86 assembly (clang, -O0):
<liberty_hash_get_next_higher_prime>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    111d <liberty_hash_get_next_higher_prime+0x1d>
movl   $0x35,-0x4(%rbp)
jmp    1185 <liberty_hash_get_next_higher_prime+0x85>
cmpl   $0x3c,-0x8(%rbp)
jge    1133 <liberty_hash_get_next_higher_prime+0x33>
movl   $0x199,-0x4(%rbp)
jmp    1185 <liberty_hash_get_next_higher_prime+0x85>
cmpl   $0x190,-0x8(%rbp)
jge    114c <liberty_hash_get_next_higher_prime+0x4c>
movl   $0x3fb,-0x4(%rbp)
jmp    1185 <liberty_hash_get_next_higher_prime+0x85>
cmpl   $0x3fc,-0x8(%rbp)
jge    1165 <liberty_hash_get_next_higher_prime+0x65>
movl   $0x1391,-0x4(%rbp)
jmp    1185 <liberty_hash_get_next_higher_prime+0x85>
cmpl   $0x1392,-0x8(%rbp)
jge    117e <liberty_hash_get_next_higher_prime+0x7e>
movl   $0x4e2b,-0x4(%rbp)
jmp    1185 <liberty_hash_get_next_higher_prime+0x85>
movl   $0x184c9,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<liberty_hash_get_next_higher_prime>:
mov    $0x35,%eax
cmp    $0x14,%edi
jl     1141 <liberty_hash_get_next_higher_prime+0x41>
mov    $0x199,%eax
cmp    $0x3c,%edi
jb     1141 <liberty_hash_get_next_higher_prime+0x41>
mov    $0x3fb,%eax
cmp    $0x190,%edi
jb     1141 <liberty_hash_get_next_higher_prime+0x41>
mov    $0x1391,%eax
cmp    $0x3fc,%edi
jb     1141 <liberty_hash_get_next_higher_prime+0x41>
cmp    $0x1392,%edi
mov    $0x4e2b,%ecx
mov    $0x184c9,%eax
cmovb  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @liberty_hash_get_next_higher_prime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 20
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 53, i32* %2
br label %24
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 60
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 409, i32* %2
br label %24
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 400
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1019, i32* %2
br label %24
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 1020
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 5009, i32* %2
br label %24
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 5010
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 20011, i32* %2
br label %24
23: ; preds = %19
store i32 99529, i32* %2
br label %24
24: ; preds = %23, %22, %18, %14, %10, %6
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
define i32 @liberty_hash_get_next_higher_prime(i32 %0) {
%2 = icmp slt i32 %0, 20
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 60
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 400
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 1020
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 5010
%11 = select i1 %10, i32 20011, i32 99529
br label %12
12: ; preds = %9, %7, %5, %3, %1
%13 = phi i32 [ 53, %1 ], [ 409, %3 ], [ 1019, %5 ], [ 5009, %7 ], [ %11, %9 ]
ret i32 %13
}