#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 CHAR_BIT;
int my_clrsbll(unsigned long long x) {
  int i;
  int leading = (x >> CHAR_BIT * sizeof(unsigned long long) - 1) & 1;
  for (i = 1; i < CHAR_BIT * sizeof(unsigned long long); i++)
    if (((x >> ((CHAR_BIT * sizeof(unsigned long long)) - i - 1)) & 1) !=
        leading)
      break;
  return i - 1;
}


x86 assembly (clang, -O0):
<my_clrsbll>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2ecd(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
shr    %cl,%rax
and    $0x1,%rax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
movslq -0xc(%rbp),%rax
mov    0x2ea6(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
cmp    %rcx,%rax
jae    1193 <my_clrsbll+0x93>
mov    -0x8(%rbp),%rax
mov    0x2e8b(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
movslq -0xc(%rbp),%rdx
sub    %rdx,%rcx
sub    $0x1,%rcx
shr    %cl,%rax
and    $0x1,%rax
movslq -0x10(%rbp),%rcx
cmp    %rcx,%rax
je     1180 <my_clrsbll+0x80>
jmp    1193 <my_clrsbll+0x93>
jmp    1185 <my_clrsbll+0x85>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112f <my_clrsbll+0x2f>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_clrsbll>:
mov    0x2ed9(%rip),%rax
movslq (%rax),%rax
lea    0x0(,%rax,8),%rdx
lea    -0x1(%rdx),%ecx
mov    %rdi,%r9
shr    %cl,%r9
test   %rax,%rax
je     1165 <my_clrsbll+0x65>
cmp    $0x3,%rdx
mov    $0x2,%r8d
cmovae %rdx,%r8
add    $0xfffffffffffffffe,%rdx
mov    $0x1,%eax
nopw   0x0(%rax,%rax,1)
mov    %rdi,%rsi
mov    %edx,%ecx
shr    %cl,%rsi
xor    %r9d,%esi
test   $0x1,%sil
jne    1161 <my_clrsbll+0x61>
add    $0x1,%rax
add    $0xffffffffffffffff,%rdx
cmp    %rax,%r8
jne    1140 <my_clrsbll+0x40>
mov    %r8,%rax
add    $0xffffffff,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define i32 @my_clrsbll(i64 %0) {
%2 = load i32, i32* @CHAR_BIT
%3 = sext i32 %2 to i64
%4 = shl nsw i64 %3, 3
%5 = add nsw i64 %4, -1
%6 = lshr i64 %0, %5
%7 = icmp eq i32 %2, 0
br i1 %7, label %25, label %8
8: ; preds = %1
%9 = call i64 @llvm.umax.i64(i64 %4, i64 2)
br label %10
10: ; preds = %8, %18
%11 = phi i64 [ 1, %8 ], [ %19, %18 ]
%12 = xor i64 %11, -1
%13 = add nsw i64 %4, %12
%14 = lshr i64 %0, %13
%15 = xor i64 %14, %6
%16 = and i64 %15, 1
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = add nuw i64 %11, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %10
21: ; preds = %10, %18
%22 = phi i64 [ %9, %18 ], [ %11, %10 ]
%23 = trunc i64 %22 to i32
%24 = add i32 %23, -1
br label %25
25: ; preds = %21, %1
%26 = phi i32 [ 0, %1 ], [ %24, %21 ]
ret i32 %26
}