#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*/ AF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ internal_recv(int, ...);
int /*<<< orphan*/ internal_send(int, ...);
double log_perf(char *, ...);
int *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double);
int socketpair(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
               int *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int size, length, i;
  int *data;
  int *target;
  char sync;
  int fds[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 (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
    perror("socketpair");
    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_send(fds[1], &sync, sizeof(char));
    br = log_perf("start read");
    internal_recv(fds[1], target, size);
    ar = log_perf("done read");
    internal_send(fds[1], &br, sizeof(double));
    internal_send(fds[1], &ar, sizeof(double));
    for (i = 0; i < length; i++)
      assert(target[i] == i);
  } else {
    internal_recv(fds[0], &sync, sizeof(char));
    bs = log_perf("start write");
    internal_send(fds[0], data, size);
    as = log_perf("done write");
    internal_recv(fds[0], &br, sizeof(double));
    internal_recv(fds[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   10b0 <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   10c0 <exit@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
lea    -0x3c(%rbp),%rcx
xor    %edx,%edx
call   1060 <socketpair@plt>
cmp    $0xffffffff,%eax
jne    1264 <main+0x94>
lea    0xdab(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1090 <log_perf@plt>
mov    -0x14(%rbp),%edi
call   1070 <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    0xd69(%rip),%rdi
mov    $0x0,%al
call   1090 <log_perf@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
cmp    $0x0,%eax
jne    1394 <main+0x1c4>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x31(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   10f0 <internal_send@plt>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1090 <log_perf@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1080 <internal_recv@plt>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1090 <log_perf@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   10f0 <internal_send@plt>
mov    -0x38(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   10f0 <internal_send@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   1050 <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   1080 <internal_recv@plt>
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1090 <log_perf@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   10f0 <internal_send@plt>
lea    0xc7a(%rip),%rdi
mov    $0x0,%al
call   1090 <log_perf@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1080 <internal_recv@plt>
mov    -0x3c(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1080 <internal_recv@plt>
movsd  -0x50(%rbp),%xmm0
ucomisd -0x60(%rbp),%xmm0
jbe    1423 <main+0x253>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    142d <main+0x25d>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    145a <main+0x28a>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    1464 <main+0x294>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
subsd  %xmm1,%xmm0
lea    0xbde(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <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    $0x30,%rsp
cmp    $0x2,%edi
jl     156a <main+0x39a>
mov    0x8(%rsi),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r14d
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rcx
xor    %edx,%edx
call   1060 <socketpair@plt>
cmp    $0xffffffff,%eax
je     1574 <main+0x3a4>
mov    %r14d,%r15d
sar    $0x2,%r15d
mov    %r14d,%ebp
and    $0xfffffffc,%ebp
lea    0xe6f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <log_perf@plt>
mov    %ebp,%edi
call   1070 <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    1262 <main+0x92>
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    1293 <main+0xc3>
movdqa 0xd74(%rip),%xmm0
xor    %edi,%edi
jmp    1368 <main+0x198>
and    $0xfffffffffffffffc,%rsi
movdqa 0xd61(%rip),%xmm0
xor    %edi,%edi
movdqa 0xd66(%rip),%xmm8
movdqa 0xd6d(%rip),%xmm9
movdqa 0xd74(%rip),%xmm10
movdqa 0xd7c(%rip),%xmm4
movdqa 0xd84(%rip),%xmm5
movdqa 0xd8c(%rip),%xmm6
movdqa 0xd94(%rip),%xmm7
movdqa 0xd9c(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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    0xcdd(%rip),%rdi
xor    %eax,%eax
call   1090 <log_perf@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     1498 <main+0x2c8>
mov    0x8(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1080 <internal_recv@plt>
lea    0xccb(%rip),%rdi
xor    %eax,%eax
call   1090 <log_perf@plt>
movq   %xmm0,0x28(%rsp)
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10f0 <internal_send@plt>
lea    0xcb3(%rip),%rdi
xor    %eax,%eax
call   1090 <log_perf@plt>
movq   %xmm0,0x20(%rsp)
mov    0x8(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1080 <internal_recv@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1080 <internal_recv@plt>
movsd  0x20(%rsp),%xmm1
maxsd  0x10(%rsp),%xmm1
movsd  0x28(%rsp),%xmm0
minsd  0x18(%rsp),%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xc60(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
jmp    155b <main+0x38b>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    0xc(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   10f0 <internal_send@plt>
lea    0xbf5(%rip),%rdi
xor    %eax,%eax
call   1090 <log_perf@plt>
movq   %xmm0,0x18(%rsp)
mov    0xc(%rsp),%edi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <internal_recv@plt>
lea    0xbdc(%rip),%rdi
xor    %eax,%eax
call   1090 <log_perf@plt>
movq   %xmm0,0x10(%rsp)
mov    0xc(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   10f0 <internal_send@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   10f0 <internal_send@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   1050 <assert@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1540 <main+0x370>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xb15(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

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

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