#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read(int, char *, int);
int main() {
  int fd;
  char *myfifo = "/tmp/myfifo";
  mkfifo(myfifo, 0666);
  char str[80];
  while (1) {
    fd = open(myfifo, O_RDONLY);
    read(fd, str, 80);
    printf("%s\n", str);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1b6,%esi
call   1050 <mkfifo@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x50,%edx
call   1040 <read@plt>
lea    -0x60(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
jmp    1168 <main+0x28>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xeae(%rip),%r14
mov    %r14,%rdi
mov    $0x1b6,%esi
call   1050 <mkfifo@plt>
mov    0x2e82(%rip),%r12
mov    %rsp,%rbx
lea    0xe9c(%rip),%r15
mov    (%r12),%esi
mov    %r14,%rdi
call   1060 <open@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1040 <read@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    1170 <main+0x30>

LLVM IR (-O0):
@.str = [12 x i8] c"/tmp/myfifo\00"
@O_RDONLY = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [80 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @mkfifo(i8* %5, i32 438)
br label %7
7: ; preds = %0, %7
%8 = load i8*, i8** %3
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* %8, i32 %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 80)
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %7
}

LLVM IR (-O2):
@.str = [12 x i8] c"/tmp/myfifo\00"
@O_RDONLY = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = tail call i32 @mkfifo(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 438)
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %4, %0
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @read(i32 %6, i8* %3, i32 80)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %4
}