#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 */

/* Variables and functions */
int INT32_MAX;
int kvs_hash_next_power(int hint) {
  int i, p;
  if (hint == INT32_MAX) {
    return hint;
  }
  for (i = 2, p = 1; i < 31; i++) {
    if (p >= hint) {
      return p;
    }
    p *= 2;
  }
  return p;
}


x86 assembly (clang, -O0):
<kvs_hash_next_power>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ecf(%rip),%rcx
cmp    (%rcx),%eax
jne    1124 <kvs_hash_next_power+0x24>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1170 <kvs_hash_next_power+0x70>
movl   $0x2,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1f,-0xc(%rbp)
jge    116a <kvs_hash_next_power+0x6a>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1153 <kvs_hash_next_power+0x53>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1170 <kvs_hash_next_power+0x70>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <kvs_hash_next_power+0x32>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<kvs_hash_next_power>:
mov    0x2ed9(%rip),%rax
cmp    %edi,(%rax)
jne    110e <kvs_hash_next_power+0xe>
mov    %edi,%eax
ret
mov    $0x1,%eax
cmp    $0x2,%edi
jl     113e <kvs_hash_next_power+0x3e>
mov    $0x2,%ecx
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %eax,%eax
cmp    $0x1d,%ecx
ja     113e <kvs_hash_next_power+0x3e>
add    $0x1,%ecx
cmp    %edi,%eax
jl     1130 <kvs_hash_next_power+0x30>
ret

LLVM IR (-O0):
@INT32_MAX = global i32 0
define i32 @kvs_hash_next_power(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = load i32, i32* @INT32_MAX
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i32, i32* %3
store i32 %10, i32* %2
br label %29
11: ; preds = %1
store i32 2, i32* %4
store i32 1, i32* %5
br label %12
12: ; preds = %24, %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 31
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = icmp sge i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i32, i32* %5
store i32 %20, i32* %2
br label %29
21: ; preds = %15
%22 = load i32, i32* %5
%23 = mul nsw i32 %22, 2
store i32 %23, i32* %5
br label %24
24: ; preds = %21
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %12
27: ; preds = %12
%28 = load i32, i32* %5
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %19, %9
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@INT32_MAX = global i32 0
define i32 @kvs_hash_next_power(i32 %0) {
%2 = load i32, i32* @INT32_MAX
%3 = icmp eq i32 %2, %0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %14
6: ; preds = %4, %6
%7 = phi i32 [ %9, %6 ], [ 1, %4 ]
%8 = phi i32 [ %10, %6 ], [ 2, %4 ]
%9 = shl nsw i32 %7, 1
%10 = add nuw nsw i32 %8, 1
%11 = icmp ult i32 %8, 30
%12 = icmp slt i32 %9, %0
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %6, label %14
14: ; preds = %6, %4, %1
%15 = phi i32 [ %0, %1 ], [ 1, %4 ], [ %9, %6 ]
ret i32 %15
}