#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*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
size_t read(int, char *, int);
int main() {
  int fd;
  size_t size;
  char resstring[14];
  char name[] = "aaa.fifo";
  if ((fd = open(name, O_RDONLY)) < 0) {
    printf("Can\'t open FIFO for reading\n");
    exit(-1);
  }
  size = read(fd, resstring, 14);
  if (size < 0) {
    printf("Can\'t read string\n");
    exit(-1);
  }
  printf("%s\n", resstring);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x27(%rbp)
mov    0xe98(%rip),%al
mov    %al,-0x1f(%rbp)
lea    -0x27(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11a9 <main+0x59>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0xe,%edx
call   1050 <read@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jae    11e1 <main+0x91>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
lea    -0x1e(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x6f6669662e616161,%rax
69 66 6f
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1060 <open@plt>
test   %eax,%eax
js     11ae <main+0x5e>
mov    %eax,%ebx
lea    0xa(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0xe,%edx
call   1050 <read@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.name = [9 x i8] c"aaa.fifo\00"
@O_RDONLY = global i32 0
@.str = [29 x i8] c"Can't open FIFO for reading\0A\00"
@.str.1 = [19 x i8] c"Can't read string\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca [14 x i8]
%5 = alloca [9 x i8]
store i32 0, i32* %1
%6 = bitcast [9 x i8]* %5 to i8*
%7 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%8 = load i32, i32* @O_RDONLY
%9 = call i32 @open(i8* %7, i32 %8)
store i32 %9, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 -1)
unreachable
14: ; preds = %0
%15 = load i32, i32* %2
%16 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%17 = call i64 @read(i32 %15, i8* %16, i32 14)
store i64 %17, i64* %3
%18 = load i64, i64* %3
%19 = icmp ult i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %14
%24 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %2
%27 = call i32 @close(i32 %26)
ret i32 0
}

LLVM IR (-O2):
@__const.main.name = [9 x i8] c"aaa.fifo\00"
@O_RDONLY = global i32 0
@str = [28 x i8] c"Can't open FIFO for reading\00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* %4, i32 %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %0
%12 = call i64 @read(i32 %6, i8* %3, i32 14)
%13 = call i32 @puts(i8* %3)
%14 = tail call i32 @close(i32 %6)
ret i32 0
}