int AVCodec_AAC_TCC_EncDSI(unsigned long usSampleRate, unsigned long ucChannels,
                           unsigned char *bitstream, unsigned int *size) {
  const unsigned int usAACSRMap[] = {96000, 88200, 64000, 48000, 44100,
                                     32000, 24000, 22050, 16000, 12000,
                                     11025, 8000,  7350};
  unsigned sampling_frequency_index;
  for (sampling_frequency_index = 0; sampling_frequency_index < 13;
       sampling_frequency_index++) {
    if (usSampleRate == usAACSRMap[sampling_frequency_index]) {
      bitstream[0] = 0x10 | ((sampling_frequency_index & 0x0F) >> 1);
      bitstream[1] =
          ((sampling_frequency_index & 0x01) << 7) | ((ucChannels & 0x0F) << 3);
      *size = 2;
      return 1;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<AVCodec_AAC_TCC_EncDSI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x34,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0xd,-0x64(%rbp)
jae    11c2 <AVCodec_AAC_TCC_EncDSI+0xb2>
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
mov    -0x60(%rbp,%rcx,4),%ecx
cmp    %rcx,%rax
jne    11af <AVCodec_AAC_TCC_EncDSI+0x9f>
mov    -0x64(%rbp),%eax
and    $0xf,%eax
shr    $0x1,%eax
or     $0x10,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x64(%rbp),%eax
and    $0x1,%eax
shl    $0x7,%eax
mov    %eax,%eax
mov    -0x18(%rbp),%rcx
and    $0xf,%rcx
shl    $0x3,%rcx
or     %rcx,%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x28(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11c9 <AVCodec_AAC_TCC_EncDSI+0xb9>
jmp    11b4 <AVCodec_AAC_TCC_EncDSI+0xa4>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1144 <AVCodec_AAC_TCC_EncDSI+0x34>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AVCodec_AAC_TCC_EncDSI>:
mov    $0xffffffff,%eax
cmp    $0x5dbf,%rdi
jle    1149 <AVCodec_AAC_TCC_EncDSI+0x49>
cmp    $0xbb7f,%rdi
jle    1184 <AVCodec_AAC_TCC_EncDSI+0x84>
cmp    $0x15887,%rdi
jg     11ce <AVCodec_AAC_TCC_EncDSI+0xce>
cmp    $0xbb80,%rdi
je     11eb <AVCodec_AAC_TCC_EncDSI+0xeb>
cmp    $0xfa00,%rdi
jne    1243 <AVCodec_AAC_TCC_EncDSI+0x143>
mov    $0x2,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
cmp    $0x2edf,%rdi
jg     11ab <AVCodec_AAC_TCC_EncDSI+0xab>
cmp    $0x1cb6,%rdi
je     11f3 <AVCodec_AAC_TCC_EncDSI+0xf3>
cmp    $0x1f40,%rdi
je     11fb <AVCodec_AAC_TCC_EncDSI+0xfb>
cmp    $0x2b11,%rdi
jne    1243 <AVCodec_AAC_TCC_EncDSI+0x143>
mov    $0xa,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
cmp    $0x5dc0,%rdi
je     1203 <AVCodec_AAC_TCC_EncDSI+0x103>
cmp    $0x7d00,%rdi
je     120b <AVCodec_AAC_TCC_EncDSI+0x10b>
cmp    $0xac44,%rdi
jne    1243 <AVCodec_AAC_TCC_EncDSI+0x143>
mov    $0x4,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
cmp    $0x2ee0,%rdi
je     1213 <AVCodec_AAC_TCC_EncDSI+0x113>
cmp    $0x3e80,%rdi
je     121b <AVCodec_AAC_TCC_EncDSI+0x11b>
cmp    $0x5622,%rdi
jne    1243 <AVCodec_AAC_TCC_EncDSI+0x143>
mov    $0x7,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
xor    %r8d,%r8d
cmp    $0x17700,%rdi
je     1221 <AVCodec_AAC_TCC_EncDSI+0x121>
cmp    $0x15888,%rdi
jne    1243 <AVCodec_AAC_TCC_EncDSI+0x143>
mov    $0x1,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
mov    $0x3,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
mov    $0xc,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
mov    $0xb,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
mov    $0x6,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
mov    $0x5,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
mov    $0x9,%r8d
jmp    1221 <AVCodec_AAC_TCC_EncDSI+0x121>
mov    $0x8,%r8d
mov    %r8d,%eax
shr    %al
or     $0x10,%al
mov    %al,(%rdx)
shl    $0x7,%r8d
and    $0xf,%esi
lea    (%r8,%rsi,8),%eax
mov    %al,0x1(%rdx)
movl   $0x2,(%rcx)
mov    $0x1,%eax
ret

LLVM IR (-O0):
@__const.AVCodec_AAC_TCC_EncDSI.usAACSRMap = [13 x i32] [i32 96000, i32 88200, i32 64000, i32 48000, i32 44100, i32 32000, i32 24000, i32 22050, i32 16000, i32 12000, i32 11025, i32 8000, i32 7350]
define i32 @AVCodec_AAC_TCC_EncDSI(i64 %0, i64 %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca [13 x i32]
%11 = alloca i32
store i64 %0, i64* %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i32* %3, i32** %9
%12 = bitcast [13 x i32]* %10 to i8*
store i32 0, i32* %11
br label %13
13: ; preds = %45, %4
%14 = load i32, i32* %11
%15 = icmp ult i32 %14, 13
br i1 %15, label %16, label %48
16: ; preds = %13
%17 = load i64, i64* %6
%18 = load i32, i32* %11
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [13 x i32], [13 x i32]* %10, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = zext i32 %21 to i64
%23 = icmp eq i64 %17, %22
br i1 %23, label %24, label %44
24: ; preds = %16
%25 = load i32, i32* %11
%26 = and i32 %25, 15
%27 = lshr i32 %26, 1
%28 = or i32 16, %27
%29 = trunc i32 %28 to i8
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 %29, i8* %31
%32 = load i32, i32* %11
%33 = and i32 %32, 1
%34 = shl i32 %33, 7
%35 = zext i32 %34 to i64
%36 = load i64, i64* %7
%37 = and i64 %36, 15
%38 = shl i64 %37, 3
%39 = or i64 %35, %38
%40 = trunc i64 %39 to i8
%41 = load i8*, i8** %8
%42 = getelementptr inbounds i8, i8* %41, i64 1
store i8 %40, i8* %42
%43 = load i32*, i32** %9
store i32 2, i32* %43
store i32 1, i32* %5
br label %49
44: ; preds = %16
br label %45
45: ; preds = %44
%46 = load i32, i32* %11
%47 = add i32 %46, 1
store i32 %47, i32* %11
br label %13
48: ; preds = %13
store i32 -1, i32* %5
br label %49
49: ; preds = %48, %24
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
define i32 @AVCodec_AAC_TCC_EncDSI(i64 %0, i64 %1, i8* nocapture writeonly %2, i32* nocapture writeonly %3) {
switch i64 %0, label %29 [
i64 96000, label %17
i64 88200, label %5
i64 64000, label %6
i64 48000, label %7
i64 44100, label %8
i64 32000, label %9
i64 24000, label %10
i64 22050, label %11
i64 16000, label %12
i64 12000, label %13
i64 11025, label %14
i64 8000, label %15
i64 7350, label %16
]
5: ; preds = %4
br label %17
6: ; preds = %4
br label %17
7: ; preds = %4
br label %17
8: ; preds = %4
br label %17
9: ; preds = %4
br label %17
10: ; preds = %4
br label %17
11: ; preds = %4
br label %17
12: ; preds = %4
br label %17
13: ; preds = %4
br label %17
14: ; preds = %4
br label %17
15: ; preds = %4
br label %17
16: ; preds = %4
br label %17
17: ; preds = %4, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%18 = phi i32 [ 0, %4 ], [ 1, %5 ], [ 2, %6 ], [ 3, %7 ], [ 4, %8 ], [ 5, %9 ], [ 6, %10 ], [ 7, %11 ], [ 8, %12 ], [ 9, %13 ], [ 10, %14 ], [ 11, %15 ], [ 12, %16 ]
%19 = trunc i32 %18 to i8
%20 = lshr i8 %19, 1
%21 = or i8 %20, 16
store i8 %21, i8* %2
%22 = shl nuw nsw i32 %18, 7
%23 = zext i32 %22 to i64
%24 = shl i64 %1, 3
%25 = and i64 %24, 120
%26 = or i64 %25, %23
%27 = trunc i64 %26 to i8
%28 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %27, i8* %28
store i32 2, i32* %3
br label %29
29: ; preds = %4, %17
%30 = phi i32 [ 1, %17 ], [ -1, %4 ]
ret i32 %30
}