#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 /*<<< orphan*/ resstring;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
scalar_t__ fork();
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int fd = 0, result = 0, size = 0;
  char resstring[14];
  char name[] = "20131028.fifo";
  memset(resstring, 0, sizeof(resstring));
  memcpy(name, "10", 2);
  if (mkfifo(name, 0666) < 0) {
  }
  if (fork()) {
    if ((fd = open(name, O_WRONLY)) < 0) {
      return -1;
    }
    size = write(fd, "20131028", strlen("20131028"));
    if (size != 14) {
    }
    close(fd);
  } else {
    if ((fd = open(name, O_RDONLY)) < 0) {
    }
    size = read(fd, resstring, 14);
    if (size != 14) {
    }
    printf("Recieved text: %s", resstring);
    close(fd);
  }
  return 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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0xe2e(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe2c(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    0xe26(%rip),%ax
mov    %ax,-0x2c(%rbp)
lea    -0x2a(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1060 <memset@plt>
lea    -0x38(%rbp),%rdi
lea    0xe09(%rip),%rsi
mov    $0x2,%edx
call   10a0 <memcpy@plt>
lea    -0x38(%rbp),%rdi
mov    $0x1b6,%esi
call   1090 <mkfifo@plt>
cmp    $0x0,%rax
jge    122c <main+0x8c>
jmp    122c <main+0x8c>
mov    $0x0,%al
call   10c0 <fork@plt>
cmp    $0x0,%rax
je     12a9 <main+0x109>
lea    -0x38(%rbp),%rdi
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1267 <main+0xc7>
movl   $0xffffffff,-0x4(%rbp)
jmp    130e <main+0x16e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    0xd9d(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%edx
lea    0xd8c(%rip),%rsi
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xe,-0x1c(%rbp)
je     129c <main+0xfc>
jmp    129c <main+0xfc>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
jmp    1307 <main+0x167>
lea    -0x38(%rbp),%rdi
mov    0x2d34(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12cc <main+0x12c>
jmp    12cc <main+0x12c>
mov    -0x14(%rbp),%edi
lea    -0x2a(%rbp),%rsi
mov    $0xe,%edx
call   1080 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xe,-0x1c(%rbp)
je     12ef <main+0x14f>
jmp    12ef <main+0x14f>
lea    -0x2a(%rbp),%rsi
lea    0xd20(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movabs $0x6f6669662e3832,%rax
mov    %rax,0xe(%rsp)
movabs $0x3832303133313032,%rax
30 32 38
mov    %rax,0x8(%rsp)
lea    0x1a(%rsp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1060 <memset@plt>
lea    0xe31(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%edx
call   10a0 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x1b6,%esi
call   1090 <mkfifo@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
je     123e <main+0x9e>
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdi
call   10b0 <open@plt>
test   %eax,%eax
js     1281 <main+0xe1>
mov    %eax,%ebx
lea    0xde9(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    1276 <main+0xd6>
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdi
call   10b0 <open@plt>
mov    %eax,%ebx
lea    0x1a(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0xe,%edx
call   1080 <read@plt>
lea    0xdac(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %eax,%eax
jmp    1286 <main+0xe6>
mov    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.name = [14 x i8] c"20131028.fifo\00"
@.str = [3 x i8] c"10\00"
@O_WRONLY = global i32 0
@.str.1 = [9 x i8] c"20131028\00"
@O_RDONLY = global i32 0
@.str.2 = [18 x i8] c"Recieved text: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [14 x i8]
%10 = alloca [14 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%11 = bitcast [14 x i8]* %10 to i8*
%12 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 14)
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %10, i64 0, i64 0
%15 = call i32 @memcpy(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%16 = getelementptr inbounds [14 x i8], [14 x i8]* %10, i64 0, i64 0
%17 = call i64 @mkfifo(i8* %16, i32 438)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %2
br label %20
20: ; preds = %19, %2
%21 = call i64 (...) @fork()
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %39
23: ; preds = %20
%24 = getelementptr inbounds [14 x i8], [14 x i8]* %10, i64 0, i64 0
%25 = load i32, i32* @O_WRONLY
%26 = call i32 @open(i8* %24, i32 %25)
store i32 %26, i32* %6
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 -1, i32* %3
br label %58
29: ; preds = %23
%30 = load i32, i32* %6
%31 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @write(i32 %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %31)
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = icmp ne i32 %33, 14
br i1 %34, label %35, label %36
35: ; preds = %29
br label %36
36: ; preds = %35, %29
%37 = load i32, i32* %6
%38 = call i32 @close(i32 %37)
br label %57
39: ; preds = %20
%40 = getelementptr inbounds [14 x i8], [14 x i8]* %10, i64 0, i64 0
%41 = load i32, i32* @O_RDONLY
%42 = call i32 @open(i8* %40, i32 %41)
store i32 %42, i32* %6
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %39
br label %45
45: ; preds = %44, %39
%46 = load i32, i32* %6
%47 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%48 = call i32 @read(i32 %46, i8* %47, i32 14)
store i32 %48, i32* %8
%49 = load i32, i32* %8
%50 = icmp ne i32 %49, 14
br i1 %50, label %51, label %52
51: ; preds = %45
br label %52
52: ; preds = %51, %45
%53 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%54 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %53)
%55 = load i32, i32* %6
%56 = call i32 @close(i32 %55)
br label %57
57: ; preds = %52, %36
store i32 0, i32* %3
br label %58
58: ; preds = %57, %28
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@__const.main.name = [14 x i8] c"20131028.fifo\00"
@.str = [3 x i8] c"10\00"
@O_WRONLY = global i32 0
@.str.1 = [9 x i8] c"20131028\00"
@O_RDONLY = global i32 0
@.str.2 = [18 x i8] c"Recieved text: %s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [14 x i8]
%4 = alloca [14 x i8]
%5 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %5, i32 0, i32 14)
%8 = call i32 @memcpy(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%9 = call i64 @mkfifo(i8* %6, i32 438)
%10 = call i64 (...) @fork()
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = load i32, i32* @O_WRONLY
%14 = call i32 @open(i8* %6, i32 %13)
%15 = icmp slt i32 %14, 0
br i1 %15, label %27, label %16
16: ; preds = %12
%17 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @write(i32 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %24
19: ; preds = %2
%20 = load i32, i32* @O_RDONLY
%21 = call i32 @open(i8* %6, i32 %20)
%22 = call i32 @read(i32 %21, i8* %5, i32 14)
%23 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %24
24: ; preds = %19, %16
%25 = phi i32 [ %14, %16 ], [ %21, %19 ]
%26 = call i32 @close(i32 %25)
br label %27
27: ; preds = %24, %12
%28 = phi i32 [ -1, %12 ], [ 0, %24 ]
ret i32 %28
}