#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 */
int /*<<< orphan*/ alsa_open(char *);
int /*<<< orphan*/ dsp_open(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout_open(char *);
void sound_open(int outp) {
  switch (outp) {
  case 1:
    alsa_open("default");
    break;
  case 2:
    dsp_open("/dev/dsp");
    break;
  case 3:
    stdout_open("/dev/dsp");
    break;
  default:
    fprintf(stderr, "Unknown output method\n");
  }
}


x86 assembly (clang, -O0):
<sound_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     1181 <sound_open+0x41>
jmp    115f <sound_open+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1192 <sound_open+0x52>
jmp    1170 <sound_open+0x30>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     11a3 <sound_open+0x63>
jmp    11b4 <sound_open+0x74>
lea    0xe78(%rip),%rdi
call   1030 <alsa_open@plt>
jmp    11c9 <sound_open+0x89>
lea    0xe6f(%rip),%rdi
call   1050 <dsp_open@plt>
jmp    11c9 <sound_open+0x89>
lea    0xe5e(%rip),%rdi
call   1060 <stdout_open@plt>
jmp    11c9 <sound_open+0x89>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sound_open>:
cmp    $0x3,%edi
je     115b <sound_open+0x1b>
cmp    $0x2,%edi
je     1167 <sound_open+0x27>
cmp    $0x1,%edi
jne    1173 <sound_open+0x33>
lea    0xeaa(%rip),%rdi
jmp    1030 <alsa_open@plt>
lea    0xea6(%rip),%rdi
jmp    1060 <stdout_open@plt>
lea    0xe9a(%rip),%rdi
jmp    1050 <dsp_open@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"default\00"
@.str.1 = [9 x i8] c"/dev/dsp\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Unknown output method\0A\00"
define void @sound_open(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %10 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
]
4: ; preds = %1
%5 = call i32 @alsa_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %13
6: ; preds = %1
%7 = call i32 @dsp_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %13
8: ; preds = %1
%9 = call i32 @stdout_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"default\00"
@.str.1 = [9 x i8] c"/dev/dsp\00"
@stderr = global i32 0
@.str.2 = [23 x i8] c"Unknown output method\0A\00"
define void @sound_open(i32 %0) {
switch i32 %0, label %8 [
i32 1, label %2
i32 2, label %4
i32 3, label %6
]
2: ; preds = %1
%3 = tail call i32 @alsa_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %11
4: ; preds = %1
%5 = tail call i32 @dsp_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %11
6: ; preds = %1
%7 = tail call i32 @stdout_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %11
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %8, %6, %4, %2
ret void
}