#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*/ F_OK;
int /*<<< orphan*/ O_WRONLY;
int PIPE_BUF;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int fd;
  char buf[PIPE_BUF];
  if (access("/tmp/myfifo", F_OK) == -1)
    mkfifo("/tmp/myfifo", 0666);
  fd = open("/tmp/myfifo", O_WRONLY);
  while (1) {
    bzero(buf, PIPE_BUF);
    fgets(buf, PIPE_BUF, stdin);
    write(fd, buf, strlen(buf));
  }
  close(fd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
lea    0xe3e(%rip),%rdi
call   1080 <access@plt>
cmp    $0xffffffff,%eax
jne    11e1 <main+0x71>
lea    0xe29(%rip),%rdi
mov    $0x1b6,%esi
call   1060 <mkfifo@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%esi
lea    0xe0f(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
jmp    11fe <main+0x8e>
mov    -0x30(%rbp),%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
call   1090 <bzero@plt>
mov    -0x30(%rbp),%rdi
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
call   1040 <strlen@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    11f9 <main+0x89>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e53(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    0x2e1f(%rip),%rax
mov    (%rax),%esi
lea    0xe56(%rip),%rdi
call   1080 <access@plt>
cmp    $0xffffffff,%eax
jne    11c5 <main+0x55>
lea    0xe45(%rip),%rdi
mov    $0x1b6,%esi
call   1060 <mkfifo@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
lea    0xe2b(%rip),%rdi
call   1070 <open@plt>
mov    %eax,%r14d
mov    0x2e04(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12),%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1090 <bzero@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <fgets@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    11f0 <main+0x80>

LLVM IR (-O0):
@PIPE_BUF = global i32 0
@.str = [12 x i8] c"/tmp/myfifo\00"
@F_OK = global i32 0
@O_WRONLY = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @PIPE_BUF
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %7
%12 = alloca i8, i64 %10
store i64 %10, i64* %8
%13 = load i32, i32* @F_OK
%14 = call i32 @access(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 438)
br label %18
18: ; preds = %16, %2
%19 = load i32, i32* @O_WRONLY
%20 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 %20, i32* %6
br label %21
21: ; preds = %22, %18
br label %22
22: ; preds = %21
%23 = load i32, i32* @PIPE_BUF
%24 = call i32 @bzero(i8* %12, i32 %23)
%25 = load i32, i32* @PIPE_BUF
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %12, i32 %25, i32 %26)
%28 = load i32, i32* %6
%29 = call i32 @strlen(i8* %12)
%30 = call i32 @write(i32 %28, i8* %12, i32 %29)
br label %21
}

LLVM IR (-O2):
@PIPE_BUF = global i32 0
@.str = [12 x i8] c"/tmp/myfifo\00"
@F_OK = global i32 0
@O_WRONLY = global i32 0
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @PIPE_BUF
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = load i32, i32* @F_OK
%7 = tail call i32 @access(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 438)
br label %11
11: ; preds = %9, %2
%12 = load i32, i32* @O_WRONLY
%13 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %14, %11
%15 = load i32, i32* @PIPE_BUF
%16 = call i32 @bzero(i8* %5, i32 %15)
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %5, i32 %15, i32 %17)
%19 = call i32 @strlen(i8* %5)
%20 = call i32 @write(i32 %13, i8* %5, i32 %19)
br label %14
}