#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*/ CloseOpenFiles();
int ESDPlaySoundFile(char *, int);
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int fork();
int SoundPlayFile(char *Output, char *Path, int Vol, int Flags) {
  int result = 0, pid = 0;
  if (Flags & 1) {
    pid = fork();
    if (pid == 0)
      CloseOpenFiles();
  }
  if (pid == 0) {
    result = ESDPlaySoundFile(Path, Vol);
    if (Flags & 1)
      _exit(0);
  }
  return (result);
}


x86 assembly (clang, -O0):
<SoundPlayFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1193 <SoundPlayFile+0x53>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    118e <SoundPlayFile+0x4e>
mov    $0x0,%al
call   1050 <CloseOpenFiles@plt>
jmp    1193 <SoundPlayFile+0x53>
cmpl   $0x0,-0x20(%rbp)
jne    11c7 <SoundPlayFile+0x87>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <ESDPlaySoundFile@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11c2 <SoundPlayFile+0x82>
xor    %edi,%edi
call   1040 <_exit@plt>
jmp    11c7 <SoundPlayFile+0x87>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SoundPlayFile>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
test   $0x1,%cl
jne    115d <SoundPlayFile+0x1d>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ESDPlaySoundFile@plt>
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
je     1171 <SoundPlayFile+0x31>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1050 <CloseOpenFiles@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <ESDPlaySoundFile@plt>
xor    %edi,%edi
call   1040 <_exit@plt>

LLVM IR (-O0):
define i32 @SoundPlayFile(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %8
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %4
%15 = call i32 (...) @fork()
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (...) @CloseOpenFiles()
br label %20
20: ; preds = %18, %14
br label %21
21: ; preds = %20, %4
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i8*, i8** %6
%26 = load i32, i32* %7
%27 = call i32 @ESDPlaySoundFile(i8* %25, i32 %26)
store i32 %27, i32* %9
%28 = load i32, i32* %8
%29 = and i32 %28, 1
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 @_exit(i32 0)
unreachable
33: ; preds = %24
br label %34
34: ; preds = %33, %21
%35 = load i32, i32* %9
ret i32 %35
}

LLVM IR (-O2):
define i32 @SoundPlayFile(i8* nocapture readnone %0, i8* %1, i32 %2, i32 %3) {
%5 = and i32 %3, 1
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @ESDPlaySoundFile(i8* %1, i32 %2)
br label %16
9: ; preds = %4
%10 = tail call i32 (...) @fork()
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = tail call i32 (...) @CloseOpenFiles()
%14 = tail call i32 @ESDPlaySoundFile(i8* %1, i32 %2)
%15 = tail call i32 @_exit(i32 0)
unreachable
16: ; preds = %7, %9
%17 = phi i32 [ 0, %9 ], [ %8, %7 ]
ret i32 %17
}