#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int am_choose_hash_prime(int x) {
  static const int p[] = {
      1103,      1217,      1361,      1499,      1657,      1823,
      2011,      2213,      2437,      2683,      2953,      3251,
      3581,      3943,      4339,      4783,      5273,      5801,
      6389,      7039,      7753,      8537,      9391,      10331,
      11369,     12511,     13763,     15149,     16673,     18341,
      20177,     22229,     24469,     26921,     29629,     32603,
      35869,     39461,     43411,     47777,     52561,     57829,
      63617,     69991,     76991,     84691,     93169,     102497,
      112757,    124067,    136481,    150131,    165161,    181693,
      199873,    219871,    241861,    266051,    292661,    321947,
      354143,    389561,    428531,    471389,    518533,    570389,
      627433,    690187,    759223,    835207,    918733,    1010617,
      1111687,   1222889,   1345207,   1479733,   1627723,   1790501,
      1969567,   2166529,   2383219,   2621551,   2883733,   3172123,
      3489347,   3838283,   4222117,   4644329,   5108767,   5619667,
      6181639,   6799811,   7479803,   8227787,   9050599,   9955697,
      10951273,  12046403,  13251047,  14576161,  16033799,  17637203,
      19400929,  21341053,  23475161,  25822679,  28404989,  31245491,
      34370053,  37807061,  41587807,  45746593,  50321261,  55353391,
      60888739,  66977621,  73675391,  81042947,  89147249,  98061979,
      107868203, 118655027, 130520531, 143572609, 157929907, 173722907,
      191095213, 210204763, 231225257, 254347801, 279782593, 307760897,
      338536987, 372390691, 409629809, 450592801, 495652109, 545217341,
      599739083, 659713007, 725684317, 798252779, 878078057, 965885863,
      1062474559};
  const int lp = sizeof(p) / sizeof(p[0]);
  int a = -1, b = lp;
  while (b - a > 1) {
    int c = ((a + b) >> 1);
    if (p[c] <= x) {
      a = c;
    } else {
      b = c;
    }
  }
  if (a < 0) {
    a++;
  }
  while (a < lp && p[a] < x) {
    a++;
  }
  assert(a < lp - 1);
  assert(x <= p[a]);
  return p[a];
}


x86 assembly (clang, -O0):
<am_choose_hash_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x91,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
movl   $0x91,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x1,%eax
jle    1178 <am_choose_hash_prime+0x68>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rcx
lea    0xeaa(%rip),%rax
mov    (%rax,%rcx,4),%eax
cmp    -0x4(%rbp),%eax
jg     116d <am_choose_hash_prime+0x5d>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <am_choose_hash_prime+0x63>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1130 <am_choose_hash_prime+0x20>
cmpl   $0x0,-0xc(%rbp)
jge    118b <am_choose_hash_prime+0x7b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1190 <am_choose_hash_prime+0x80>
xor    %eax,%eax
cmpl   $0x91,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jge    11b9 <am_choose_hash_prime+0xa9>
movslq -0xc(%rbp),%rcx
lea    0xe53(%rip),%rax
mov    (%rax,%rcx,4),%eax
cmp    -0x4(%rbp),%eax
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11c9 <am_choose_hash_prime+0xb9>
jmp    11d7 <am_choose_hash_prime+0xc7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1190 <am_choose_hash_prime+0x80>
cmpl   $0x90,-0xc(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
movslq -0xc(%rbp),%rdx
lea    0xe07(%rip),%rcx
cmp    (%rcx,%rdx,4),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movslq -0xc(%rbp),%rcx
lea    0xdec(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<am_choose_hash_prime>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
mov    $0x91,%ecx
mov    $0xffffffff,%eax
lea    0xed9(%rip),%r14
jmp    113b <am_choose_hash_prime+0x2b>
nopl   0x0(%rax)
mov    %edx,%eax
mov    %ecx,%edx
sub    %eax,%edx
cmp    $0x1,%edx
jle    114d <am_choose_hash_prime+0x3d>
lea    (%rax,%rcx,1),%edx
sar    %edx
movslq %edx,%rsi
cmp    %ebx,(%r14,%rsi,4)
jle    1130 <am_choose_hash_prime+0x20>
mov    %edx,%ecx
jmp    1132 <am_choose_hash_prime+0x22>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
cmp    $0x90,%ebp
jg     1188 <am_choose_hash_prime+0x78>
movslq %ebp,%rax
lea    (%r14,%rax,4),%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %ebx,(%rax)
jge    1188 <am_choose_hash_prime+0x78>
add    $0x1,%ebp
add    $0x4,%rax
cmp    $0x91,%ebp
jne    1170 <am_choose_hash_prime+0x60>
mov    $0x91,%ebp
xor    %edi,%edi
cmp    $0x90,%ebp
setl   %dil
call   1030 <assert@plt>
movslq %ebp,%rax
mov    (%r14,%rax,4),%ebp
xor    %edi,%edi
cmp    %ebx,%ebp
setge  %dil
call   1030 <assert@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@am_choose_hash_prime.p = internal constant [145 x i32] [i32 1103, i32 1217, i32 1361, i32 1499, i32 1657, i32 1823, i32 2011, i32 2213, i32 2437, i32 2683, i32 2953, i32 3251, i32 3581, i32 3943, i32 4339, i32 4783, i32 5273, i32 5801, i32 6389, i32 7039, i32 7753, i32 8537, i32 9391, i32 10331, i32 11369, i32 12511, i32 13763, i32 15149, i32 16673, i32 18341, i32 20177, i32 22229, i32 24469, i32 26921, i32 29629, i32 32603, i32 35869, i32 39461, i32 43411, i32 47777, i32 52561, i32 57829, i32 63617, i32 69991, i32 76991, i32 84691, i32 93169, i32 102497, i32 112757, i32 124067, i32 136481, i32 150131, i32 165161, i32 181693, i32 199873, i32 219871, i32 241861, i32 266051, i32 292661, i32 321947, i32 354143, i32 389561, i32 428531, i32 471389, i32 518533, i32 570389, i32 627433, i32 690187, i32 759223, i32 835207, i32 918733, i32 1010617, i32 1111687, i32 1222889, i32 1345207, i32 1479733, i32 1627723, i32 1790501, i32 1969567, i32 2166529, i32 2383219, i32 2621551, i32 2883733, i32 3172123, i32 3489347, i32 3838283, i32 4222117, i32 4644329, i32 5108767, i32 5619667, i32 6181639, i32 6799811, i32 7479803, i32 8227787, i32 9050599, i32 9955697, i32 10951273, i32 12046403, i32 13251047, i32 14576161, i32 16033799, i32 17637203, i32 19400929, i32 21341053, i32 23475161, i32 25822679, i32 28404989, i32 31245491, i32 34370053, i32 37807061, i32 41587807, i32 45746593, i32 50321261, i32 55353391, i32 60888739, i32 66977621, i32 73675391, i32 81042947, i32 89147249, i32 98061979, i32 107868203, i32 118655027, i32 130520531, i32 143572609, i32 157929907, i32 173722907, i32 191095213, i32 210204763, i32 231225257, i32 254347801, i32 279782593, i32 307760897, i32 338536987, i32 372390691, i32 409629809, i32 450592801, i32 495652109, i32 545217341, i32 599739083, i32 659713007, i32 725684317, i32 798252779, i32 878078057, i32 965885863, i32 1062474559]
define i32 @am_choose_hash_prime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 145, i32* %3
store i32 -1, i32* %4
store i32 145, i32* %5
br label %7
7: ; preds = %27, %1
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %8, %9
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %28
12: ; preds = %7
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = add nsw i32 %13, %14
%16 = ashr i32 %15, 1
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [145 x i32], [145 x i32]* @am_choose_hash_prime.p, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %2
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %12
%24 = load i32, i32* %6
store i32 %24, i32* %4
br label %27
25: ; preds = %12
%26 = load i32, i32* %6
store i32 %26, i32* %5
br label %27
27: ; preds = %25, %23
br label %7
28: ; preds = %7
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %31, %28
br label %35
35: ; preds = %47, %34
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 145
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [145 x i32], [145 x i32]* @am_choose_hash_prime.p, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = load i32, i32* %2
%44 = icmp slt i32 %42, %43
br label %45
45: ; preds = %38, %35
%46 = phi i1 [ false, %35 ], [ %44, %38 ]
br i1 %46, label %47, label %50
47: ; preds = %45
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %35
50: ; preds = %45
%51 = load i32, i32* %4
%52 = icmp slt i32 %51, 144
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i32, i32* %2
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [145 x i32], [145 x i32]* @am_choose_hash_prime.p, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = icmp sle i32 %55, %59
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [145 x i32], [145 x i32]* @am_choose_hash_prime.p, i64 0, i64 %64
%66 = load i32, i32* %65
ret i32 %66
}

LLVM IR (-O2):
@am_choose_hash_prime.p = internal unnamed_addr constant [145 x i32] [i32 1103, i32 1217, i32 1361, i32 1499, i32 1657, i32 1823, i32 2011, i32 2213, i32 2437, i32 2683, i32 2953, i32 3251, i32 3581, i32 3943, i32 4339, i32 4783, i32 5273, i32 5801, i32 6389, i32 7039, i32 7753, i32 8537, i32 9391, i32 10331, i32 11369, i32 12511, i32 13763, i32 15149, i32 16673, i32 18341, i32 20177, i32 22229, i32 24469, i32 26921, i32 29629, i32 32603, i32 35869, i32 39461, i32 43411, i32 47777, i32 52561, i32 57829, i32 63617, i32 69991, i32 76991, i32 84691, i32 93169, i32 102497, i32 112757, i32 124067, i32 136481, i32 150131, i32 165161, i32 181693, i32 199873, i32 219871, i32 241861, i32 266051, i32 292661, i32 321947, i32 354143, i32 389561, i32 428531, i32 471389, i32 518533, i32 570389, i32 627433, i32 690187, i32 759223, i32 835207, i32 918733, i32 1010617, i32 1111687, i32 1222889, i32 1345207, i32 1479733, i32 1627723, i32 1790501, i32 1969567, i32 2166529, i32 2383219, i32 2621551, i32 2883733, i32 3172123, i32 3489347, i32 3838283, i32 4222117, i32 4644329, i32 5108767, i32 5619667, i32 6181639, i32 6799811, i32 7479803, i32 8227787, i32 9050599, i32 9955697, i32 10951273, i32 12046403, i32 13251047, i32 14576161, i32 16033799, i32 17637203, i32 19400929, i32 21341053, i32 23475161, i32 25822679, i32 28404989, i32 31245491, i32 34370053, i32 37807061, i32 41587807, i32 45746593, i32 50321261, i32 55353391, i32 60888739, i32 66977621, i32 73675391, i32 81042947, i32 89147249, i32 98061979, i32 107868203, i32 118655027, i32 130520531, i32 143572609, i32 157929907, i32 173722907, i32 191095213, i32 210204763, i32 231225257, i32 254347801, i32 279782593, i32 307760897, i32 338536987, i32 372390691, i32 409629809, i32 450592801, i32 495652109, i32 545217341, i32 599739083, i32 659713007, i32 725684317, i32 798252779, i32 878078057, i32 965885863, i32 1062474559]
define i32 @am_choose_hash_prime(i32 %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ -1, %1 ], [ %12, %2 ]
%4 = phi i32 [ 145, %1 ], [ %11, %2 ]
%5 = add nsw i32 %3, %4
%6 = ashr i32 %5, 1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [145 x i32], [145 x i32]* @am_choose_hash_prime.p, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = icmp sgt i32 %9, %0
%11 = select i1 %10, i32 %6, i32 %4
%12 = select i1 %10, i32 %3, i32 %6
%13 = sub nsw i32 %11, %12
%14 = icmp sgt i32 %13, 1
br i1 %14, label %2, label %15
15: ; preds = %2
%16 = lshr i32 %12, 31
%17 = add i32 %16, %12
%18 = icmp slt i32 %17, 145
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = sext i32 %17 to i64
br label %21
21: ; preds = %19, %26
%22 = phi i64 [ %20, %19 ], [ %27, %26 ]
%23 = getelementptr inbounds [145 x i32], [145 x i32]* @am_choose_hash_prime.p, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = icmp slt i32 %24, %0
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = add nsw i64 %22, 1
%28 = trunc i64 %27 to i32
%29 = icmp eq i32 %28, 145
br i1 %29, label %32, label %21
30: ; preds = %21
%31 = trunc i64 %22 to i32
br label %32
32: ; preds = %26, %30, %15
%33 = phi i32 [ %17, %15 ], [ %31, %30 ], [ 145, %26 ]
%34 = icmp slt i32 %33, 144
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = sext i32 %33 to i64
%38 = getelementptr inbounds [145 x i32], [145 x i32]* @am_choose_hash_prime.p, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = icmp sge i32 %39, %0
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
ret i32 %39
}