#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*/ off_t;

/* Variables and functions */
int /*<<< orphan*/ mus_bytes_per_sample(int);
int /*<<< orphan*/ mus_file_open_descriptors(int, char const *, int,
                                             int /*<<< orphan*/,
                                             int /*<<< orphan*/, int, int);
int mus_file_reopen_write(char const *);
int /*<<< orphan*/ mus_sound_initialize();
int mus_sound_reopen_output(const char *arg, int chans, int format, int type,
                            off_t data_loc) {
  int fd;
  mus_sound_initialize();
  fd = mus_file_reopen_write(arg);
  if (fd != -1)
    mus_file_open_descriptors(fd, arg, format, mus_bytes_per_sample(format),
                              data_loc, chans, type);
  return (fd);
}


x86 assembly (clang, -O0):
<mus_sound_reopen_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    $0x0,%al
call   1050 <mus_sound_initialize@plt>
mov    -0x8(%rbp),%rdi
call   1040 <mus_file_reopen_write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     11b1 <mus_sound_reopen_output+0x71>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <mus_bytes_per_sample@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
mov    -0x18(%rbp),%r8d
mov    -0xc(%rbp),%r9d
mov    -0x14(%rbp),%eax
mov    %eax,(%rsp)
call   1060 <mus_file_open_descriptors@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mus_sound_reopen_output>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%r15d
mov    %rdi,%rbp
xor    %eax,%eax
call   1050 <mus_sound_initialize@plt>
mov    %rbp,%rdi
call   1040 <mus_file_reopen_write@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1191 <mus_sound_reopen_output+0x51>
mov    %r13d,%edi
call   1030 <mus_bytes_per_sample@plt>
mov    %r12d,(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %eax,%ecx
mov    %r14d,%r8d
mov    %r15d,%r9d
call   1060 <mus_file_open_descriptors@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mus_sound_reopen_output(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = call i32 (...) @mus_sound_initialize()
%13 = load i8*, i8** %6
%14 = call i32 @mus_file_reopen_write(i8* %13)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %27
17: ; preds = %5
%18 = load i32, i32* %11
%19 = load i8*, i8** %6
%20 = load i32, i32* %8
%21 = load i32, i32* %8
%22 = call i32 @mus_bytes_per_sample(i32 %21)
%23 = load i32, i32* %10
%24 = load i32, i32* %7
%25 = load i32, i32* %9
%26 = call i32 @mus_file_open_descriptors(i32 %18, i8* %19, i32 %20, i32 %22, i32 %23, i32 %24, i32 %25)
br label %27
27: ; preds = %17, %5
%28 = load i32, i32* %11
ret i32 %28
}

LLVM IR (-O2):
define i32 @mus_sound_reopen_output(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 (...) @mus_sound_initialize()
%7 = tail call i32 @mus_file_reopen_write(i8* %0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 @mus_bytes_per_sample(i32 %2)
%11 = tail call i32 @mus_file_open_descriptors(i32 %7, i8* %0, i32 %2, i32 %10, i32 %4, i32 %1, i32 %3)
br label %12
12: ; preds = %9, %5
ret i32 %7
}