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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int file_exists(char const *);
int mkfifo(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
void safe_mkfifo(const char *pathname, mode_t mode) {
  if (file_exists(pathname) == false) {
    if (mkfifo(pathname, mode) == -1) {
      perror("safe_makefifo - Failed to create named fifo.");
      exit(EXIT_FAILURE);
    }
  } else {
    if (true) {
      printf("DEBUG: ");
      printf("safe_makefifo - FIFO '%s' already exists. Clean it properly!\n",
             pathname);
    };
  }
}


x86 assembly (clang, -O0):
<safe_mkfifo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <file_exists@plt>
cmp    $0x0,%eax
jne    11a5 <safe_mkfifo+0x55>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    11a0 <safe_mkfifo+0x50>
lea    0xe73(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    11c5 <safe_mkfifo+0x75>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_mkfifo>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <file_exists@plt>
test   %eax,%eax
je     1186 <safe_mkfifo+0x36>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <mkfifo@plt>
cmp    $0xffffffff,%eax
je     119c <safe_mkfifo+0x4c>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe5d(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"safe_makefifo - Failed to create named fifo.\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"DEBUG: \00"
@.str.2 = [62 x i8] c"safe_makefifo - FIFO '%s' already exists. Clean it properly!\0A\00"
define void @safe_mkfifo(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = call i32 @file_exists(i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = call i32 @mkfifo(i8* %9, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %8
br label %22
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8*, i8** %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %18, %17
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"safe_makefifo - Failed to create named fifo.\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"DEBUG: \00"
@.str.2 = [62 x i8] c"safe_makefifo - FIFO '%s' already exists. Clean it properly!\0A\00"
define void @safe_mkfifo(i8* %0, i32 %1) {
%3 = tail call i32 @file_exists(i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i32 @mkfifo(i8* %0, i32 %1)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = tail call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %5, %12
ret void
}