#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 var_size_u64(uint64_t v) {
  if (v < 177)
    return 1;
  else if (v < 16561)
    return 2;
  else if (v < 540849)
    return 3;
  int i = 0;
  do {
    v >>= 8;
    i++;
  } while (v);
  return i + 1;
}


x86 assembly (clang, -O0):
<var_size_u64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0xb1,-0x8(%rbp)
jge    1120 <var_size_u64+0x20>
movl   $0x1,-0x4(%rbp)
jmp    1188 <var_size_u64+0x88>
cmpl   $0x40b1,-0x8(%rbp)
jge    1139 <var_size_u64+0x39>
movl   $0x2,-0x4(%rbp)
jmp    1188 <var_size_u64+0x88>
cmpl   $0x840b1,-0x8(%rbp)
jge    1152 <var_size_u64+0x52>
movl   $0x3,-0x4(%rbp)
jmp    1188 <var_size_u64+0x88>
jmp    1157 <var_size_u64+0x57>
jmp    115c <var_size_u64+0x5c>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1163 <var_size_u64+0x63>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<var_size_u64>:
mov    $0x1,%eax
cmp    $0xb1,%edi
jl     1140 <var_size_u64+0x40>
mov    $0x2,%eax
cmp    $0x40b1,%edi
jb     1140 <var_size_u64+0x40>
mov    $0x3,%eax
cmp    $0x840b1,%edi
jb     1140 <var_size_u64+0x40>
mov    $0x1,%eax
mov    %edi,%ecx
xchg   %ax,%ax
sar    $0x8,%ecx
add    $0x1,%eax
cmp    $0xff,%edi
mov    %ecx,%edi
ja     1130 <var_size_u64+0x30>
ret

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

LLVM IR (-O2):
define i32 @var_size_u64(i32 %0) {
%2 = icmp slt i32 %0, 177
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 16561
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 540849
br i1 %6, label %15, label %7
7: ; preds = %5, %7
%8 = phi i32 [ %10, %7 ], [ %0, %5 ]
%9 = phi i32 [ %11, %7 ], [ 0, %5 ]
%10 = ashr i32 %8, 8
%11 = add nuw nsw i32 %9, 1
%12 = icmp ult i32 %8, 256
br i1 %12, label %13, label %7
13: ; preds = %7
%14 = add nuw nsw i32 %9, 2
br label %15
15: ; preds = %5, %3, %1, %13
%16 = phi i32 [ %14, %13 ], [ 1, %1 ], [ 2, %3 ], [ 3, %5 ]
ret i32 %16
}