#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*/ free(double *);
int /*<<< orphan*/ get_particles_E(int, double *, double *, double *, double *,
                                   double *, double *, double *, double);
double *malloc(int);
int /*<<< orphan*/ scale(int, double, int, double *, ...);
double sqrt(double);
int virialise(int N, double Q, int Standard, double *m, double *rx, double *ry,
              double *rz, double *vx, double *vy, double *vz, double G) {
  double tEk = 0, tEp = 0, target_tEk, target_tEp;
  double tol = 1e-8;
  int i, inc = 0;
  double *V2 = malloc(N * sizeof(double));
  double *Ek = malloc(N * sizeof(double));
  double *Ep = malloc(N * sizeof(double));
  for (i = 0; i < N; i++)
    V2[i] = vx[i] * vx[i] + vy[i] * vy[i] + vz[i] * vz[i];
  get_particles_E(N, m, rx, ry, rz, V2, Ek, Ep, G);
  for (i = 0; i < N; i++) {
    tEk += Ek[i];
    tEp += 0.5 * Ep[i];
  }
  if (Standard == 1) {
    target_tEp = -0.25 / (1 - Q);
    target_tEk = -Q * target_tEp;
    scale(N, tEp / target_tEp, 3, rx, ry, rz);
  } else {
    target_tEk = -Q * tEp;
  }
  if (Q == 0) {
    scale(N, 0., 1, V2);
    scale(N, sqrt(target_tEk / tEk), 3, vx, vy, vz);
  } else {
    scale(N, sqrt(target_tEk / tEk), 3, vx, vy, vz);
  }
  free(V2);
  free(Ek);
  free(Ep);
  return 0;
}


x86 assembly (clang, -O0):
<virialise>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x70(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x78(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x80(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1273 <virialise+0x123>
mov    0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x78(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11ee <virialise+0x9e>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x78(%rbp),%r9
mov    -0x80(%rbp),%r10
mov    -0x88(%rbp),%rax
movsd  -0x40(%rbp),%xmm0
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1070 <get_particles_E@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    130a <virialise+0x1ba>
mov    -0x80(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x88(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xd29(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    12af <virialise+0x15f>
cmpl   $0x1,-0x14(%rbp)
jne    1382 <virialise+0x232>
movsd  0xcf4(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xcdf(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x50(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    $0x3,%esi
mov    $0x1,%al
call   1050 <scale@plt>
jmp    13a8 <virialise+0x258>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1411 <virialise+0x2c1>
jp     1411 <virialise+0x2c1>
mov    -0x4(%rbp),%edi
mov    -0x78(%rbp),%rdx
xorps  %xmm0,%xmm0
mov    $0x1,%esi
mov    $0x1,%al
call   1050 <scale@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8c(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    -0x8c(%rbp),%edi
mov    0x10(%rbp),%rdx
mov    0x18(%rbp),%rcx
mov    0x20(%rbp),%r8
mov    $0x3,%esi
mov    $0x1,%al
call   1050 <scale@plt>
jmp    1447 <virialise+0x2f7>
mov    -0x4(%rbp),%eax
mov    %eax,-0x90(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    -0x90(%rbp),%edi
mov    0x10(%rbp),%rdx
mov    0x18(%rbp),%rcx
mov    0x20(%rbp),%r8
mov    $0x3,%esi
mov    $0x1,%al
call   1050 <scale@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<virialise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm1,0x30(%rsp)
mov    %r9,0x28(%rsp)
mov    %r8,0x20(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x48(%rsp)
mov    %esi,0x14(%rsp)
movapd %xmm0,0x50(%rsp)
mov    %edi,%r13d
mov    0xa8(%rsp),%r15
mov    0xa0(%rsp),%r12
lea    0x0(,%r13,8),%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
mov    %r13,%rbp
call   1040 <malloc@plt>
mov    0x18(%rsp),%rdx
mov    0x20(%rsp),%rcx
mov    %rax,%r13
test   %ebp,%ebp
jle    1208 <virialise+0xb8>
movsd  0x30(%rsp),%xmm4
mov    %rbp,%rax
mov    %eax,%ebp
mov    %rax,0x8(%rsp)
cmp    $0x4,%eax
mov    0x28(%rsp),%r8
mov    0x48(%rsp),%r9
jae    1237 <virialise+0xe7>
xor    %eax,%eax
mov    0xb0(%rsp),%rsi
mov    0x20(%rsp),%rcx
mov    0x18(%rsp),%rdx
movapd %xmm4,%xmm0
jmp    12e0 <virialise+0x190>
mov    %ebp,%edi
mov    0x48(%rsp),%rsi
mov    0x28(%rsp),%r8
mov    %rbx,%r9
movsd  0x30(%rsp),%xmm0
push   %r13
push   %r14
call   1070 <get_particles_E@plt>
add    $0x10,%rsp
xorpd  %xmm0,%xmm0
xorpd  %xmm4,%xmm4
jmp    1367 <virialise+0x217>
mov    %ebp,%eax
and    $0xfffffffc,%eax
lea    0x0(,%rbp,8),%rcx
and    $0xffffffffffffffe0,%rcx
xor    %edx,%edx
mov    0xb0(%rsp),%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movupd (%r12,%rdx,1),%xmm0
movupd 0x10(%r12,%rdx,1),%xmm1
movupd (%r15,%rdx,1),%xmm2
movupd 0x10(%r15,%rdx,1),%xmm3
mulpd  %xmm2,%xmm2
mulpd  %xmm3,%xmm3
mulpd  %xmm0,%xmm0
addpd  %xmm2,%xmm0
mulpd  %xmm1,%xmm1
addpd  %xmm3,%xmm1
movupd (%rsi,%rdx,1),%xmm2
movupd 0x10(%rsi,%rdx,1),%xmm3
mulpd  %xmm2,%xmm2
addpd  %xmm0,%xmm2
mulpd  %xmm3,%xmm3
addpd  %xmm1,%xmm3
movupd %xmm2,(%rbx,%rdx,1)
movupd %xmm3,0x10(%rbx,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%rcx
jne    1260 <virialise+0x110>
cmp    %rbp,%rax
mov    0x20(%rsp),%rcx
mov    0x18(%rsp),%rdx
movapd %xmm4,%xmm0
je     1313 <virialise+0x1c3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r12,%rax,8),%xmm2
movsd  (%r15,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  (%rsi,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rbx,%rax,8)
add    $0x1,%rax
cmp    %rax,%rbp
jne    12e0 <virialise+0x190>
mov    0x8(%rsp),%rdi
mov    %r9,%rsi
mov    %rbx,%r9
push   %r13
push   %r14
call   1070 <get_particles_E@plt>
add    $0x10,%rsp
cmpl   $0x0,0x8(%rsp)
jle    135a <virialise+0x20a>
lea    -0x1(%rbp),%rcx
mov    %ebp,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
movapd 0x50(%rsp),%xmm3
mov    0x14(%rsp),%edi
jae    1376 <virialise+0x226>
xorpd  %xmm4,%xmm4
xor    %ecx,%ecx
xorpd  %xmm0,%xmm0
jmp    13f0 <virialise+0x2a0>
xorpd  %xmm0,%xmm0
xorpd  %xmm4,%xmm4
mov    0x8(%rsp),%rbp
movapd 0x50(%rsp),%xmm3
mov    0x14(%rsp),%edi
jmp    143b <virialise+0x2eb>
and    $0xfffffffc,%ebp
xorpd  %xmm4,%xmm4
xor    %ecx,%ecx
movsd  0xc79(%rip),%xmm1
xorpd  %xmm0,%xmm0
nopl   0x0(%rax,%rax,1)
addsd  (%r14,%rcx,8),%xmm4
movsd  0x0(%r13,%rcx,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  0x8(%r14,%rcx,8),%xmm4
addsd  %xmm0,%xmm2
movsd  0x8(%r13,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
addsd  0x10(%r14,%rcx,8),%xmm4
movsd  0x10(%r13,%rcx,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
addsd  0x18(%r14,%rcx,8),%xmm4
movsd  0x18(%r13,%rcx,8),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
add    $0x4,%rcx
cmp    %rcx,%rbp
jne    1390 <virialise+0x240>
test   %rax,%rax
mov    0x8(%rsp),%rbp
je     143b <virialise+0x2eb>
lea    0x0(,%rcx,8),%rdx
add    %r13,%rdx
lea    (%r14,%rcx,8),%rcx
xor    %esi,%esi
movsd  0xbed(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  (%rcx,%rsi,8),%xmm4
movsd  (%rdx,%rsi,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
add    $0x1,%rsi
cmp    %rsi,%rax
jne    1420 <virialise+0x2d0>
cmp    $0x1,%edi
movsd  %xmm4,0x8(%rsp)
jne    14a3 <virialise+0x353>
movsd  0xbba(%rip),%xmm1
subsd  %xmm3,%xmm1
movsd  0xbb6(%rip),%xmm2
divsd  %xmm1,%xmm2
movapd 0xbba(%rip),%xmm1
xorpd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,0x30(%rsp)
divsd  %xmm2,%xmm0
mov    %ebp,%edi
mov    $0x3,%esi
mov    0x18(%rsp),%rdx
mov    0x20(%rsp),%rcx
mov    0x28(%rsp),%r8
mov    $0x1,%al
call   1050 <scale@plt>
movsd  0x8(%rsp),%xmm4
movapd 0x50(%rsp),%xmm3
jmp    14b9 <virialise+0x369>
movapd 0xb75(%rip),%xmm1
xorpd  %xmm3,%xmm1
mulsd  %xmm1,%xmm0
movapd %xmm0,0x30(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm3
jne    14e4 <virialise+0x394>
jp     14e4 <virialise+0x394>
xorpd  %xmm0,%xmm0
mov    %ebp,%edi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    $0x1,%al
call   1050 <scale@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm4
movapd 0x30(%rsp),%xmm0
divsd  %xmm4,%xmm0
ucomisd %xmm1,%xmm0
jb     14fa <virialise+0x3aa>
sqrtsd %xmm0,%xmm0
jmp    14ff <virialise+0x3af>
call   1060 <sqrt@plt>
mov    0xb0(%rsp),%r8
mov    %ebp,%edi
mov    $0x3,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    $0x1,%al
call   1050 <scale@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @virialise(i32 %0, double %1, i32 %2, double* %3, double* %4, double* %5, double* %6, double* %7, double* %8, double* %9, double %10) {
%12 = alloca i32
%13 = alloca double
%14 = alloca i32
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca i32
%29 = alloca i32
%30 = alloca double*
%31 = alloca double*
%32 = alloca double*
store i32 %0, i32* %12
store double %1, double* %13
store i32 %2, i32* %14
store double* %3, double** %15
store double* %4, double** %16
store double* %5, double** %17
store double* %6, double** %18
store double* %7, double** %19
store double* %8, double** %20
store double* %9, double** %21
store double %10, double* %22
store double 0.000000e+00, double* %23
store double 0.000000e+00, double* %24
store double 1.000000e-08, double* %27
store i32 0, i32* %29
%33 = load i32, i32* %12
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 8
%36 = trunc i64 %35 to i32
%37 = call double* @malloc(i32 %36)
store double* %37, double** %30
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = mul i64 %39, 8
%41 = trunc i64 %40 to i32
%42 = call double* @malloc(i32 %41)
store double* %42, double** %31
%43 = load i32, i32* %12
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 8
%46 = trunc i64 %45 to i32
%47 = call double* @malloc(i32 %46)
store double* %47, double** %32
store i32 0, i32* %28
br label %48
48: ; preds = %90, %11
%49 = load i32, i32* %28
%50 = load i32, i32* %12
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %93
52: ; preds = %48
%53 = load double*, double** %19
%54 = load i32, i32* %28
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %19
%59 = load i32, i32* %28
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = load double*, double** %20
%64 = load i32, i32* %28
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = load double*, double** %20
%69 = load i32, i32* %28
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
%72 = load double, double* %71
%73 = fmul double %67, %72
%74 = call double @llvm.fmuladd.f64(double %57, double %62, double %73)
%75 = load double*, double** %21
%76 = load i32, i32* %28
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %75, i64 %77
%79 = load double, double* %78
%80 = load double*, double** %21
%81 = load i32, i32* %28
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = call double @llvm.fmuladd.f64(double %79, double %84, double %74)
%86 = load double*, double** %30
%87 = load i32, i32* %28
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %86, i64 %88
store double %85, double* %89
br label %90
90: ; preds = %52
%91 = load i32, i32* %28
%92 = add nsw i32 %91, 1
store i32 %92, i32* %28
br label %48
93: ; preds = %48
%94 = load i32, i32* %12
%95 = load double*, double** %15
%96 = load double*, double** %16
%97 = load double*, double** %17
%98 = load double*, double** %18
%99 = load double*, double** %30
%100 = load double*, double** %31
%101 = load double*, double** %32
%102 = load double, double* %22
%103 = call i32 @get_particles_E(i32 %94, double* %95, double* %96, double* %97, double* %98, double* %99, double* %100, double* %101, double %102)
store i32 0, i32* %28
br label %104
104: ; preds = %123, %93
%105 = load i32, i32* %28
%106 = load i32, i32* %12
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %126
108: ; preds = %104
%109 = load double*, double** %31
%110 = load i32, i32* %28
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = load double, double* %23
%115 = fadd double %114, %113
store double %115, double* %23
%116 = load double*, double** %32
%117 = load i32, i32* %28
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %116, i64 %118
%120 = load double, double* %119
%121 = load double, double* %24
%122 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %120, double %121)
store double %122, double* %24
br label %123
123: ; preds = %108
%124 = load i32, i32* %28
%125 = add nsw i32 %124, 1
store i32 %125, i32* %28
br label %104
126: ; preds = %104
%127 = load i32, i32* %14
%128 = icmp eq i32 %127, 1
br i1 %128, label %129, label %145
129: ; preds = %126
%130 = load double, double* %13
%131 = fsub double 1.000000e+00, %130
%132 = fdiv double -2.500000e-01, %131
store double %132, double* %26
%133 = load double, double* %13
%134 = fneg double %133
%135 = load double, double* %26
%136 = fmul double %134, %135
store double %136, double* %25
%137 = load i32, i32* %12
%138 = load double, double* %24
%139 = load double, double* %26
%140 = fdiv double %138, %139
%141 = load double*, double** %16
%142 = load double*, double** %17
%143 = load double*, double** %18
%144 = call i32 (i32, double, i32, double*, ...) @scale(i32 %137, double %140, i32 3, double* %141, double* %142, double* %143)
br label %150
145: ; preds = %126
%146 = load double, double* %13
%147 = fneg double %146
%148 = load double, double* %24
%149 = fmul double %147, %148
store double %149, double* %25
br label %150
150: ; preds = %145, %129
%151 = load double, double* %13
%152 = fcmp oeq double %151, 0.000000e+00
br i1 %152, label %153, label %166
153: ; preds = %150
%154 = load i32, i32* %12
%155 = load double*, double** %30
%156 = call i32 (i32, double, i32, double*, ...) @scale(i32 %154, double 0.000000e+00, i32 1, double* %155)
%157 = load i32, i32* %12
%158 = load double, double* %25
%159 = load double, double* %23
%160 = fdiv double %158, %159
%161 = call double @sqrt(double %160)
%162 = load double*, double** %19
%163 = load double*, double** %20
%164 = load double*, double** %21
%165 = call i32 (i32, double, i32, double*, ...) @scale(i32 %157, double %161, i32 3, double* %162, double* %163, double* %164)
br label %176
166: ; preds = %150
%167 = load i32, i32* %12
%168 = load double, double* %25
%169 = load double, double* %23
%170 = fdiv double %168, %169
%171 = call double @sqrt(double %170)
%172 = load double*, double** %19
%173 = load double*, double** %20
%174 = load double*, double** %21
%175 = call i32 (i32, double, i32, double*, ...) @scale(i32 %167, double %171, i32 3, double* %172, double* %173, double* %174)
br label %176
176: ; preds = %166, %153
%177 = load double*, double** %30
%178 = call i32 @free(double* %177)
%179 = load double*, double** %31
%180 = call i32 @free(double* %179)
%181 = load double*, double** %32
%182 = call i32 @free(double* %181)
ret i32 0
}

LLVM IR (-O2):
define i32 @virialise(i32 %0, double %1, i32 %2, double* %3, double* %4, double* %5, double* %6, double* %7, double* %8, double* %9, double %10) {
%12 = shl i32 %0, 3
%13 = tail call double* @malloc(i32 %12)
%14 = tail call double* @malloc(i32 %12)
%15 = tail call double* @malloc(i32 %12)
%16 = icmp sgt i32 %0, 0
br i1 %16, label %19, label %17
17: ; preds = %11
%18 = tail call i32 @get_particles_E(i32 %0, double* %3, double* %4, double* %5, double* %6, double* %13, double* %14, double* %15, double %10)
br label %138
19: ; preds = %11
%20 = zext i32 %0 to i64
%21 = icmp ult i32 %0, 4
br i1 %21, label %58, label %22
22: ; preds = %19
%23 = and i64 %20, 4294967292
br label %24
24: ; preds = %24, %22
%25 = phi i64 [ 0, %22 ], [ %54, %24 ]
%26 = getelementptr inbounds double, double* %7, i64 %25
%27 = bitcast double* %26 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = getelementptr inbounds double, double* %26, i64 2
%30 = bitcast double* %29 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = getelementptr inbounds double, double* %8, i64 %25
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = getelementptr inbounds double, double* %32, i64 2
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = fmul <2 x double> %34, %34
%39 = fmul <2 x double> %37, %37
%40 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> %28, <2 x double> %38)
%41 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %31, <2 x double> %39)
%42 = getelementptr inbounds double, double* %9, i64 %25
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = getelementptr inbounds double, double* %42, i64 2
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %44, <2 x double> %44, <2 x double> %40)
%49 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %47, <2 x double> %47, <2 x double> %41)
%50 = getelementptr inbounds double, double* %13, i64 %25
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %48, <2 x double>* %51
%52 = getelementptr inbounds double, double* %50, i64 2
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %49, <2 x double>* %53
%54 = add nuw i64 %25, 4
%55 = icmp eq i64 %54, %23
br i1 %55, label %56, label %24
56: ; preds = %24
%57 = icmp eq i64 %23, %20
br i1 %57, label %74, label %58
58: ; preds = %19, %56
%59 = phi i64 [ 0, %19 ], [ %23, %56 ]
br label %60
60: ; preds = %58, %60
%61 = phi i64 [ %72, %60 ], [ %59, %58 ]
%62 = getelementptr inbounds double, double* %7, i64 %61
%63 = load double, double* %62
%64 = getelementptr inbounds double, double* %8, i64 %61
%65 = load double, double* %64
%66 = fmul double %65, %65
%67 = tail call double @llvm.fmuladd.f64(double %63, double %63, double %66)
%68 = getelementptr inbounds double, double* %9, i64 %61
%69 = load double, double* %68
%70 = tail call double @llvm.fmuladd.f64(double %69, double %69, double %67)
%71 = getelementptr inbounds double, double* %13, i64 %61
store double %70, double* %71
%72 = add nuw nsw i64 %61, 1
%73 = icmp eq i64 %72, %20
br i1 %73, label %74, label %60
74: ; preds = %60, %56
%75 = tail call i32 @get_particles_E(i32 %0, double* %3, double* %4, double* %5, double* %6, double* %13, double* %14, double* %15, double %10)
br i1 %16, label %76, label %138
76: ; preds = %74
%77 = add nsw i64 %20, -1
%78 = and i64 %20, 3
%79 = icmp ult i64 %77, 3
br i1 %79, label %117, label %80
80: ; preds = %76
%81 = and i64 %20, 4294967292
br label %82
82: ; preds = %82, %80
%83 = phi i64 [ 0, %80 ], [ %114, %82 ]
%84 = phi double [ 0.000000e+00, %80 ], [ %110, %82 ]
%85 = phi double [ 0.000000e+00, %80 ], [ %113, %82 ]
%86 = phi i64 [ 0, %80 ], [ %115, %82 ]
%87 = getelementptr inbounds double, double* %14, i64 %83
%88 = load double, double* %87
%89 = fadd double %84, %88
%90 = getelementptr inbounds double, double* %15, i64 %83
%91 = load double, double* %90
%92 = tail call double @llvm.fmuladd.f64(double %91, double 5.000000e-01, double %85)
%93 = or i64 %83, 1
%94 = getelementptr inbounds double, double* %14, i64 %93
%95 = load double, double* %94
%96 = fadd double %89, %95
%97 = getelementptr inbounds double, double* %15, i64 %93
%98 = load double, double* %97
%99 = tail call double @llvm.fmuladd.f64(double %98, double 5.000000e-01, double %92)
%100 = or i64 %83, 2
%101 = getelementptr inbounds double, double* %14, i64 %100
%102 = load double, double* %101
%103 = fadd double %96, %102
%104 = getelementptr inbounds double, double* %15, i64 %100
%105 = load double, double* %104
%106 = tail call double @llvm.fmuladd.f64(double %105, double 5.000000e-01, double %99)
%107 = or i64 %83, 3
%108 = getelementptr inbounds double, double* %14, i64 %107
%109 = load double, double* %108
%110 = fadd double %103, %109
%111 = getelementptr inbounds double, double* %15, i64 %107
%112 = load double, double* %111
%113 = tail call double @llvm.fmuladd.f64(double %112, double 5.000000e-01, double %106)
%114 = add nuw nsw i64 %83, 4
%115 = add i64 %86, 4
%116 = icmp eq i64 %115, %81
br i1 %116, label %117, label %82
117: ; preds = %82, %76
%118 = phi double [ undef, %76 ], [ %110, %82 ]
%119 = phi double [ undef, %76 ], [ %113, %82 ]
%120 = phi i64 [ 0, %76 ], [ %114, %82 ]
%121 = phi double [ 0.000000e+00, %76 ], [ %110, %82 ]
%122 = phi double [ 0.000000e+00, %76 ], [ %113, %82 ]
%123 = icmp eq i64 %78, 0
br i1 %123, label %138, label %124
124: ; preds = %117, %124
%125 = phi i64 [ %135, %124 ], [ %120, %117 ]
%126 = phi double [ %131, %124 ], [ %121, %117 ]
%127 = phi double [ %134, %124 ], [ %122, %117 ]
%128 = phi i64 [ %136, %124 ], [ 0, %117 ]
%129 = getelementptr inbounds double, double* %14, i64 %125
%130 = load double, double* %129
%131 = fadd double %126, %130
%132 = getelementptr inbounds double, double* %15, i64 %125
%133 = load double, double* %132
%134 = tail call double @llvm.fmuladd.f64(double %133, double 5.000000e-01, double %127)
%135 = add nuw nsw i64 %125, 1
%136 = add i64 %128, 1
%137 = icmp eq i64 %136, %78
br i1 %137, label %138, label %124
138: ; preds = %117, %124, %17, %74
%139 = phi double [ 0.000000e+00, %74 ], [ 0.000000e+00, %17 ], [ %119, %117 ], [ %134, %124 ]
%140 = phi double [ 0.000000e+00, %74 ], [ 0.000000e+00, %17 ], [ %118, %117 ], [ %131, %124 ]
%141 = icmp eq i32 %2, 1
br i1 %141, label %142, label %149
142: ; preds = %138
%143 = fsub double 1.000000e+00, %1
%144 = fdiv double -2.500000e-01, %143
%145 = fneg double %1
%146 = fmul double %144, %145
%147 = fdiv double %139, %144
%148 = tail call i32 (i32, double, i32, double*, ...) @scale(i32 %0, double %147, i32 3, double* %4, double* %5, double* %6)
br label %152
149: ; preds = %138
%150 = fneg double %1
%151 = fmul double %139, %150
br label %152
152: ; preds = %149, %142
%153 = phi double [ %146, %142 ], [ %151, %149 ]
%154 = fcmp oeq double %1, 0.000000e+00
br i1 %154, label %155, label %157
155: ; preds = %152
%156 = tail call i32 (i32, double, i32, double*, ...) @scale(i32 %0, double 0.000000e+00, i32 1, double* %13)
br label %157
157: ; preds = %152, %155
%158 = fdiv double %153, %140
%159 = tail call double @sqrt(double %158)
%160 = tail call i32 (i32, double, i32, double*, ...) @scale(i32 %0, double %159, i32 3, double* %7, double* %8, double* %9)
%161 = tail call i32 @free(double* %13)
%162 = tail call i32 @free(double* %14)
%163 = tail call i32 @free(double* %15)
ret i32 0
}