#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*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ internal_read(int, ...);
int /*<<< orphan*/ internal_write(int, ...);
double log_perf(char *, ...);
int *malloc(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int size, length, i;
  int *data;
  int *target;
  char sync;
  int fds1[2], fds2[2];
  double bs, as, br, ar;
  if (argc > 1) {
    size = atoi(argv[1]);
    length = size / sizeof(int);
    size = sizeof(int) * length;
  } else
    exit(1);
  if (pipe(fds1) < 0 || pipe(fds2) < 0) {
    perror("pipe");
    exit(1);
  }
  log_perf("before init, size=%d", size);
  data = malloc(size);
  for (i = 0; i < length; i++)
    data[i] = i;
  log_perf("after init");
  if (!fork()) {
    free(data);
    target = malloc(size);
    internal_write(fds1[1], &sync, sizeof(char));
    br = log_perf("start read");
    internal_read(fds2[0], target, size);
    ar = log_perf("done read");
    internal_write(fds1[1], &br, sizeof(double));
    internal_write(fds1[1], &ar, sizeof(double));
    for (i = 0; i < length; i++)
      assert(target[i] == i);
  } else {
    internal_read(fds1[0], &sync, sizeof(char));
    bs = log_perf("start write");
    internal_write(fds2[1], data, size);
    as = log_perf("done write");
    internal_read(fds1[0], &br, sizeof(double));
    internal_read(fds1[0], &ar, sizeof(double));
    printf("TIME: %f\n",
           (((as) > (ar)) ? (as) : (ar)) - (((bs) < (br)) ? (bs) : (br)));
    wait(NULL);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    121e <main+0x4e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shr    $0x2,%rax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,-0x14(%rbp)
jmp    1228 <main+0x58>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    -0x3c(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0x0,%rax
jl     124e <main+0x7e>
lea    -0x44(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0x0,%rax
jge    1264 <main+0x94>
lea    0xdab(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   10a0 <log_perf@plt>
mov    -0x14(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12b0 <main+0xe0>
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1288 <main+0xb8>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   10a0 <log_perf@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
cmp    $0x0,%eax
jne    1394 <main+0x1c4>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x31(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <internal_write@plt>
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   10a0 <log_perf@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x44(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1070 <internal_read@plt>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   10a0 <log_perf@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <internal_write@plt>
mov    -0x38(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <internal_write@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    138f <main+0x1bf>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x1c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    135a <main+0x18a>
jmp    1487 <main+0x2b7>
mov    -0x3c(%rbp),%edi
lea    -0x31(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1070 <internal_read@plt>
lea    0xc8c(%rip),%rdi
mov    $0x0,%al
call   10a0 <log_perf@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1040 <internal_write@plt>
lea    0xc74(%rip),%rdi
mov    $0x0,%al
call   10a0 <log_perf@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1070 <internal_read@plt>
mov    -0x3c(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1070 <internal_read@plt>
movsd  -0x58(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    1423 <main+0x253>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    142d <main+0x25d>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    145a <main+0x28a>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1464 <main+0x294>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
subsd  %xmm1,%xmm0
lea    0xbd8(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <wait@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
cmp    $0x2,%edi
jl     1576 <main+0x3a6>
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
lea    0x10(%rsp),%rdi
call   1060 <pipe@plt>
test   %rax,%rax
js     156a <main+0x39a>
lea    0x28(%rsp),%rdi
call   1060 <pipe@plt>
test   %rax,%rax
js     156a <main+0x39a>
mov    %r14d,%r15d
sar    $0x2,%r15d
mov    %r14d,%ebp
and    $0xfffffffc,%ebp
lea    0xe6a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   10a0 <log_perf@plt>
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
cmp    $0x4,%r14d
jl     13cc <main+0x1fc>
cmp    $0x2,%r15d
mov    $0x1,%eax
cmovge %r15d,%eax
cmp    $0x8,%eax
jae    1261 <main+0x91>
xor    %ecx,%ecx
jmp    13c0 <main+0x1f0>
mov    %eax,%ecx
and    $0x7ffffff8,%ecx
lea    -0x8(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x3,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x18,%rdi
jae    1292 <main+0xc2>
movdqa 0xd75(%rip),%xmm0
xor    %edi,%edi
jmp    1368 <main+0x198>
and    $0xfffffffffffffffc,%rsi
movdqa 0xd62(%rip),%xmm0
xor    %edi,%edi
movdqa 0xd67(%rip),%xmm8
movdqa 0xd6e(%rip),%xmm9
movdqa 0xd75(%rip),%xmm10
movdqa 0xd7d(%rip),%xmm4
movdqa 0xd85(%rip),%xmm5
movdqa 0xd8d(%rip),%xmm6
movdqa 0xd95(%rip),%xmm7
movdqa 0xd9d(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqu %xmm0,(%rbx,%rdi,4)
movdqu %xmm2,0x10(%rbx,%rdi,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqu %xmm2,0x20(%rbx,%rdi,4)
movdqu %xmm3,0x30(%rbx,%rdi,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqu %xmm2,0x40(%rbx,%rdi,4)
movdqu %xmm3,0x50(%rbx,%rdi,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqu %xmm2,0x60(%rbx,%rdi,4)
movdqu %xmm3,0x70(%rbx,%rdi,4)
add    $0x20,%rdi
paddd  %xmm1,%xmm0
add    $0xfffffffffffffffc,%rsi
jne    12f0 <main+0x120>
test   %rdx,%rdx
je     13b0 <main+0x1e0>
lea    (%rbx,%rdi,4),%rsi
add    $0x10,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
movdqa 0xc8d(%rip),%xmm1
movdqa 0xc95(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm3
paddd  %xmm1,%xmm3
movdqu %xmm0,-0x10(%rsi,%rdi,1)
movdqu %xmm3,(%rsi,%rdi,1)
paddd  %xmm2,%xmm0
add    $0x20,%rdi
cmp    %rdi,%rdx
jne    1390 <main+0x1c0>
cmp    %rax,%rcx
je     13cc <main+0x1fc>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,(%rbx,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    13c0 <main+0x1f0>
lea    0xcd7(%rip),%rdi
xor    %eax,%eax
call   10a0 <log_perf@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     1498 <main+0x2c8>
mov    0x10(%rsp),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1070 <internal_read@plt>
lea    0xcc5(%rip),%rdi
xor    %eax,%eax
call   10a0 <log_perf@plt>
movq   %xmm0,0x38(%rsp)
mov    0x2c(%rsp),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <internal_write@plt>
lea    0xcad(%rip),%rdi
xor    %eax,%eax
call   10a0 <log_perf@plt>
movq   %xmm0,0x30(%rsp)
mov    0x10(%rsp),%edi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1070 <internal_read@plt>
mov    0x10(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1070 <internal_read@plt>
movsd  0x30(%rsp),%xmm1
maxsd  0x18(%rsp),%xmm1
movsd  0x38(%rsp),%xmm0
minsd  0x20(%rsp),%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xc5a(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10e0 <wait@plt>
jmp    155b <main+0x38b>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    0x14(%rsp),%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <internal_write@plt>
lea    0xbef(%rip),%rdi
xor    %eax,%eax
call   10a0 <log_perf@plt>
movq   %xmm0,0x20(%rsp)
mov    0x28(%rsp),%edi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <internal_read@plt>
lea    0xbd6(%rip),%rdi
xor    %eax,%eax
call   10a0 <log_perf@plt>
movq   %xmm0,0x18(%rsp)
mov    0x14(%rsp),%edi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <internal_write@plt>
mov    0x14(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <internal_write@plt>
cmp    $0x4,%r14d
jl     155b <main+0x38b>
cmp    $0x2,%r15d
mov    $0x1,%ebp
cmovge %r15d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%eax
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1080 <assert@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1540 <main+0x370>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb1f(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"pipe\00"
@.str.1 = [21 x i8] c"before init, size=%d\00"
@.str.2 = [11 x i8] c"after init\00"
@.str.3 = [11 x i8] c"start read\00"
@.str.4 = [10 x i8] c"done read\00"
@.str.5 = [12 x i8] c"start write\00"
@.str.6 = [11 x i8] c"done write\00"
@.str.7 = [10 x i8] c"TIME: %f\0A\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 i32*
%10 = alloca i32*
%11 = alloca i8
%12 = alloca [2 x i32]
%13 = alloca [2 x i32]
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 1
br i1 %19, label %20, label %33
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = udiv i64 %26, 4
%28 = trunc i64 %27 to i32
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = mul i64 4, %30
%32 = trunc i64 %31 to i32
store i32 %32, i32* %6
br label %35
33: ; preds = %2
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %20
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%37 = call i64 @pipe(i32* %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%41 = call i64 @pipe(i32* %40)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39, %35
%44 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = load i32, i32* %6
%48 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %6
%50 = call i32* @malloc(i32 %49)
store i32* %50, i32** %9
store i32 0, i32* %8
br label %51
51: ; preds = %61, %46
%52 = load i32, i32* %8
%53 = load i32, i32* %7
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %64
55: ; preds = %51
%56 = load i32, i32* %8
%57 = load i32*, i32** %9
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
store i32 %56, i32* %60
br label %61
61: ; preds = %55
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %51
64: ; preds = %51
%65 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%66 = call i32 (...) @fork()
%67 = icmp ne i32 %66, 0
br i1 %67, label %107, label %68
68: ; preds = %64
%69 = load i32*, i32** %9
%70 = call i32 @free(i32* %69)
%71 = load i32, i32* %6
%72 = call i32* @malloc(i32 %71)
store i32* %72, i32** %10
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%74 = load i32, i32* %73
%75 = call i32 (i32, ...) @internal_write(i32 %74, i8* %11, i64 1)
%76 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store double %76, double* %16
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%78 = load i32, i32* %77
%79 = load i32*, i32** %10
%80 = load i32, i32* %6
%81 = call i32 (i32, ...) @internal_read(i32 %78, i32* %79, i32 %80)
%82 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store double %82, double* %17
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%84 = load i32, i32* %83
%85 = call i32 (i32, ...) @internal_write(i32 %84, double* %16, i64 8)
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%87 = load i32, i32* %86
%88 = call i32 (i32, ...) @internal_write(i32 %87, double* %17, i64 8)
store i32 0, i32* %8
br label %89
89: ; preds = %103, %68
%90 = load i32, i32* %8
%91 = load i32, i32* %7
%92 = icmp slt i32 %90, %91
br i1 %92, label %93, label %106
93: ; preds = %89
%94 = load i32*, i32** %10
%95 = load i32, i32* %8
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %94, i64 %96
%98 = load i32, i32* %97
%99 = load i32, i32* %8
%100 = icmp eq i32 %98, %99
%101 = zext i1 %100 to i32
%102 = call i32 @assert(i32 %101)
br label %103
103: ; preds = %93
%104 = load i32, i32* %8
%105 = add nsw i32 %104, 1
store i32 %105, i32* %8
br label %89
106: ; preds = %89
br label %145
107: ; preds = %64
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%109 = load i32, i32* %108
%110 = call i32 (i32, ...) @internal_read(i32 %109, i8* %11, i64 1)
%111 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store double %111, double* %14
%112 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%113 = load i32, i32* %112
%114 = load i32*, i32** %9
%115 = load i32, i32* %6
%116 = call i32 (i32, ...) @internal_write(i32 %113, i32* %114, i32 %115)
%117 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
store double %117, double* %15
%118 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%119 = load i32, i32* %118
%120 = call i32 (i32, ...) @internal_read(i32 %119, double* %16, i64 8)
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%122 = load i32, i32* %121
%123 = call i32 (i32, ...) @internal_read(i32 %122, double* %17, i64 8)
%124 = load double, double* %15
%125 = load double, double* %17
%126 = fcmp ogt double %124, %125
br i1 %126, label %127, label %129
127: ; preds = %107
%128 = load double, double* %15
br label %131
129: ; preds = %107
%130 = load double, double* %17
br label %131
131: ; preds = %129, %127
%132 = phi double [ %128, %127 ], [ %130, %129 ]
%133 = load double, double* %14
%134 = load double, double* %16
%135 = fcmp olt double %133, %134
br i1 %135, label %136, label %138
136: ; preds = %131
%137 = load double, double* %14
br label %140
138: ; preds = %131
%139 = load double, double* %16
br label %140
140: ; preds = %138, %136
%141 = phi double [ %137, %136 ], [ %139, %138 ]
%142 = fsub double %132, %141
%143 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %142)
%144 = call i32 @wait(i32* null)
br label %145
145: ; preds = %140, %106
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"pipe\00"
@.str.1 = [21 x i8] c"before init, size=%d\00"
@.str.2 = [11 x i8] c"after init\00"
@.str.3 = [11 x i8] c"start read\00"
@.str.4 = [10 x i8] c"done read\00"
@.str.5 = [12 x i8] c"start write\00"
@.str.6 = [11 x i8] c"done write\00"
@.str.7 = [10 x i8] c"TIME: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca double
%7 = alloca double
%8 = bitcast [2 x i32]* %4 to i8*
%9 = bitcast [2 x i32]* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = bitcast double* %7 to i8*
%12 = icmp sgt i32 %0, 1
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = ashr i32 %16, 2
%18 = and i32 %16, -4
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%20 = call i64 @pipe(i32* %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %28, label %24
22: ; preds = %2
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %13
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%26 = call i64 @pipe(i32* %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24, %13
%29 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %24
%32 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%33 = call i32* @malloc(i32 %18)
%34 = icmp sgt i32 %16, 3
br i1 %34, label %35, label %109
35: ; preds = %31
%36 = call i32 @llvm.smax.i32(i32 %17, i32 1)
%37 = zext i32 %36 to i64
%38 = icmp ult i32 %36, 8
br i1 %38, label %101, label %39
39: ; preds = %35
%40 = and i64 %37, 2147483640
%41 = add nsw i64 %40, -8
%42 = lshr exact i64 %41, 3
%43 = add nuw nsw i64 %42, 1
%44 = and i64 %43, 3
%45 = icmp ult i64 %41, 24
br i1 %45, label %82, label %46
46: ; preds = %39
%47 = and i64 %43, 4611686018427387900
br label %48
48: ; preds = %48, %46
%49 = phi i64 [ 0, %46 ], [ %78, %48 ]
%50 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %46 ], [ %79, %48 ]
%51 = phi i64 [ 0, %46 ], [ %80, %48 ]
%52 = add <4 x i32> %50, <i32 4, i32 4, i32 4, i32 4>
%53 = getelementptr inbounds i32, i32* %33, i64 %49
%54 = bitcast i32* %53 to <4 x i32>*
store <4 x i32> %50, <4 x i32>* %54
%55 = getelementptr inbounds i32, i32* %53, i64 4
%56 = bitcast i32* %55 to <4 x i32>*
store <4 x i32> %52, <4 x i32>* %56
%57 = or i64 %49, 8
%58 = add <4 x i32> %50, <i32 8, i32 8, i32 8, i32 8>
%59 = add <4 x i32> %50, <i32 12, i32 12, i32 12, i32 12>
%60 = getelementptr inbounds i32, i32* %33, i64 %57
%61 = bitcast i32* %60 to <4 x i32>*
store <4 x i32> %58, <4 x i32>* %61
%62 = getelementptr inbounds i32, i32* %60, i64 4
%63 = bitcast i32* %62 to <4 x i32>*
store <4 x i32> %59, <4 x i32>* %63
%64 = or i64 %49, 16
%65 = add <4 x i32> %50, <i32 16, i32 16, i32 16, i32 16>
%66 = add <4 x i32> %50, <i32 20, i32 20, i32 20, i32 20>
%67 = getelementptr inbounds i32, i32* %33, i64 %64
%68 = bitcast i32* %67 to <4 x i32>*
store <4 x i32> %65, <4 x i32>* %68
%69 = getelementptr inbounds i32, i32* %67, i64 4
%70 = bitcast i32* %69 to <4 x i32>*
store <4 x i32> %66, <4 x i32>* %70
%71 = or i64 %49, 24
%72 = add <4 x i32> %50, <i32 24, i32 24, i32 24, i32 24>
%73 = add <4 x i32> %50, <i32 28, i32 28, i32 28, i32 28>
%74 = getelementptr inbounds i32, i32* %33, i64 %71
%75 = bitcast i32* %74 to <4 x i32>*
store <4 x i32> %72, <4 x i32>* %75
%76 = getelementptr inbounds i32, i32* %74, i64 4
%77 = bitcast i32* %76 to <4 x i32>*
store <4 x i32> %73, <4 x i32>* %77
%78 = add nuw i64 %49, 32
%79 = add <4 x i32> %50, <i32 32, i32 32, i32 32, i32 32>
%80 = add i64 %51, 4
%81 = icmp eq i64 %80, %47
br i1 %81, label %82, label %48
82: ; preds = %48, %39
%83 = phi i64 [ 0, %39 ], [ %78, %48 ]
%84 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %39 ], [ %79, %48 ]
%85 = icmp eq i64 %44, 0
br i1 %85, label %99, label %86
86: ; preds = %82, %86
%87 = phi i64 [ %95, %86 ], [ %83, %82 ]
%88 = phi <4 x i32> [ %96, %86 ], [ %84, %82 ]
%89 = phi i64 [ %97, %86 ], [ 0, %82 ]
%90 = add <4 x i32> %88, <i32 4, i32 4, i32 4, i32 4>
%91 = getelementptr inbounds i32, i32* %33, i64 %87
%92 = bitcast i32* %91 to <4 x i32>*
store <4 x i32> %88, <4 x i32>* %92
%93 = getelementptr inbounds i32, i32* %91, i64 4
%94 = bitcast i32* %93 to <4 x i32>*
store <4 x i32> %90, <4 x i32>* %94
%95 = add nuw i64 %87, 8
%96 = add <4 x i32> %88, <i32 8, i32 8, i32 8, i32 8>
%97 = add i64 %89, 1
%98 = icmp eq i64 %97, %44
br i1 %98, label %99, label %86
99: ; preds = %86, %82
%100 = icmp eq i64 %40, %37
br i1 %100, label %109, label %101
101: ; preds = %35, %99
%102 = phi i64 [ 0, %35 ], [ %40, %99 ]
br label %103
103: ; preds = %101, %103
%104 = phi i64 [ %107, %103 ], [ %102, %101 ]
%105 = getelementptr inbounds i32, i32* %33, i64 %104
%106 = trunc i64 %104 to i32
store i32 %106, i32* %105
%107 = add nuw nsw i64 %104, 1
%108 = icmp eq i64 %107, %37
br i1 %108, label %109, label %103
109: ; preds = %103, %99, %31
%110 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%111 = call i32 (...) @fork()
%112 = icmp eq i32 %111, 0
br i1 %112, label %113, label %140
113: ; preds = %109
%114 = call i32 @free(i32* %33)
%115 = call i32* @malloc(i32 %18)
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%117 = load i32, i32* %116
%118 = call i32 (i32, ...) @internal_write(i32 %117, i8* %3, i64 1)
%119 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store double %119, double* %6
%120 = load i32, i32* %25
%121 = call i32 (i32, ...) @internal_read(i32 %120, i32* %115, i32 %18)
%122 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store double %122, double* %7
%123 = load i32, i32* %116
%124 = call i32 (i32, ...) @internal_write(i32 %123, double* %6, i64 8)
%125 = load i32, i32* %116
%126 = call i32 (i32, ...) @internal_write(i32 %125, double* %7, i64 8)
br i1 %34, label %127, label %161
127: ; preds = %113
%128 = call i32 @llvm.smax.i32(i32 %17, i32 1)
%129 = zext i32 %128 to i64
br label %130
130: ; preds = %127, %130
%131 = phi i64 [ 0, %127 ], [ %138, %130 ]
%132 = getelementptr inbounds i32, i32* %115, i64 %131
%133 = load i32, i32* %132
%134 = zext i32 %133 to i64
%135 = icmp eq i64 %131, %134
%136 = zext i1 %135 to i32
%137 = call i32 @assert(i32 %136)
%138 = add nuw nsw i64 %131, 1
%139 = icmp eq i64 %138, %129
br i1 %139, label %161, label %130
140: ; preds = %109
%141 = load i32, i32* %19
%142 = call i32 (i32, ...) @internal_read(i32 %141, i8* %3, i64 1)
%143 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%144 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%145 = load i32, i32* %144
%146 = call i32 (i32, ...) @internal_write(i32 %145, i32* %33, i32 %18)
%147 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%148 = load i32, i32* %19
%149 = call i32 (i32, ...) @internal_read(i32 %148, double* %6, i64 8)
%150 = load i32, i32* %19
%151 = call i32 (i32, ...) @internal_read(i32 %150, double* %7, i64 8)
%152 = load double, double* %7
%153 = fcmp ogt double %147, %152
%154 = select i1 %153, double %147, double %152
%155 = load double, double* %6
%156 = fcmp olt double %143, %155
%157 = select i1 %156, double %143, double %155
%158 = fsub double %154, %157
%159 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %158)
%160 = call i32 @wait(i32* null)
br label %161
161: ; preds = %130, %113, %140
ret i32 0
}