#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 */
struct wavProcess {
  int dummy;
};
struct wavHeader {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int RecordWavDesc(char *, int, int, struct wavHeader *, struct wavProcess *,
                  unsigned int);
int open(char *, int /*<<< orphan*/);
int RecordWavFile(char *sFilename, char *sAudio, int dSeconds,
                  struct wavHeader *wavHeader, struct wavProcess *wavProcess,
                  unsigned dOptions) {
  int hAudio;
  hAudio = open(sAudio, O_RDWR);
  if (hAudio < 0) {
    return -1;
  }
  return RecordWavDesc(sFilename, hAudio, dSeconds, wavHeader, wavProcess,
                       dOptions);
}


x86 assembly (clang, -O0):
<RecordWavFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e9e(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    116a <RecordWavFile+0x4a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <RecordWavFile+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
call   1030 <RecordWavDesc@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RecordWavFile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r14d
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%ebx
mov    %rsi,%rax
mov    %rdi,%rbp
mov    0x2ea8(%rip),%rcx
mov    (%rcx),%esi
mov    %rax,%rdi
call   1040 <open@plt>
test   %eax,%eax
js     116b <RecordWavFile+0x4b>
mov    %rbp,%rdi
mov    %eax,%esi
mov    %ebx,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14d,%r9d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <RecordWavDesc@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.wavHeader = type { i32 }
%struct.wavProcess = type { i32 }
@O_RDWR = global i32 0
define i32 @RecordWavFile(i8* %0, i8* %1, i32 %2, %struct.wavHeader* %3, %struct.wavProcess* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.wavHeader*
%12 = alloca %struct.wavProcess*
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store %struct.wavHeader* %3, %struct.wavHeader** %11
store %struct.wavProcess* %4, %struct.wavProcess** %12
store i32 %5, i32* %13
%15 = load i8*, i8** %9
%16 = load i32, i32* @O_RDWR
%17 = call i32 @open(i8* %15, i32 %16)
store i32 %17, i32* %14
%18 = load i32, i32* %14
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %6
store i32 -1, i32* %7
br label %29
21: ; preds = %6
%22 = load i8*, i8** %8
%23 = load i32, i32* %14
%24 = load i32, i32* %10
%25 = load %struct.wavHeader*, %struct.wavHeader** %11
%26 = load %struct.wavProcess*, %struct.wavProcess** %12
%27 = load i32, i32* %13
%28 = call i32 @RecordWavDesc(i8* %22, i32 %23, i32 %24, %struct.wavHeader* %25, %struct.wavProcess* %26, i32 %27)
store i32 %28, i32* %7
br label %29
29: ; preds = %21, %20
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
%struct.wavHeader = type { i32 }
%struct.wavProcess = type { i32 }
@O_RDWR = global i32 0
define i32 @RecordWavFile(i8* %0, i8* nocapture %1, i32 %2, %struct.wavHeader* %3, %struct.wavProcess* %4, i32 %5) {
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 @open(i8* %1, i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @RecordWavDesc(i8* %0, i32 %8, i32 %2, %struct.wavHeader* %3, %struct.wavProcess* %4, i32 %5)
br label %12
12: ; preds = %6, %10
%13 = phi i32 [ %11, %10 ], [ -1, %6 ]
ret i32 %13
}