int L3_find_bitrate_index(int bitr, int mpegtype) {
  static long mpeg1[15] = {0,   32,  40,  48,  56,  64,  80, 96,
                           112, 128, 160, 192, 224, 256, 320};
  static long mpeg2[15] = {0,  8,  16, 24,  32,  40,  48, 56,
                           64, 80, 96, 112, 128, 144, 160};
  int i;
  if (mpegtype == 1) {
    for (i = 0; i < 15; i++)
      if (bitr == mpeg1[i])
        return i;
  } else {
    for (i = 0; i < 15; i++)
      if (bitr == mpeg2[i])
        return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<L3_find_bitrate_index>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1161 <L3_find_bitrate_index+0x61>
movl   $0x0,-0x10(%rbp)
cmpl   $0xf,-0x10(%rbp)
jge    115c <L3_find_bitrate_index+0x5c>
movslq -0x8(%rbp),%rax
movslq -0x10(%rbp),%rdx
lea    0x2efc(%rip),%rcx
cmp    (%rcx,%rdx,8),%rax
jne    1149 <L3_find_bitrate_index+0x49>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <L3_find_bitrate_index+0xb5>
jmp    114e <L3_find_bitrate_index+0x4e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    111b <L3_find_bitrate_index+0x1b>
jmp    11ae <L3_find_bitrate_index+0xae>
movl   $0x0,-0x10(%rbp)
cmpl   $0xf,-0x10(%rbp)
jge    11a9 <L3_find_bitrate_index+0xa9>
movslq -0x8(%rbp),%rax
movslq -0x10(%rbp),%rdx
lea    0x2f2f(%rip),%rcx
cmp    (%rcx,%rdx,8),%rax
jne    1196 <L3_find_bitrate_index+0x96>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b5 <L3_find_bitrate_index+0xb5>
jmp    119b <L3_find_bitrate_index+0x9b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1168 <L3_find_bitrate_index+0x68>
jmp    11ae <L3_find_bitrate_index+0xae>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<L3_find_bitrate_index>:
cmp    $0x1,%esi
jne    1135 <L3_find_bitrate_index+0x35>
test   %edi,%edi
je     1157 <L3_find_bitrate_index+0x57>
cmp    $0x6f,%edi
jg     115a <L3_find_bitrate_index+0x5a>
add    $0xffffffe0,%edi
cmp    $0x40,%edi
ja     11e7 <L3_find_bitrate_index+0xe7>
mov    $0x1,%eax
lea    0xeda(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    $0x2,%eax
ret
test   %edi,%edi
je     1157 <L3_find_bitrate_index+0x57>
add    $0xfffffff8,%edi
rol    $0x1d,%edi
mov    $0xffffffff,%eax
cmp    $0x14,%edi
jae    1156 <L3_find_bitrate_index+0x56>
movslq %edi,%rax
lea    0xfb1(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret
xor    %eax,%eax
ret
cmp    $0xbf,%edi
jle    1180 <L3_find_bitrate_index+0x80>
cmp    $0xff,%edi
jg     119b <L3_find_bitrate_index+0x9b>
cmp    $0xc0,%edi
je     11cf <L3_find_bitrate_index+0xcf>
cmp    $0xe0,%edi
jne    11e7 <L3_find_bitrate_index+0xe7>
mov    $0xc,%eax
ret
cmp    $0x70,%edi
je     11d5 <L3_find_bitrate_index+0xd5>
cmp    $0x80,%edi
je     11db <L3_find_bitrate_index+0xdb>
cmp    $0xa0,%edi
jne    11e7 <L3_find_bitrate_index+0xe7>
mov    $0xa,%eax
ret
cmp    $0x100,%edi
je     11e1 <L3_find_bitrate_index+0xe1>
cmp    $0x140,%edi
jne    11e7 <L3_find_bitrate_index+0xe7>
mov    $0xe,%eax
ret
mov    $0x3,%eax
ret
mov    $0x4,%eax
ret
mov    $0x5,%eax
ret
mov    $0x6,%eax
ret
mov    $0x7,%eax
ret
mov    $0xb,%eax
ret
mov    $0x8,%eax
ret
mov    $0x9,%eax
ret
mov    $0xd,%eax
ret
mov    $0xffffffff,%eax
ret

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

LLVM IR (-O2):
@switch.table.L3_find_bitrate_index = [20 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 -1, i32 9, i32 -1, i32 10, i32 -1, i32 11, i32 -1, i32 12, i32 -1, i32 13, i32 -1, i32 14]
define i32 @L3_find_bitrate_index(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 1
%4 = icmp eq i32 %0, 0
br i1 %3, label %6, label %5
5: ; preds = %2
br i1 %4, label %30, label %9
6: ; preds = %2
br i1 %4, label %30, label %7
7: ; preds = %6
switch i32 %0, label %8 [
i32 32, label %30
i32 40, label %13
i32 48, label %14
i32 56, label %15
i32 64, label %16
i32 80, label %17
i32 96, label %18
i32 112, label %19
i32 128, label %20
i32 160, label %21
i32 192, label %22
i32 224, label %23
i32 256, label %24
i32 320, label %25
]
8: ; preds = %7
br label %30
9: ; preds = %5
%10 = add i32 %0, -8
%11 = call i32 @llvm.fshl.i32(i32 %10, i32 %10, i32 29)
%12 = icmp ult i32 %11, 20
br i1 %12, label %26, label %30
13: ; preds = %7
br label %30
14: ; preds = %7
br label %30
15: ; preds = %7
br label %30
16: ; preds = %7
br label %30
17: ; preds = %7
br label %30
18: ; preds = %7
br label %30
19: ; preds = %7
br label %30
20: ; preds = %7
br label %30
21: ; preds = %7
br label %30
22: ; preds = %7
br label %30
23: ; preds = %7
br label %30
24: ; preds = %7
br label %30
25: ; preds = %7
br label %30
26: ; preds = %9
%27 = sext i32 %11 to i64
%28 = getelementptr inbounds [20 x i32], [20 x i32]* @switch.table.L3_find_bitrate_index, i64 0, i64 %27
%29 = load i32, i32* %28
br label %30
30: ; preds = %9, %26, %7, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %5, %6, %8
%31 = phi i32 [ 0, %6 ], [ 1, %7 ], [ -1, %8 ], [ 0, %5 ], [ 2, %13 ], [ 3, %14 ], [ 4, %15 ], [ 5, %16 ], [ 6, %17 ], [ 7, %18 ], [ 8, %19 ], [ 9, %20 ], [ 10, %21 ], [ 11, %22 ], [ 12, %23 ], [ 13, %24 ], [ 14, %25 ], [ %29, %26 ], [ -1, %9 ]
ret i32 %31
}