#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 */
struct timeval {
  int tv_sec;
  long tv_usec;
};
typedef int /*<<< orphan*/ rank;
typedef int /*<<< orphan*/ r;

/* Variables and functions */
int /*<<< orphan*/ M_MMAP_THRESHOLD;
int /*<<< orphan*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
char *malloc(unsigned long long);
int /*<<< orphan*/ mallopt(int /*<<< orphan*/, unsigned long long);
int /*<<< orphan*/ mmpi_barrier();
int /*<<< orphan*/ mmpi_init(int, int, int);
int /*<<< orphan*/ mmpi_recv(int, ...);
int /*<<< orphan*/ mmpi_send(int /*<<< orphan*/, ...);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int jobid, nprocs, rank, iter;
  char *buf;
  if (argc != 5)
    usage(argv[0]);
  jobid = atoi(argv[1]);
  nprocs = atoi(argv[2]);
  rank = atoi(argv[3]);
  iter = atoi(argv[4]);
  mmpi_init(jobid, nprocs, rank);
  printf("rank %d enters barrier\n", rank);
  mmpi_barrier();
  printf("rank %d exits barrier\n", rank);
  if (rank != 0) {
    int i;
    for (i = 0; i < iter; i++)
      mmpi_barrier();
  } else {
    int i;
    struct timeval tv1, tv2;
    long delta;
    printf("now time barrier latency (%d iterations)...\n", iter);
    gettimeofday(&tv1, NULL);
    for (i = 0; i < iter; i++)
      mmpi_barrier();
    gettimeofday(&tv2, NULL);
    delta = (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec;
    printf("average barrier latency: %.2fusec\n", (float)delta / (float)iter);
  }
  mmpi_barrier();
  if (rank != 0) {
    int i;
    printf("%d: send to %d\n", rank, 0);
    for (i = 0; i < iter; i++)
      mmpi_send(0, &rank, sizeof(rank));
  } else {
    int i, j;
    struct timeval tv1, tv2;
    long delta;
    printf("now time send/recv latency (%d iterations)...\n", iter);
    gettimeofday(&tv1, NULL);
    for (j = 1; j < nprocs; j++) {
      int r;
      size_t sz;
      printf("%d: recv from %d\n", rank, j);
      for (i = 0; i < iter; i++) {
        mmpi_recv(j, &r, &sz);
        assert(sz == sizeof(r));
        assert(r == j);
      }
      gettimeofday(&tv2, NULL);
      delta = (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec;
      printf("average send/recv latency: %.2fusec\n",
             (float)delta / (float)iter);
    }
  }
  mmpi_barrier();
  mallopt(M_MMAP_THRESHOLD, (1ULL << 23));
  buf = malloc((1ULL << 23));
  if (rank != 0) {
    int i, size, count;
    for (size = (1ULL << 8); size <= (1ULL << 23); size <<= 1) {
      count = (1ULL << 27) / size;
      for (i = 0; i < count; i++) {
        buf[0] = buf[size - 1] = (char)i;
        mmpi_send(0, buf, size);
      }
      mmpi_barrier();
    }
  } else {
    int i, j, size, count;
    struct timeval tv1, tv2;
    float delta;
    printf("now time send/recv throughput (%lld MB per iteration)...\n",
           (1ULL << 27) >> 20);
    for (size = (1ULL << 8); size <= (1ULL << 23); size <<= 1) {
      count = (1ULL << 27) / size;
      gettimeofday(&tv1, NULL);
      for (j = 1; j < nprocs; j++) {
        size_t sz;
        for (i = 0; i < count; i++) {
          mmpi_recv(j, buf, &sz);
          assert(sz == size);
          assert(buf[0] == (char)i);
          assert(buf[size - 1] == (char)i);
        }
      }
      gettimeofday(&tv2, NULL);
      delta = (float)(tv2.tv_usec - tv1.tv_usec) / 1E6 +
              (float)(tv2.tv_sec - tv1.tv_sec);
      printf("throughput: %6.1f MB/s (%.2fs) chunk % 8d\n",
             (float)((nprocs - 1) * ((1ULL << 27) >> 20)) / delta, delta, size);
      mmpi_barrier();
    }
  }
  free(buf);
  mmpi_barrier();
  printf("SUCCESS! rank %d exits\n", rank);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     11ef <main+0x2f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10c0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <mmpi_init@plt>
mov    -0x1c(%rbp),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
mov    -0x1c(%rbp),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     129d <main+0xdd>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1298 <main+0xd8>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1277 <main+0xb7>
jmp    132b <main+0x16b>
mov    -0x20(%rbp),%esi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12e3 <main+0x123>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12c2 <main+0x102>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
mov    -0x50(%rbp),%eax
sub    -0x40(%rbp),%eax
imul   $0xf4240,%eax,%eax
cltq
add    -0x48(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
cvtsi2ssq -0x58(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1387 <main+0x1c7>
mov    -0x1c(%rbp),%esi
lea    0xd41(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1382 <main+0x1c2>
xor    %edi,%edi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1080 <mmpi_send@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1356 <main+0x196>
jmp    1497 <main+0x2d7>
mov    -0x20(%rbp),%esi
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x78(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1492 <main+0x2d2>
mov    -0x1c(%rbp),%esi
mov    -0x64(%rbp),%edx
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1430 <main+0x270>
mov    -0x64(%rbp),%edi
lea    -0x94(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
mov    $0x0,%al
call   10d0 <mmpi_recv@plt>
cmpq   $0x4,-0xa0(%rbp)
04
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x94(%rbp),%eax
cmp    -0x64(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    13d3 <main+0x213>
lea    -0x88(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
mov    -0x88(%rbp),%eax
sub    -0x78(%rbp),%eax
imul   $0xf4240,%eax,%eax
cltq
add    -0x80(%rbp),%rax
sub    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
cvtsi2ssq -0x90(%rbp),%xmm0
ff ff
cvtsi2ssl -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    13ac <main+0x1ec>
jmp    1497 <main+0x2d7>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
mov    $0x800000,%esi
call   1050 <mallopt@plt>
mov    $0x800000,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1581 <main+0x3c1>
movl   $0x100,-0xa8(%rbp)
movslq -0xa8(%rbp),%rax
cmp    $0x800000,%rax
ja     157c <main+0x3bc>
movslq -0xa8(%rbp),%rcx
mov    $0x8000000,%eax
xor    %edx,%edx
div    %rcx
mov    %eax,-0xac(%rbp)
movl   $0x0,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
cmp    -0xac(%rbp),%eax
jge    1561 <main+0x3a1>
mov    -0xa4(%rbp),%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    -0xa8(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
mov    %cl,(%rax,%rdx,1)
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rsi
mov    -0xa8(%rbp),%edx
xor    %edi,%edi
mov    $0x0,%al
call   1080 <mmpi_send@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1507 <main+0x347>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
mov    -0xa8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    14d3 <main+0x313>
jmp    17b4 <main+0x5f4>
lea    0xb75(%rip),%rdi
mov    $0x80,%esi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x100,-0xb8(%rbp)
movslq -0xb8(%rbp),%rax
cmp    $0x800000,%rax
ja     17af <main+0x5ef>
movslq -0xb8(%rbp),%rcx
mov    $0x8000000,%eax
xor    %edx,%edx
div    %rcx
mov    %eax,-0xbc(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
movl   $0x1,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    16bb <main+0x4fb>
movl   $0x0,-0xb0(%rbp)
mov    -0xb0(%rbp),%eax
cmp    -0xbc(%rbp),%eax
jge    16a2 <main+0x4e2>
mov    -0xb4(%rbp),%edi
mov    -0x28(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
mov    $0x0,%al
call   10d0 <mmpi_recv@plt>
mov    -0xf0(%rbp),%rax
movslq -0xb8(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    -0xb0(%rbp),%ecx
movsbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x28(%rbp),%rax
mov    -0xb8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0xb0(%rbp),%ecx
movsbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0xb0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb0(%rbp)
jmp    15fb <main+0x43b>
jmp    16a7 <main+0x4e7>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    15e2 <main+0x422>
xor    %eax,%eax
mov    %eax,%esi
lea    -0xe0(%rbp),%rdi
call   1070 <gettimeofday@plt>
mov    -0xd8(%rbp),%rax
mov    -0xc8(%rbp),%rcx
sub    %rcx,%rax
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x913(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0xe0(%rbp),%eax
mov    -0xd0(%rbp),%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xe4(%rbp)
ff
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
cltq
shl    $0x7,%rax
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0xf8(%rbp)
ff
mov    %rax,%rcx
shr    %rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
test   %rax,%rax
movss  %xmm0,-0xf4(%rbp)
ff
js     1760 <main+0x5a0>
movss  -0xf8(%rbp),%xmm0
ff
movss  %xmm0,-0xf4(%rbp)
ff
movss  -0xf4(%rbp),%xmm0
ff
divss  -0xe4(%rbp),%xmm0
ff
cvttss2si %xmm0,%esi
movss  -0xe4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
mov    -0xb8(%rbp),%edx
lea    0x9aa(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
mov    -0xb8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    159e <main+0x3de>
jmp    17b4 <main+0x5f4>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1090 <mmpi_barrier@plt>
mov    -0x1c(%rbp),%esi
lea    0x994(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
cmp    $0x5,%edi
je     11df <main+0x1f>
mov    0x0(%rbp),%rdi
call   10c0 <usage@plt>
mov    0x8(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r15d
mov    0x10(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ebx
mov    0x18(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r12d
mov    %eax,0x10(%rsp)
mov    0x20(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r14d
mov    %r15d,%edi
mov    %ebx,0x4(%rsp)
mov    %ebx,%esi
mov    %r12d,%edx
call   1040 <mmpi_init@plt>
lea    0xdde(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
lea    0xdde(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12d,%r12d
je     1271 <main+0xb1>
test   %r14d,%r14d
jle    145a <main+0x29a>
mov    %r14d,%ebp
nopl   (%rax)
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
add    $0xffffffff,%ebp
jne    1260 <main+0xa0>
jmp    12f9 <main+0x139>
lea    0xdbf(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
test   %r14d,%r14d
jle    12ac <main+0xec>
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
add    $0xffffffff,%ebp
jne    12a0 <main+0xe0>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
movslq 0x18(%rsp),%rax
movslq 0x28(%rsp),%rcx
sub    %rcx,%rax
imul   $0xf4240,%rax,%rax
mov    0x20(%rsp),%rcx
sub    0x30(%rsp),%rcx
add    %rax,%rcx
cvtsi2ss %rcx,%xmm0
cvtsi2ss %r14d,%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
lea    0xd72(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
test   %r12d,%r12d
je     134c <main+0x18c>
lea    0xd7b(%rip),%rdi
mov    %r12d,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %r14d,%r14d
jle    1474 <main+0x2b4>
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    $0x4,%edx
xor    %edi,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <mmpi_send@plt>
add    $0xffffffff,%r14d
jne    1330 <main+0x170>
jmp    1474 <main+0x2b4>
lea    0xd44(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
cmpl   $0x2,0x4(%rsp)
jl     1474 <main+0x2b4>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
movss  %xmm0,0x8(%rsp)
movslq 0x28(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    0x30(%rsp),%r15
mov    $0x1,%ebx
lea    0x4c(%rsp),%r13
lea    0x40(%rsp),%rbp
jmp    1401 <main+0x241>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
movslq 0x18(%rsp),%rax
sub    0x38(%rsp),%rax
imul   $0xf4240,%rax,%rax
mov    0x20(%rsp),%rcx
sub    %r15,%rcx
add    %rax,%rcx
xorps  %xmm0,%xmm0
cvtsi2ss %rcx,%xmm0
divss  0x8(%rsp),%xmm0
cvttss2si %xmm0,%esi
lea    0xce7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
je     1474 <main+0x2b4>
lea    0xcbe(%rip),%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
test   %r14d,%r14d
jle    13b0 <main+0x1f0>
mov    %r14d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10d0 <mmpi_recv@plt>
xor    %edi,%edi
cmpq   $0x4,0x40(%rsp)
sete   %dil
call   10a0 <assert@plt>
xor    %edi,%edi
cmp    %ebx,0x4c(%rsp)
sete   %dil
call   10a0 <assert@plt>
add    $0xffffffff,%r12d
jne    1420 <main+0x260>
jmp    13b0 <main+0x1f0>
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
lea    0xc1f(%rip),%rdi
mov    %r12d,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
mov    0x2b5e(%rip),%rax
mov    (%rax),%edi
mov    $0x800000,%esi
call   1050 <mallopt@plt>
mov    $0x800000,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbp
cmpl   $0x0,0x10(%rsp)
je     1507 <main+0x347>
mov    $0x100,%r15d
nopl   0x0(%rax,%rax,1)
mov    $0x8000000,%eax
xor    %edx,%edx
div    %r15d
mov    %eax,%r14d
movslq %r15d,%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %bl,-0x1(%rbp,%r12,1)
mov    %bl,0x0(%rbp)
xor    %edi,%edi
mov    %rbp,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <mmpi_send@plt>
add    $0x1,%ebx
cmp    %r14d,%ebx
jne    14d0 <main+0x310>
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
add    %r15d,%r15d
cmp    $0x800001,%r15d
jb     14b0 <main+0x2f0>
jmp    16e1 <main+0x521>
lea    0xbef(%rip),%rdi
mov    $0x80,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movslq 0x4(%rsp),%rax
shl    $0x7,%rax
add    $0xffffffffffffff80,%rax
mov    %rbp,0x50(%rsp)
js     1538 <main+0x378>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
jmp    1547 <main+0x387>
shr    %rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  %xmm0,%xmm0
movss  %xmm0,0x14(%rsp)
movl   $0x100,0xc(%rsp)
mov    $0x100,%r15d
mov    0x50(%rsp),%r12
jmp    15fb <main+0x43b>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    0x20(%rsp),%rax
sub    0x30(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mov    0x18(%rsp),%eax
sub    0x28(%rsp),%eax
divsd  0xa5e(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  0x14(%rsp),%xmm1
divss  %xmm0,%xmm1
cvttss2si %xmm1,%esi
cvtss2sd %xmm0,%xmm0
lea    0xb66(%rip),%rdi
mov    0xc(%rsp),%ebx
mov    %ebx,%edx
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
add    %ebx,%ebx
mov    %ebx,0xc(%rsp)
movslq %ebx,%r15
cmp    $0x800001,%r15d
jae    16dc <main+0x51c>
cmp    $0x8000000,%r15
ja     1620 <main+0x460>
mov    $0x8000000,%eax
xor    %edx,%edx
div    %r15d
mov    %eax,%ebp
jmp    1622 <main+0x462>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebp,%ebp
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
cmpl   $0x2,0x4(%rsp)
jl     1570 <main+0x3b0>
movslq 0xc(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    $0x1,%ecx
jmp    165d <main+0x49d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ecx
cmp    0x4(%rsp),%ecx
je     1570 <main+0x3b0>
test   %ebp,%ebp
je     1650 <main+0x490>
xor    %r13d,%r13d
xor    %r14d,%r14d
mov    %ecx,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%edi
mov    %r12,%rsi
lea    0x40(%rsp),%rdx
xor    %eax,%eax
call   10d0 <mmpi_recv@plt>
xor    %edi,%edi
cmp    %r15,0x40(%rsp)
sete   %dil
call   10a0 <assert@plt>
movsbl (%r12),%eax
mov    %r13d,%ebx
sar    $0x18,%ebx
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
call   10a0 <assert@plt>
mov    0x38(%rsp),%rax
movsbl -0x1(%r12,%rax,1),%eax
xor    %edi,%edi
cmp    %eax,%ebx
sete   %dil
call   10a0 <assert@plt>
mov    0x8(%rsp),%ecx
add    $0x1,%r14d
add    $0x1000000,%r13d
cmp    %ebp,%r14d
jne    1670 <main+0x4b0>
jmp    1650 <main+0x490>
mov    0x50(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1090 <mmpi_barrier@plt>
mov    0x10(%rsp),%esi
lea    0xa67(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@.str = [24 x i8] c"rank %d enters barrier\0A\00"
@.str.1 = [23 x i8] c"rank %d exits barrier\0A\00"
@.str.2 = [45 x i8] c"now time barrier latency (%d iterations)...\0A\00"
@.str.3 = [35 x i8] c"average barrier latency: %.2fusec\0A\00"
@.str.4 = [16 x i8] c"%d: send to %d\0A\00"
@.str.5 = [47 x i8] c"now time send/recv latency (%d iterations)...\0A\00"
@.str.6 = [18 x i8] c"%d: recv from %d\0A\00"
@.str.7 = [37 x i8] c"average send/recv latency: %.2fusec\0A\00"
@M_MMAP_THRESHOLD = global i32 0
@.str.8 = [58 x i8] c"now time send/recv throughput (%lld MB per iteration)...\0A\00"
@.str.9 = [43 x i8] c"throughput: %6.1f MB/s (%.2fs) chunk % 8d\0A\00"
@.str.10 = [24 x i8] c"SUCCESS! rank %d exits\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 i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.timeval
%14 = alloca %struct.timeval
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca %struct.timeval
%20 = alloca %struct.timeval
%21 = alloca i64
%22 = alloca i32
%23 = alloca i64
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca %struct.timeval
%32 = alloca %struct.timeval
%33 = alloca float
%34 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 5
br i1 %36, label %37, label %42
37: ; preds = %2
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @usage(i8* %40)
br label %42
42: ; preds = %37, %2
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %6
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %7
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 3
%53 = load i8*, i8** %52
%54 = call i32 @atoi(i8* %53)
store i32 %54, i32* %8
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 4
%57 = load i8*, i8** %56
%58 = call i32 @atoi(i8* %57)
store i32 %58, i32* %9
%59 = load i32, i32* %6
%60 = load i32, i32* %7
%61 = load i32, i32* %8
%62 = call i32 @mmpi_init(i32 %59, i32 %60, i32 %61)
%63 = load i32, i32* %8
%64 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = call i32 (...) @mmpi_barrier()
%66 = load i32, i32* %8
%67 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %66)
%68 = load i32, i32* %8
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %81
70: ; preds = %42
store i32 0, i32* %11
br label %71
71: ; preds = %77, %70
%72 = load i32, i32* %11
%73 = load i32, i32* %9
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %80
75: ; preds = %71
%76 = call i32 (...) @mmpi_barrier()
br label %77
77: ; preds = %75
%78 = load i32, i32* %11
%79 = add nsw i32 %78, 1
store i32 %79, i32* %11
br label %71
80: ; preds = %71
br label %116
81: ; preds = %42
%82 = load i32, i32* %9
%83 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %82)
%84 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
store i32 0, i32* %12
br label %85
85: ; preds = %91, %81
%86 = load i32, i32* %12
%87 = load i32, i32* %9
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %94
89: ; preds = %85
%90 = call i32 (...) @mmpi_barrier()
br label %91
91: ; preds = %89
%92 = load i32, i32* %12
%93 = add nsw i32 %92, 1
store i32 %93, i32* %12
br label %85
94: ; preds = %85
%95 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%96 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%97 = load i32, i32* %96
%98 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%99 = load i32, i32* %98
%100 = sub nsw i32 %97, %99
%101 = mul nsw i32 %100, 1000000
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%104 = load i64, i64* %103
%105 = add nsw i64 %102, %104
%106 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%107 = load i64, i64* %106
%108 = sub nsw i64 %105, %107
store i64 %108, i64* %15
%109 = load i64, i64* %15
%110 = sitofp i64 %109 to float
%111 = load i32, i32* %9
%112 = sitofp i32 %111 to float
%113 = fdiv float %110, %112
%114 = fptosi float %113 to i32
%115 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %114)
br label %116
116: ; preds = %94, %80
%117 = call i32 (...) @mmpi_barrier()
%118 = load i32, i32* %8
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %133
120: ; preds = %116
%121 = load i32, i32* %8
%122 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %121, i32 0)
store i32 0, i32* %16
br label %123
123: ; preds = %129, %120
%124 = load i32, i32* %16
%125 = load i32, i32* %9
%126 = icmp slt i32 %124, %125
br i1 %126, label %127, label %132
127: ; preds = %123
%128 = call i32 (i32, ...) @mmpi_send(i32 0, i32* %8, i64 4)
br label %129
129: ; preds = %127
%130 = load i32, i32* %16
%131 = add nsw i32 %130, 1
store i32 %131, i32* %16
br label %123
132: ; preds = %123
br label %190
133: ; preds = %116
%134 = load i32, i32* %9
%135 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %134)
%136 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
store i32 1, i32* %18
br label %137
137: ; preds = %186, %133
%138 = load i32, i32* %18
%139 = load i32, i32* %7
%140 = icmp slt i32 %138, %139
br i1 %140, label %141, label %189
141: ; preds = %137
%142 = load i32, i32* %8
%143 = load i32, i32* %18
%144 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %142, i32 %143)
store i32 0, i32* %17
br label %145
145: ; preds = %161, %141
%146 = load i32, i32* %17
%147 = load i32, i32* %9
%148 = icmp slt i32 %146, %147
br i1 %148, label %149, label %164
149: ; preds = %145
%150 = load i32, i32* %18
%151 = call i32 (i32, ...) @mmpi_recv(i32 %150, i32* %22, i64* %23)
%152 = load i64, i64* %23
%153 = icmp eq i64 %152, 4
%154 = zext i1 %153 to i32
%155 = call i32 @assert(i32 %154)
%156 = load i32, i32* %22
%157 = load i32, i32* %18
%158 = icmp eq i32 %156, %157
%159 = zext i1 %158 to i32
%160 = call i32 @assert(i32 %159)
br label %161
161: ; preds = %149
%162 = load i32, i32* %17
%163 = add nsw i32 %162, 1
store i32 %163, i32* %17
br label %145
164: ; preds = %145
%165 = call i32 @gettimeofday(%struct.timeval* %20, i32* null)
%166 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 0
%167 = load i32, i32* %166
%168 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%169 = load i32, i32* %168
%170 = sub nsw i32 %167, %169
%171 = mul nsw i32 %170, 1000000
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%174 = load i64, i64* %173
%175 = add nsw i64 %172, %174
%176 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%177 = load i64, i64* %176
%178 = sub nsw i64 %175, %177
store i64 %178, i64* %21
%179 = load i64, i64* %21
%180 = sitofp i64 %179 to float
%181 = load i32, i32* %9
%182 = sitofp i32 %181 to float
%183 = fdiv float %180, %182
%184 = fptosi float %183 to i32
%185 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %184)
br label %186
186: ; preds = %164
%187 = load i32, i32* %18
%188 = add nsw i32 %187, 1
store i32 %188, i32* %18
br label %137
189: ; preds = %137
br label %190
190: ; preds = %189, %132
%191 = call i32 (...) @mmpi_barrier()
%192 = load i32, i32* @M_MMAP_THRESHOLD
%193 = call i32 @mallopt(i32 %192, i64 8388608)
%194 = call i8* @malloc(i64 8388608)
store i8* %194, i8** %10
%195 = load i32, i32* %8
%196 = icmp ne i32 %195, 0
br i1 %196, label %197, label %233
197: ; preds = %190
store i32 256, i32* %25
br label %198
198: ; preds = %229, %197
%199 = load i32, i32* %25
%200 = sext i32 %199 to i64
%201 = icmp ule i64 %200, 8388608
br i1 %201, label %202, label %232
202: ; preds = %198
%203 = load i32, i32* %25
%204 = sext i32 %203 to i64
%205 = udiv i64 134217728, %204
%206 = trunc i64 %205 to i32
store i32 %206, i32* %26
store i32 0, i32* %24
br label %207
207: ; preds = %224, %202
%208 = load i32, i32* %24
%209 = load i32, i32* %26
%210 = icmp slt i32 %208, %209
br i1 %210, label %211, label %227
211: ; preds = %207
%212 = load i32, i32* %24
%213 = trunc i32 %212 to i8
%214 = load i8*, i8** %10
%215 = load i32, i32* %25
%216 = sub nsw i32 %215, 1
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds i8, i8* %214, i64 %217
store i8 %213, i8* %218
%219 = load i8*, i8** %10
%220 = getelementptr inbounds i8, i8* %219, i64 0
store i8 %213, i8* %220
%221 = load i8*, i8** %10
%222 = load i32, i32* %25
%223 = call i32 (i32, ...) @mmpi_send(i32 0, i8* %221, i32 %222)
br label %224
224: ; preds = %211
%225 = load i32, i32* %24
%226 = add nsw i32 %225, 1
store i32 %226, i32* %24
br label %207
227: ; preds = %207
%228 = call i32 (...) @mmpi_barrier()
br label %229
229: ; preds = %227
%230 = load i32, i32* %25
%231 = shl i32 %230, 1
store i32 %231, i32* %25
br label %198
232: ; preds = %198
br label %330
233: ; preds = %190
%234 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i32 128)
store i32 256, i32* %29
br label %235
235: ; preds = %326, %233
%236 = load i32, i32* %29
%237 = sext i32 %236 to i64
%238 = icmp ule i64 %237, 8388608
br i1 %238, label %239, label %329
239: ; preds = %235
%240 = load i32, i32* %29
%241 = sext i32 %240 to i64
%242 = udiv i64 134217728, %241
%243 = trunc i64 %242 to i32
store i32 %243, i32* %30
%244 = call i32 @gettimeofday(%struct.timeval* %31, i32* null)
store i32 1, i32* %28
br label %245
245: ; preds = %291, %239
%246 = load i32, i32* %28
%247 = load i32, i32* %7
%248 = icmp slt i32 %246, %247
br i1 %248, label %249, label %294
249: ; preds = %245
store i32 0, i32* %27
br label %250
250: ; preds = %287, %249
%251 = load i32, i32* %27
%252 = load i32, i32* %30
%253 = icmp slt i32 %251, %252
br i1 %253, label %254, label %290
254: ; preds = %250
%255 = load i32, i32* %28
%256 = load i8*, i8** %10
%257 = call i32 (i32, ...) @mmpi_recv(i32 %255, i8* %256, i64* %34)
%258 = load i64, i64* %34
%259 = load i32, i32* %29
%260 = sext i32 %259 to i64
%261 = icmp eq i64 %258, %260
%262 = zext i1 %261 to i32
%263 = call i32 @assert(i32 %262)
%264 = load i8*, i8** %10
%265 = getelementptr inbounds i8, i8* %264, i64 0
%266 = load i8, i8* %265
%267 = sext i8 %266 to i32
%268 = load i32, i32* %27
%269 = trunc i32 %268 to i8
%270 = sext i8 %269 to i32
%271 = icmp eq i32 %267, %270
%272 = zext i1 %271 to i32
%273 = call i32 @assert(i32 %272)
%274 = load i8*, i8** %10
%275 = load i32, i32* %29
%276 = sub nsw i32 %275, 1
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds i8, i8* %274, i64 %277
%279 = load i8, i8* %278
%280 = sext i8 %279 to i32
%281 = load i32, i32* %27
%282 = trunc i32 %281 to i8
%283 = sext i8 %282 to i32
%284 = icmp eq i32 %280, %283
%285 = zext i1 %284 to i32
%286 = call i32 @assert(i32 %285)
br label %287
287: ; preds = %254
%288 = load i32, i32* %27
%289 = add nsw i32 %288, 1
store i32 %289, i32* %27
br label %250
290: ; preds = %250
br label %291
291: ; preds = %290
%292 = load i32, i32* %28
%293 = add nsw i32 %292, 1
store i32 %293, i32* %28
br label %245
294: ; preds = %245
%295 = call i32 @gettimeofday(%struct.timeval* %32, i32* null)
%296 = getelementptr inbounds %struct.timeval, %struct.timeval* %32, i32 0, i32 1
%297 = load i64, i64* %296
%298 = getelementptr inbounds %struct.timeval, %struct.timeval* %31, i32 0, i32 1
%299 = load i64, i64* %298
%300 = sub nsw i64 %297, %299
%301 = sitofp i64 %300 to float
%302 = fpext float %301 to double
%303 = fdiv double %302, 1.000000e+06
%304 = getelementptr inbounds %struct.timeval, %struct.timeval* %32, i32 0, i32 0
%305 = load i32, i32* %304
%306 = getelementptr inbounds %struct.timeval, %struct.timeval* %31, i32 0, i32 0
%307 = load i32, i32* %306
%308 = sub nsw i32 %305, %307
%309 = sitofp i32 %308 to float
%310 = fpext float %309 to double
%311 = fadd double %303, %310
%312 = fptrunc double %311 to float
store float %312, float* %33
%313 = load i32, i32* %7
%314 = sub nsw i32 %313, 1
%315 = sext i32 %314 to i64
%316 = mul i64 %315, 128
%317 = uitofp i64 %316 to float
%318 = load float, float* %33
%319 = fdiv float %317, %318
%320 = fptosi float %319 to i32
%321 = load float, float* %33
%322 = fpext float %321 to double
%323 = load i32, i32* %29
%324 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %320, double %322, i32 %323)
%325 = call i32 (...) @mmpi_barrier()
br label %326
326: ; preds = %294
%327 = load i32, i32* %29
%328 = shl i32 %327, 1
store i32 %328, i32* %29
br label %235
329: ; preds = %235
br label %330
330: ; preds = %329, %232
%331 = load i8*, i8** %10
%332 = call i32 @free(i8* %331)
%333 = call i32 (...) @mmpi_barrier()
%334 = load i32, i32* %8
%335 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %334)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@.str = [24 x i8] c"rank %d enters barrier\0A\00"
@.str.1 = [23 x i8] c"rank %d exits barrier\0A\00"
@.str.2 = [45 x i8] c"now time barrier latency (%d iterations)...\0A\00"
@.str.3 = [35 x i8] c"average barrier latency: %.2fusec\0A\00"
@.str.4 = [16 x i8] c"%d: send to %d\0A\00"
@.str.5 = [47 x i8] c"now time send/recv latency (%d iterations)...\0A\00"
@.str.6 = [18 x i8] c"%d: recv from %d\0A\00"
@.str.7 = [37 x i8] c"average send/recv latency: %.2fusec\0A\00"
@M_MMAP_THRESHOLD = global i32 0
@.str.8 = [58 x i8] c"now time send/recv throughput (%lld MB per iteration)...\0A\00"
@.str.9 = [43 x i8] c"throughput: %6.1f MB/s (%.2fs) chunk % 8d\0A\00"
@.str.10 = [24 x i8] c"SUCCESS! rank %d exits\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca i32
%9 = alloca i64
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca i64
%13 = bitcast i32* %3 to i8*
%14 = icmp eq i32 %0, 5
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i8*, i8** %1
%17 = tail call i32 @usage(i8* %16)
br label %18
18: ; preds = %15, %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call i32 @atoi(i8* %26)
store i32 %27, i32* %3
%28 = getelementptr inbounds i8*, i8** %1, i64 4
%29 = load i8*, i8** %28
%30 = tail call i32 @atoi(i8* %29)
%31 = tail call i32 @mmpi_init(i32 %21, i32 %24, i32 %27)
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %27)
%33 = tail call i32 (...) @mmpi_barrier()
%34 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%35 = icmp eq i32 %27, 0
br i1 %35, label %46, label %36
36: ; preds = %18
%37 = icmp sgt i32 %30, 0
br i1 %37, label %41, label %38
38: ; preds = %36
%39 = tail call i32 (...) @mmpi_barrier()
%40 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 0)
br label %136
41: ; preds = %36, %41
%42 = phi i32 [ %44, %41 ], [ 0, %36 ]
%43 = tail call i32 (...) @mmpi_barrier()
%44 = add nuw nsw i32 %42, 1
%45 = icmp eq i32 %44, %30
br i1 %45, label %77, label %41
46: ; preds = %18
%47 = bitcast %struct.timeval* %4 to i8*
%48 = bitcast %struct.timeval* %5 to i8*
%49 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%50 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%51 = icmp sgt i32 %30, 0
br i1 %51, label %52, label %57
52: ; preds = %46, %52
%53 = phi i32 [ %55, %52 ], [ 0, %46 ]
%54 = tail call i32 (...) @mmpi_barrier()
%55 = add nuw nsw i32 %53, 1
%56 = icmp eq i32 %55, %30
br i1 %56, label %57, label %52
57: ; preds = %52, %46
%58 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%60 = load i32, i32* %59
%61 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%62 = load i32, i32* %61
%63 = sub nsw i32 %60, %62
%64 = mul nsw i32 %63, 1000000
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%67 = load i64, i64* %66
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%69 = load i64, i64* %68
%70 = sub i64 %67, %69
%71 = add i64 %70, %65
%72 = sitofp i64 %71 to float
%73 = sitofp i32 %30 to float
%74 = fdiv float %72, %73
%75 = fptosi float %74 to i32
%76 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %41, %57
%78 = tail call i32 (...) @mmpi_barrier()
br i1 %35, label %87, label %79
79: ; preds = %77
%80 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 0)
%81 = icmp sgt i32 %30, 0
br i1 %81, label %82, label %136
82: ; preds = %79, %82
%83 = phi i32 [ %85, %82 ], [ 0, %79 ]
%84 = call i32 (i32, ...) @mmpi_send(i32 0, i32* %3, i64 4)
%85 = add nuw nsw i32 %83, 1
%86 = icmp eq i32 %85, %30
br i1 %86, label %136, label %82
87: ; preds = %77
%88 = bitcast %struct.timeval* %6 to i8*
%89 = bitcast %struct.timeval* %7 to i8*
%90 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%91 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%92 = icmp sgt i32 %24, 1
br i1 %92, label %93, label %135
93: ; preds = %87
%94 = bitcast i32* %8 to i8*
%95 = bitcast i64* %9 to i8*
%96 = icmp sgt i32 %30, 0
%97 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%98 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%99 = load i32, i32* %98
%100 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%101 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%102 = load i64, i64* %101
%103 = sitofp i32 %30 to float
br label %104
104: ; preds = %93, %120
%105 = phi i32 [ 1, %93 ], [ %133, %120 ]
%106 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 %105)
br i1 %96, label %107, label %120
107: ; preds = %104, %107
%108 = phi i32 [ %118, %107 ], [ 0, %104 ]
%109 = call i32 (i32, ...) @mmpi_recv(i32 %105, i32* %8, i64* %9)
%110 = load i64, i64* %9
%111 = icmp eq i64 %110, 4
%112 = zext i1 %111 to i32
%113 = call i32 @assert(i32 %112)
%114 = load i32, i32* %8
%115 = icmp eq i32 %114, %105
%116 = zext i1 %115 to i32
%117 = call i32 @assert(i32 %116)
%118 = add nuw nsw i32 %108, 1
%119 = icmp eq i32 %118, %30
br i1 %119, label %120, label %107
120: ; preds = %107, %104
%121 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%122 = load i32, i32* %97
%123 = sub nsw i32 %122, %99
%124 = mul nsw i32 %123, 1000000
%125 = sext i32 %124 to i64
%126 = load i64, i64* %100
%127 = sub i64 %126, %102
%128 = add i64 %127, %125
%129 = sitofp i64 %128 to float
%130 = fdiv float %129, %103
%131 = fptosi float %130 to i32
%132 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %131)
%133 = add nuw nsw i32 %105, 1
%134 = icmp eq i32 %133, %24
br i1 %134, label %135, label %104
135: ; preds = %120, %87
br label %136
136: ; preds = %82, %38, %79, %135
%137 = call i32 (...) @mmpi_barrier()
%138 = load i32, i32* @M_MMAP_THRESHOLD
%139 = call i32 @mallopt(i32 %138, i64 8388608)
%140 = call dereferenceable_or_null(8388608) i8* @malloc(i64 8388608)
%141 = load i32, i32* %3
%142 = icmp eq i32 %141, 0
br i1 %142, label %159, label %143
143: ; preds = %136, %155
%144 = phi i32 [ %157, %155 ], [ 256, %136 ]
%145 = udiv i32 134217728, %144
%146 = add nsw i32 %144, -1
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i8, i8* %140, i64 %147
br label %149
149: ; preds = %143, %149
%150 = phi i32 [ 0, %143 ], [ %153, %149 ]
%151 = trunc i32 %150 to i8
store i8 %151, i8* %148
store i8 %151, i8* %140
%152 = call i32 (i32, ...) @mmpi_send(i32 0, i8* %140, i32 %144)
%153 = add nuw nsw i32 %150, 1
%154 = icmp eq i32 %153, %145
br i1 %154, label %155, label %149
155: ; preds = %149
%156 = call i32 (...) @mmpi_barrier()
%157 = shl i32 %144, 1
%158 = icmp ult i32 %157, 8388609
br i1 %158, label %143, label %234
159: ; preds = %136
%160 = bitcast %struct.timeval* %10 to i8*
%161 = bitcast %struct.timeval* %11 to i8*
%162 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0), i32 128)
%163 = icmp sgt i32 %24, 1
%164 = bitcast i64* %12 to i8*
%165 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 1
%166 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
%167 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 0
%168 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
%169 = add nsw i32 %24, -1
%170 = sext i32 %169 to i64
%171 = shl nsw i64 %170, 7
%172 = uitofp i64 %171 to float
br label %173
173: ; preds = %159, %210
%174 = phi i64 [ 256, %159 ], [ %231, %210 ]
%175 = phi i32 [ 256, %159 ], [ %230, %210 ]
%176 = udiv i64 134217728, %174
%177 = trunc i64 %176 to i32
%178 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
br i1 %163, label %179, label %210
179: ; preds = %173
%180 = icmp eq i32 %177, 0
%181 = add nsw i32 %175, -1
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i8, i8* %140, i64 %182
br label %184
184: ; preds = %179, %207
%185 = phi i32 [ 1, %179 ], [ %208, %207 ]
br i1 %180, label %207, label %186
186: ; preds = %184, %186
%187 = phi i32 [ %205, %186 ], [ 0, %184 ]
%188 = call i32 (i32, ...) @mmpi_recv(i32 %185, i8* %140, i64* %12)
%189 = load i64, i64* %12
%190 = icmp eq i64 %189, %174
%191 = zext i1 %190 to i32
%192 = call i32 @assert(i32 %191)
%193 = load i8, i8* %140
%194 = sext i8 %193 to i32
%195 = shl i32 %187, 24
%196 = ashr exact i32 %195, 24
%197 = icmp eq i32 %196, %194
%198 = zext i1 %197 to i32
%199 = call i32 @assert(i32 %198)
%200 = load i8, i8* %183
%201 = sext i8 %200 to i32
%202 = icmp eq i32 %196, %201
%203 = zext i1 %202 to i32
%204 = call i32 @assert(i32 %203)
%205 = add nuw nsw i32 %187, 1
%206 = icmp eq i32 %205, %177
br i1 %206, label %207, label %186
207: ; preds = %186, %184
%208 = add nuw nsw i32 %185, 1
%209 = icmp eq i32 %208, %24
br i1 %209, label %210, label %184
210: ; preds = %207, %173
%211 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%212 = load i64, i64* %165
%213 = load i64, i64* %166
%214 = sub nsw i64 %212, %213
%215 = sitofp i64 %214 to float
%216 = fpext float %215 to double
%217 = fdiv double %216, 1.000000e+06
%218 = load i32, i32* %167
%219 = load i32, i32* %168
%220 = sub nsw i32 %218, %219
%221 = sitofp i32 %220 to float
%222 = fpext float %221 to double
%223 = fadd double %217, %222
%224 = fptrunc double %223 to float
%225 = fdiv float %172, %224
%226 = fptosi float %225 to i32
%227 = fpext float %224 to double
%228 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %226, double %227, i32 %175)
%229 = call i32 (...) @mmpi_barrier()
%230 = shl i32 %175, 1
%231 = sext i32 %230 to i64
%232 = icmp ult i32 %230, 8388609
br i1 %232, label %173, label %233
233: ; preds = %210
br label %234
234: ; preds = %155, %233
%235 = call i32 @free(i8* %140)
%236 = call i32 (...) @mmpi_barrier()
%237 = load i32, i32* %3
%238 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %237)
ret i32 0
}