#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 */
typedef int /*<<< orphan*/ int16_t;

/* Variables and functions */
int alsa_write(int /*<<< orphan*/ **, int *);
int dsp_write(int /*<<< orphan*/ **, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int stdout_write(int /*<<< orphan*/ **, int *);
int sound_write(int16_t **bf, int *nbf, int outp) {
  switch (outp) {
  case 1:
    return alsa_write(bf, nbf);
    break;
  case 2:
    return dsp_write(bf, nbf);
    break;
  case 3:
    return stdout_write(bf, nbf);
    break;
  default:
    fprintf(stderr, "Unknown output method\n");
  }
  return -1;
}


x86 assembly (clang, -O0):
<sound_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x1,%eax
je     1189 <sound_write+0x49>
jmp    1167 <sound_write+0x27>
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
je     119e <sound_write+0x5e>
jmp    1178 <sound_write+0x38>
mov    -0x20(%rbp),%eax
sub    $0x3,%eax
je     11b3 <sound_write+0x73>
jmp    11c8 <sound_write+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <alsa_write@plt>
mov    %eax,-0x4(%rbp)
jmp    11e4 <sound_write+0xa4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <dsp_write@plt>
mov    %eax,-0x4(%rbp)
jmp    11e4 <sound_write+0xa4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <stdout_write@plt>
mov    %eax,-0x4(%rbp)
jmp    11e4 <sound_write+0xa4>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sound_write>:
cmp    $0x3,%edx
je     1154 <sound_write+0x14>
cmp    $0x2,%edx
je     1159 <sound_write+0x19>
cmp    $0x1,%edx
jne    115e <sound_write+0x1e>
jmp    1050 <alsa_write@plt>
jmp    1060 <stdout_write@plt>
jmp    1030 <dsp_write@plt>
push   %rax
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Unknown output method\0A\00"
define i32 @sound_write(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* %7
switch i32 %8, label %21 [
i32 1, label %9
i32 2, label %13
i32 3, label %17
]
9: ; preds = %3
%10 = load i32**, i32*** %5
%11 = load i32*, i32** %6
%12 = call i32 @alsa_write(i32** %10, i32* %11)
store i32 %12, i32* %4
br label %25
13: ; preds = %3
%14 = load i32**, i32*** %5
%15 = load i32*, i32** %6
%16 = call i32 @dsp_write(i32** %14, i32* %15)
store i32 %16, i32* %4
br label %25
17: ; preds = %3
%18 = load i32**, i32*** %5
%19 = load i32*, i32** %6
%20 = call i32 @stdout_write(i32** %18, i32* %19)
store i32 %20, i32* %4
br label %25
21: ; preds = %3
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21
store i32 -1, i32* %4
br label %25
25: ; preds = %24, %17, %13, %9
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Unknown output method\0A\00"
define i32 @sound_write(i32** %0, i32* %1, i32 %2) {
switch i32 %2, label %10 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
]
4: ; preds = %3
%5 = tail call i32 @alsa_write(i32** %0, i32* %1)
br label %13
6: ; preds = %3
%7 = tail call i32 @dsp_write(i32** %0, i32* %1)
br label %13
8: ; preds = %3
%9 = tail call i32 @stdout_write(i32** %0, i32* %1)
br label %13
10: ; preds = %3
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %8, %6, %4
%14 = phi i32 [ -1, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
ret i32 %14
}