#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
size_t get_sr_index(unsigned int);
unsigned char qmf_start_channel(unsigned char bs_start_freq,
                                unsigned char bs_samplerate_mode,
                                unsigned int sample_rate) {
  static const unsigned char startMinTable[12] = {7,  7,  10, 11, 12, 16,
                                                  16, 17, 24, 32, 35, 48};
  static const unsigned char offsetIndexTable[12] = {5, 5, 4, 4, 4, 3,
                                                     2, 1, 0, 6, 6, 6};
  static const signed char offset[7][16] = {
      {-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7},
      {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13},
      {-5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16},
      {-6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16},
      {-4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20},
      {-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24},
      {0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33}};
  unsigned char startMin = startMinTable[get_sr_index(sample_rate)];
  unsigned char offsetIndex = offsetIndexTable[get_sr_index(sample_rate)];
  if (bs_samplerate_mode) {
    return startMin + offset[offsetIndex][bs_start_freq];
  } else {
    return startMin + offset[6][bs_start_freq];
  }
}


x86 assembly (clang, -O0):
<qmf_start_channel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <get_sr_index@plt>
mov    %rax,%rcx
lea    0xec7(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <get_sr_index@plt>
mov    %rax,%rcx
lea    0xebb(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0xa(%rbp)
cmpb   $0x0,-0x3(%rbp)
je     118b <qmf_start_channel+0x7b>
movzbl -0x9(%rbp),%eax
movzbl -0xa(%rbp),%ecx
mov    %ecx,%edx
lea    0xeae(%rip),%rcx
shl    $0x4,%rdx
add    %rdx,%rcx
movzbl -0x2(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %al,-0x1(%rbp)
jmp    11a6 <qmf_start_channel+0x96>
movzbl -0x9(%rbp),%eax
movzbl -0x2(%rbp),%ecx
mov    %ecx,%edx
lea    0xe84(%rip),%rcx
movsbl 0x60(%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qmf_start_channel>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r15d
mov    %edi,%r14d
mov    %edx,%edi
call   1030 <get_sr_index@plt>
lea    0xed3(%rip),%rcx
mov    (%rax,%rcx,1),%bl
mov    %ebp,%edi
call   1030 <get_sr_index@plt>
test   %r15d,%r15d
je     1149 <qmf_start_channel+0x39>
lea    0xec9(%rip),%rcx
movzbl (%rax,%rcx,1),%eax
jmp    114e <qmf_start_channel+0x3e>
mov    $0x6,%eax
movzbl %r14b,%ecx
shl    $0x4,%rax
lea    0xec3(%rip),%rdx
add    %rax,%rdx
add    (%rcx,%rdx,1),%bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@qmf_start_channel.startMinTable = internal constant [12 x i8] c"\07\07\0A\0B\0C\10\10\11\18"
@qmf_start_channel.offsetIndexTable = internal constant [12 x i8] c"\05\05\04\04\04\03\02\01\00\06\06\06"
@qmf_start_channel.offset = internal constant [7 x [16 x i8]] [[16 x i8] c"\F8\F9\FA\FB\FC\FD\FE\FF\00\01\02\03\04\05\06\07", [16 x i8] c"\FB\FC\FD\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D", [16 x i8] c"\FB\FD\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10", [16 x i8] c"\FA\FC\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10", [16 x i8] c"\FC\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10\14", [16 x i8] c"\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10\14\18", [16 x i8] c"\00\01\02\03\04\05\06\07\09\0B\0D\10\14\18\1C!"]
define zeroext i8 @qmf_start_channel(i8 zeroext %0, i8 zeroext %1, i32 %2) {
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
store i8 %0, i8* %5
store i8 %1, i8* %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = call i64 @get_sr_index(i32 %10)
%12 = getelementptr inbounds [12 x i8], [12 x i8]* @qmf_start_channel.startMinTable, i64 0, i64 %11
%13 = load i8, i8* %12
store i8 %13, i8* %8
%14 = load i32, i32* %7
%15 = call i64 @get_sr_index(i32 %14)
%16 = getelementptr inbounds [12 x i8], [12 x i8]* @qmf_start_channel.offsetIndexTable, i64 0, i64 %15
%17 = load i8, i8* %16
store i8 %17, i8* %9
%18 = load i8, i8* %6
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %3
%21 = load i8, i8* %8
%22 = zext i8 %21 to i32
%23 = load i8, i8* %9
%24 = zext i8 %23 to i64
%25 = getelementptr inbounds [7 x [16 x i8]], [7 x [16 x i8]]* @qmf_start_channel.offset, i64 0, i64 %24
%26 = load i8, i8* %5
%27 = zext i8 %26 to i64
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = add nsw i32 %22, %30
%32 = trunc i32 %31 to i8
store i8 %32, i8* %4
br label %43
33: ; preds = %3
%34 = load i8, i8* %8
%35 = zext i8 %34 to i32
%36 = load i8, i8* %5
%37 = zext i8 %36 to i64
%38 = getelementptr inbounds [16 x i8], [16 x i8]* getelementptr inbounds ([7 x [16 x i8]], [7 x [16 x i8]]* @qmf_start_channel.offset, i64 0, i64 6), i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = add nsw i32 %35, %40
%42 = trunc i32 %41 to i8
store i8 %42, i8* %4
br label %43
43: ; preds = %33, %20
%44 = load i8, i8* %4
ret i8 %44
}

LLVM IR (-O2):
@qmf_start_channel.startMinTable = internal unnamed_addr constant [12 x i8] c"\07\07\0A\0B\0C\10\10\11\18"
@qmf_start_channel.offsetIndexTable = internal unnamed_addr constant [12 x i8] c"\05\05\04\04\04\03\02\01\00\06\06\06"
@qmf_start_channel.offset = internal unnamed_addr constant [7 x [16 x i8]] [[16 x i8] c"\F8\F9\FA\FB\FC\FD\FE\FF\00\01\02\03\04\05\06\07", [16 x i8] c"\FB\FC\FD\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D", [16 x i8] c"\FB\FD\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10", [16 x i8] c"\FA\FC\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10", [16 x i8] c"\FC\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10\14", [16 x i8] c"\FE\FF\00\01\02\03\04\05\06\07\09\0B\0D\10\14\18", [16 x i8] c"\00\01\02\03\04\05\06\07\09\0B\0D\10\14\18\1C!"]
define zeroext i8 @qmf_start_channel(i8 zeroext %0, i8 zeroext %1, i32 %2) {
%4 = tail call i64 @get_sr_index(i32 %2)
%5 = getelementptr inbounds [12 x i8], [12 x i8]* @qmf_start_channel.startMinTable, i64 0, i64 %4
%6 = load i8, i8* %5
%7 = tail call i64 @get_sr_index(i32 %2)
%8 = icmp eq i8 %1, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = getelementptr inbounds [12 x i8], [12 x i8]* @qmf_start_channel.offsetIndexTable, i64 0, i64 %7
%11 = load i8, i8* %10
%12 = zext i8 %11 to i64
br label %13
13: ; preds = %3, %9
%14 = phi i64 [ %12, %9 ], [ 6, %3 ]
%15 = zext i8 %0 to i64
%16 = getelementptr inbounds [7 x [16 x i8]], [7 x [16 x i8]]* @qmf_start_channel.offset, i64 0, i64 %14, i64 %15
%17 = load i8, i8* %16
%18 = add i8 %17, %6
ret i8 %18
}