#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 ssize_t;

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ O_RDONLY;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ unlink(char *);
int main() {
  char line[(8092)];
  int fifo;
  ssize_t nread;
  if (access("myfifo.f", F_OK) == -1) {
    perror("[read]");
    if (mkfifo("myfifo.f", (0644)) == -1) {
      perror("[read]");
      return -1;
    }
  }
  if ((fifo = open("myfifo.f", O_RDONLY)) == -1) {
    perror("[read]");
    return -1;
  }
  while (1) {
    memset(line, 0, (8092));
    nread = read(fifo, line, (8092) - 1);
    if (nread == -1) {
      perror("[read]");
      break;
    } else if (nread > 0) {
      printf("[read]:%s\n", line);
    }
  }
  close(fifo);
  unlink("myfifo.f");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1fb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   10a0 <access@plt>
cmp    $0xffffffff,%eax
jne    1213 <main+0x73>
lea    0xe32(%rip),%rdi
call   10b0 <perror@plt>
lea    0xe1d(%rip),%rdi
mov    $0x1a4,%esi
call   1080 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    120e <main+0x6e>
lea    0xe0c(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ea <main+0x14a>
jmp    1213 <main+0x73>
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
lea    0xddd(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x1fa4(%rbp)
cmp    $0xffffffff,%eax
jne    124f <main+0xaf>
lea    0xdcb(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ea <main+0x14a>
jmp    1254 <main+0xb4>
lea    -0x1fa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x1f9c,%edx
call   1050 <memset@plt>
mov    -0x1fa4(%rbp),%edi
lea    -0x1fa0(%rbp),%rsi
mov    $0x1f9b,%edx
call   1070 <read@plt>
mov    %eax,-0x1fa8(%rbp)
cmpl   $0xffffffff,-0x1fa8(%rbp)
jne    12a2 <main+0x102>
lea    0xd71(%rip),%rdi
call   10b0 <perror@plt>
jmp    12cc <main+0x12c>
cmpl   $0x0,-0x1fa8(%rbp)
jle    12c2 <main+0x122>
lea    -0x1fa0(%rbp),%rsi
lea    0xd53(%rip),%rdi
call   1040 <printf@plt>
jmp    12c7 <main+0x127>
jmp    1254 <main+0xb4>
mov    -0x1fa4(%rbp),%edi
call   1060 <close@plt>
lea    0xd22(%rip),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x1fb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1fa0,%rsp
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
lea    0xe45(%rip),%rdi
call   10a0 <access@plt>
cmp    $0xffffffff,%eax
jne    11e7 <main+0x47>
lea    0xe3d(%rip),%rdi
call   10b0 <perror@plt>
lea    0xe28(%rip),%rdi
mov    $0x1a4,%esi
call   1080 <mkfifo@plt>
cmp    $0xffffffff,%eax
je     1201 <main+0x61>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
lea    0xe09(%rip),%rdi
call   1090 <open@plt>
cmp    $0xffffffff,%eax
jne    121e <main+0x7e>
lea    0xe01(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%eax
add    $0x1fa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1f9c,%edx
call   1050 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1f9b,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
jne    126c <main+0xcc>
lea    0xdbc(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebp,%edi
call   1060 <close@plt>
lea    0xda0(%rip),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    0xd9d(%rip),%r14
mov    %rsp,%rbx
jmp    12a3 <main+0x103>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1f9c,%edx
call   1050 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1f9b,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     1246 <main+0xa6>
test   %eax,%eax
jle    1280 <main+0xe0>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    1280 <main+0xe0>

LLVM IR (-O0):
@.str = [9 x i8] c"myfifo.f\00"
@F_OK = global i32 0
@.str.1 = [7 x i8] c"[read]\00"
@O_RDONLY = global i32 0
@.str.2 = [11 x i8] c"[read]:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8092 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @F_OK
%6 = call i32 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 420)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %45
14: ; preds = %8
br label %15
15: ; preds = %14, %0
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %16)
store i32 %17, i32* %3
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %45
21: ; preds = %15
br label %22
22: ; preds = %21, %39
%23 = getelementptr inbounds [8092 x i8], [8092 x i8]* %2, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 8092)
%25 = load i32, i32* %3
%26 = getelementptr inbounds [8092 x i8], [8092 x i8]* %2, i64 0, i64 0
%27 = call i32 @read(i32 %25, i8* %26, i32 8091)
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %40
32: ; preds = %22
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = getelementptr inbounds [8092 x i8], [8092 x i8]* %2, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %38
br label %22
40: ; preds = %30
%41 = load i32, i32* %3
%42 = call i32 @close(i32 %41)
%43 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %19, %12
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [9 x i8] c"myfifo.f\00"
@F_OK = global i32 0
@.str.1 = [7 x i8] c"[read]\00"
@O_RDONLY = global i32 0
@.str.2 = [11 x i8] c"[read]:%s\0A\00"
define i32 @main() {
%1 = alloca [8092 x i8]
%2 = getelementptr inbounds [8092 x i8], [8092 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @F_OK
%4 = tail call i32 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @mkfifo(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 420)
%9 = icmp eq i32 %8, -1
br i1 %9, label %32, label %10
10: ; preds = %6, %0
%11 = load i32, i32* @O_RDONLY
%12 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %32, label %14
14: ; preds = %10
%15 = call i32 @memset(i8* %2, i32 0, i32 8092)
%16 = call i32 @read(i32 %12, i8* %2, i32 8091)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %23
18: ; preds = %28, %14
%19 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @close(i32 %12)
%21 = call i32 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %14, %28
%24 = phi i32 [ %30, %28 ], [ %16, %14 ]
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %28
28: ; preds = %23, %26
%29 = call i32 @memset(i8* %2, i32 0, i32 8092)
%30 = call i32 @read(i32 %12, i8* %2, i32 8091)
%31 = icmp eq i32 %30, -1
br i1 %31, label %18, label %23
32: ; preds = %10, %6
%33 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret i32 -1
}