#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 */
scalar_t__ EEXIST;
scalar_t__ errno;
int mkfifo(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char const *);
int Mkfifo(const char *fifoname, mode_t mode) {
  if (-1 == mkfifo(fifoname, mode) && errno != EEXIST) {
    perror("mkfifo");
    return (-1);
  }
  if (errno == EEXIST) {
    printf("fifo: %s exists!\n", fifoname);
  }
  return (0);
}


x86 assembly (clang, -O0):
<Mkfifo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <mkfifo@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    118c <Mkfifo+0x5c>
mov    0x2e77(%rip),%rax
mov    (%rax),%rax
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%rax
je     118c <Mkfifo+0x5c>
lea    0xe85(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <Mkfifo+0x8d>
mov    0x2e45(%rip),%rax
mov    (%rax),%rax
mov    0x2e43(%rip),%rcx
cmp    (%rcx),%rax
jne    11b6 <Mkfifo+0x86>
mov    -0x10(%rbp),%rsi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mkfifo>:
push   %rbx
mov    %rdi,%rbx
call   1040 <mkfifo@plt>
mov    0x2e98(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e96(%rip),%rdx
mov    (%rdx),%rdx
cmp    $0xffffffff,%eax
je     115b <Mkfifo+0x2b>
xor    %eax,%eax
cmp    %rdx,%rcx
je     1160 <Mkfifo+0x30>
pop    %rbx
ret
cmp    %rdx,%rcx
jne    1173 <Mkfifo+0x43>
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe86(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@errno = global i64 0
@EEXIST = global i64 0
@.str = [7 x i8] c"mkfifo\00"
@.str.1 = [18 x i8] c"fifo: %s exists!\0A\00"
define i32 @Mkfifo(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = load i32, i32* %5
%8 = call i32 @mkfifo(i8* %6, i32 %7)
%9 = icmp eq i32 -1, %8
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i64, i64* @errno
%12 = load i64, i64* @EEXIST
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %24
16: ; preds = %10, %2
%17 = load i64, i64* @errno
%18 = load i64, i64* @EEXIST
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %16
store i32 0, i32* %3
br label %24
24: ; preds = %23, %14
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@errno = global i64 0
@EEXIST = global i64 0
@.str = [7 x i8] c"mkfifo\00"
@.str.1 = [18 x i8] c"fifo: %s exists!\0A\00"
define i32 @Mkfifo(i8* %0, i32 %1) {
%3 = tail call i32 @mkfifo(i8* %0, i32 %1)
%4 = icmp eq i32 %3, -1
%5 = load i64, i64* @errno
%6 = load i64, i64* @EEXIST
%7 = icmp eq i64 %5, %6
br i1 %4, label %8, label %11
8: ; preds = %2
br i1 %7, label %12, label %9
9: ; preds = %8
%10 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %14
11: ; preds = %2
br i1 %7, label %12, label %14
12: ; preds = %8, %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %11, %12, %9
%15 = phi i32 [ -1, %9 ], [ 0, %12 ], [ 0, %11 ]
ret i32 %15
}