int main() {
  volatile long a = 0x0000000000000001L;
  if (__builtin_clzl(a) != sizeof(long long) * 8 - 1) {
    return 1;
  }
  volatile long b = 0x000000006000beefL;
  if (__builtin_clzl(b) != sizeof(long long) * 8 - 31) {
    return 1;
  }
  volatile long c = 0x000000008abc0000L;
  if (__builtin_clzl(c) != sizeof(long long) * 8 - 32) {
    return 1;
  }
  volatile long d = 0x6000beef00000000L;
  if (__builtin_clzl(d) != sizeof(long long) * 8 - 63) {
    return 1;
  }
  volatile long e = 0x8abc000000000000L;
  if (__builtin_clzl(e) != sizeof(long long) * 8 - 64) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%rax
bsr    %rax,%rax
xor    $0x3f,%rax
cltq
cmp    $0x3f,%rax
je     1137 <main+0x37>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xfb>
movq   $0x6000beef,-0x18(%rbp)
60
mov    -0x18(%rbp),%rax
bsr    %rax,%rax
xor    $0x3f,%rax
cltq
cmp    $0x21,%rax
je     1163 <main+0x63>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xfb>
mov    $0x8abc0000,%eax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
bsr    %rax,%rax
xor    $0x3f,%rax
cltq
cmp    $0x20,%rax
je     1190 <main+0x90>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xfb>
movabs $0x6000beef00000000,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
bsr    %rax,%rax
xor    $0x3f,%rax
cltq
cmp    $0x1,%rax
je     11c2 <main+0xc2>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xfb>
movabs $0x8abc000000000000,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
bsr    %rax,%rax
xor    $0x3f,%rax
cltq
cmp    $0x0,%rax
je     11f4 <main+0xf4>
movl   $0x1,-0x4(%rbp)
jmp    11fb <main+0xfb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movq   $0x1,-0x8(%rsp)
mov    -0x8(%rsp),%rcx
mov    $0x1,%eax
cmp    $0x1,%rcx
jne    11a1 <main+0xa1>
movq   $0x6000beef,-0x10(%rsp)
mov    $0xffffffffc0000000,%rcx
and    -0x10(%rsp),%rcx
mov    $0x1,%eax
cmp    $0x40000000,%rcx
jne    11a1 <main+0xa1>
mov    $0x80000000,%eax
or     $0xabc0000,%rax
mov    %rax,-0x18(%rsp)
mov    -0x18(%rsp),%rcx
shr    $0x1f,%rcx
mov    $0x1,%eax
cmp    $0x1,%rcx
jne    11a1 <main+0xa1>
movabs $0x6000beef00000000,%rax
mov    %rax,-0x20(%rsp)
mov    -0x20(%rsp),%rcx
shr    $0x3e,%rcx
mov    $0x1,%eax
cmp    $0x1,%ecx
jne    11a1 <main+0xa1>
movabs $0x8abc000000000000,%rax
mov    %rax,-0x28(%rsp)
mov    -0x28(%rsp),%rax
shr    $0x3f,%rax
xor    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store volatile i64 1, i64* %2
%7 = load volatile i64, i64* %2
%8 = call i64 @llvm.ctlz.i64(i64 %7, i1 true)
%9 = trunc i64 %8 to i32
%10 = sext i32 %9 to i64
%11 = icmp ne i64 %10, 63
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 1, i32* %1
br label %42
13: ; preds = %0
store volatile i64 1610661615, i64* %3
%14 = load volatile i64, i64* %3
%15 = call i64 @llvm.ctlz.i64(i64 %14, i1 true)
%16 = trunc i64 %15 to i32
%17 = sext i32 %16 to i64
%18 = icmp ne i64 %17, 33
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 1, i32* %1
br label %42
20: ; preds = %13
store volatile i64 2327576576, i64* %4
%21 = load volatile i64, i64* %4
%22 = call i64 @llvm.ctlz.i64(i64 %21, i1 true)
%23 = trunc i64 %22 to i32
%24 = sext i32 %23 to i64
%25 = icmp ne i64 %24, 32
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 1, i32* %1
br label %42
27: ; preds = %20
store volatile i64 6917738961347543040, i64* %5
%28 = load volatile i64, i64* %5
%29 = call i64 @llvm.ctlz.i64(i64 %28, i1 true)
%30 = trunc i64 %29 to i32
%31 = sext i32 %30 to i64
%32 = icmp ne i64 %31, 1
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 1, i32* %1
br label %42
34: ; preds = %27
store volatile i64 -8449878800853893120, i64* %6
%35 = load volatile i64, i64* %6
%36 = call i64 @llvm.ctlz.i64(i64 %35, i1 true)
%37 = trunc i64 %36 to i32
%38 = sext i32 %37 to i64
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 1, i32* %1
br label %42
41: ; preds = %34
store i32 0, i32* %1
br label %42
42: ; preds = %41, %40, %33, %26, %19, %12
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %1 to i8*
store volatile i64 1, i64* %1
%7 = load volatile i64, i64* %1
%8 = icmp eq i64 %7, 1
br i1 %8, label %9, label %36
9: ; preds = %0
%10 = bitcast i64* %2 to i8*
store volatile i64 1610661615, i64* %2
%11 = load volatile i64, i64* %2
%12 = and i64 %11, -1073741824
%13 = icmp eq i64 %12, 1073741824
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = bitcast i64* %3 to i8*
store volatile i64 2327576576, i64* %3
%16 = load volatile i64, i64* %3
%17 = and i64 %16, -2147483648
%18 = icmp eq i64 %17, 2147483648
br i1 %18, label %19, label %32
19: ; preds = %14
%20 = bitcast i64* %4 to i8*
store volatile i64 6917738961347543040, i64* %4
%21 = load volatile i64, i64* %4
%22 = and i64 %21, -4611686018427387904
%23 = icmp eq i64 %22, 4611686018427387904
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = bitcast i64* %5 to i8*
store volatile i64 -8449878800853893120, i64* %5
%26 = load volatile i64, i64* %5
%27 = lshr i64 %26, 63
%28 = trunc i64 %27 to i32
%29 = xor i32 %28, 1
br label %30
30: ; preds = %19, %24
%31 = phi i32 [ %29, %24 ], [ 1, %19 ]
br label %32
32: ; preds = %14, %30
%33 = phi i32 [ %31, %30 ], [ 1, %14 ]
br label %34
34: ; preds = %9, %32
%35 = phi i32 [ %33, %32 ], [ 1, %9 ]
br label %36
36: ; preds = %0, %34
%37 = phi i32 [ %35, %34 ], [ 1, %0 ]
ret i32 %37
}