#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 S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
scalar_t__ errno;
scalar_t__ mkfifo(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ unlink(char *);
int mkfifos() {
  if ((mkfifo("/tmp/fifo.1", (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) &&
      errno != EEXIST) {
    perror("Can't create Fifo1: ");
  }
  if ((mkfifo("/tmp/fifo.2", (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) &&
      errno != EEXIST) {
    perror("Can't create Fifo2: ");
    unlink("/tmp/fifo.1");
  }
  printf("FIFOs made\n");
}


x86 assembly (clang, -O0):
<mkfifos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    0x2e90(%rip),%rax
or     (%rax),%esi
mov    0x2e67(%rip),%rax
or     (%rax),%esi
mov    0x2e56(%rip),%rax
or     (%rax),%esi
lea    0xe8d(%rip),%rdi
call   1050 <mkfifo@plt>
cmp    $0x0,%rax
jge    11a8 <mkfifos+0x68>
mov    0x2e47(%rip),%rax
mov    (%rax),%rax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%rax
je     11a8 <mkfifos+0x68>
lea    0xe69(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%esi
mov    0x2e30(%rip),%rax
or     (%rax),%esi
mov    0x2e07(%rip),%rax
or     (%rax),%esi
mov    0x2df6(%rip),%rax
or     (%rax),%esi
lea    0xe4e(%rip),%rdi
call   1050 <mkfifo@plt>
cmp    $0x0,%rax
jge    1214 <mkfifos+0xd4>
mov    0x2de7(%rip),%rax
mov    (%rax),%rax
mov    0x2de5(%rip),%rcx
cmp    (%rcx),%rax
je     1214 <mkfifos+0xd4>
lea    0xe2a(%rip),%rdi
call   1060 <perror@plt>
lea    0xdf1(%rip),%rdi
call   1030 <unlink@plt>
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkfifos>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e69(%rip),%r14
mov    0x2e92(%rip),%r12
mov    (%r12),%esi
or     (%r14),%esi
mov    0x2e64(%rip),%r15
or     (%r15),%esi
mov    0x2e52(%rip),%rbx
or     (%rbx),%esi
lea    0xe89(%rip),%rdi
call   1050 <mkfifo@plt>
test   %rax,%rax
jns    1197 <mkfifos+0x57>
mov    0x2e48(%rip),%rax
mov    (%rax),%rax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%rax
jne    11e1 <mkfifos+0xa1>
mov    (%r12),%esi
or     (%r14),%esi
or     (%r15),%esi
or     (%rbx),%esi
lea    0xe77(%rip),%rdi
call   1050 <mkfifo@plt>
test   %rax,%rax
jns    11ca <mkfifos+0x8a>
mov    0x2e15(%rip),%rax
mov    (%rax),%rax
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%rax
jne    11ef <mkfifos+0xaf>
lea    0xe71(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <puts@plt>
lea    0xe24(%rip),%rdi
call   1060 <perror@plt>
jmp    1197 <mkfifos+0x57>
lea    0xe37(%rip),%rdi
call   1060 <perror@plt>
lea    0xdfe(%rip),%rdi
call   1030 <unlink@plt>
jmp    11ca <mkfifos+0x8a>

LLVM IR (-O0):
@.str = [12 x i8] c"/tmp/fifo.1\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [21 x i8] c"Can't create Fifo1: \00"
@.str.2 = [12 x i8] c"/tmp/fifo.2\00"
@.str.3 = [21 x i8] c"Can't create Fifo2: \00"
@.str.4 = [12 x i8] c"FIFOs made\0A\00"
define i32 @mkfifos() {
%1 = alloca i32
%2 = load i32, i32* @S_IRUSR
%3 = load i32, i32* @S_IWUSR
%4 = or i32 %2, %3
%5 = load i32, i32* @S_IRGRP
%6 = or i32 %4, %5
%7 = load i32, i32* @S_IROTH
%8 = or i32 %6, %7
%9 = call i64 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = load i64, i64* @errno
%13 = load i64, i64* @EEXIST
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %11, %0
%18 = load i32, i32* @S_IRUSR
%19 = load i32, i32* @S_IWUSR
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IRGRP
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IROTH
%24 = or i32 %22, %23
%25 = call i64 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %17
%28 = load i64, i64* @errno
%29 = load i64, i64* @EEXIST
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %31, %27, %17
%35 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [12 x i8] c"/tmp/fifo.1\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [21 x i8] c"Can't create Fifo1: \00"
@.str.2 = [12 x i8] c"/tmp/fifo.2\00"
@.str.3 = [21 x i8] c"Can't create Fifo2: \00"
@str = [11 x i8] c"FIFOs made\00"
define i32 @mkfifos() {
%1 = load i32, i32* @S_IRUSR
%2 = load i32, i32* @S_IWUSR
%3 = or i32 %2, %1
%4 = load i32, i32* @S_IRGRP
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IROTH
%7 = or i32 %5, %6
%8 = tail call i64 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = load i64, i64* @errno
%12 = load i64, i64* @EEXIST
%13 = icmp eq i64 %11, %12
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %10, %0
%17 = load i32, i32* @S_IRUSR
%18 = load i32, i32* @S_IWUSR
%19 = or i32 %18, %17
%20 = load i32, i32* @S_IRGRP
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IROTH
%23 = or i32 %21, %22
%24 = tail call i64 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %33
26: ; preds = %16
%27 = load i64, i64* @errno
%28 = load i64, i64* @EEXIST
%29 = icmp eq i64 %27, %28
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %30, %26, %16
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 undef
}