int get_prime_size(int size) {
  int primes[] = {
      3UL,          5UL,         7UL,         11UL,        13UL,
      17UL,         19UL,        23UL,        29UL,        31UL,
      37UL,         41UL,        43UL,        47UL,        53UL,
      97UL,         193UL,       389UL,       769UL,       1543UL,
      3079UL,       6151UL,      12289UL,     24593UL,     49157UL,
      98317UL,      196613UL,    393241UL,    786433UL,    1572869UL,
      3145739UL,    6291469UL,   12582917UL,  25165843UL,  50331653UL,
      100663319UL,  201326611UL, 402653189UL, 805306457UL, 1610612741UL,
      3221225473UL, 4294967291UL};
  int i = 0;
  if (size < 97)
    return 97;
  while (i < sizeof(primes)) {
    if (size < primes[i])
      break;
    i++;
  }
  return primes[i - 1];
}


x86 assembly (clang, -O0):
<get_prime_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x8(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xed4(%rip),%rsi
mov    $0xa8,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x61,-0x8(%rbp)
jge    1156 <get_prime_size+0x46>
movl   $0x61,-0x4(%rbp)
jmp    11b3 <get_prime_size+0xa3>
jmp    115b <get_prime_size+0x4b>
movslq -0xb4(%rbp),%rax
cmp    $0xa8,%rax
jae    119e <get_prime_size+0x8e>
mov    -0x8(%rbp),%eax
movslq -0xb4(%rbp),%rcx
cmp    -0xb0(%rbp,%rcx,4),%eax
jge    118a <get_prime_size+0x7a>
jmp    119e <get_prime_size+0x8e>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    115b <get_prime_size+0x4b>
mov    -0xb4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xb0(%rbp,%rax,4),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_prime_size>:
mov    $0x61,%eax
cmp    $0x61,%edi
jl     1173 <get_prime_size+0x73>
mov    $0x3,%ecx
lea    0xeea(%rip),%rax
cs nopw 0x0(%rax,%rax,1)
cmp    %edi,-0xc(%rax,%rcx,4)
jg     114b <get_prime_size+0x4b>
cmp    %edi,-0x8(%rax,%rcx,4)
jg     1151 <get_prime_size+0x51>
cmp    %edi,-0x4(%rax,%rcx,4)
jg     1157 <get_prime_size+0x57>
cmp    %edi,(%rax,%rcx,4)
jg     115b <get_prime_size+0x5b>
add    $0x4,%rcx
cmp    $0xab,%rcx
jne    1120 <get_prime_size+0x20>
mov    $0xa8,%ecx
jmp    115b <get_prime_size+0x5b>
add    $0xfffffffffffffffd,%rcx
jmp    115b <get_prime_size+0x5b>
add    $0xfffffffffffffffe,%rcx
jmp    115b <get_prime_size+0x5b>
add    $0xffffffffffffffff,%rcx
shl    $0x20,%rcx
movabs $0xffffffff00000000,%rdx
ff ff ff
add    %rcx,%rdx
sar    $0x1e,%rdx
mov    (%rdx,%rax,1),%eax
ret

LLVM IR (-O0):
@__const.get_prime_size.primes = [42 x i32] [i32 3, i32 5, i32 7, i32 11, i32 13, i32 17, i32 19, i32 23, i32 29, i32 31, i32 37, i32 41, i32 43, i32 47, i32 53, i32 97, i32 193, i32 389, i32 769, i32 1543, i32 3079, i32 6151, i32 12289, i32 24593, i32 49157, i32 98317, i32 196613, i32 393241, i32 786433, i32 1572869, i32 3145739, i32 6291469, i32 12582917, i32 25165843, i32 50331653, i32 100663319, i32 201326611, i32 402653189, i32 805306457, i32 1610612741, i32 -1073741823, i32 -5]
define i32 @get_prime_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [42 x i32]
%5 = alloca i32
store i32 %0, i32* %3
%6 = bitcast [42 x i32]* %4 to i8*
store i32 0, i32* %5
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 97
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 97, i32* %2
br label %32
10: ; preds = %1
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = icmp ult i64 %13, 168
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [42 x i32], [42 x i32]* %4, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp slt i32 %16, %20
br i1 %21, label %22, label %23
22: ; preds = %15
br label %26
23: ; preds = %15
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %11
26: ; preds = %22, %11
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [42 x i32], [42 x i32]* %4, i64 0, i64 %29
%31 = load i32, i32* %30
store i32 %31, i32* %2
br label %32
32: ; preds = %26, %9
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@__const.get_prime_size.primes = [42 x i32] [i32 3, i32 5, i32 7, i32 11, i32 13, i32 17, i32 19, i32 23, i32 29, i32 31, i32 37, i32 41, i32 43, i32 47, i32 53, i32 97, i32 193, i32 389, i32 769, i32 1543, i32 3079, i32 6151, i32 12289, i32 24593, i32 49157, i32 98317, i32 196613, i32 393241, i32 786433, i32 1572869, i32 3145739, i32 6291469, i32 12582917, i32 25165843, i32 50331653, i32 100663319, i32 201326611, i32 402653189, i32 805306457, i32 1610612741, i32 -1073741823, i32 -5]
define i32 @get_prime_size(i32 %0) {
%2 = icmp slt i32 %0, 97
br i1 %2, label %33, label %3
3: ; preds = %1, %23
%4 = phi i64 [ %24, %23 ], [ 0, %1 ]
%5 = getelementptr inbounds [42 x i32], [42 x i32]* @__const.get_prime_size.primes, i64 0, i64 %4
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, %0
br i1 %7, label %26, label %8
8: ; preds = %3
%9 = or i64 %4, 1
%10 = getelementptr inbounds [42 x i32], [42 x i32]* @__const.get_prime_size.primes, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, %0
br i1 %12, label %26, label %13
13: ; preds = %8
%14 = or i64 %4, 2
%15 = getelementptr inbounds [42 x i32], [42 x i32]* @__const.get_prime_size.primes, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp sgt i32 %16, %0
br i1 %17, label %26, label %18
18: ; preds = %13
%19 = or i64 %4, 3
%20 = getelementptr inbounds [42 x i32], [42 x i32]* @__const.get_prime_size.primes, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp sgt i32 %21, %0
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = add nuw nsw i64 %4, 4
%25 = icmp eq i64 %24, 168
br i1 %25, label %26, label %3
26: ; preds = %23, %18, %13, %8, %3
%27 = phi i64 [ %4, %3 ], [ %9, %8 ], [ %14, %13 ], [ %19, %18 ], [ 168, %23 ]
%28 = shl i64 %27, 32
%29 = add i64 %28, -4294967296
%30 = ashr exact i64 %29, 32
%31 = getelementptr inbounds [42 x i32], [42 x i32]* @__const.get_prime_size.primes, i64 0, i64 %30
%32 = load i32, i32* %31
br label %33
33: ; preds = %1, %26
%34 = phi i32 [ %32, %26 ], [ 97, %1 ]
ret i32 %34
}