#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;
int O_CREAT;
int O_EXCL;
scalar_t__ errno;
scalar_t__ mkfifo(char *, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(scalar_t__);
int /*<<< orphan*/ unlink(char *);
int pipeCreate(void) {
  printf("pipe create begin\n");
  unlink("/tmp/.public-cmdin");
  if ((mkfifo("/tmp/.public-cmdin", O_CREAT | O_EXCL) < 0) &&
      (errno != EEXIST)) {
    printf("can't create fifo server\n");
    printf("error: %s!\n", strerror(errno));
    return -1;
  }
  unlink("/tmp/.public-cmdout");
  if ((mkfifo("/tmp/.public-cmdout", O_CREAT | O_EXCL) < 0) &&
      (errno != EEXIST)) {
    printf("can't create fifoserver\n");
    printf("error: %s!\n", strerror(errno));
    return -1;
  }
  printf("pipe create end\n");
  return 0;
}


x86 assembly (clang, -O0):
<pipeCreate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
mov    0x2e5e(%rip),%rax
or     (%rax),%esi
lea    0xe98(%rip),%rdi
call   1050 <mkfifo@plt>
cmp    $0x0,%rax
jge    11de <pipeCreate+0x9e>
mov    0x2e37(%rip),%rax
mov    (%rax),%rax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%rax
je     11de <pipeCreate+0x9e>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127b <pipeCreate+0x13b>
lea    0xe67(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
mov    0x2dd6(%rip),%rax
or     (%rax),%esi
lea    0xe49(%rip),%rdi
call   1050 <mkfifo@plt>
cmp    $0x0,%rax
jge    1266 <pipeCreate+0x126>
mov    0x2daf(%rip),%rax
mov    (%rax),%rax
mov    0x2db5(%rip),%rcx
cmp    (%rcx),%rax
je     1266 <pipeCreate+0x126>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127b <pipeCreate+0x13b>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipeCreate>:
push   %r15
push   %r14
push   %rbx
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe98(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2e81(%rip),%r14
mov    0x2e52(%rip),%r15
mov    (%r15),%esi
or     (%r14),%esi
mov    %rbx,%rdi
call   1060 <mkfifo@plt>
test   %rax,%rax
jns    11a7 <pipeCreate+0x57>
mov    0x2e30(%rip),%rbx
mov    (%rbx),%rax
mov    0x2e36(%rip),%rcx
cmp    (%rcx),%rax
jne    11ef <pipeCreate+0x9f>
lea    0xe71(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    (%r15),%esi
or     (%r14),%esi
mov    %rbx,%rdi
call   1060 <mkfifo@plt>
test   %rax,%rax
jns    11df <pipeCreate+0x8f>
mov    0x2df8(%rip),%rbx
mov    (%rbx),%rax
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%rax
jne    11f8 <pipeCreate+0xa8>
lea    0xe5f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    1222 <pipeCreate+0xd2>
lea    0xe77(%rip),%rdi
jmp    11ff <pipeCreate+0xaf>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%rdi
call   1070 <strerror@plt>
lea    0xe00(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"pipe create begin\0A\00"
@.str.1 = [19 x i8] c"/tmp/.public-cmdin\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.2 = [26 x i8] c"can't create fifo server\0A\00"
@.str.3 = [12 x i8] c"error: %s!\0A\00"
@.str.4 = [20 x i8] c"/tmp/.public-cmdout\00"
@.str.5 = [25 x i8] c"can't create fifoserver\0A\00"
@.str.6 = [17 x i8] c"pipe create end\0A\00"
define i32 @pipeCreate() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @unlink(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @O_CREAT
%5 = load i32, i32* @O_EXCL
%6 = or i32 %4, %5
%7 = call i64 @mkfifo(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %0
%10 = load i64, i64* @errno
%11 = load i64, i64* @EEXIST
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%15 = load i64, i64* @errno
%16 = call i8* @strerror(i64 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %16)
store i32 -1, i32* %1
br label %36
18: ; preds = %9, %0
%19 = call i32 @unlink(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%20 = load i32, i32* @O_CREAT
%21 = load i32, i32* @O_EXCL
%22 = or i32 %20, %21
%23 = call i64 @mkfifo(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %18
%26 = load i64, i64* @errno
%27 = load i64, i64* @EEXIST
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%31 = load i64, i64* @errno
%32 = call i8* @strerror(i64 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %32)
store i32 -1, i32* %1
br label %36
34: ; preds = %25, %18
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %36
36: ; preds = %34, %29, %13
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"/tmp/.public-cmdin\00"
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.3 = [12 x i8] c"error: %s!\0A\00"
@.str.4 = [20 x i8] c"/tmp/.public-cmdout\00"
@str = [18 x i8] c"pipe create begin\00"
@str.7 = [16 x i8] c"pipe create end\00"
@str.8 = [24 x i8] c"can't create fifoserver\00"
@str.9 = [25 x i8] c"can't create fifo server\00"
define i32 @pipeCreate() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @unlink(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%3 = load i32, i32* @O_CREAT
%4 = load i32, i32* @O_EXCL
%5 = or i32 %4, %3
%6 = tail call i64 @mkfifo(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %0
%9 = load i64, i64* @errno
%10 = load i64, i64* @EEXIST
%11 = icmp eq i64 %9, %10
br i1 %11, label %17, label %12
12: ; preds = %8
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
%14 = load i64, i64* @errno
%15 = tail call i8* @strerror(i64 %14)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %15)
br label %35
17: ; preds = %8, %0
%18 = tail call i32 @unlink(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32, i32* @O_CREAT
%20 = load i32, i32* @O_EXCL
%21 = or i32 %20, %19
%22 = tail call i64 @mkfifo(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %17
%25 = load i64, i64* @errno
%26 = load i64, i64* @EEXIST
%27 = icmp eq i64 %25, %26
br i1 %27, label %33, label %28
28: ; preds = %24
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0))
%30 = load i64, i64* @errno
%31 = tail call i8* @strerror(i64 %30)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %31)
br label %35
33: ; preds = %24, %17
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.7, i64 0, i64 0))
br label %35
35: ; preds = %33, %28, %12
%36 = phi i32 [ -1, %12 ], [ -1, %28 ], [ 0, %33 ]
ret i32 %36
}