unsigned bucket(unsigned l) {
  if (l <= 1)
    return 1;
  else if (l <= 10)
    return 10;
  else if (l <= 50)
    return 50;
  else if (l <= 100)
    return 100;
  else if (l <= 250)
    return 250;
  else if (l <= 500)
    return 500;
  else if (l <= 1000)
    return 1000;
  else if (l <= 1500)
    return 1500;
  return 3000;
}


x86 assembly (clang, -O0):
<bucket>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
ja     111d <bucket+0x1d>
movl   $0x1,-0x4(%rbp)
jmp    11ed <bucket+0xed>
cmpl   $0xa,-0x8(%rbp)
ja     1133 <bucket+0x33>
movl   $0xa,-0x4(%rbp)
jmp    11ed <bucket+0xed>
cmpl   $0x32,-0x8(%rbp)
ja     1149 <bucket+0x49>
movl   $0x32,-0x4(%rbp)
jmp    11ed <bucket+0xed>
cmpl   $0x64,-0x8(%rbp)
ja     115f <bucket+0x5f>
movl   $0x64,-0x4(%rbp)
jmp    11ed <bucket+0xed>
cmpl   $0xfa,-0x8(%rbp)
ja     1178 <bucket+0x78>
movl   $0xfa,-0x4(%rbp)
jmp    11ed <bucket+0xed>
cmpl   $0x1f4,-0x8(%rbp)
ja     1191 <bucket+0x91>
movl   $0x1f4,-0x4(%rbp)
jmp    11ed <bucket+0xed>
cmpl   $0x3e8,-0x8(%rbp)
ja     11aa <bucket+0xaa>
movl   $0x3e8,-0x4(%rbp)
jmp    11ed <bucket+0xed>
cmpl   $0x5dc,-0x8(%rbp)
ja     11c3 <bucket+0xc3>
movl   $0x5dc,-0x4(%rbp)
jmp    11ed <bucket+0xed>
jmp    11c8 <bucket+0xc8>
jmp    11cd <bucket+0xcd>
jmp    11d2 <bucket+0xd2>
jmp    11d7 <bucket+0xd7>
jmp    11dc <bucket+0xdc>
jmp    11e1 <bucket+0xe1>
jmp    11e6 <bucket+0xe6>
movl   $0xbb8,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bucket>:
mov    $0x1,%eax
cmp    $0x2,%edi
jb     1162 <bucket+0x62>
mov    $0xa,%eax
cmp    $0xb,%edi
jb     1162 <bucket+0x62>
mov    $0x32,%eax
cmp    $0x33,%edi
jb     1162 <bucket+0x62>
mov    $0x64,%eax
cmp    $0x65,%edi
jb     1162 <bucket+0x62>
mov    $0xfa,%eax
cmp    $0xfb,%edi
jb     1162 <bucket+0x62>
mov    $0x1f4,%eax
cmp    $0x1f5,%edi
jb     1162 <bucket+0x62>
mov    $0x3e8,%eax
cmp    $0x3e9,%edi
jb     1162 <bucket+0x62>
cmp    $0x5dd,%edi
mov    $0xbb8,%ecx
mov    $0x5dc,%eax
cmovae %ecx,%eax
ret

LLVM IR (-O0):
define i32 @bucket(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp ule i32 %4, 1
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %43
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp ule i32 %8, 10
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 10, i32* %2
br label %43
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp ule i32 %12, 50
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 50, i32* %2
br label %43
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp ule i32 %16, 100
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 100, i32* %2
br label %43
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp ule i32 %20, 250
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 250, i32* %2
br label %43
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp ule i32 %24, 500
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 500, i32* %2
br label %43
27: ; preds = %23
%28 = load i32, i32* %3
%29 = icmp ule i32 %28, 1000
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 1000, i32* %2
br label %43
31: ; preds = %27
%32 = load i32, i32* %3
%33 = icmp ule i32 %32, 1500
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 1500, i32* %2
br label %43
35: ; preds = %31
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41
store i32 3000, i32* %2
br label %43
43: ; preds = %42, %34, %30, %26, %22, %18, %14, %10, %6
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
define i32 @bucket(i32 %0) {
%2 = icmp ult i32 %0, 2
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 11
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 51
br i1 %6, label %18, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 101
br i1 %8, label %18, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 251
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = icmp ult i32 %0, 501
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = icmp ult i32 %0, 1001
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = icmp ugt i32 %0, 1500
%17 = select i1 %16, i32 3000, i32 1500
br label %18
18: ; preds = %15, %13, %11, %9, %7, %5, %3, %1
%19 = phi i32 [ 1, %1 ], [ 10, %3 ], [ 50, %5 ], [ 100, %7 ], [ 250, %9 ], [ 500, %11 ], [ 1000, %13 ], [ %17, %15 ]
ret i32 %19
}