int opus_packet_get_bandwidth(const unsigned char *data) {
  int bandwidth;
  if (data[0] & 0x80) {
    bandwidth = 1102 + ((data[0] >> 5) & 0x3);
    if (bandwidth == 1102)
      bandwidth = 1101;
  } else if ((data[0] & 0x60) == 0x60) {
    bandwidth = (data[0] & 0x10) ? 1105 : 1104;
  } else {
    bandwidth = 1101 + ((data[0] >> 5) & 0x3);
  }
  return bandwidth;
}


x86 assembly (clang, -O0):
<opus_packet_get_bandwidth>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     114b <opus_packet_get_bandwidth+0x4b>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
sar    $0x5,%eax
and    $0x3,%eax
add    $0x44e,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x44e,-0xc(%rbp)
jne    1146 <opus_packet_get_bandwidth+0x46>
movl   $0x44d,-0xc(%rbp)
jmp    119a <opus_packet_get_bandwidth+0x9a>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0x60,%eax
cmp    $0x60,%eax
jne    1180 <opus_packet_get_bandwidth+0x80>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edx
and    $0x10,%edx
mov    $0x450,%eax
mov    $0x451,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0xc(%rbp)
jmp    1195 <opus_packet_get_bandwidth+0x95>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
sar    $0x5,%eax
and    $0x3,%eax
add    $0x44d,%eax
mov    %eax,-0xc(%rbp)
jmp    119a <opus_packet_get_bandwidth+0x9a>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<opus_packet_get_bandwidth>:
movzbl (%rdi),%eax
test   $0x80,%al
jne    111f <opus_packet_get_bandwidth+0x1f>
mov    %eax,%ecx
not    %ecx
test   $0x60,%cl
jne    1136 <opus_packet_get_bandwidth+0x36>
and    $0x10,%eax
cmp    $0x1,%eax
mov    $0x451,%eax
sbb    $0x0,%eax
ret
shr    $0x5,%eax
and    $0x3,%eax
lea    0x44e(%rax),%ecx
test   %eax,%eax
mov    $0x44d,%eax
cmovne %ecx,%eax
ret
shr    $0x5,%eax
and    $0x3,%eax
add    $0x44d,%eax
ret

LLVM IR (-O0):
define i32 @opus_packet_get_bandwidth(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = and i32 %7, 128
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = ashr i32 %14, 5
%16 = and i32 %15, 3
%17 = add nsw i32 1102, %16
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 1102
br i1 %19, label %20, label %21
20: ; preds = %10
store i32 1101, i32* %3
br label %21
21: ; preds = %20, %10
br label %47
22: ; preds = %1
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = and i32 %26, 96
%28 = icmp eq i32 %27, 96
br i1 %28, label %29, label %38
29: ; preds = %22
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = and i32 %33, 16
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 1105, i32 1104
store i32 %37, i32* %3
br label %46
38: ; preds = %22
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = ashr i32 %42, 5
%44 = and i32 %43, 3
%45 = add nsw i32 1101, %44
store i32 %45, i32* %3
br label %46
46: ; preds = %38, %29
br label %47
47: ; preds = %46, %21
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
define i32 @opus_packet_get_bandwidth(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = zext i8 %2 to i32
%4 = and i32 %3, 128
%5 = icmp eq i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = lshr i32 %3, 5
%8 = and i32 %7, 3
%9 = add nuw nsw i32 %8, 1102
%10 = icmp eq i32 %8, 0
%11 = select i1 %10, i32 1101, i32 %9
br label %23
12: ; preds = %1
%13 = and i32 %3, 96
%14 = icmp eq i32 %13, 96
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = and i32 %3, 16
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i32 1104, i32 1105
br label %23
19: ; preds = %12
%20 = lshr i32 %3, 5
%21 = and i32 %20, 3
%22 = add nuw nsw i32 %21, 1101
br label %23
23: ; preds = %15, %19, %6
%24 = phi i32 [ %11, %6 ], [ %18, %15 ], [ %22, %19 ]
ret i32 %24
}