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

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


x86 assembly (clang, -O0):
<RecordWavFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
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    0x2e88(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1180 <RecordWavFile+0x50>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <RecordWavFile+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <RecordWavDesc@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%edi
call   1030 <close@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RecordWavFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%r13d
mov    %rsi,%rax
mov    %rdi,%rbx
mov    0x2e94(%rip),%rcx
mov    (%rcx),%esi
mov    %rax,%rdi
call   1050 <open@plt>
test   %eax,%eax
js     1197 <RecordWavFile+0x67>
mov    %eax,%ebp
mov    0x48(%rsp),%eax
mov    0x40(%rsp),%r10d
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14d,%r9d
push   %rax
push   %r10
call   1040 <RecordWavDesc@plt>
add    $0x10,%rsp
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <close@plt>
mov    %ebx,%eax
jmp    119c <RecordWavFile+0x6c>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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