#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*/ O_RDONLY;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int main() {
  char buffer[256];
  mkfifo("S_QUEUE", 0666);
  int sound_queue = open("S_QUEUE", O_RDONLY);
  if (sound_queue == -1) {
    perror("error_fifo yould not be opened!");
    exit(-1);
  }
  while (strcmp(buffer, "END")) {
    while (3 > read(sound_queue, buffer, 265))
      ;
    if (!strcmp(buffer, "hit")) {
      system("afplay ./fx/explosion-04.wav ");
    } else if (!strcmp(buffer, "shot")) {
    }
    printf("%s", buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x1b6,%esi
call   1070 <mkfifo@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
lea    0xe4d(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0xffffffff,-0x114(%rbp)
jne    11e1 <main+0x61>
lea    0xe36(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
jmp    11e6 <main+0x66>
lea    -0x110(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12a0 <main+0x120>
jmp    1208 <main+0x88>
mov    -0x114(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x109,%edx
call   1050 <read@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
jle    1233 <main+0xb3>
jmp    1208 <main+0x88>
lea    -0x110(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1261 <main+0xe1>
lea    0xdd9(%rip),%rdi
call   1030 <system@plt>
jmp    1288 <main+0x108>
lea    -0x110(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1283 <main+0x103>
jmp    1283 <main+0x103>
jmp    1288 <main+0x108>
lea    -0x110(%rbp),%rsi
lea    0xdbd(%rip),%rdi
call   1040 <printf@plt>
jmp    11e6 <main+0x66>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe68(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1b6,%esi
call   1070 <mkfifo@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     126c <main+0xec>
mov    %eax,%ebp
lea    0xe60(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1258 <main+0xd8>
mov    %rsp,%rbx
lea    0xe49(%rip),%r14
lea    0xe69(%rip),%r12
lea    0xe37(%rip),%r13
lea    0xe56(%rip),%r15
jmp    1226 <main+0xa6>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1258 <main+0xd8>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x109,%edx
call   1050 <read@plt>
cmp    $0x3,%eax
jl     1226 <main+0xa6>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1200 <main+0x80>
lea    0xddf(%rip),%rdi
call   1030 <system@plt>
jmp    120b <main+0x8b>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd95(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"S_QUEUE\00"
@O_RDONLY = global i32 0
@.str.1 = [32 x i8] c"error_fifo yould not be opened!\00"
@.str.2 = [4 x i8] c"END\00"
@.str.3 = [4 x i8] c"hit\00"
@.str.4 = [30 x i8] c"afplay ./fx/explosion-04.wav \00"
@.str.5 = [5 x i8] c"shot\00"
@.str.6 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @mkfifo(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 438)
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %0
br label %13
13: ; preds = %36, %12
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %13
br label %18
18: ; preds = %23, %17
%19 = load i32, i32* %3
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i32 265)
%22 = icmp sgt i32 3, %21
br i1 %22, label %23, label %24
23: ; preds = %18
br label %18
24: ; preds = %18
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %36
30: ; preds = %24
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %30
br label %35
35: ; preds = %34, %30
br label %36
36: ; preds = %35, %28
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %37)
br label %13
39: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"S_QUEUE\00"
@O_RDONLY = global i32 0
@.str.1 = [32 x i8] c"error_fifo yould not be opened!\00"
@.str.2 = [4 x i8] c"END\00"
@.str.3 = [4 x i8] c"hit\00"
@.str.4 = [30 x i8] c"afplay ./fx/explosion-04.wav \00"
@.str.5 = [5 x i8] c"shot\00"
@.str.6 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @mkfifo(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 438)
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %28, label %13
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %7, %16
%14 = call i32 @read(i32 %5, i8* %2, i32 265)
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %17
16: ; preds = %13, %24
br label %13
17: ; preds = %13
%18 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %24
22: ; preds = %17
%23 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%26 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %16
28: ; preds = %24, %7
ret i32 0
}