void blogic_incszbucket(unsigned int *cmdsz_buckets, unsigned int amount) {
  int index = 0;
  if (amount < 8 * 1024) {
    if (amount < 2 * 1024)
      index = (amount < 1 * 1024 ? 0 : 1);
    else
      index = (amount < 4 * 1024 ? 2 : 3);
  } else if (amount < 128 * 1024) {
    if (amount < 32 * 1024)
      index = (amount < 16 * 1024 ? 4 : 5);
    else
      index = (amount < 64 * 1024 ? 6 : 7);
  } else
    index = (amount < 256 * 1024 ? 8 : 9);
  cmdsz_buckets[index]++;
}


x86 assembly (clang, -O0):
<blogic_incszbucket>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x2000,-0xc(%rbp)
jae    1165 <blogic_incszbucket+0x65>
cmpl   $0x800,-0xc(%rbp)
jae    1147 <blogic_incszbucket+0x47>
mov    -0xc(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x400,%edx
cmovb  %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    1160 <blogic_incszbucket+0x60>
mov    -0xc(%rbp),%edx
mov    $0x3,%eax
mov    $0x2,%ecx
cmp    $0x1000,%edx
cmovb  %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11d9 <blogic_incszbucket+0xd9>
cmpl   $0x20000,-0xc(%rbp)
jae    11bb <blogic_incszbucket+0xbb>
cmpl   $0x8000,-0xc(%rbp)
jae    119d <blogic_incszbucket+0x9d>
mov    -0xc(%rbp),%edx
mov    $0x5,%eax
mov    $0x4,%ecx
cmp    $0x4000,%edx
cmovb  %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11b6 <blogic_incszbucket+0xb6>
mov    -0xc(%rbp),%edx
mov    $0x7,%eax
mov    $0x6,%ecx
cmp    $0x10000,%edx
cmovb  %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11d4 <blogic_incszbucket+0xd4>
mov    -0xc(%rbp),%edx
mov    $0x9,%eax
mov    $0x8,%ecx
cmp    $0x40000,%edx
cmovb  %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11d9 <blogic_incszbucket+0xd9>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<blogic_incszbucket>:
cmp    $0x1fff,%esi
ja     1120 <blogic_incszbucket+0x20>
cmp    $0x7ff,%esi
ja     113d <blogic_incszbucket+0x3d>
xor    %eax,%eax
cmp    $0x400,%esi
setae  %al
addl   $0x1,(%rdi,%rax,4)
ret
cmp    $0x1ffff,%esi
ja     114a <blogic_incszbucket+0x4a>
cmp    $0x7fff,%esi
ja     1157 <blogic_incszbucket+0x57>
cmp    $0x4000,%esi
mov    $0x5,%eax
jmp    1162 <blogic_incszbucket+0x62>
cmp    $0x1000,%esi
mov    $0x3,%eax
jmp    1162 <blogic_incszbucket+0x62>
cmp    $0x40000,%esi
mov    $0x9,%eax
jmp    1162 <blogic_incszbucket+0x62>
cmp    $0x10000,%esi
mov    $0x7,%eax
sbb    $0x0,%rax
addl   $0x1,(%rdi,%rax,4)
ret

LLVM IR (-O0):
define void @blogic_incszbucket(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %4
%7 = icmp ult i32 %6, 8192
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = load i32, i32* %4
%10 = icmp ult i32 %9, 2048
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load i32, i32* %4
%13 = icmp ult i32 %12, 1024
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 0, i32 1
store i32 %15, i32* %5
br label %21
16: ; preds = %8
%17 = load i32, i32* %4
%18 = icmp ult i32 %17, 4096
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 2, i32 3
store i32 %20, i32* %5
br label %21
21: ; preds = %16, %11
br label %45
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp ult i32 %23, 131072
br i1 %24, label %25, label %39
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp ult i32 %26, 32768
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* %4
%30 = icmp ult i32 %29, 16384
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 4, i32 5
store i32 %32, i32* %5
br label %38
33: ; preds = %25
%34 = load i32, i32* %4
%35 = icmp ult i32 %34, 65536
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 6, i32 7
store i32 %37, i32* %5
br label %38
38: ; preds = %33, %28
br label %44
39: ; preds = %22
%40 = load i32, i32* %4
%41 = icmp ult i32 %40, 262144
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 8, i32 9
store i32 %43, i32* %5
br label %44
44: ; preds = %39, %38
br label %45
45: ; preds = %44, %21
%46 = load i32*, i32** %3
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = add i32 %50, 1
store i32 %51, i32* %49
ret void
}

LLVM IR (-O2):
define void @blogic_incszbucket(i32* nocapture %0, i32 %1) {
%3 = icmp ult i32 %1, 8192
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = icmp ult i32 %1, 2048
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = icmp ugt i32 %1, 1023
%8 = zext i1 %7 to i64
br label %25
9: ; preds = %4
%10 = icmp ult i32 %1, 4096
%11 = select i1 %10, i64 2, i64 3
br label %25
12: ; preds = %2
%13 = icmp ult i32 %1, 131072
br i1 %13, label %14, label %22
14: ; preds = %12
%15 = icmp ult i32 %1, 32768
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = icmp ult i32 %1, 16384
%18 = select i1 %17, i64 4, i64 5
br label %25
19: ; preds = %14
%20 = icmp ult i32 %1, 65536
%21 = select i1 %20, i64 6, i64 7
br label %25
22: ; preds = %12
%23 = icmp ult i32 %1, 262144
%24 = select i1 %23, i64 8, i64 9
br label %25
25: ; preds = %22, %19, %16, %6, %9
%26 = phi i64 [ %8, %6 ], [ %11, %9 ], [ %18, %16 ], [ %21, %19 ], [ %24, %22 ]
%27 = getelementptr inbounds i32, i32* %0, i64 %26
%28 = load i32, i32* %27
%29 = add i32 %28, 1
store i32 %29, i32* %27
ret void
}