#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*/ close(int);
int mus_create(char *);
int mus_write_header_with_fd(int, int, int, int, int, int, int, char *, int);
int mus_write_header(char *name, int type, int in_srate, int in_chans, int loc,
                     int size, int format, char *comment, int len) {
  int chan, err;
  chan = mus_create(name);
  if (chan == -1)
    return (-1);
  err = mus_write_header_with_fd(chan, type, in_srate, in_chans, loc, size,
                                 format, comment, len);
  close(chan);
  return (err);
}


x86 assembly (clang, -O0):
<mus_write_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <mus_create@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1179 <mus_write_header+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <mus_write_header+0x8b>
mov    -0x28(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    0x10(%rbp),%r11d
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <mus_write_header_with_fd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%edi
call   1040 <close@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mus_write_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebp
call   1050 <mus_create@plt>
cmp    $0xffffffff,%eax
je     118f <mus_write_header+0x5f>
mov    %eax,%ebx
mov    0x50(%rsp),%eax
mov    0x40(%rsp),%r10d
sub    $0x8,%rsp
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    %r14d,%r9d
push   %rax
push   0x58(%rsp)
push   %r10
call   1030 <mus_write_header_with_fd@plt>
add    $0x20,%rsp
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <close@plt>
mov    %ebp,%eax
jmp    1194 <mus_write_header+0x64>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @mus_write_header(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i8* %7, i32 %8) {
%10 = tail call i32 @mus_create(i8* %0)
%11 = icmp eq i32 %10, -1
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @mus_write_header_with_fd(i32 %10, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i8* %7, i32 %8)
%14 = tail call i32 @close(i32 %10)
br label %15
15: ; preds = %9, %12
%16 = phi i32 [ %13, %12 ], [ -1, %9 ]
ret i32 %16
}