#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ client(int, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int main(int argc, char **argv) {
  int readfd;
  int writefd;
  if (0 > (writefd = open("/tmp/fifo.1", O_WRONLY, 0))) {
    printf("open %s error: %s", "/tmp/fifo.1", strerror(errno));
  }
  if (0 > (readfd = open("/tmp/fifo.2", O_RDONLY, 0))) {
    printf("open %s error: %s", "/tmp/fifo.2", strerror(errno));
  }
  client(readfd, writefd);
  close(readfd);
  close(writefd);
  unlink("/tmp/fifo.1");
  unlink("/tmp/fifo.2");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
lea    0xe6a(%rip),%rdi
xor    %edx,%edx
call   1060 <open@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jle    11d0 <main+0x60>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rdx
lea    0xe48(%rip),%rdi
lea    0xe35(%rip),%rsi
call   1040 <printf@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
xor    %edx,%edx
call   1060 <open@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jle    121a <main+0xaa>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %rax,%rdx
lea    0xdfe(%rip),%rdi
lea    0xe09(%rip),%rsi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <client@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
lea    0xdc4(%rip),%rdi
call   1030 <unlink@plt>
lea    0xdd6(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
lea    0xe7d(%rip),%rdi
xor    %edx,%edx
call   1060 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11b4 <main+0x44>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe67(%rip),%rdi
lea    0xe54(%rip),%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
lea    0xe5a(%rip),%rdi
xor    %edx,%edx
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11f5 <main+0x85>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe26(%rip),%rdi
lea    0xe31(%rip),%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <client@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %ebx,%edi
call   1050 <close@plt>
lea    0xded(%rip),%rdi
call   1030 <unlink@plt>
lea    0xdff(%rip),%rdi
call   1030 <unlink@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"/tmp/fifo.1\00"
@O_WRONLY = global i32 0
@.str.1 = [18 x i8] c"open %s error: %s\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"/tmp/fifo.2\00"
@O_RDONLY = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @O_WRONLY
%9 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 0)
store i32 %9, i32* %7
%10 = icmp sgt i32 0, %9
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %11, %2
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 0)
store i32 %17, i32* %6
%18 = icmp sgt i32 0, %17
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %15
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = call i32 @client(i32 %24, i32 %25)
%27 = load i32, i32* %6
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %7
%30 = call i32 @close(i32 %29)
%31 = call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* @EXIT_SUCCESS
%34 = call i32 @exit(i32 %33)
unreachable
}

LLVM IR (-O2):
@.str = [12 x i8] c"/tmp/fifo.1\00"
@O_WRONLY = global i32 0
@.str.1 = [18 x i8] c"open %s error: %s\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"/tmp/fifo.2\00"
@O_RDONLY = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_WRONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %3, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %6, %2
%11 = load i32, i32* @O_RDONLY
%12 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 0)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %14, %10
%19 = tail call i32 @client(i32 %12, i32 %4)
%20 = tail call i32 @close(i32 %12)
%21 = tail call i32 @close(i32 %4)
%22 = tail call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @unlink(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @EXIT_SUCCESS
%25 = tail call i32 @exit(i32 %24)
unreachable
}