#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_RDONLY;
int RecWavDesc(char *, int, unsigned int, unsigned short, unsigned int,
               unsigned short, unsigned int);
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int RecWavFile(char *sFilename, char *sAudioDev, unsigned dSeconds,
               unsigned short dChannels, unsigned ldSamplesPerSec,
               unsigned short dBitsPerSample, unsigned dOptions) {
  int hAudio;
  int i;
  hAudio = open(sAudioDev, O_RDONLY);
  if (hAudio < 0) {
    return -1;
  }
  i = RecWavDesc(sFilename, hAudio, dSeconds, dChannels, ldSamplesPerSec,
                 dBitsPerSample, dOptions);
  close(hAudio);
  if (i < 0) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<RecWavFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r9w,%ax
mov    0x10(%rbp),%r9d
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %cx,-0x1e(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %ax,-0x26(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1182 <RecWavFile+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d3 <RecWavFile+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x1e(%rbp),%cx
mov    -0x24(%rbp),%r8d
mov    -0x26(%rbp),%r9w
mov    0x10(%rbp),%eax
movzwl %cx,%ecx
movzwl %r9w,%r9d
mov    %eax,(%rsp)
call   1030 <RecWavDesc@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <close@plt>
cmpl   $0x0,-0x30(%rbp)
jge    11cc <RecWavFile+0x9c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d3 <RecWavFile+0xa3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RecWavFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r15d
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %edx,%r12d
mov    %rsi,%rax
mov    %rdi,%rbp
mov    0x2e94(%rip),%rcx
mov    (%rcx),%esi
mov    %rax,%rdi
call   1050 <open@plt>
test   %eax,%eax
js     1191 <RecWavFile+0x61>
mov    %eax,%ebx
mov    0x40(%rsp),%eax
mov    %eax,(%rsp)
movzwl %r13w,%ecx
movzwl %r15w,%r9d
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r14d,%r8d
call   1030 <RecWavDesc@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <close@plt>
sar    $0x1f,%ebp
jmp    1196 <RecWavFile+0x66>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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