#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*/ F_OK;
int access(char *, int /*<<< orphan*/);
int mkfifo(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ unlink(char *);
int main() {
  char *fifo_name = "/tmp/my_fifo";
  if (access(fifo_name, F_OK) == -1) {
    int res = mkfifo(fifo_name, 0777);
    printf("FIFO created %s\n", res == 0 ? "success" : "failed");
  } else {
    printf("file exists\n");
    unlink(fifo_name);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0xffffffff,%eax
jne    11b1 <main+0x71>
mov    -0x10(%rbp),%rdi
mov    $0x1ff,%esi
call   1050 <mkfifo@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
lea    0xe96(%rip),%rsi
lea    0xe87(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c8 <main+0x88>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1070 <access@plt>
cmp    $0xffffffff,%eax
je     1185 <main+0x35>
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
lea    0xe82(%rip),%rdi
call   1030 <unlink@plt>
jmp    11b8 <main+0x68>
lea    0xe74(%rip),%rdi
mov    $0x1ff,%esi
call   1060 <mkfifo@plt>
test   %eax,%eax
lea    0xe7f(%rip),%rax
lea    0xe80(%rip),%rsi
cmove  %rax,%rsi
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/tmp/my_fifo\00"
@F_OK = global i32 0
@.str.1 = [17 x i8] c"FIFO created %s\0A\00"
@.str.2 = [8 x i8] c"success\00"
@.str.3 = [7 x i8] c"failed\00"
@.str.4 = [13 x i8] c"file exists\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @F_OK
%6 = call i32 @access(i8* %4, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %16
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i32 @mkfifo(i8* %9, i32 511)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %20
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%18 = load i8*, i8** %2
%19 = call i32 @unlink(i8* %18)
br label %20
20: ; preds = %16, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"/tmp/my_fifo\00"
@F_OK = global i32 0
@.str.1 = [17 x i8] c"FIFO created %s\0A\00"
@.str.2 = [8 x i8] c"success\00"
@.str.3 = [7 x i8] c"failed\00"
@str = [12 x i8] c"file exists\00"
define i32 @main() {
%1 = load i32, i32* @F_OK
%2 = tail call i32 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = tail call i32 @mkfifo(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 511)
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %12
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %9, %4
ret i32 0
}