int choose_search_step(int delta_bits) {
  int step;
  if (delta_bits < 128)
    step = 1;
  else if (delta_bits < 256)
    step = 2;
  else if (delta_bits < 512)
    step = 4;
  else if (delta_bits < 768)
    step = 16;
  else if (delta_bits < 1024)
    step = 32;
  else
    step = 64;
  return step;
}


x86 assembly (clang, -O0):
<choose_search_step>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jge    1120 <choose_search_step+0x20>
movl   $0x1,-0x8(%rbp)
jmp    119f <choose_search_step+0x9f>
cmpl   $0x100,-0x4(%rbp)
jge    1139 <choose_search_step+0x39>
movl   $0x2,-0x8(%rbp)
jmp    119a <choose_search_step+0x9a>
cmpl   $0x200,-0x4(%rbp)
jge    1152 <choose_search_step+0x52>
movl   $0x4,-0x8(%rbp)
jmp    1195 <choose_search_step+0x95>
cmpl   $0x300,-0x4(%rbp)
jge    116b <choose_search_step+0x6b>
movl   $0x10,-0x8(%rbp)
jmp    1190 <choose_search_step+0x90>
cmpl   $0x400,-0x4(%rbp)
jge    1184 <choose_search_step+0x84>
movl   $0x20,-0x8(%rbp)
jmp    118b <choose_search_step+0x8b>
movl   $0x40,-0x8(%rbp)
jmp    1190 <choose_search_step+0x90>
jmp    1195 <choose_search_step+0x95>
jmp    119a <choose_search_step+0x9a>
jmp    119f <choose_search_step+0x9f>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<choose_search_step>:
mov    $0x1,%eax
cmp    $0x80,%edi
jl     1145 <choose_search_step+0x45>
mov    $0x2,%eax
cmp    $0x100,%edi
jb     1145 <choose_search_step+0x45>
mov    $0x4,%eax
cmp    $0x200,%edi
jb     1145 <choose_search_step+0x45>
mov    $0x10,%eax
cmp    $0x300,%edi
jb     1145 <choose_search_step+0x45>
xor    %eax,%eax
cmp    $0x400,%edi
setae  %al
shl    $0x5,%eax
add    $0x20,%eax
ret

LLVM IR (-O0):
define i32 @choose_search_step(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 128
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %3
br label %28
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 256
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 2, i32* %3
br label %27
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 512
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 4, i32* %3
br label %26
15: ; preds = %11
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 768
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 16, i32* %3
br label %25
19: ; preds = %15
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 1024
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 32, i32* %3
br label %24
23: ; preds = %19
store i32 64, i32* %3
br label %24
24: ; preds = %23, %22
br label %25
25: ; preds = %24, %18
br label %26
26: ; preds = %25, %14
br label %27
27: ; preds = %26, %10
br label %28
28: ; preds = %27, %6
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @choose_search_step(i32 %0) {
%2 = icmp slt i32 %0, 128
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 256
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 512
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 768
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 1024
%11 = select i1 %10, i32 32, i32 64
br label %12
12: ; preds = %9, %7, %5, %3, %1
%13 = phi i32 [ 1, %1 ], [ 2, %3 ], [ 4, %5 ], [ 16, %7 ], [ %11, %9 ]
ret i32 %13
}