#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 {
  double tv_sec;
  double tv_usec;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int drand48();
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double *malloc(int);
int /*<<< orphan*/ print_hist(double *, int, double, double, int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
double sqrt(double);
int /*<<< orphan*/ srand48(int);
int main(int argc, char **argv) {
  int me, you, i, step;
  double G = 1.0;
  int twidth = 80;
  int theight = 40;
  if (argc < 3) {
    puts("Usage: nbody PARTICLES STEPS SHOW_INTERVAL");
    return EXIT_FAILURE;
  }
  int nparticles = atoi(argv[1]);
  int N = 3 * nparticles;
  double sidelength = 10000.0;
  int nsteps = atoi(argv[2]);
  int output = 1;
  int prescale = 100;
  if (argc >= 4) {
    prescale = atoi(argv[3]);
    if (prescale == 0) {
      output = 0;
      prescale = nsteps / 10;
    }
  }
  double *r = malloc(3 * nparticles * sizeof(double));
  double *v = malloc(3 * nparticles * sizeof(double));
  double *m = malloc(nparticles * sizeof(double));
  double *rnew = malloc(3 * nparticles * sizeof(double));
  double *tmp = NULL;
  srand48(11);
  for (i = 0; i < nparticles; i++) {
    r[3 * i] = drand48() * sidelength - sidelength / 2;
    r[3 * i + 1] = drand48() * sidelength - sidelength / 2;
    r[3 * i + 2] = drand48() * sidelength - sidelength / 2;
    v[i] = 0;
    m[i] = 1000 * drand48();
  }
  puts("Starting simulation");
  struct timeval begin, end;
  gettimeofday(&begin, NULL);
  for (step = 1; step <= nsteps; ++step) {
#pragma omp parallel for private(me, you, i)
    for (me = 0; me < nparticles; ++me) {
      double sep[3];
      double a[3] = {0, 0, 0};
      for (you = 0; you < nparticles; ++you) {
        for (i = 0; i < 3; ++i)
          sep[i] = r[3 * you + i] - r[3 * me + i];
        double r2 = sep[0] * sep[0] + sep[1] * sep[1] + sep[2] * sep[2];
        double prop = (r2 != 0) ? (G * m[you] / (r2 * sqrt(r2))) : 0;
        for (i = 0; i < 3; ++i)
          a[i] += prop * sep[i];
      }
      for (i = 0; i < 3; ++i) {
        rnew[3 * me + i] = r[3 * me + i] + v[3 * me + i];
        v[3 * me + i] += a[i];
      }
    }
    tmp = r;
    r = rnew;
    rnew = tmp;
    if (step % prescale == 0) {
      if (output == 1) {
        print_hist(r, nparticles, sidelength, sidelength, twidth, theight);
      } else {
        printf("Step %d completed.\n", step);
      }
    }
  }
  gettimeofday(&end, NULL);
  double time = 1.0 * (end.tv_sec - begin.tv_sec) +
                1.0e-6 * (end.tv_usec - begin.tv_usec);
  printf("\n\nTotal time: %f secs\n", time);
  printf("Interactions per second: %f\n",
         ((nsteps / time) * nparticles) * (nparticles - 1));
  free(m);
  free(v);
  free(rnew);
  free(r);
  puts("Done!");
  return EXIT_SUCCESS;
}


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)
movsd  0xe2f(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x50,-0x2c(%rbp)
movl   $0x28,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    120b <main+0x5b>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    180d <main+0x65d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x34(%rbp)
imul   $0x3,-0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
movsd  0xdde(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
movl   $0x64,-0x4c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     128b <main+0xdb>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jne    1286 <main+0xd6>
movl   $0x0,-0x48(%rbp)
mov    -0x44(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
jmp    128b <main+0xdb>
imul   $0x3,-0x34(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x58(%rbp)
imul   $0x3,-0x34(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x60(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x68(%rbp)
imul   $0x3,-0x34(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
mov    $0xb,%edi
call   10a0 <srand48@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1434 <main+0x284>
mov    $0x0,%al
call   10d0 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movsd  0xcf9(%rip),%xmm3
divsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x58(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    $0x0,%al
call   10d0 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movsd  0xca9(%rip),%xmm3
divsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x58(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    $0x0,%al
call   10d0 <drand48@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
movsd  0xc56(%rip),%xmm3
divsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x58(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    $0x0,%al
call   10d0 <drand48@plt>
imul   $0x3e8,%eax,%eax
cvtsi2sd %eax,%xmm0
mov    -0x68(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f6 <main+0x146>
lea    0xc10(%rip),%rdi
call   1040 <puts@plt>
lea    -0x88(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x44(%rbp),%eax
jg     1744 <main+0x594>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    16ca <main+0x51a>
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    163a <main+0x48a>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    14ee <main+0x33e>
mov    -0x58(%rbp),%rax
imul   $0x3,-0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x1c(%rbp),%rax
movsd  %xmm0,-0xb0(%rbp,%rax,8)
ff ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14a3 <main+0x2f3>
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0xa0(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1556 <main+0x3a6>
jp     1556 <main+0x3a6>
jmp    15b5 <main+0x405>
movsd  -0x28(%rbp),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x18(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
call   10c0 <sqrt@plt>
movsd  -0x100(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0xf8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
jmp    15c5 <main+0x415>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
jmp    15c5 <main+0x415>
movsd  -0xf0(%rbp),%xmm0
ff
movsd  %xmm0,-0xe0(%rbp)
ff
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    1627 <main+0x477>
movsd  -0xe0(%rbp),%xmm0
ff
movslq -0x1c(%rbp),%rax
movsd  -0xb0(%rbp,%rax,8),%xmm2
ff ff
movslq -0x1c(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm1
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp,%rax,8)
ff ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    15dc <main+0x42c>
jmp    162c <main+0x47c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1490 <main+0x2e0>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    16b7 <main+0x507>
mov    -0x58(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movslq -0x1c(%rbp),%rax
movsd  -0xd0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x60(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1641 <main+0x491>
jmp    16bc <main+0x50c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    146a <main+0x2ba>
mov    -0x58(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%eax
cltd
idivl  -0x4c(%rbp)
cmp    $0x0,%edx
jne    1731 <main+0x581>
cmpl   $0x1,-0x48(%rbp)
jne    171d <main+0x56d>
mov    -0x58(%rbp),%rdi
mov    -0x34(%rbp),%esi
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
call   1090 <print_hist@plt>
jmp    172c <main+0x57c>
mov    -0x20(%rbp),%esi
lea    0x938(%rip),%rdi
call   1050 <printf@plt>
jmp    1731 <main+0x581>
jmp    1736 <main+0x586>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1457 <main+0x2a7>
lea    -0x98(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movsd  -0x98(%rbp),%xmm0
ff
subsd  -0x88(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm2
ff
subsd  -0x80(%rbp),%xmm2
movsd  0x897(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
cvttsd2si -0xe8(%rbp),%esi
ff
lea    0x8db(%rip),%rdi
call   1050 <printf@plt>
cvtsi2sdl -0x44(%rbp),%xmm0
divsd  -0xe8(%rbp),%xmm0
ff
cvtsi2sdl -0x34(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0x8be(%rip),%rdi
call   1050 <printf@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
lea    0x8ab(%rip),%rdi
call   1040 <puts@plt>
mov    0x27d0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%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    $0xc8,%rsp
cmp    $0x2,%edi
jg     11ce <main+0x2e>
lea    0xe63(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e17(%rip),%rax
jmp    1695 <main+0x4f5>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %rax,0x10(%rsp)
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    $0x64,%eax
mov    %rax,0x18(%rsp)
mov    $0x1,%al
mov    %eax,0xc(%rsp)
cmp    $0x3,%ebp
je     123b <main+0x9b>
mov    0x18(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %rax,0x18(%rsp)
test   %eax,%eax
jne    123b <main+0x9b>
movslq 0x8(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x22,%rcx
add    %eax,%ecx
mov    %rcx,0x18(%rsp)
movl   $0x0,0xc(%rsp)
mov    0x10(%rsp),%r14
lea    0x0(,%r14,8),%ebp
lea    0x0(%rbp,%rbp,2),%r15d
mov    %r15d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r15d,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %r15d,%edi
call   1070 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    $0xb,%edi
call   1090 <srand48@plt>
mov    %r14d,%r15d
test   %r14d,%r14d
jle    1351 <main+0x1b1>
xor    %r14d,%r14d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   10c0 <drand48@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xd4a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd46(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    %r14d,%eax
movsd  %xmm0,(%rbx,%rax,8)
xor    %eax,%eax
call   10c0 <drand48@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd1c(%rip),%xmm0
addsd  0xd1c(%rip),%xmm0
lea    0x1(%r14),%eax
movsd  %xmm0,(%rbx,%rax,8)
xor    %eax,%eax
call   10c0 <drand48@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xcf5(%rip),%xmm0
addsd  0xcf5(%rip),%xmm0
lea    0x2(%r14),%eax
movsd  %xmm0,(%rbx,%rax,8)
movq   $0x0,0x0(%r13,%r12,8)
xor    %eax,%eax
call   10c0 <drand48@plt>
imul   $0x3e8,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x0(%rbp,%r12,8)
add    $0x1,%r12
add    $0x3,%r14d
cmp    %r12,%r15
jne    12a0 <main+0x100>
mov    %r13,0x38(%rsp)
lea    0xcee(%rip),%rdi
call   1040 <puts@plt>
lea    0xb0(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
cmpl   $0x0,0x8(%rsp)
jle    15d3 <main+0x433>
mov    $0x1,%eax
mov    0x20(%rsp),%rcx
jmp    13b7 <main+0x217>
nopl   0x0(%rax,%rax,1)
mov    0x40(%rsp),%r14
mov    %r14d,%eax
cltd
idivl  0x18(%rsp)
test   %edx,%edx
je     1590 <main+0x3f0>
lea    0x1(%r14),%eax
mov    %r13,%rcx
cmp    0x8(%rsp),%r14d
je     15d8 <main+0x438>
mov    %rax,0x40(%rsp)
mov    %rbx,%r13
mov    %rcx,%rbx
cmpl   $0x0,0x10(%rsp)
jle    1390 <main+0x1f0>
lea    0x10(%r13),%rax
mov    %rax,0x48(%rsp)
xor    %eax,%eax
mov    %rbx,0x50(%rsp)
jmp    1469 <main+0x2c9>
xchg   %ax,%ax
movsd  0x0(%r13,%r14,8),%xmm0
mov    0x38(%rsp),%rax
addsd  (%rax,%r14,8),%xmm0
mov    0x50(%rsp),%rbx
movsd  %xmm0,(%rbx,%r14,8)
movsd  (%rax,%r14,8),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,(%rax,%r14,8)
movsd  0x8(%r13,%r14,8),%xmm0
addsd  0x8(%rax,%r14,8),%xmm0
movsd  %xmm0,0x8(%rbx,%r14,8)
unpckhpd %xmm3,%xmm3
addsd  0x8(%rax,%r14,8),%xmm3
movsd  %xmm3,0x8(%rax,%r14,8)
movsd  0x10(%r13,%r14,8),%xmm0
addsd  0x10(%rax,%r14,8),%xmm0
addsd  0x10(%rax,%r14,8),%xmm2
movsd  %xmm0,0x10(%rbx,%r14,8)
movsd  %xmm2,0x10(%rax,%r14,8)
mov    0x58(%rsp),%rax
add    $0x1,%rax
cmp    %r15,%rax
je     1390 <main+0x1f0>
mov    %rax,0x58(%rsp)
lea    (%rax,%rax,2),%r14d
xorpd  %xmm3,%xmm3
xorpd  %xmm4,%xmm4
mov    0x48(%rsp),%rbx
xorpd  %xmm2,%xmm2
xor    %r12d,%r12d
jmp    1522 <main+0x382>
nopl   0x0(%rax,%rax,1)
movapd %xmm7,%xmm0
movsd  %xmm2,0x20(%rsp)
movapd %xmm3,0x90(%rsp)
movsd  %xmm5,0x68(%rsp)
movapd %xmm6,0x80(%rsp)
movapd %xmm1,0x70(%rsp)
movsd  %xmm7,0x60(%rsp)
call   10b0 <sqrt@plt>
movsd  0x60(%rsp),%xmm7
movapd 0x70(%rsp),%xmm1
movapd 0x80(%rsp),%xmm6
movsd  0x68(%rsp),%xmm5
xorpd  %xmm4,%xmm4
movapd 0x90(%rsp),%xmm3
movsd  0x20(%rsp),%xmm2
mulsd  %xmm0,%xmm7
divsd  %xmm7,%xmm1
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
mulpd  %xmm6,%xmm0
addpd  %xmm0,%xmm3
mulsd  %xmm1,%xmm5
addsd  %xmm5,%xmm2
add    $0x1,%r12
add    $0x18,%rbx
cmp    %r12,%r15
je     13e0 <main+0x240>
movupd -0x10(%rbx),%xmm6
movupd 0x0(%r13,%r14,8),%xmm0
subpd  %xmm0,%xmm6
movsd  (%rbx),%xmm5
subsd  0x10(%r13,%r14,8),%xmm5
movapd %xmm6,%xmm0
mulpd  %xmm6,%xmm0
unpckhpd %xmm0,%xmm0
movapd %xmm6,%xmm1
mulsd  %xmm6,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm5,%xmm7
mulsd  %xmm5,%xmm7
addsd  %xmm1,%xmm7
ucomisd %xmm4,%xmm7
xorpd  %xmm1,%xmm1
jne    156d <main+0x3cd>
jnp    14f9 <main+0x359>
movsd  0x0(%rbp,%r12,8),%xmm1
ucomisd 0xa9c(%rip),%xmm7
jb     1490 <main+0x2f0>
xorps  %xmm0,%xmm0
sqrtsd %xmm7,%xmm0
jmp    14f1 <main+0x351>
xchg   %ax,%ax
cmpb   $0x0,0xc(%rsp)
je     15bf <main+0x41f>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
movsd  0xa59(%rip),%xmm0
movapd %xmm0,%xmm1
mov    $0x50,%edx
mov    $0x28,%ecx
call   1080 <print_hist@plt>
jmp    13a5 <main+0x205>
lea    0xa99(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
jmp    13a5 <main+0x205>
mov    0x20(%rsp),%r13
lea    0xa0(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movapd 0xa0(%rsp),%xmm0
subpd  0xb0(%rsp),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
mulsd  0xa07(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
cvttsd2si %xmm1,%esi
lea    0xa55(%rip),%rdi
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x8(%rsp),%xmm0
mov    0x10(%rsp),%rax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  0x20(%rsp),%xmm0
add    $0xffffffff,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
mulsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm2
cvttsd2si %xmm2,%esi
lea    0xa2f(%rip),%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xa1e(%rip),%rdi
call   1040 <puts@plt>
mov    0x2943(%rip),%rax
mov    (%rax),%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [43 x i8] c"Usage: nbody PARTICLES STEPS SHOW_INTERVAL\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"Starting simulation\00"
@.str.2 = [20 x i8] c"Step %d completed.\0A\00"
@.str.3 = [23 x i8] c"\0A\0ATotal time: %f secs\0A\00"
@.str.4 = [29 x i8] c"Interactions per second: %f\0A\00"
@.str.5 = [6 x i8] c"Done!\00"
@EXIT_SUCCESS = global i32 0
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 double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double*
%23 = alloca double*
%24 = alloca %struct.timeval
%25 = alloca %struct.timeval
%26 = alloca [3 x double]
%27 = alloca [3 x double]
%28 = alloca double
%29 = alloca double
%30 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 1.000000e+00, double* %10
store i32 80, i32* %11
store i32 40, i32* %12
%31 = load i32, i32* %4
%32 = icmp slt i32 %31, 3
br i1 %32, label %33, label %36
33: ; preds = %2
%34 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
store i32 %35, i32* %3
br label %359
36: ; preds = %2
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
store i32 %40, i32* %13
%41 = load i32, i32* %13
%42 = mul nsw i32 3, %41
store i32 %42, i32* %14
store double 1.000000e+04, double* %15
%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* %16
store i32 1, i32* %17
store i32 100, i32* %18
%47 = load i32, i32* %4
%48 = icmp sge i32 %47, 4
br i1 %48, label %49, label %60
49: ; preds = %36
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i32 @atoi(i8* %52)
store i32 %53, i32* %18
%54 = load i32, i32* %18
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %49
store i32 0, i32* %17
%57 = load i32, i32* %16
%58 = sdiv i32 %57, 10
store i32 %58, i32* %18
br label %59
59: ; preds = %56, %49
br label %60
60: ; preds = %59, %36
%61 = load i32, i32* %13
%62 = mul nsw i32 3, %61
%63 = sext i32 %62 to i64
%64 = mul i64 %63, 8
%65 = trunc i64 %64 to i32
%66 = call double* @malloc(i32 %65)
store double* %66, double** %19
%67 = load i32, i32* %13
%68 = mul nsw i32 3, %67
%69 = sext i32 %68 to i64
%70 = mul i64 %69, 8
%71 = trunc i64 %70 to i32
%72 = call double* @malloc(i32 %71)
store double* %72, double** %20
%73 = load i32, i32* %13
%74 = sext i32 %73 to i64
%75 = mul i64 %74, 8
%76 = trunc i64 %75 to i32
%77 = call double* @malloc(i32 %76)
store double* %77, double** %21
%78 = load i32, i32* %13
%79 = mul nsw i32 3, %78
%80 = sext i32 %79 to i64
%81 = mul i64 %80, 8
%82 = trunc i64 %81 to i32
%83 = call double* @malloc(i32 %82)
store double* %83, double** %22
store double* null, double** %23
%84 = call i32 @srand48(i32 11)
store i32 0, i32* %8
br label %85
85: ; preds = %139, %60
%86 = load i32, i32* %8
%87 = load i32, i32* %13
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %142
89: ; preds = %85
%90 = call i32 (...) @drand48()
%91 = sitofp i32 %90 to double
%92 = load double, double* %15
%93 = load double, double* %15
%94 = fdiv double %93, 2.000000e+00
%95 = fneg double %94
%96 = call double @llvm.fmuladd.f64(double %91, double %92, double %95)
%97 = load double*, double** %19
%98 = load i32, i32* %8
%99 = mul nsw i32 3, %98
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %97, i64 %100
store double %96, double* %101
%102 = call i32 (...) @drand48()
%103 = sitofp i32 %102 to double
%104 = load double, double* %15
%105 = load double, double* %15
%106 = fdiv double %105, 2.000000e+00
%107 = fneg double %106
%108 = call double @llvm.fmuladd.f64(double %103, double %104, double %107)
%109 = load double*, double** %19
%110 = load i32, i32* %8
%111 = mul nsw i32 3, %110
%112 = add nsw i32 %111, 1
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %109, i64 %113
store double %108, double* %114
%115 = call i32 (...) @drand48()
%116 = sitofp i32 %115 to double
%117 = load double, double* %15
%118 = load double, double* %15
%119 = fdiv double %118, 2.000000e+00
%120 = fneg double %119
%121 = call double @llvm.fmuladd.f64(double %116, double %117, double %120)
%122 = load double*, double** %19
%123 = load i32, i32* %8
%124 = mul nsw i32 3, %123
%125 = add nsw i32 %124, 2
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds double, double* %122, i64 %126
store double %121, double* %127
%128 = load double*, double** %20
%129 = load i32, i32* %8
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds double, double* %128, i64 %130
store double 0.000000e+00, double* %131
%132 = call i32 (...) @drand48()
%133 = mul nsw i32 1000, %132
%134 = sitofp i32 %133 to double
%135 = load double*, double** %21
%136 = load i32, i32* %8
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds double, double* %135, i64 %137
store double %134, double* %138
br label %139
139: ; preds = %89
%140 = load i32, i32* %8
%141 = add nsw i32 %140, 1
store i32 %141, i32* %8
br label %85
142: ; preds = %85
%143 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%144 = call i32 @gettimeofday(%struct.timeval* %24, i32* null)
store i32 1, i32* %9
br label %145
145: ; preds = %316, %142
%146 = load i32, i32* %9
%147 = load i32, i32* %16
%148 = icmp sle i32 %146, %147
br i1 %148, label %149, label %319
149: ; preds = %145
store i32 0, i32* %6
br label %150
150: ; preds = %289, %149
%151 = load i32, i32* %6
%152 = load i32, i32* %13
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %292
154: ; preds = %150
%155 = bitcast [3 x double]* %27 to i8*
store i32 0, i32* %7
br label %156
156: ; preds = %240, %154
%157 = load i32, i32* %7
%158 = load i32, i32* %13
%159 = icmp slt i32 %157, %158
br i1 %159, label %160, label %243
160: ; preds = %156
store i32 0, i32* %8
br label %161
161: ; preds = %185, %160
%162 = load i32, i32* %8
%163 = icmp slt i32 %162, 3
br i1 %163, label %164, label %188
164: ; preds = %161
%165 = load double*, double** %19
%166 = load i32, i32* %7
%167 = mul nsw i32 3, %166
%168 = load i32, i32* %8
%169 = add nsw i32 %167, %168
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %165, i64 %170
%172 = load double, double* %171
%173 = load double*, double** %19
%174 = load i32, i32* %6
%175 = mul nsw i32 3, %174
%176 = load i32, i32* %8
%177 = add nsw i32 %175, %176
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %173, i64 %178
%180 = load double, double* %179
%181 = fsub double %172, %180
%182 = load i32, i32* %8
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 %183
store double %181, double* %184
br label %185
185: ; preds = %164
%186 = load i32, i32* %8
%187 = add nsw i32 %186, 1
store i32 %187, i32* %8
br label %161
188: ; preds = %161
%189 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 0
%190 = load double, double* %189
%191 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 0
%192 = load double, double* %191
%193 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 1
%194 = load double, double* %193
%195 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 1
%196 = load double, double* %195
%197 = fmul double %194, %196
%198 = call double @llvm.fmuladd.f64(double %190, double %192, double %197)
%199 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 2
%200 = load double, double* %199
%201 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 2
%202 = load double, double* %201
%203 = call double @llvm.fmuladd.f64(double %200, double %202, double %198)
store double %203, double* %28
%204 = load double, double* %28
%205 = fcmp une double %204, 0.000000e+00
br i1 %205, label %206, label %219
206: ; preds = %188
%207 = load double, double* %10
%208 = load double*, double** %21
%209 = load i32, i32* %7
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds double, double* %208, i64 %210
%212 = load double, double* %211
%213 = fmul double %207, %212
%214 = load double, double* %28
%215 = load double, double* %28
%216 = call double @sqrt(double %215)
%217 = fmul double %214, %216
%218 = fdiv double %213, %217
br label %220
219: ; preds = %188
br label %220
220: ; preds = %219, %206
%221 = phi double [ %218, %206 ], [ 0.000000e+00, %219 ]
store double %221, double* %29
store i32 0, i32* %8
br label %222
222: ; preds = %236, %220
%223 = load i32, i32* %8
%224 = icmp slt i32 %223, 3
br i1 %224, label %225, label %239
225: ; preds = %222
%226 = load double, double* %29
%227 = load i32, i32* %8
%228 = sext i32 %227 to i64
%229 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 %228
%230 = load double, double* %229
%231 = load i32, i32* %8
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds [3 x double], [3 x double]* %27, i64 0, i64 %232
%234 = load double, double* %233
%235 = call double @llvm.fmuladd.f64(double %226, double %230, double %234)
store double %235, double* %233
br label %236
236: ; preds = %225
%237 = load i32, i32* %8
%238 = add nsw i32 %237, 1
store i32 %238, i32* %8
br label %222
239: ; preds = %222
br label %240
240: ; preds = %239
%241 = load i32, i32* %7
%242 = add nsw i32 %241, 1
store i32 %242, i32* %7
br label %156
243: ; preds = %156
store i32 0, i32* %8
br label %244
244: ; preds = %285, %243
%245 = load i32, i32* %8
%246 = icmp slt i32 %245, 3
br i1 %246, label %247, label %288
247: ; preds = %244
%248 = load double*, double** %19
%249 = load i32, i32* %6
%250 = mul nsw i32 3, %249
%251 = load i32, i32* %8
%252 = add nsw i32 %250, %251
%253 = sext i32 %252 to i64
%254 = getelementptr inbounds double, double* %248, i64 %253
%255 = load double, double* %254
%256 = load double*, double** %20
%257 = load i32, i32* %6
%258 = mul nsw i32 3, %257
%259 = load i32, i32* %8
%260 = add nsw i32 %258, %259
%261 = sext i32 %260 to i64
%262 = getelementptr inbounds double, double* %256, i64 %261
%263 = load double, double* %262
%264 = fadd double %255, %263
%265 = load double*, double** %22
%266 = load i32, i32* %6
%267 = mul nsw i32 3, %266
%268 = load i32, i32* %8
%269 = add nsw i32 %267, %268
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds double, double* %265, i64 %270
store double %264, double* %271
%272 = load i32, i32* %8
%273 = sext i32 %272 to i64
%274 = getelementptr inbounds [3 x double], [3 x double]* %27, i64 0, i64 %273
%275 = load double, double* %274
%276 = load double*, double** %20
%277 = load i32, i32* %6
%278 = mul nsw i32 3, %277
%279 = load i32, i32* %8
%280 = add nsw i32 %278, %279
%281 = sext i32 %280 to i64
%282 = getelementptr inbounds double, double* %276, i64 %281
%283 = load double, double* %282
%284 = fadd double %283, %275
store double %284, double* %282
br label %285
285: ; preds = %247
%286 = load i32, i32* %8
%287 = add nsw i32 %286, 1
store i32 %287, i32* %8
br label %244
288: ; preds = %244
br label %289
289: ; preds = %288
%290 = load i32, i32* %6
%291 = add nsw i32 %290, 1
store i32 %291, i32* %6
br label %150
292: ; preds = %150
%293 = load double*, double** %19
store double* %293, double** %23
%294 = load double*, double** %22
store double* %294, double** %19
%295 = load double*, double** %23
store double* %295, double** %22
%296 = load i32, i32* %9
%297 = load i32, i32* %18
%298 = srem i32 %296, %297
%299 = icmp eq i32 %298, 0
br i1 %299, label %300, label %315
300: ; preds = %292
%301 = load i32, i32* %17
%302 = icmp eq i32 %301, 1
br i1 %302, label %303, label %311
303: ; preds = %300
%304 = load double*, double** %19
%305 = load i32, i32* %13
%306 = load double, double* %15
%307 = load double, double* %15
%308 = load i32, i32* %11
%309 = load i32, i32* %12
%310 = call i32 @print_hist(double* %304, i32 %305, double %306, double %307, i32 %308, i32 %309)
br label %314
311: ; preds = %300
%312 = load i32, i32* %9
%313 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %312)
br label %314
314: ; preds = %311, %303
br label %315
315: ; preds = %314, %292
br label %316
316: ; preds = %315
%317 = load i32, i32* %9
%318 = add nsw i32 %317, 1
store i32 %318, i32* %9
br label %145
319: ; preds = %145
%320 = call i32 @gettimeofday(%struct.timeval* %25, i32* null)
%321 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 0
%322 = load double, double* %321
%323 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 0
%324 = load double, double* %323
%325 = fsub double %322, %324
%326 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 1
%327 = load double, double* %326
%328 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 1
%329 = load double, double* %328
%330 = fsub double %327, %329
%331 = fmul double 0x3EB0C6F7A0B5ED8D, %330
%332 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %325, double %331)
store double %332, double* %30
%333 = load double, double* %30
%334 = fptosi double %333 to i32
%335 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %334)
%336 = load i32, i32* %16
%337 = sitofp i32 %336 to double
%338 = load double, double* %30
%339 = fdiv double %337, %338
%340 = load i32, i32* %13
%341 = sitofp i32 %340 to double
%342 = fmul double %339, %341
%343 = load i32, i32* %13
%344 = sub nsw i32 %343, 1
%345 = sitofp i32 %344 to double
%346 = fmul double %342, %345
%347 = fptosi double %346 to i32
%348 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %347)
%349 = load double*, double** %21
%350 = call i32 @free(double* %349)
%351 = load double*, double** %20
%352 = call i32 @free(double* %351)
%353 = load double*, double** %22
%354 = call i32 @free(double* %353)
%355 = load double*, double** %19
%356 = call i32 @free(double* %355)
%357 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%358 = load i32, i32* @EXIT_SUCCESS
store i32 %358, i32* %3
br label %359
359: ; preds = %319, %33
%360 = load i32, i32* %3
ret i32 %360
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [43 x i8] c"Usage: nbody PARTICLES STEPS SHOW_INTERVAL\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"Starting simulation\00"
@.str.2 = [20 x i8] c"Step %d completed.\0A\00"
@.str.3 = [23 x i8] c"\0A\0ATotal time: %f secs\0A\00"
@.str.4 = [29 x i8] c"Interactions per second: %f\0A\00"
@.str.5 = [6 x i8] c"Done!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca <2 x double>
%4 = bitcast <2 x double>* %3 to %struct.timeval*
%5 = alloca <2 x double>
%6 = bitcast <2 x double>* %5 to %struct.timeval*
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
br label %191
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = icmp eq i32 %0, 3
br i1 %18, label %26, label %19
19: ; preds = %11
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = sdiv i32 %17, 10
br label %26
26: ; preds = %19, %24, %11
%27 = phi i1 [ true, %19 ], [ false, %24 ], [ true, %11 ]
%28 = phi i32 [ %22, %19 ], [ %25, %24 ], [ 100, %11 ]
%29 = mul i32 %14, 24
%30 = tail call double* @malloc(i32 %29)
%31 = tail call double* @malloc(i32 %29)
%32 = shl i32 %14, 3
%33 = tail call double* @malloc(i32 %32)
%34 = tail call double* @malloc(i32 %29)
%35 = tail call i32 @srand48(i32 11)
%36 = icmp sgt i32 %14, 0
br i1 %36, label %37, label %67
37: ; preds = %26
%38 = zext i32 %14 to i64
br label %39
39: ; preds = %37, %39
%40 = phi i64 [ 0, %37 ], [ %65, %39 ]
%41 = tail call i32 (...) @drand48()
%42 = sitofp i32 %41 to double
%43 = tail call double @llvm.fmuladd.f64(double %42, double 1.000000e+04, double -5.000000e+03)
%44 = trunc i64 %40 to i32
%45 = mul nsw i32 %44, 3
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds double, double* %30, i64 %46
store double %43, double* %47
%48 = tail call i32 (...) @drand48()
%49 = sitofp i32 %48 to double
%50 = tail call double @llvm.fmuladd.f64(double %49, double 1.000000e+04, double -5.000000e+03)
%51 = add nuw nsw i32 %45, 1
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds double, double* %30, i64 %52
store double %50, double* %53
%54 = tail call i32 (...) @drand48()
%55 = sitofp i32 %54 to double
%56 = tail call double @llvm.fmuladd.f64(double %55, double 1.000000e+04, double -5.000000e+03)
%57 = add nuw nsw i32 %45, 2
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds double, double* %30, i64 %58
store double %56, double* %59
%60 = getelementptr inbounds double, double* %31, i64 %40
store double 0.000000e+00, double* %60
%61 = tail call i32 (...) @drand48()
%62 = mul nsw i32 %61, 1000
%63 = sitofp i32 %62 to double
%64 = getelementptr inbounds double, double* %33, i64 %40
store double %63, double* %64
%65 = add nuw nsw i64 %40, 1
%66 = icmp eq i64 %65, %38
br i1 %66, label %67, label %39
67: ; preds = %39, %26
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%69 = bitcast <2 x double>* %3 to i8*
%70 = bitcast <2 x double>* %5 to i8*
%71 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%72 = icmp slt i32 %17, 1
br i1 %72, label %163, label %73
73: ; preds = %67
%74 = zext i32 %14 to i64
br label %75
75: ; preds = %73, %160
%76 = phi double* [ %34, %73 ], [ %78, %160 ]
%77 = phi i32 [ 1, %73 ], [ %161, %160 ]
%78 = phi double* [ %30, %73 ], [ %76, %160 ]
br i1 %36, label %79, label %152
79: ; preds = %75, %88
%80 = phi i64 [ %115, %88 ], [ 0, %75 ]
%81 = mul i64 %80, 3
%82 = and i64 %81, 4294967295
%83 = getelementptr inbounds double, double* %78, i64 %82
%84 = add nuw nsw i64 %82, 1
%85 = add nuw nsw i64 %82, 2
%86 = getelementptr inbounds double, double* %78, i64 %85
%87 = bitcast double* %83 to <2 x double>*
br label %117
88: ; preds = %144
%89 = getelementptr inbounds double, double* %78, i64 %82
%90 = load double, double* %89
%91 = getelementptr inbounds double, double* %31, i64 %82
%92 = load double, double* %91
%93 = fadd double %90, %92
%94 = getelementptr inbounds double, double* %76, i64 %82
store double %93, double* %94
%95 = load double, double* %91
%96 = extractelement <2 x double> %148, i64 0
%97 = fadd double %96, %95
store double %97, double* %91
%98 = getelementptr inbounds double, double* %78, i64 %84
%99 = load double, double* %98
%100 = getelementptr inbounds double, double* %31, i64 %84
%101 = load double, double* %100
%102 = fadd double %99, %101
%103 = getelementptr inbounds double, double* %76, i64 %84
store double %102, double* %103
%104 = load double, double* %100
%105 = extractelement <2 x double> %148, i64 1
%106 = fadd double %105, %104
store double %106, double* %100
%107 = getelementptr inbounds double, double* %78, i64 %85
%108 = load double, double* %107
%109 = getelementptr inbounds double, double* %31, i64 %85
%110 = load double, double* %109
%111 = fadd double %108, %110
%112 = getelementptr inbounds double, double* %76, i64 %85
store double %111, double* %112
%113 = load double, double* %109
%114 = fadd double %149, %113
store double %114, double* %109
%115 = add nuw nsw i64 %80, 1
%116 = icmp eq i64 %115, %74
br i1 %116, label %152, label %79
117: ; preds = %79, %144
%118 = phi double [ 0.000000e+00, %79 ], [ %149, %144 ]
%119 = phi i64 [ 0, %79 ], [ %150, %144 ]
%120 = phi <2 x double> [ zeroinitializer, %79 ], [ %148, %144 ]
%121 = mul nuw nsw i64 %119, 3
%122 = getelementptr inbounds double, double* %78, i64 %121
%123 = bitcast double* %122 to <2 x double>*
%124 = load <2 x double>, <2 x double>* %123
%125 = load <2 x double>, <2 x double>* %87
%126 = fsub <2 x double> %124, %125
%127 = add nuw nsw i64 %121, 2
%128 = getelementptr inbounds double, double* %78, i64 %127
%129 = load double, double* %128
%130 = load double, double* %86
%131 = fsub double %129, %130
%132 = fmul <2 x double> %126, %126
%133 = extractelement <2 x double> %132, i64 1
%134 = extractelement <2 x double> %126, i64 0
%135 = tail call double @llvm.fmuladd.f64(double %134, double %134, double %133)
%136 = tail call double @llvm.fmuladd.f64(double %131, double %131, double %135)
%137 = fcmp une double %136, 0.000000e+00
br i1 %137, label %138, label %144
138: ; preds = %117
%139 = getelementptr inbounds double, double* %33, i64 %119
%140 = load double, double* %139
%141 = tail call double @sqrt(double %136)
%142 = fmul double %136, %141
%143 = fdiv double %140, %142
br label %144
144: ; preds = %117, %138
%145 = phi double [ %143, %138 ], [ 0.000000e+00, %117 ]
%146 = insertelement <2 x double> poison, double %145, i64 0
%147 = shufflevector <2 x double> %146, <2 x double> poison, <2 x i32> zeroinitializer
%148 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %147, <2 x double> %126, <2 x double> %120)
%149 = tail call double @llvm.fmuladd.f64(double %145, double %131, double %118)
%150 = add nuw nsw i64 %119, 1
%151 = icmp eq i64 %150, %74
br i1 %151, label %88, label %117
152: ; preds = %88, %75
%153 = srem i32 %77, %28
%154 = icmp eq i32 %153, 0
br i1 %154, label %155, label %160
155: ; preds = %152
br i1 %27, label %156, label %158
156: ; preds = %155
%157 = tail call i32 @print_hist(double* %76, i32 %14, double 1.000000e+04, double 1.000000e+04, i32 80, i32 40)
br label %160
158: ; preds = %155
%159 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %77)
br label %160
160: ; preds = %152, %158, %156
%161 = add nuw i32 %77, 1
%162 = icmp eq i32 %77, %17
br i1 %162, label %163, label %75
163: ; preds = %160, %67
%164 = phi double* [ %30, %67 ], [ %76, %160 ]
%165 = phi double* [ %34, %67 ], [ %78, %160 ]
%166 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%167 = load <2 x double>, <2 x double>* %5
%168 = load <2 x double>, <2 x double>* %3
%169 = fsub <2 x double> %167, %168
%170 = extractelement <2 x double> %169, i64 1
%171 = fmul double %170, 0x3EB0C6F7A0B5ED8D
%172 = extractelement <2 x double> %169, i64 0
%173 = fadd double %172, %171
%174 = fptosi double %173 to i32
%175 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %174)
%176 = sitofp i32 %17 to double
%177 = fdiv double %176, %173
%178 = sitofp i32 %14 to double
%179 = fmul double %177, %178
%180 = add nsw i32 %14, -1
%181 = sitofp i32 %180 to double
%182 = fmul double %179, %181
%183 = fptosi double %182 to i32
%184 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %183)
%185 = tail call i32 @free(double* %33)
%186 = tail call i32 @free(double* %31)
%187 = tail call i32 @free(double* %165)
%188 = tail call i32 @free(double* %164)
%189 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%190 = load i32, i32* @EXIT_SUCCESS
br label %191
191: ; preds = %163, %8
%192 = phi i32 [ %10, %8 ], [ %190, %163 ]
ret i32 %192
}