#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*/ O_WRONLY;
int PlayWavDesc(char *, int, unsigned int);
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int PlayWavFile(char *sFilename, char *sAudioDev, unsigned dOptions) {
  int hAudio;
  int i;
  if ((hAudio = open(sAudioDev, O_WRONLY)) < 0) {
    return -1;
  }
  i = PlayWavDesc(sFilename, hAudio, dOptions);
  close(hAudio);
  if (i < 0) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<PlayWavFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    116d <PlayWavFile+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <PlayWavFile+0x74>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <PlayWavDesc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <close@plt>
cmpl   $0x0,-0x24(%rbp)
jge    119d <PlayWavFile+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <PlayWavFile+0x74>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PlayWavFile>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rax
mov    %rdi,%rbx
mov    0x2e94(%rip),%rcx
mov    (%rcx),%esi
mov    %rax,%rdi
call   1050 <open@plt>
test   %eax,%eax
js     116f <PlayWavFile+0x3f>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14d,%edx
call   1040 <PlayWavDesc@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <close@plt>
sar    $0x1f,%ebx
jmp    1174 <PlayWavFile+0x44>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@O_WRONLY = global i32 0
define i32 @PlayWavFile(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %6
%11 = load i32, i32* @O_WRONLY
%12 = call i32 @open(i8* %10, i32 %11)
store i32 %12, i32* %8
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %26
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = call i32 @PlayWavDesc(i8* %16, i32 %17, i32 %18)
store i32 %19, i32* %9
%20 = load i32, i32* %8
%21 = call i32 @close(i32 %20)
%22 = load i32, i32* %9
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %15
store i32 -1, i32* %4
br label %26
25: ; preds = %15
store i32 0, i32* %4
br label %26
26: ; preds = %25, %24, %14
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
define i32 @PlayWavFile(i8* %0, i8* nocapture %1, i32 %2) {
%4 = load i32, i32* @O_WRONLY
%5 = tail call i32 @open(i8* %1, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = tail call i32 @PlayWavDesc(i8* %0, i32 %5, i32 %2)
%9 = tail call i32 @close(i32 %5)
%10 = ashr i32 %8, 31
br label %11
11: ; preds = %7, %3
%12 = phi i32 [ -1, %3 ], [ %10, %7 ]
ret i32 %12
}