int SmpFrqIndex(int sample_freq, unsigned char *const version) {
  switch (sample_freq) {
  case 44100:
    *version = 1;
    return 0;
  case 48000:
    *version = 1;
    return 1;
  case 32000:
    *version = 1;
    return 2;
  case 22050:
    *version = 0;
    return 0;
  case 24000:
    *version = 0;
    return 1;
  case 16000:
    *version = 0;
    return 2;
  default:
    *version = 0;
    return -1;
  }
}


x86 assembly (clang, -O0):
<SmpFrqIndex>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x3e80,%eax
je     11df <SmpFrqIndex+0xdf>
jmp    1121 <SmpFrqIndex+0x21>
mov    -0x14(%rbp),%eax
sub    $0x5622,%eax
je     11b9 <SmpFrqIndex+0xb9>
jmp    1134 <SmpFrqIndex+0x34>
mov    -0x14(%rbp),%eax
sub    $0x5dc0,%eax
je     11cc <SmpFrqIndex+0xcc>
jmp    1147 <SmpFrqIndex+0x47>
mov    -0x14(%rbp),%eax
sub    $0x7d00,%eax
je     11a6 <SmpFrqIndex+0xa6>
jmp    115a <SmpFrqIndex+0x5a>
mov    -0x14(%rbp),%eax
sub    $0xac44,%eax
je     1180 <SmpFrqIndex+0x80>
jmp    116d <SmpFrqIndex+0x6d>
mov    -0x14(%rbp),%eax
sub    $0xbb80,%eax
je     1193 <SmpFrqIndex+0x93>
jmp    11f2 <SmpFrqIndex+0xf2>
mov    -0x10(%rbp),%rax
movb   $0x1,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1200 <SmpFrqIndex+0x100>
mov    -0x10(%rbp),%rax
movb   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1200 <SmpFrqIndex+0x100>
mov    -0x10(%rbp),%rax
movb   $0x1,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    1200 <SmpFrqIndex+0x100>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1200 <SmpFrqIndex+0x100>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1200 <SmpFrqIndex+0x100>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    1200 <SmpFrqIndex+0x100>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<SmpFrqIndex>:
cmp    $0x7cff,%edi
jg     1127 <SmpFrqIndex+0x27>
cmp    $0x3e80,%edi
je     1149 <SmpFrqIndex+0x49>
cmp    $0x5622,%edi
je     1150 <SmpFrqIndex+0x50>
cmp    $0x5dc0,%edi
jne    115f <SmpFrqIndex+0x5f>
mov    $0x1,%eax
jmp    1164 <SmpFrqIndex+0x64>
mov    $0x1,%cl
cmp    $0x7d00,%edi
je     1157 <SmpFrqIndex+0x57>
cmp    $0xac44,%edi
je     1152 <SmpFrqIndex+0x52>
cmp    $0xbb80,%edi
jne    115f <SmpFrqIndex+0x5f>
mov    $0x1,%eax
mov    %cl,(%rsi)
ret
mov    $0x2,%eax
jmp    1164 <SmpFrqIndex+0x64>
xor    %ecx,%ecx
xor    %eax,%eax
mov    %cl,(%rsi)
ret
mov    $0x2,%eax
mov    %cl,(%rsi)
ret
mov    $0xffffffff,%eax
xor    %ecx,%ecx
mov    %cl,(%rsi)
ret

LLVM IR (-O0):
define i32 @SmpFrqIndex(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i32, i32* %4
switch i32 %6, label %19 [
i32 44100, label %7
i32 48000, label %9
i32 32000, label %11
i32 22050, label %13
i32 24000, label %15
i32 16000, label %17
]
7: ; preds = %2
%8 = load i8*, i8** %5
store i8 1, i8* %8
store i32 0, i32* %3
br label %21
9: ; preds = %2
%10 = load i8*, i8** %5
store i8 1, i8* %10
store i32 1, i32* %3
br label %21
11: ; preds = %2
%12 = load i8*, i8** %5
store i8 1, i8* %12
store i32 2, i32* %3
br label %21
13: ; preds = %2
%14 = load i8*, i8** %5
store i8 0, i8* %14
store i32 0, i32* %3
br label %21
15: ; preds = %2
%16 = load i8*, i8** %5
store i8 0, i8* %16
store i32 1, i32* %3
br label %21
17: ; preds = %2
%18 = load i8*, i8** %5
store i8 0, i8* %18
store i32 2, i32* %3
br label %21
19: ; preds = %2
%20 = load i8*, i8** %5
store i8 0, i8* %20
store i32 -1, i32* %3
br label %21
21: ; preds = %19, %17, %15, %13, %11, %9, %7
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
define i32 @SmpFrqIndex(i32 %0, i8* nocapture writeonly %1) {
switch i32 %0, label %8 [
i32 44100, label %9
i32 48000, label %3
i32 32000, label %4
i32 22050, label %5
i32 24000, label %6
i32 16000, label %7
]
3: ; preds = %2
br label %9
4: ; preds = %2
br label %9
5: ; preds = %2
br label %9
6: ; preds = %2
br label %9
7: ; preds = %2
br label %9
8: ; preds = %2
br label %9
9: ; preds = %2, %8, %7, %6, %5, %4, %3
%10 = phi i8 [ 0, %8 ], [ 0, %7 ], [ 0, %6 ], [ 0, %5 ], [ 1, %4 ], [ 1, %3 ], [ 1, %2 ]
%11 = phi i32 [ -1, %8 ], [ 2, %7 ], [ 1, %6 ], [ 0, %5 ], [ 2, %4 ], [ 1, %3 ], [ 0, %2 ]
store i8 %10, i8* %1
ret i32 %11
}