int nearestBitrateFullIndex(const int bitrate) {
  int index;
  const int bitrate_table[] = {8,  16,  24,  32,  40,  48,  56,  64, 80,
                               96, 112, 128, 160, 192, 224, 256, 320};
  int lower_range = 0, lower_range_kbps = 0, upper_range = 0,
      upper_range_kbps = 0;
  int b;
  upper_range_kbps = bitrate_table[16];
  upper_range = 16;
  lower_range_kbps = bitrate_table[16];
  lower_range = 16;
  for (b = 0; b < 16; b++) {
    if ((((bitrate) > (bitrate_table[b + 1]) ? (bitrate)
                                             : (bitrate_table[b + 1]))) !=
        bitrate) {
      upper_range_kbps = bitrate_table[b + 1];
      upper_range = b + 1;
      lower_range_kbps = bitrate_table[b];
      lower_range = (b);
      break;
    }
  }
  if ((upper_range_kbps - bitrate) > (bitrate - lower_range_kbps))
    index = lower_range;
  else
    index = upper_range;
  return index;
}


x86 assembly (clang, -O0):
<nearestBitrateFullIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeda(%rip),%rsi
mov    $0x44,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x60(%rbp)
movl   $0x10,-0x5c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x58(%rbp)
movl   $0x10,-0x54(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x10,-0x64(%rbp)
jge    11f4 <nearestBitrateFullIndex+0xe4>
mov    -0x4(%rbp),%eax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x50(%rbp,%rcx,4),%eax
jle    1198 <nearestBitrateFullIndex+0x88>
mov    -0x4(%rbp),%eax
mov    %eax,-0x68(%rbp)
jmp    11a7 <nearestBitrateFullIndex+0x97>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     11e1 <nearestBitrateFullIndex+0xd1>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x60(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
movslq -0x64(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %eax,-0x58(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    11f4 <nearestBitrateFullIndex+0xe4>
jmp    11e6 <nearestBitrateFullIndex+0xd6>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    116d <nearestBitrateFullIndex+0x5d>
mov    -0x60(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0x58(%rbp),%ecx
cmp    %ecx,%eax
jle    1213 <nearestBitrateFullIndex+0x103>
mov    -0x54(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1219 <nearestBitrateFullIndex+0x109>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nearestBitrateFullIndex>:
cmp    $0x10,%edi
jge    1117 <nearestBitrateFullIndex+0x17>
xor    %ecx,%ecx
mov    $0x10,%edx
mov    $0x1,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x18,%edi
jae    1131 <nearestBitrateFullIndex+0x31>
mov    $0x1,%ecx
mov    $0x18,%edx
mov    $0x2,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x20,%edi
jae    114b <nearestBitrateFullIndex+0x4b>
mov    $0x2,%ecx
mov    $0x20,%edx
mov    $0x3,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x28,%edi
jae    1165 <nearestBitrateFullIndex+0x65>
mov    $0x3,%ecx
mov    $0x28,%edx
mov    $0x4,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x30,%edi
jae    117f <nearestBitrateFullIndex+0x7f>
mov    $0x4,%ecx
mov    $0x30,%edx
mov    $0x5,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x38,%edi
jae    1199 <nearestBitrateFullIndex+0x99>
mov    $0x5,%ecx
mov    $0x38,%edx
mov    $0x6,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x40,%edi
jae    11b3 <nearestBitrateFullIndex+0xb3>
mov    $0x6,%ecx
mov    $0x40,%edx
mov    $0x7,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x50,%edi
jae    11cd <nearestBitrateFullIndex+0xcd>
mov    $0x7,%ecx
mov    $0x50,%edx
mov    $0x8,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x60,%edi
jae    11e7 <nearestBitrateFullIndex+0xe7>
mov    $0x8,%ecx
mov    $0x60,%edx
mov    $0x9,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x70,%edi
jae    1201 <nearestBitrateFullIndex+0x101>
mov    $0x9,%ecx
mov    $0x70,%edx
mov    $0xa,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x80,%edi
jae    121e <nearestBitrateFullIndex+0x11e>
mov    $0xa,%ecx
mov    $0x80,%edx
mov    $0xb,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0xa0,%edi
jae    1238 <nearestBitrateFullIndex+0x138>
mov    $0xb,%ecx
mov    $0xa0,%edx
mov    $0xc,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0xc0,%edi
jae    1252 <nearestBitrateFullIndex+0x152>
mov    $0xc,%ecx
mov    $0xc0,%edx
mov    $0xd,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0xe0,%edi
jae    126c <nearestBitrateFullIndex+0x16c>
mov    $0xd,%ecx
mov    $0xe0,%edx
mov    $0xe,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
cmp    $0x100,%edi
jae    1286 <nearestBitrateFullIndex+0x186>
mov    $0xe,%ecx
mov    $0x100,%edx
mov    $0xf,%r8d
jmp    12a8 <nearestBitrateFullIndex+0x1a8>
mov    $0xf,%ecx
mov    $0x140,%edx
mov    $0x10,%r8d
mov    $0x10,%eax
mov    $0x140,%esi
cmp    $0x13f,%edi
ja     12b6 <nearestBitrateFullIndex+0x1b6>
mov    %ecx,%eax
lea    0xd4f(%rip),%rsi
mov    (%rsi,%rax,4),%esi
mov    %ecx,%eax
sub    %edi,%edx
sub    %esi,%edi
cmp    %edi,%edx
cmovle %r8d,%eax
ret

LLVM IR (-O0):
@__const.nearestBitrateFullIndex.bitrate_table = [17 x i32] [i32 8, i32 16, i32 24, i32 32, i32 40, i32 48, i32 56, i32 64, i32 80, i32 96, i32 112, i32 128, i32 160, i32 192, i32 224, i32 256, i32 320]
define i32 @nearestBitrateFullIndex(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [17 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %2
%10 = bitcast [17 x i32]* %4 to i8*
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%11 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 16
%12 = load i32, i32* %11
store i32 %12, i32* %8
store i32 16, i32* %7
%13 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 16
%14 = load i32, i32* %13
store i32 %14, i32* %6
store i32 16, i32* %5
store i32 0, i32* %9
br label %15
15: ; preds = %52, %1
%16 = load i32, i32* %9
%17 = icmp slt i32 %16, 16
br i1 %17, label %18, label %55
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %9
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = icmp sgt i32 %19, %24
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = load i32, i32* %2
br label %34
28: ; preds = %18
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 %31
%33 = load i32, i32* %32
br label %34
34: ; preds = %28, %26
%35 = phi i32 [ %27, %26 ], [ %33, %28 ]
%36 = load i32, i32* %2
%37 = icmp ne i32 %35, %36
br i1 %37, label %38, label %51
38: ; preds = %34
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 %41
%43 = load i32, i32* %42
store i32 %43, i32* %8
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [17 x i32], [17 x i32]* %4, i64 0, i64 %47
%49 = load i32, i32* %48
store i32 %49, i32* %6
%50 = load i32, i32* %9
store i32 %50, i32* %5
br label %55
51: ; preds = %34
br label %52
52: ; preds = %51
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %15
55: ; preds = %38, %15
%56 = load i32, i32* %8
%57 = load i32, i32* %2
%58 = sub nsw i32 %56, %57
%59 = load i32, i32* %2
%60 = load i32, i32* %6
%61 = sub nsw i32 %59, %60
%62 = icmp sgt i32 %58, %61
br i1 %62, label %63, label %65
63: ; preds = %55
%64 = load i32, i32* %5
store i32 %64, i32* %3
br label %67
65: ; preds = %55
%66 = load i32, i32* %7
store i32 %66, i32* %3
br label %67
67: ; preds = %65, %63
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@__const.nearestBitrateFullIndex.bitrate_table = [17 x i32] [i32 8, i32 16, i32 24, i32 32, i32 40, i32 48, i32 56, i32 64, i32 80, i32 96, i32 112, i32 128, i32 160, i32 192, i32 224, i32 256, i32 320]
define i32 @nearestBitrateFullIndex(i32 %0) {
%2 = icmp slt i32 %0, 16
br i1 %2, label %33, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 24
br i1 %4, label %33, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 32
br i1 %6, label %33, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 40
br i1 %8, label %33, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 48
br i1 %10, label %33, label %11
11: ; preds = %9
%12 = icmp ult i32 %0, 56
br i1 %12, label %33, label %13
13: ; preds = %11
%14 = icmp ult i32 %0, 64
br i1 %14, label %33, label %15
15: ; preds = %13
%16 = icmp ult i32 %0, 80
br i1 %16, label %33, label %17
17: ; preds = %15
%18 = icmp ult i32 %0, 96
br i1 %18, label %33, label %19
19: ; preds = %17
%20 = icmp ult i32 %0, 112
br i1 %20, label %33, label %21
21: ; preds = %19
%22 = icmp ult i32 %0, 128
br i1 %22, label %33, label %23
23: ; preds = %21
%24 = icmp ult i32 %0, 160
br i1 %24, label %33, label %25
25: ; preds = %23
%26 = icmp ult i32 %0, 192
br i1 %26, label %33, label %27
27: ; preds = %25
%28 = icmp ult i32 %0, 224
br i1 %28, label %33, label %29
29: ; preds = %27
%30 = icmp ult i32 %0, 256
br i1 %30, label %33, label %31
31: ; preds = %29
%32 = icmp ult i32 %0, 320
br i1 %32, label %33, label %40
33: ; preds = %31, %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3, %1
%34 = phi i32 [ 1, %1 ], [ 2, %3 ], [ 3, %5 ], [ 4, %7 ], [ 5, %9 ], [ 6, %11 ], [ 7, %13 ], [ 8, %15 ], [ 9, %17 ], [ 10, %19 ], [ 11, %21 ], [ 12, %23 ], [ 13, %25 ], [ 14, %27 ], [ 15, %29 ], [ 16, %31 ]
%35 = phi i32 [ 16, %1 ], [ 24, %3 ], [ 32, %5 ], [ 40, %7 ], [ 48, %9 ], [ 56, %11 ], [ 64, %13 ], [ 80, %15 ], [ 96, %17 ], [ 112, %19 ], [ 128, %21 ], [ 160, %23 ], [ 192, %25 ], [ 224, %27 ], [ 256, %29 ], [ 320, %31 ]
%36 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 2, %5 ], [ 3, %7 ], [ 4, %9 ], [ 5, %11 ], [ 6, %13 ], [ 7, %15 ], [ 8, %17 ], [ 9, %19 ], [ 10, %21 ], [ 11, %23 ], [ 12, %25 ], [ 13, %27 ], [ 14, %29 ], [ 15, %31 ]
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds [17 x i32], [17 x i32]* @__const.nearestBitrateFullIndex.bitrate_table, i64 0, i64 %37
%39 = load i32, i32* %38
br label %40
40: ; preds = %31, %33
%41 = phi i32 [ %36, %33 ], [ 16, %31 ]
%42 = phi i32 [ %39, %33 ], [ 320, %31 ]
%43 = phi i32 [ %34, %33 ], [ 16, %31 ]
%44 = phi i32 [ %35, %33 ], [ 320, %31 ]
%45 = sub nsw i32 %44, %0
%46 = sub nsw i32 %0, %42
%47 = icmp sgt i32 %45, %46
%48 = select i1 %47, i32 %41, i32 %43
ret i32 %48
}