#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*/ initialize_sndlib();
int /*<<< orphan*/ mus_format2bytes(int);
int mus_reopen_write(char *);
int /*<<< orphan*/ mus_set_file_descriptors(int, int, int /*<<< orphan*/, int,
                                            int, int);
int /*<<< orphan*/ save_header_name(int, char *);
int /*<<< orphan*/ set_audio_error(int /*<<< orphan*/);
int reopen_sound_output(char *arg, int chans, int format, int type,
                        int data_loc) {
  int fd;
  set_audio_error(0);
  initialize_sndlib();
  fd = mus_reopen_write(arg);
  mus_set_file_descriptors(fd, format, mus_format2bytes(format), data_loc,
                           chans, type);
  save_header_name(fd, arg);
  return (fd);
}


x86 assembly (clang, -O0):
<reopen_sound_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
xor    %edi,%edi
call   1050 <set_audio_error@plt>
mov    $0x0,%al
call   1060 <initialize_sndlib@plt>
mov    -0x8(%rbp),%rdi
call   1080 <mus_reopen_write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <mus_format2bytes@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    %eax,%edx
mov    -0x18(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x14(%rbp),%r9d
call   1070 <mus_set_file_descriptors@plt>
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <save_header_name@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reopen_sound_output>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %rdi,%r13
xor    %edi,%edi
call   1050 <set_audio_error@plt>
xor    %eax,%eax
call   1060 <initialize_sndlib@plt>
mov    %r13,%rdi
call   1080 <mus_reopen_write@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <mus_format2bytes@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
mov    %r15d,%ecx
mov    %r12d,%r8d
mov    %r14d,%r9d
call   1070 <mus_set_file_descriptors@plt>
mov    %ebx,%edi
mov    %r13,%rsi
call   1040 <save_header_name@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 @reopen_sound_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 @set_audio_error(i32 0)
%13 = call i32 (...) @initialize_sndlib()
%14 = load i8*, i8** %6
%15 = call i32 @mus_reopen_write(i8* %14)
store i32 %15, i32* %11
%16 = load i32, i32* %11
%17 = load i32, i32* %8
%18 = load i32, i32* %8
%19 = call i32 @mus_format2bytes(i32 %18)
%20 = load i32, i32* %10
%21 = load i32, i32* %7
%22 = load i32, i32* %9
%23 = call i32 @mus_set_file_descriptors(i32 %16, i32 %17, i32 %19, i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %11
%25 = load i8*, i8** %6
%26 = call i32 @save_header_name(i32 %24, i8* %25)
%27 = load i32, i32* %11
ret i32 %27
}

LLVM IR (-O2):
define i32 @reopen_sound_output(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @set_audio_error(i32 0)
%7 = tail call i32 (...) @initialize_sndlib()
%8 = tail call i32 @mus_reopen_write(i8* %0)
%9 = tail call i32 @mus_format2bytes(i32 %2)
%10 = tail call i32 @mus_set_file_descriptors(i32 %8, i32 %2, i32 %9, i32 %4, i32 %1, i32 %3)
%11 = tail call i32 @save_header_name(i32 %8, i8* %0)
ret i32 %8
}