int wave_to_sndlib_format(int osf, int bps, int little) {
  switch (osf) {
  case 1:
    switch (bps) {
    case 8:
      return (7);
      break;
    case 16:
      if (little)
        return (10);
      else
        return (1);
      break;
    case 32:
      if (little)
        return (11);
      else
        return (5);
      break;
    case 24:
      if (little)
        return (16);
      else
        return (8);
      break;
    default:
      return (7);
      break;
    }
    break;
  case 3:
    if (little)
      return (12);
    else
      return (4);
    break;
  case 6:
    if (bps == 8)
      return (6);
    break;
  case 7:
    if (bps == 8)
      return (2);
    break;
  case 0x101:
    return (2);
    break;
  case 0x102:
    return (6);
    break;
  }
  return (-1);
}


x86 assembly (clang, -O0):
<wave_to_sndlib_format>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x1,%eax
je     117a <wave_to_sndlib_format+0x7a>
jmp    1121 <wave_to_sndlib_format+0x21>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     1221 <wave_to_sndlib_format+0x121>
jmp    1132 <wave_to_sndlib_format+0x32>
mov    -0x14(%rbp),%eax
sub    $0x6,%eax
je     1243 <wave_to_sndlib_format+0x143>
jmp    1143 <wave_to_sndlib_format+0x43>
mov    -0x14(%rbp),%eax
sub    $0x7,%eax
je     125e <wave_to_sndlib_format+0x15e>
jmp    1154 <wave_to_sndlib_format+0x54>
mov    -0x14(%rbp),%eax
sub    $0x101,%eax
je     1279 <wave_to_sndlib_format+0x179>
jmp    1167 <wave_to_sndlib_format+0x67>
mov    -0x14(%rbp),%eax
sub    $0x102,%eax
je     1285 <wave_to_sndlib_format+0x185>
jmp    1291 <wave_to_sndlib_format+0x191>
mov    -0xc(%rbp),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x18,%eax
ja     1215 <wave_to_sndlib_format+0x115>
mov    -0x20(%rbp),%rax
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x7,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
cmpl   $0x0,-0x10(%rbp)
je     11c5 <wave_to_sndlib_format+0xc5>
movl   $0xa,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
movl   $0x1,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
cmpl   $0x0,-0x10(%rbp)
je     11e7 <wave_to_sndlib_format+0xe7>
movl   $0xb,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
movl   $0x5,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
cmpl   $0x0,-0x10(%rbp)
je     1209 <wave_to_sndlib_format+0x109>
movl   $0x10,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
movl   $0x8,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
movl   $0x7,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
cmpl   $0x0,-0x10(%rbp)
je     1237 <wave_to_sndlib_format+0x137>
movl   $0xc,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
movl   $0x4,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
cmpl   $0x8,-0xc(%rbp)
jne    1259 <wave_to_sndlib_format+0x159>
movl   $0x6,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
jmp    1291 <wave_to_sndlib_format+0x191>
cmpl   $0x8,-0xc(%rbp)
jne    1274 <wave_to_sndlib_format+0x174>
movl   $0x2,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
jmp    1291 <wave_to_sndlib_format+0x191>
movl   $0x2,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
movl   $0x6,-0x4(%rbp)
jmp    1298 <wave_to_sndlib_format+0x198>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<wave_to_sndlib_format>:
mov    $0x2,%eax
lea    -0x1(%rdi),%ecx
cmp    $0x6,%ecx
ja     1145 <wave_to_sndlib_format+0x45>
lea    0xeec(%rip),%rdi
movslq (%rdi,%rcx,4),%rcx
add    %rdi,%rcx
jmp    *%rcx
add    $0xfffffff8,%esi
rol    $0x1d,%esi
cmp    $0x3,%esi
je     117a <wave_to_sndlib_format+0x7a>
cmp    $0x2,%esi
je     118a <wave_to_sndlib_format+0x8a>
mov    $0x7,%eax
cmp    $0x1,%esi
jne    1179 <wave_to_sndlib_format+0x79>
xor    %eax,%eax
test   %edx,%edx
setne  %al
lea    (%rax,%rax,8),%eax
add    $0x1,%eax
ret
cmp    $0x101,%edi
je     1179 <wave_to_sndlib_format+0x79>
cmp    $0x102,%edi
jne    1174 <wave_to_sndlib_format+0x74>
mov    $0x6,%eax
ret
xor    %eax,%eax
test   %edx,%edx
setne  %al
lea    0x4(,%rax,8),%eax
ret
mov    $0x6,%eax
cmp    $0x8,%esi
je     1179 <wave_to_sndlib_format+0x79>
mov    $0xffffffff,%eax
ret
test   %edx,%edx
mov    $0x5,%ecx
mov    $0xb,%eax
cmove  %ecx,%eax
ret
xor    %eax,%eax
test   %edx,%edx
setne  %al
lea    0x8(,%rax,8),%eax
ret

LLVM IR (-O0):
define i32 @wave_to_sndlib_format(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
switch i32 %8, label %45 [
i32 1, label %9
i32 3, label %28
i32 6, label %33
i32 7, label %38
i32 257, label %43
i32 258, label %44
]
9: ; preds = %3
%10 = load i32, i32* %6
switch i32 %10, label %27 [
i32 8, label %11
i32 16, label %12
i32 32, label %17
i32 24, label %22
]
11: ; preds = %9
store i32 7, i32* %4
br label %46
12: ; preds = %9
%13 = load i32, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 10, i32* %4
br label %46
16: ; preds = %12
store i32 1, i32* %4
br label %46
17: ; preds = %9
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 11, i32* %4
br label %46
21: ; preds = %17
store i32 5, i32* %4
br label %46
22: ; preds = %9
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 16, i32* %4
br label %46
26: ; preds = %22
store i32 8, i32* %4
br label %46
27: ; preds = %9
store i32 7, i32* %4
br label %46
28: ; preds = %3
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 12, i32* %4
br label %46
32: ; preds = %28
store i32 4, i32* %4
br label %46
33: ; preds = %3
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 8
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 6, i32* %4
br label %46
37: ; preds = %33
br label %45
38: ; preds = %3
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 8
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 2, i32* %4
br label %46
42: ; preds = %38
br label %45
43: ; preds = %3
store i32 2, i32* %4
br label %46
44: ; preds = %3
store i32 6, i32* %4
br label %46
45: ; preds = %3, %42, %37
store i32 -1, i32* %4
br label %46
46: ; preds = %45, %44, %43, %41, %36, %32, %31, %27, %26, %25, %21, %20, %16, %15, %11
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
define i32 @wave_to_sndlib_format(i32 %0, i32 %1, i32 %2) {
switch i32 %0, label %24 [
i32 1, label %4
i32 3, label %16
i32 6, label %19
i32 7, label %21
i32 257, label %25
i32 258, label %23
]
4: ; preds = %3
%5 = add i32 %1, -8
%6 = tail call i32 @llvm.fshl.i32(i32 %5, i32 %5, i32 29)
switch i32 %6, label %25 [
i32 2, label %13
i32 1, label %7
i32 3, label %10
]
7: ; preds = %4
%8 = icmp eq i32 %2, 0
%9 = select i1 %8, i32 1, i32 10
br label %25
10: ; preds = %4
%11 = icmp eq i32 %2, 0
%12 = select i1 %11, i32 5, i32 11
br label %25
13: ; preds = %4
%14 = icmp eq i32 %2, 0
%15 = select i1 %14, i32 8, i32 16
br label %25
16: ; preds = %3
%17 = icmp eq i32 %2, 0
%18 = select i1 %17, i32 4, i32 12
br label %25
19: ; preds = %3
%20 = icmp eq i32 %1, 8
br i1 %20, label %25, label %24
21: ; preds = %3
%22 = icmp eq i32 %1, 8
br i1 %22, label %25, label %24
23: ; preds = %3
br label %25
24: ; preds = %21, %19, %3
br label %25
25: ; preds = %3, %21, %19, %16, %4, %13, %10, %7, %24, %23
%26 = phi i32 [ -1, %24 ], [ 6, %23 ], [ %9, %7 ], [ %12, %10 ], [ %15, %13 ], [ 7, %4 ], [ %18, %16 ], [ 6, %19 ], [ 2, %21 ], [ 2, %3 ]
ret i32 %26
}