#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 MAP_ANON;
char *MAP_FAILED;
int MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ internal_recv(int, double *, int);
int /*<<< orphan*/ internal_send(int, double *, int);
double log_perf(char *, ...);
int *malloc(int);
int /*<<< orphan*/ memcpy(char *, void *, int);
char *mmap(int /*<<< orphan*/, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double);
int socketpair(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
               int *);
int /*<<< orphan*/ syncup(int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int size, length, i;
  int *data;
  int *target;
  int fds[2];
  int shm_size = 360000;
  char *areas[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 (argc > 2) {
    shm_size = atoi(argv[2]);
  }
  if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
    perror("socketpair");
    exit(1);
  }
  areas[0] =
      mmap(0, shm_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
  if (areas[0] == MAP_FAILED) {
    perror("mmap: ");
    abort();
  }
  areas[1] =
      mmap(0, shm_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
  if (areas[1] == MAP_FAILED) {
    perror("mmap: ");
    abort();
  }
  log_perf("before init, size=%d", size);
  data = malloc(size);
  for (i = 0; i < length; i++)
    data[i] = i;
  log_perf("after init");
  int idx;
  int count = 0;
  if (!fork()) {
    free(data);
    target = malloc(size);
    idx = 0;
    count = 0;
    syncup(fds[1]);
    br = log_perf("start read");
    syncup(fds[1]);
    while (count < size) {
      int read_size = (size - count) > shm_size ? shm_size : (size - count);
      memcpy(((void *)target) + count, areas[idx], read_size);
      count += read_size;
      idx = (idx + 1) % 2;
      syncup(fds[1]);
    }
    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 {
    idx = 0;
    count = 0;
    syncup(fds[0]);
    bs = log_perf("start write");
    while (count < size) {
      int write_size = (size - count) > shm_size ? shm_size : (size - count);
      memcpy(areas[idx], ((void *)data) + count, write_size);
      count += write_size;
      idx = (idx + 1) % 2;
      syncup(fds[0]);
    }
    syncup(fds[0]);
    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    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x57e40,-0x3c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1265 <main+0x55>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <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    126f <main+0x5f>
mov    $0x1,%edi
call   10f0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jle    1289 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rcx
xor    %edx,%edx
call   1090 <socketpair@plt>
cmp    $0xffffffff,%eax
jne    12c5 <main+0xb5>
lea    0xd4a(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x3c(%rbp),%esi
mov    0x2d29(%rip),%rax
mov    (%rax),%edx
mov    0x2ce8(%rip),%rax
or     (%rax),%edx
mov    0x2cd7(%rip),%rax
mov    (%rax),%ecx
mov    0x2cfe(%rip),%rax
or     (%rax),%ecx
xor    %r9d,%r9d
mov    $0xffffffff,%r8d
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    0x2ca4(%rip),%rcx
cmp    (%rcx),%rax
jne    1328 <main+0x118>
lea    0xcef(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x3c(%rbp),%esi
mov    0x2cc6(%rip),%rax
mov    (%rax),%edx
mov    0x2c85(%rip),%rax
or     (%rax),%edx
mov    0x2c74(%rip),%rax
mov    (%rax),%ecx
mov    0x2c9b(%rip),%rax
or     (%rax),%ecx
xor    %r9d,%r9d
mov    $0xffffffff,%r8d
mov    %r9d,%edi
call   1050 <mmap@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    0x2c41(%rip),%rcx
cmp    (%rcx),%rax
jne    138b <main+0x17b>
lea    0xc8c(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x14(%rbp),%esi
lea    0xc7d(%rip),%rdi
mov    $0x0,%al
call   10c0 <log_perf@plt>
mov    -0x14(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13d7 <main+0x1c7>
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    13af <main+0x19f>
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   10c0 <log_perf@plt>
movl   $0x0,-0x78(%rbp)
mov    $0x0,%al
call   1120 <fork@plt>
cmp    $0x0,%eax
jne    1539 <main+0x329>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x34(%rbp),%edi
call   1100 <syncup@plt>
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   10c0 <log_perf@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x34(%rbp),%edi
call   1100 <syncup@plt>
mov    -0x78(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    14c3 <main+0x2b3>
mov    -0x14(%rbp),%eax
sub    -0x78(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jle    146b <main+0x25b>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    1477 <main+0x267>
mov    -0x14(%rbp),%eax
sub    -0x78(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x30(%rbp),%rdi
movslq -0x78(%rbp),%rax
add    %rax,%rdi
movslq -0x74(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
mov    -0x7c(%rbp),%edx
call   1080 <memcpy@plt>
mov    -0x7c(%rbp),%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x74(%rbp)
mov    -0x34(%rbp),%edi
call   1100 <syncup@plt>
jmp    1442 <main+0x232>
lea    0xb73(%rip),%rdi
mov    $0x0,%al
call   10c0 <log_perf@plt>
movsd  %xmm0,-0x70(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0x8,%edx
call   1130 <internal_send@plt>
mov    -0x34(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x8,%edx
call   1130 <internal_send@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1534 <main+0x324>
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   1070 <assert@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14ff <main+0x2ef>
jmp    16bb <main+0x4ab>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x38(%rbp),%edi
call   1100 <syncup@plt>
lea    0xaf1(%rip),%rdi
mov    $0x0,%al
call   10c0 <log_perf@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    15e3 <main+0x3d3>
mov    -0x14(%rbp),%eax
sub    -0x78(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jle    158b <main+0x37b>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x88(%rbp)
jmp    1597 <main+0x387>
mov    -0x14(%rbp),%eax
sub    -0x78(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x80(%rbp)
movslq -0x74(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x78(%rbp),%rax
add    %rax,%rsi
mov    -0x80(%rbp),%edx
call   1080 <memcpy@plt>
mov    -0x80(%rbp),%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x74(%rbp)
mov    -0x38(%rbp),%edi
call   1100 <syncup@plt>
jmp    1562 <main+0x352>
mov    -0x38(%rbp),%edi
call   1100 <syncup@plt>
lea    0xa61(%rip),%rdi
mov    $0x0,%al
call   10c0 <log_perf@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x68(%rbp),%rsi
mov    $0x8,%edx
call   10b0 <internal_recv@plt>
mov    -0x38(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x8,%edx
call   10b0 <internal_recv@plt>
movsd  -0x60(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    1642 <main+0x432>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    164f <main+0x43f>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x58(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1685 <main+0x475>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
jmp    1692 <main+0x482>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0xa0(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
lea    0x9b1(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1110 <wait@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jl     16ff <main+0x4ef>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   10e0 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    $0x57e40,%r12d
cmp    $0x2,%ebp
je     1250 <main+0x40>
mov    0x10(%rbx),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r12d
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
xor    %edx,%edx
call   1090 <socketpair@plt>
cmp    $0xffffffff,%eax
je     1709 <main+0x4f9>
mov    0x2d7c(%rip),%r14
mov    0x2d3d(%rip),%r13
mov    0x0(%r13),%edx
or     (%r14),%edx
mov    0x2d27(%rip),%r15
mov    0x2d50(%rip),%rbp
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    %r12d,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,0x30(%rsp)
mov    0x2cf3(%rip),%rbx
cmp    (%rbx),%rax
je     16ec <main+0x4dc>
mov    %r12d,%esi
mov    %rax,%r12
mov    0x0(%r13),%edx
or     (%r14),%edx
mov    0x0(%rbp),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    %esi,0x10(%rsp)
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,0x38(%rsp)
cmp    (%rbx),%rax
je     16ec <main+0x4dc>
mov    0x8(%rsp),%ebx
mov    %ebx,%ebp
sar    $0x2,%ebp
mov    %ebx,%r13d
and    $0xfffffffc,%r13d
lea    0xd90(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   10c0 <log_perf@plt>
mov    %r13d,%edi
call   10a0 <malloc@plt>
mov    %rax,%r14
cmp    $0x4,%ebx
jl     14bd <main+0x2ad>
cmp    $0x2,%ebp
mov    $0x1,%eax
cmovge %ebp,%eax
cmp    $0x8,%eax
jae    1347 <main+0x137>
xor    %ecx,%ecx
jmp    14b0 <main+0x2a0>
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    1378 <main+0x168>
movdqa 0xc8f(%rip),%xmm0
xor    %edi,%edi
jmp    1450 <main+0x240>
and    $0xfffffffffffffffc,%rsi
movdqa 0xc7c(%rip),%xmm0
xor    %edi,%edi
movdqa 0xc81(%rip),%xmm8
movdqa 0xc88(%rip),%xmm9
movdqa 0xc8f(%rip),%xmm10
movdqa 0xc97(%rip),%xmm4
movdqa 0xc9f(%rip),%xmm5
movdqa 0xca7(%rip),%xmm6
movdqa 0xcaf(%rip),%xmm7
movdqa 0xcb7(%rip),%xmm1
nopl   0x0(%rax)
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqu %xmm0,(%r14,%rdi,4)
movdqu %xmm2,0x10(%r14,%rdi,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqu %xmm2,0x20(%r14,%rdi,4)
movdqu %xmm3,0x30(%r14,%rdi,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqu %xmm2,0x40(%r14,%rdi,4)
movdqu %xmm3,0x50(%r14,%rdi,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqu %xmm2,0x60(%r14,%rdi,4)
movdqu %xmm3,0x70(%r14,%rdi,4)
add    $0x20,%rdi
paddd  %xmm1,%xmm0
add    $0xfffffffffffffffc,%rsi
jne    13d0 <main+0x1c0>
test   %rdx,%rdx
je     14a0 <main+0x290>
lea    (%r14,%rdi,4),%rsi
add    $0x10,%rsi
shl    $0x5,%rdx
xor    %edi,%edi
movdqa 0xba5(%rip),%xmm1
movdqa 0xbad(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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    1480 <main+0x270>
cmp    %rax,%rcx
je     14bd <main+0x2ad>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,(%r14,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
jne    14b0 <main+0x2a0>
lea    0xbf3(%rip),%rdi
xor    %eax,%eax
call   10c0 <log_perf@plt>
xor    %eax,%eax
call   1120 <fork@plt>
test   %eax,%eax
je     15c8 <main+0x3b8>
mov    (%rsp),%edi
call   1100 <syncup@plt>
lea    0xbee(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   10c0 <log_perf@plt>
movq   %xmm0,0x8(%rsp)
test   %r13d,%r13d
jle    1550 <main+0x340>
xor    %r15d,%r15d
mov    %r13d,%ebp
sub    %ebx,%ebp
mov    0x10(%rsp),%eax
cmp    %eax,%ebp
cmovg  %eax,%ebp
movslq %ebx,%rbx
lea    (%r14,%rbx,1),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1080 <memcpy@plt>
add    %ebp,%ebx
mov    (%rsp),%edi
call   1100 <syncup@plt>
cmp    %ebx,%r13d
jle    1550 <main+0x340>
mov    %r15d,%eax
add    $0x1,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %r15d,%ecx
add    $0x1,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    0x30(%rsp,%rcx,8),%r12
mov    %eax,%r15d
jmp    1500 <main+0x2f0>
mov    (%rsp),%edi
call   1100 <syncup@plt>
lea    0xb84(%rip),%rdi
xor    %eax,%eax
call   10c0 <log_perf@plt>
movq   %xmm0,0x10(%rsp)
mov    (%rsp),%edi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
call   10b0 <internal_recv@plt>
mov    (%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
call   10b0 <internal_recv@plt>
movsd  0x10(%rsp),%xmm1
maxsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
minsd  0x20(%rsp),%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
lea    0xb37(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   1110 <wait@plt>
jmp    16db <main+0x4cb>
mov    %ebp,0x2c(%rsp)
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13d,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
mov    0x4(%rsp),%edi
call   1100 <syncup@plt>
lea    0xad3(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   10c0 <log_perf@plt>
movq   %xmm0,0x20(%rsp)
mov    0x4(%rsp),%edi
call   1100 <syncup@plt>
test   %r13d,%r13d
jle    1660 <main+0x450>
xor    %ebx,%ebx
nop
mov    %r13d,%ebp
sub    %r14d,%ebp
mov    0x10(%rsp),%eax
cmp    %eax,%ebp
cmovg  %eax,%ebp
movslq %r14d,%r14
lea    (%r15,%r14,1),%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1080 <memcpy@plt>
add    %ebp,%r14d
mov    0x4(%rsp),%edi
call   1100 <syncup@plt>
cmp    %r14d,%r13d
jle    1660 <main+0x450>
mov    %ebx,%eax
add    $0x1,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %ebx,%ecx
add    $0x1,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    0x30(%rsp,%rcx,8),%r12
mov    %eax,%ebx
jmp    1610 <main+0x400>
lea    0xa66(%rip),%rdi
xor    %eax,%eax
call   10c0 <log_perf@plt>
movq   %xmm0,0x18(%rsp)
mov    0x4(%rsp),%edi
lea    0x20(%rsp),%rsi
mov    $0x8,%edx
call   1130 <internal_send@plt>
mov    0x4(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x8,%edx
call   1130 <internal_send@plt>
cmpl   $0x4,0x8(%rsp)
jl     16db <main+0x4cb>
mov    0x2c(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%ebx
cmovge %eax,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%rbp,4),%eax
xor    %edi,%edi
cmp    %rax,%rbp
sete   %dil
call   1070 <assert@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    16c0 <main+0x4b0>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x9a8(%rip),%rdi
call   10d0 <perror@plt>
xor    %eax,%eax
call   1040 <abort@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0x980(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [11 x i8] c"socketpair\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANON = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.1 = [7 x i8] c"mmap: \00"
@.str.2 = [21 x i8] c"before init, size=%d\00"
@.str.3 = [11 x i8] c"after init\00"
@.str.4 = [11 x i8] c"start read\00"
@.str.5 = [10 x i8] c"done read\00"
@.str.6 = [12 x i8] c"start write\00"
@.str.7 = [11 x i8] c"done write\00"
@.str.8 = [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 [2 x i32]
%12 = alloca i32
%13 = alloca [2 x i8*]
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 360000, i32* %12
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 1
br i1 %23, label %24, label %37
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = udiv i64 %30, 4
%32 = trunc i64 %31 to i32
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = mul i64 4, %34
%36 = trunc i64 %35 to i32
store i32 %36, i32* %6
br label %39
37: ; preds = %2
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %24
%40 = load i32, i32* %4
%41 = icmp sgt i32 %40, 2
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %12
br label %47
47: ; preds = %42, %39
%48 = load i32, i32* @AF_UNIX
%49 = load i32, i32* @SOCK_STREAM
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%51 = call i32 @socketpair(i32 %48, i32 %49, i32 0, i32* %50)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %47
%54 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %47
%57 = load i32, i32* %12
%58 = load i32, i32* @PROT_READ
%59 = load i32, i32* @PROT_WRITE
%60 = or i32 %58, %59
%61 = load i32, i32* @MAP_ANON
%62 = load i32, i32* @MAP_SHARED
%63 = or i32 %61, %62
%64 = call i8* @mmap(i32 0, i32 %57, i32 %60, i32 %63, i32 -1, i32 0)
%65 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 0
store i8* %64, i8** %65
%66 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 0
%67 = load i8*, i8** %66
%68 = load i8*, i8** @MAP_FAILED
%69 = icmp eq i8* %67, %68
br i1 %69, label %70, label %73
70: ; preds = %56
%71 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%72 = call i32 (...) @abort()
unreachable
73: ; preds = %56
%74 = load i32, i32* %12
%75 = load i32, i32* @PROT_READ
%76 = load i32, i32* @PROT_WRITE
%77 = or i32 %75, %76
%78 = load i32, i32* @MAP_ANON
%79 = load i32, i32* @MAP_SHARED
%80 = or i32 %78, %79
%81 = call i8* @mmap(i32 0, i32 %74, i32 %77, i32 %80, i32 -1, i32 0)
%82 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 1
store i8* %81, i8** %82
%83 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 1
%84 = load i8*, i8** %83
%85 = load i8*, i8** @MAP_FAILED
%86 = icmp eq i8* %84, %85
br i1 %86, label %87, label %90
87: ; preds = %73
%88 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%89 = call i32 (...) @abort()
unreachable
90: ; preds = %73
%91 = load i32, i32* %6
%92 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %6
%94 = call i32* @malloc(i32 %93)
store i32* %94, i32** %9
store i32 0, i32* %8
br label %95
95: ; preds = %105, %90
%96 = load i32, i32* %8
%97 = load i32, i32* %7
%98 = icmp slt i32 %96, %97
br i1 %98, label %99, label %108
99: ; preds = %95
%100 = load i32, i32* %8
%101 = load i32*, i32** %9
%102 = load i32, i32* %8
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i32, i32* %101, i64 %103
store i32 %100, i32* %104
br label %105
105: ; preds = %99
%106 = load i32, i32* %8
%107 = add nsw i32 %106, 1
store i32 %107, i32* %8
br label %95
108: ; preds = %95
%109 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %19
%110 = call i32 (...) @fork()
%111 = icmp ne i32 %110, 0
br i1 %111, label %188, label %112
112: ; preds = %108
%113 = load i32*, i32** %9
%114 = call i32 @free(i32* %113)
%115 = load i32, i32* %6
%116 = call i32* @malloc(i32 %115)
store i32* %116, i32** %10
store i32 0, i32* %18
store i32 0, i32* %19
%117 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%118 = load i32, i32* %117
%119 = call i32 @syncup(i32 %118)
%120 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store double %120, double* %16
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%122 = load i32, i32* %121
%123 = call i32 @syncup(i32 %122)
br label %124
124: ; preds = %140, %112
%125 = load i32, i32* %19
%126 = load i32, i32* %6
%127 = icmp slt i32 %125, %126
br i1 %127, label %128, label %162
128: ; preds = %124
%129 = load i32, i32* %6
%130 = load i32, i32* %19
%131 = sub nsw i32 %129, %130
%132 = load i32, i32* %12
%133 = icmp sgt i32 %131, %132
br i1 %133, label %134, label %136
134: ; preds = %128
%135 = load i32, i32* %12
br label %140
136: ; preds = %128
%137 = load i32, i32* %6
%138 = load i32, i32* %19
%139 = sub nsw i32 %137, %138
br label %140
140: ; preds = %136, %134
%141 = phi i32 [ %135, %134 ], [ %139, %136 ]
store i32 %141, i32* %20
%142 = load i32*, i32** %10
%143 = bitcast i32* %142 to i8*
%144 = load i32, i32* %19
%145 = sext i32 %144 to i64
%146 = getelementptr i8, i8* %143, i64 %145
%147 = load i32, i32* %18
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 %148
%150 = load i8*, i8** %149
%151 = load i32, i32* %20
%152 = call i32 @memcpy(i8* %146, i8* %150, i32 %151)
%153 = load i32, i32* %20
%154 = load i32, i32* %19
%155 = add nsw i32 %154, %153
store i32 %155, i32* %19
%156 = load i32, i32* %18
%157 = add nsw i32 %156, 1
%158 = srem i32 %157, 2
store i32 %158, i32* %18
%159 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%160 = load i32, i32* %159
%161 = call i32 @syncup(i32 %160)
br label %124
162: ; preds = %124
%163 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
store double %163, double* %17
%164 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%165 = load i32, i32* %164
%166 = call i32 @internal_send(i32 %165, double* %16, i32 8)
%167 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%168 = load i32, i32* %167
%169 = call i32 @internal_send(i32 %168, double* %17, i32 8)
store i32 0, i32* %8
br label %170
170: ; preds = %184, %162
%171 = load i32, i32* %8
%172 = load i32, i32* %7
%173 = icmp slt i32 %171, %172
br i1 %173, label %174, label %187
174: ; preds = %170
%175 = load i32*, i32** %10
%176 = load i32, i32* %8
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds i32, i32* %175, i64 %177
%179 = load i32, i32* %178
%180 = load i32, i32* %8
%181 = icmp eq i32 %179, %180
%182 = zext i1 %181 to i32
%183 = call i32 @assert(i32 %182)
br label %184
184: ; preds = %174
%185 = load i32, i32* %8
%186 = add nsw i32 %185, 1
store i32 %186, i32* %8
br label %170
187: ; preds = %170
br label %263
188: ; preds = %108
store i32 0, i32* %18
store i32 0, i32* %19
%189 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%190 = load i32, i32* %189
%191 = call i32 @syncup(i32 %190)
%192 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store double %192, double* %14
br label %193
193: ; preds = %209, %188
%194 = load i32, i32* %19
%195 = load i32, i32* %6
%196 = icmp slt i32 %194, %195
br i1 %196, label %197, label %231
197: ; preds = %193
%198 = load i32, i32* %6
%199 = load i32, i32* %19
%200 = sub nsw i32 %198, %199
%201 = load i32, i32* %12
%202 = icmp sgt i32 %200, %201
br i1 %202, label %203, label %205
203: ; preds = %197
%204 = load i32, i32* %12
br label %209
205: ; preds = %197
%206 = load i32, i32* %6
%207 = load i32, i32* %19
%208 = sub nsw i32 %206, %207
br label %209
209: ; preds = %205, %203
%210 = phi i32 [ %204, %203 ], [ %208, %205 ]
store i32 %210, i32* %21
%211 = load i32, i32* %18
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 %212
%214 = load i8*, i8** %213
%215 = load i32*, i32** %9
%216 = bitcast i32* %215 to i8*
%217 = load i32, i32* %19
%218 = sext i32 %217 to i64
%219 = getelementptr i8, i8* %216, i64 %218
%220 = load i32, i32* %21
%221 = call i32 @memcpy(i8* %214, i8* %219, i32 %220)
%222 = load i32, i32* %21
%223 = load i32, i32* %19
%224 = add nsw i32 %223, %222
store i32 %224, i32* %19
%225 = load i32, i32* %18
%226 = add nsw i32 %225, 1
%227 = srem i32 %226, 2
store i32 %227, i32* %18
%228 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%229 = load i32, i32* %228
%230 = call i32 @syncup(i32 %229)
br label %193
231: ; preds = %193
%232 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%233 = load i32, i32* %232
%234 = call i32 @syncup(i32 %233)
%235 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
store double %235, double* %15
%236 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%237 = load i32, i32* %236
%238 = call i32 @internal_recv(i32 %237, double* %16, i32 8)
%239 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%240 = load i32, i32* %239
%241 = call i32 @internal_recv(i32 %240, double* %17, i32 8)
%242 = load double, double* %15
%243 = load double, double* %17
%244 = fcmp ogt double %242, %243
br i1 %244, label %245, label %247
245: ; preds = %231
%246 = load double, double* %15
br label %249
247: ; preds = %231
%248 = load double, double* %17
br label %249
249: ; preds = %247, %245
%250 = phi double [ %246, %245 ], [ %248, %247 ]
%251 = load double, double* %14
%252 = load double, double* %16
%253 = fcmp olt double %251, %252
br i1 %253, label %254, label %256
254: ; preds = %249
%255 = load double, double* %14
br label %258
256: ; preds = %249
%257 = load double, double* %16
br label %258
258: ; preds = %256, %254
%259 = phi double [ %255, %254 ], [ %257, %256 ]
%260 = fsub double %250, %259
%261 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), double %260)
%262 = call i32 @wait(i32* null)
br label %263
263: ; preds = %258, %187
ret i32 0
}

LLVM IR (-O2):
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [11 x i8] c"socketpair\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANON = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.1 = [7 x i8] c"mmap: \00"
@.str.2 = [21 x i8] c"before init, size=%d\00"
@.str.3 = [11 x i8] c"after init\00"
@.str.4 = [11 x i8] c"start read\00"
@.str.5 = [10 x i8] c"done read\00"
@.str.6 = [12 x i8] c"start write\00"
@.str.7 = [11 x i8] c"done write\00"
@.str.8 = [10 x i8] c"TIME: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i8*]
%5 = alloca double
%6 = alloca double
%7 = bitcast [2 x i32]* %3 to i8*
%8 = bitcast [2 x i8*]* %4 to i8*
%9 = bitcast double* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = icmp sgt i32 %0, 1
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = ashr i32 %15, 2
%17 = and i32 %15, -4
%18 = icmp eq i32 %0, 2
br i1 %18, label %25, label %21
19: ; preds = %2
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %12
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
br label %25
25: ; preds = %21, %12
%26 = phi i32 [ %24, %21 ], [ 360000, %12 ]
%27 = load i32, i32* @AF_UNIX
%28 = load i32, i32* @SOCK_STREAM
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%30 = call i32 @socketpair(i32 %27, i32 %28, i32 0, i32* %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %25
%36 = load i32, i32* @PROT_READ
%37 = load i32, i32* @PROT_WRITE
%38 = or i32 %37, %36
%39 = load i32, i32* @MAP_ANON
%40 = load i32, i32* @MAP_SHARED
%41 = or i32 %40, %39
%42 = call i8* @mmap(i32 0, i32 %26, i32 %38, i32 %41, i32 -1, i32 0)
%43 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
store i8* %42, i8** %43
%44 = load i8*, i8** @MAP_FAILED
%45 = icmp eq i8* %42, %44
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%48 = call i32 (...) @abort()
unreachable
49: ; preds = %35
%50 = load i32, i32* @PROT_READ
%51 = load i32, i32* @PROT_WRITE
%52 = or i32 %51, %50
%53 = load i32, i32* @MAP_ANON
%54 = load i32, i32* @MAP_SHARED
%55 = or i32 %54, %53
%56 = call i8* @mmap(i32 0, i32 %26, i32 %52, i32 %55, i32 -1, i32 0)
%57 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
store i8* %56, i8** %57
%58 = load i8*, i8** @MAP_FAILED
%59 = icmp eq i8* %56, %58
br i1 %59, label %60, label %63
60: ; preds = %49
%61 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%62 = call i32 (...) @abort()
unreachable
63: ; preds = %49
%64 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%65 = call i32* @malloc(i32 %17)
%66 = icmp sgt i32 %15, 3
br i1 %66, label %67, label %141
67: ; preds = %63
%68 = call i32 @llvm.smax.i32(i32 %16, i32 1)
%69 = zext i32 %68 to i64
%70 = icmp ult i32 %68, 8
br i1 %70, label %133, label %71
71: ; preds = %67
%72 = and i64 %69, 2147483640
%73 = add nsw i64 %72, -8
%74 = lshr exact i64 %73, 3
%75 = add nuw nsw i64 %74, 1
%76 = and i64 %75, 3
%77 = icmp ult i64 %73, 24
br i1 %77, label %114, label %78
78: ; preds = %71
%79 = and i64 %75, 4611686018427387900
br label %80
80: ; preds = %80, %78
%81 = phi i64 [ 0, %78 ], [ %110, %80 ]
%82 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %78 ], [ %111, %80 ]
%83 = phi i64 [ 0, %78 ], [ %112, %80 ]
%84 = add <4 x i32> %82, <i32 4, i32 4, i32 4, i32 4>
%85 = getelementptr inbounds i32, i32* %65, i64 %81
%86 = bitcast i32* %85 to <4 x i32>*
store <4 x i32> %82, <4 x i32>* %86
%87 = getelementptr inbounds i32, i32* %85, i64 4
%88 = bitcast i32* %87 to <4 x i32>*
store <4 x i32> %84, <4 x i32>* %88
%89 = or i64 %81, 8
%90 = add <4 x i32> %82, <i32 8, i32 8, i32 8, i32 8>
%91 = add <4 x i32> %82, <i32 12, i32 12, i32 12, i32 12>
%92 = getelementptr inbounds i32, i32* %65, i64 %89
%93 = bitcast i32* %92 to <4 x i32>*
store <4 x i32> %90, <4 x i32>* %93
%94 = getelementptr inbounds i32, i32* %92, i64 4
%95 = bitcast i32* %94 to <4 x i32>*
store <4 x i32> %91, <4 x i32>* %95
%96 = or i64 %81, 16
%97 = add <4 x i32> %82, <i32 16, i32 16, i32 16, i32 16>
%98 = add <4 x i32> %82, <i32 20, i32 20, i32 20, i32 20>
%99 = getelementptr inbounds i32, i32* %65, i64 %96
%100 = bitcast i32* %99 to <4 x i32>*
store <4 x i32> %97, <4 x i32>* %100
%101 = getelementptr inbounds i32, i32* %99, i64 4
%102 = bitcast i32* %101 to <4 x i32>*
store <4 x i32> %98, <4 x i32>* %102
%103 = or i64 %81, 24
%104 = add <4 x i32> %82, <i32 24, i32 24, i32 24, i32 24>
%105 = add <4 x i32> %82, <i32 28, i32 28, i32 28, i32 28>
%106 = getelementptr inbounds i32, i32* %65, i64 %103
%107 = bitcast i32* %106 to <4 x i32>*
store <4 x i32> %104, <4 x i32>* %107
%108 = getelementptr inbounds i32, i32* %106, i64 4
%109 = bitcast i32* %108 to <4 x i32>*
store <4 x i32> %105, <4 x i32>* %109
%110 = add nuw i64 %81, 32
%111 = add <4 x i32> %82, <i32 32, i32 32, i32 32, i32 32>
%112 = add i64 %83, 4
%113 = icmp eq i64 %112, %79
br i1 %113, label %114, label %80
114: ; preds = %80, %71
%115 = phi i64 [ 0, %71 ], [ %110, %80 ]
%116 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %71 ], [ %111, %80 ]
%117 = icmp eq i64 %76, 0
br i1 %117, label %131, label %118
118: ; preds = %114, %118
%119 = phi i64 [ %127, %118 ], [ %115, %114 ]
%120 = phi <4 x i32> [ %128, %118 ], [ %116, %114 ]
%121 = phi i64 [ %129, %118 ], [ 0, %114 ]
%122 = add <4 x i32> %120, <i32 4, i32 4, i32 4, i32 4>
%123 = getelementptr inbounds i32, i32* %65, i64 %119
%124 = bitcast i32* %123 to <4 x i32>*
store <4 x i32> %120, <4 x i32>* %124
%125 = getelementptr inbounds i32, i32* %123, i64 4
%126 = bitcast i32* %125 to <4 x i32>*
store <4 x i32> %122, <4 x i32>* %126
%127 = add nuw i64 %119, 8
%128 = add <4 x i32> %120, <i32 8, i32 8, i32 8, i32 8>
%129 = add i64 %121, 1
%130 = icmp eq i64 %129, %76
br i1 %130, label %131, label %118
131: ; preds = %118, %114
%132 = icmp eq i64 %72, %69
br i1 %132, label %141, label %133
133: ; preds = %67, %131
%134 = phi i64 [ 0, %67 ], [ %72, %131 ]
br label %135
135: ; preds = %133, %135
%136 = phi i64 [ %139, %135 ], [ %134, %133 ]
%137 = getelementptr inbounds i32, i32* %65, i64 %136
%138 = trunc i64 %136 to i32
store i32 %138, i32* %137
%139 = add nuw nsw i64 %136, 1
%140 = icmp eq i64 %139, %69
br i1 %140, label %141, label %135
141: ; preds = %135, %131, %63
%142 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%143 = call i32 (...) @fork()
%144 = icmp eq i32 %143, 0
br i1 %144, label %145, label %196
145: ; preds = %141
%146 = call i32 @free(i32* %65)
%147 = call i32* @malloc(i32 %17)
%148 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%149 = load i32, i32* %148
%150 = call i32 @syncup(i32 %149)
%151 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store double %151, double* %5
%152 = load i32, i32* %148
%153 = call i32 @syncup(i32 %152)
%154 = icmp sgt i32 %17, 0
br i1 %154, label %155, label %177
155: ; preds = %145
%156 = bitcast i32* %147 to i8*
br label %157
157: ; preds = %173, %155
%158 = phi i8* [ %42, %155 ], [ %176, %173 ]
%159 = phi i32 [ 0, %155 ], [ %167, %173 ]
%160 = phi i32 [ 0, %155 ], [ %169, %173 ]
%161 = sub nsw i32 %17, %159
%162 = icmp sgt i32 %161, %26
%163 = select i1 %162, i32 %26, i32 %161
%164 = sext i32 %159 to i64
%165 = getelementptr i8, i8* %156, i64 %164
%166 = call i32 @memcpy(i8* %165, i8* %158, i32 %163)
%167 = add nsw i32 %163, %159
%168 = add nsw i32 %160, 1
%169 = srem i32 %168, 2
%170 = load i32, i32* %148
%171 = call i32 @syncup(i32 %170)
%172 = icmp sgt i32 %17, %167
br i1 %172, label %173, label %177
173: ; preds = %157
%174 = zext i32 %169 to i64
%175 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 %174
%176 = load i8*, i8** %175
br label %157
177: ; preds = %157, %145
%178 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
store double %178, double* %6
%179 = load i32, i32* %148
%180 = call i32 @internal_send(i32 %179, double* %5, i32 8)
%181 = load i32, i32* %148
%182 = call i32 @internal_send(i32 %181, double* %6, i32 8)
br i1 %66, label %183, label %240
183: ; preds = %177
%184 = call i32 @llvm.smax.i32(i32 %16, i32 1)
%185 = zext i32 %184 to i64
br label %186
186: ; preds = %183, %186
%187 = phi i64 [ 0, %183 ], [ %194, %186 ]
%188 = getelementptr inbounds i32, i32* %147, i64 %187
%189 = load i32, i32* %188
%190 = zext i32 %189 to i64
%191 = icmp eq i64 %187, %190
%192 = zext i1 %191 to i32
%193 = call i32 @assert(i32 %192)
%194 = add nuw nsw i64 %187, 1
%195 = icmp eq i64 %194, %185
br i1 %195, label %240, label %186
196: ; preds = %141
%197 = load i32, i32* %29
%198 = call i32 @syncup(i32 %197)
%199 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%200 = icmp sgt i32 %17, 0
br i1 %200, label %201, label %223
201: ; preds = %196
%202 = bitcast i32* %65 to i8*
br label %203
203: ; preds = %219, %201
%204 = phi i8* [ %42, %201 ], [ %222, %219 ]
%205 = phi i32 [ 0, %201 ], [ %213, %219 ]
%206 = phi i32 [ 0, %201 ], [ %215, %219 ]
%207 = sub nsw i32 %17, %205
%208 = icmp sgt i32 %207, %26
%209 = select i1 %208, i32 %26, i32 %207
%210 = sext i32 %205 to i64
%211 = getelementptr i8, i8* %202, i64 %210
%212 = call i32 @memcpy(i8* %204, i8* %211, i32 %209)
%213 = add nsw i32 %209, %205
%214 = add nsw i32 %206, 1
%215 = srem i32 %214, 2
%216 = load i32, i32* %29
%217 = call i32 @syncup(i32 %216)
%218 = icmp sgt i32 %17, %213
br i1 %218, label %219, label %223
219: ; preds = %203
%220 = zext i32 %215 to i64
%221 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 %220
%222 = load i8*, i8** %221
br label %203
223: ; preds = %203, %196
%224 = load i32, i32* %29
%225 = call i32 @syncup(i32 %224)
%226 = call double (i8*, ...) @log_perf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%227 = load i32, i32* %29
%228 = call i32 @internal_recv(i32 %227, double* %5, i32 8)
%229 = load i32, i32* %29
%230 = call i32 @internal_recv(i32 %229, double* %6, i32 8)
%231 = load double, double* %6
%232 = fcmp ogt double %226, %231
%233 = select i1 %232, double %226, double %231
%234 = load double, double* %5
%235 = fcmp olt double %199, %234
%236 = select i1 %235, double %199, double %234
%237 = fsub double %233, %236
%238 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), double %237)
%239 = call i32 @wait(i32* null)
br label %240
240: ; preds = %186, %177, %223
ret i32 0
}