#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 open_soundfile_via_fd(int, int, int *, int *, int *, long *, long);
int open_via_path(char const *, char const *, char *, char *, char **, int,
                  int);
int open_soundfile(const char *dirname, const char *filename, int headersize,
                   int *p_bytespersamp, int *p_bigendian, int *p_nchannels,
                   long *p_bytelimit, long skipframes) {
  char buf[1000], *bufptr;
  int fd;
  fd = open_via_path(dirname, filename, "", buf, &bufptr, 1000, 1);
  if (fd < 0)
    return (-1);
  else
    return (open_soundfile_via_fd(fd, headersize, p_bytespersamp, p_bigendian,
                                  p_nchannels, p_bytelimit, skipframes));
}


x86 assembly (clang, -O0):
<open_soundfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x420(%rbp),%rcx
lea    0xea0(%rip),%rdx
lea    -0x428(%rbp),%r8
mov    $0x3e8,%r9d
movl   $0x1,(%rsp)
call   1030 <open_via_path@plt>
mov    %eax,-0x42c(%rbp)
cmpl   $0x0,-0x42c(%rbp)
jge    1198 <open_soundfile+0x78>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c1 <open_soundfile+0xa1>
mov    -0x42c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <open_soundfile_via_fd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_soundfile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3f8,%rsp
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%rbx
mov    %edx,%ebp
movl   $0x1,(%rsp)
lea    0xeba(%rip),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x3e8,%r9d
call   1030 <open_via_path@plt>
test   %eax,%eax
js     1187 <open_soundfile+0x67>
mov    0x428(%rsp),%rcx
mov    0x420(%rsp),%r9
mov    %rcx,(%rsp)
mov    %eax,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <open_soundfile_via_fd@plt>
jmp    118c <open_soundfile+0x6c>
mov    $0xffffffff,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @open_soundfile(i8* %0, i8* %1, i32 %2, i32* %3, i32* %4, i32* %5, i64* %6, i64 %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i64*
%17 = alloca i64
%18 = alloca [1000 x i8]
%19 = alloca i8*
%20 = alloca i32
store i8* %0, i8** %10
store i8* %1, i8** %11
store i32 %2, i32* %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i64* %6, i64** %16
store i64 %7, i64* %17
%21 = load i8*, i8** %10
%22 = load i8*, i8** %11
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %18, i64 0, i64 0
%24 = call i32 @open_via_path(i8* %21, i8* %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %23, i8** %19, i32 1000, i32 1)
store i32 %24, i32* %20
%25 = load i32, i32* %20
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %8
store i32 -1, i32* %9
br label %37
28: ; preds = %8
%29 = load i32, i32* %20
%30 = load i32, i32* %12
%31 = load i32*, i32** %13
%32 = load i32*, i32** %14
%33 = load i32*, i32** %15
%34 = load i64*, i64** %16
%35 = load i64, i64* %17
%36 = call i32 @open_soundfile_via_fd(i32 %29, i32 %30, i32* %31, i32* %32, i32* %33, i64* %34, i64 %35)
store i32 %36, i32* %9
br label %37
37: ; preds = %28, %27
%38 = load i32, i32* %9
ret i32 %38
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @open_soundfile(i8* %0, i8* %1, i32 %2, i32* %3, i32* %4, i32* %5, i64* %6, i64 %7) {
%9 = alloca [1000 x i8]
%10 = alloca i8*
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%12 = bitcast i8** %10 to i8*
%13 = call i32 @open_via_path(i8* %0, i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %11, i8** %10, i32 1000, i32 1)
%14 = icmp slt i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %8
%16 = call i32 @open_soundfile_via_fd(i32 %13, i32 %2, i32* %3, i32* %4, i32* %5, i64* %6, i64 %7)
br label %17
17: ; preds = %8, %15
%18 = phi i32 [ %16, %15 ], [ -1, %8 ]
ret i32 %18
}