#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 */
scalar_t__ EEXIST;
char action();
scalar_t__ errno;
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ mem_map();
int mkfifo(char *, int);
int /*<<< orphan*/ process_options(int, char **);
int /*<<< orphan*/ remove(char *);
int main(int argc, char **argv) {
  int ret;
  char ch;
  process_options(argc, argv);
  ret = mkfifo("status_pipe", 0666);
  if (ret == -1 && errno != EEXIST)
    errx(1, "Error creating named pipe");
  do {
    ch = action();
    if (ch == 'm')
      mem_map();
  } while (ch != 'x');
  remove("status_pipe");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <process_options@plt>
lea    0xe77(%rip),%rdi
mov    $0x1b6,%esi
call   1060 <mkfifo@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11cb <main+0x6b>
mov    0x2e31(%rip),%rax
mov    (%rax),%rax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
je     11cb <main+0x6b>
mov    $0x1,%edi
lea    0xe46(%rip),%rsi
call   1050 <errx@plt>
jmp    11d0 <main+0x70>
mov    $0x0,%al
call   1070 <action@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x6d,%eax
jne    11ee <main+0x8e>
mov    $0x0,%al
call   1080 <mem_map@plt>
jmp    11f3 <main+0x93>
movsbl -0x15(%rbp),%eax
cmp    $0x78,%eax
jne    11d0 <main+0x70>
lea    0xdf9(%rip),%rdi
call   1040 <remove@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1030 <process_options@plt>
lea    0xe93(%rip),%rdi
mov    $0x1b6,%esi
call   1060 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    11b7 <main+0x57>
mov    0x2e55(%rip),%rax
mov    (%rax),%rax
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%rax
je     11b7 <main+0x57>
lea    0xe73(%rip),%rsi
mov    $0x1,%edi
call   1050 <errx@plt>
jmp    11b7 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <mem_map@plt>
xor    %eax,%eax
call   1070 <action@plt>
cmp    $0x6d,%al
je     11b0 <main+0x50>
cmp    $0x78,%al
jne    11b7 <main+0x57>
lea    0xe33(%rip),%rdi
call   1040 <remove@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"status_pipe\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [26 x i8] c"Error creating named pipe\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @process_options(i32 %8, i8** %9)
%11 = call i32 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 438)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i64, i64* @errno
%16 = load i64, i64* @EEXIST
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @errx(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %14, %2
br label %21
21: ; preds = %29, %20
%22 = call signext i8 (...) @action()
store i8 %22, i8* %7
%23 = load i8, i8* %7
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 109
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 (...) @mem_map()
br label %28
28: ; preds = %26, %21
br label %29
29: ; preds = %28
%30 = load i8, i8* %7
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 120
br i1 %32, label %21, label %33
33: ; preds = %29
%34 = call i32 @remove(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"status_pipe\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [26 x i8] c"Error creating named pipe\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @process_options(i32 %0, i8** %1)
%4 = tail call i32 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 438)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i64, i64* @errno
%8 = load i64, i64* @EEXIST
%9 = icmp eq i64 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %6, %2
br label %13
13: ; preds = %15, %12
%14 = tail call signext i8 (...) @action()
switch i8 %14, label %15 [
i8 109, label %16
i8 120, label %18
]
15: ; preds = %13, %16
br label %13
16: ; preds = %13
%17 = tail call i32 (...) @mem_map()
br label %15
18: ; preds = %13
%19 = tail call i32 @remove(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}