#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 */
size_t __nbucket_roundup(size_t size) {
  if (size < 8U)
    return (8U);
  size--;
  size |= size >> 1;
  size |= size >> 2;
  size |= size >> 4;
  size |= size >> 8;
  size |= size >> 16;
  size |= size >> 32;
  size++;
  return (size);
}


x86 assembly (clang, -O0):
<__nbucket_roundup>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x8,-0x10(%rbp)
jae    1120 <__nbucket_roundup+0x20>
movq   $0x8,-0x8(%rbp)
jmp    11a0 <__nbucket_roundup+0xa0>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x1,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x2,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x4,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x20,%rax
or     -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__nbucket_roundup>:
mov    $0x8,%eax
cmp    $0x8,%rdi
jb     114e <__nbucket_roundup+0x4e>
add    $0xffffffffffffffff,%rdi
mov    %rdi,%rax
shr    %rax
or     %rdi,%rax
mov    %rax,%rcx
shr    $0x2,%rcx
or     %rax,%rcx
mov    %rcx,%rax
shr    $0x4,%rax
or     %rcx,%rax
mov    %rax,%rcx
shr    $0x8,%rcx
or     %rax,%rcx
mov    %rcx,%rdx
shr    $0x10,%rdx
or     %rcx,%rdx
mov    %rdx,%rax
shr    $0x20,%rax
or     %rdx,%rax
add    $0x1,%rax
ret

LLVM IR (-O0):
define i64 @__nbucket_roundup(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i64, i64* %3
%5 = icmp ult i64 %4, 8
br i1 %5, label %6, label %7
6: ; preds = %1
store i64 8, i64* %2
br label %37
7: ; preds = %1
%8 = load i64, i64* %3
%9 = add i64 %8, -1
store i64 %9, i64* %3
%10 = load i64, i64* %3
%11 = lshr i64 %10, 1
%12 = load i64, i64* %3
%13 = or i64 %12, %11
store i64 %13, i64* %3
%14 = load i64, i64* %3
%15 = lshr i64 %14, 2
%16 = load i64, i64* %3
%17 = or i64 %16, %15
store i64 %17, i64* %3
%18 = load i64, i64* %3
%19 = lshr i64 %18, 4
%20 = load i64, i64* %3
%21 = or i64 %20, %19
store i64 %21, i64* %3
%22 = load i64, i64* %3
%23 = lshr i64 %22, 8
%24 = load i64, i64* %3
%25 = or i64 %24, %23
store i64 %25, i64* %3
%26 = load i64, i64* %3
%27 = lshr i64 %26, 16
%28 = load i64, i64* %3
%29 = or i64 %28, %27
store i64 %29, i64* %3
%30 = load i64, i64* %3
%31 = lshr i64 %30, 32
%32 = load i64, i64* %3
%33 = or i64 %32, %31
store i64 %33, i64* %3
%34 = load i64, i64* %3
%35 = add i64 %34, 1
store i64 %35, i64* %3
%36 = load i64, i64* %3
store i64 %36, i64* %2
br label %37
37: ; preds = %7, %6
%38 = load i64, i64* %2
ret i64 %38
}

LLVM IR (-O2):
define i64 @__nbucket_roundup(i64 %0) {
%2 = icmp ult i64 %0, 8
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = add i64 %0, -1
%5 = lshr i64 %4, 1
%6 = or i64 %5, %4
%7 = lshr i64 %6, 2
%8 = or i64 %7, %6
%9 = lshr i64 %8, 4
%10 = or i64 %9, %8
%11 = lshr i64 %10, 8
%12 = or i64 %11, %10
%13 = lshr i64 %12, 16
%14 = or i64 %13, %12
%15 = lshr i64 %14, 32
%16 = or i64 %15, %14
%17 = add i64 %16, 1
br label %18
18: ; preds = %1, %3
%19 = phi i64 [ %17, %3 ], [ 8, %1 ]
ret i64 %19
}