#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 uint64_t;

/* Variables and functions */
int ___constant_clz64(uint64_t x) {
  int n;
  if (x == 0)
    return 64;
  n = 1;
  if ((x >> 32) == 0) {
    n += 32;
    x <<= 32;
  }
  if ((x >> 48) == 0) {
    n += 16;
    x <<= 16;
  }
  if ((x >> 56) == 0) {
    n += 8;
    x <<= 8;
  }
  if ((x >> 60) == 0) {
    n += 4;
    x <<= 4;
  }
  if ((x >> 62) == 0) {
    n += 2;
    x <<= 2;
  }
  n -= (x >> 63);
  return n;
}


x86 assembly (clang, -O0):
<___constant_clz64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    111d <___constant_clz64+0x1d>
movl   $0x40,-0x4(%rbp)
jmp    11fb <___constant_clz64+0xfb>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
cmp    $0x0,%eax
jne    114d <___constant_clz64+0x4d>
mov    -0xc(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
cmp    $0x0,%eax
jne    1172 <___constant_clz64+0x72>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
cmp    $0x0,%eax
jne    1197 <___constant_clz64+0x97>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3c,%ecx
sar    %cl,%eax
cmp    $0x0,%eax
jne    11bc <___constant_clz64+0xbc>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e,%ecx
sar    %cl,%eax
cmp    $0x0,%eax
jne    11e1 <___constant_clz64+0xe1>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3f,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<___constant_clz64>:
mov    $0x40,%eax
ret

LLVM IR (-O0):
define i32 @___constant_clz64(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 64, i32* %2
br label %59
8: ; preds = %1
store i32 1, i32* %4
%9 = load i32, i32* %3
%10 = ashr i32 %9, 32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 32
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = shl i32 %15, 32
store i32 %16, i32* %3
br label %17
17: ; preds = %12, %8
%18 = load i32, i32* %3
%19 = ashr i32 %18, 48
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 16
store i32 %23, i32* %4
%24 = load i32, i32* %3
%25 = shl i32 %24, 16
store i32 %25, i32* %3
br label %26
26: ; preds = %21, %17
%27 = load i32, i32* %3
%28 = ashr i32 %27, 56
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 8
store i32 %32, i32* %4
%33 = load i32, i32* %3
%34 = shl i32 %33, 8
store i32 %34, i32* %3
br label %35
35: ; preds = %30, %26
%36 = load i32, i32* %3
%37 = ashr i32 %36, 60
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 4
store i32 %41, i32* %4
%42 = load i32, i32* %3
%43 = shl i32 %42, 4
store i32 %43, i32* %3
br label %44
44: ; preds = %39, %35
%45 = load i32, i32* %3
%46 = ashr i32 %45, 62
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 2
store i32 %50, i32* %4
%51 = load i32, i32* %3
%52 = shl i32 %51, 2
store i32 %52, i32* %3
br label %53
53: ; preds = %48, %44
%54 = load i32, i32* %3
%55 = ashr i32 %54, 63
%56 = load i32, i32* %4
%57 = sub nsw i32 %56, %55
store i32 %57, i32* %4
%58 = load i32, i32* %4
store i32 %58, i32* %2
br label %59
59: ; preds = %53, %7
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
define i32 @___constant_clz64(i32 %0) {
ret i32 64
}