#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 */
typedef int /*<<< orphan*/ temp;

/* Variables and functions */
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
double pow(double, int);
int /*<<< orphan*/ printf(char *);
double sqrt(double);
int nbody_eq(double dx[], double x[], double mus[], int n) {
  double temp[3] = {0.0};
  double rnorm3;
  int j;
  int k;
  int i;
  for (j = 0; j < n; j++) {
    memset(temp, 0, sizeof(temp));
    for (k = 0; k < n; k++) {
      if (k == j) {
        continue;
      }
      rnorm3 = pow(sqrt(pow(x[k * 3] - x[j * 3], 2) +
                        pow(x[k * 3 + 1] - x[j * 3 + 1], 2) +
                        pow(x[k * 3 + 2] - x[j * 3 + 2], 2)),
                   3);
      if (rnorm3 == 0.0) {
        printf("Division by zero!\n");
        return -1;
      }
      for (i = 0; i < 3; i++) {
        temp[i] += (x[k * 3 + i] - x[j * 3 + i]) / rnorm3 * mus[k];
      }
    }
    for (i = 0; i < 3; i++) {
      dx[j * 3 + i] = temp[i];
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<nbody_eq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    136f <nbody_eq+0x22f>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1320 <nbody_eq+0x1e0>
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jne    11ae <nbody_eq+0x6e>
jmp    1312 <nbody_eq+0x1d2>
mov    -0x18(%rbp),%rax
imul   $0x3,-0x50(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x4c(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
imul   $0x3,-0x50(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x18(%rbp),%rax
imul   $0x3,-0x50(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x4c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
mov    $0x3,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    129e <nbody_eq+0x15e>
jp     129e <nbody_eq+0x15e>
lea    0xd73(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1376 <nbody_eq+0x236>
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jge    130d <nbody_eq+0x1cd>
mov    -0x18(%rbp),%rax
imul   $0x3,-0x50(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x4c(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
divsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x50(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movslq -0x54(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12a5 <nbody_eq+0x165>
jmp    1312 <nbody_eq+0x1d2>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1191 <nbody_eq+0x51>
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jge    135c <nbody_eq+0x21c>
movslq -0x54(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
mov    -0x10(%rbp),%rax
imul   $0x3,-0x4c(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1327 <nbody_eq+0x1e7>
jmp    1361 <nbody_eq+0x221>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    116e <nbody_eq+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbody_eq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,0x38(%rsp)
mov    %rdi,0x30(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
test   %ecx,%ecx
jle    1331 <nbody_eq+0x1f1>
mov    %rsi,%rbx
mov    %ecx,%eax
mov    %rax,0x28(%rsp)
lea    (%rax,%rax,2),%r12
xor    %ebp,%ebp
lea    0x10(%rsp),%rdi
xor    %r14d,%r14d
jmp    11c5 <nbody_eq+0x85>
nopl   (%rax)
mov    0x20(%rsp),%rax
mov    0x40(%rsp),%rcx
mov    %rax,0x10(%rcx)
movapd 0x10(%rsp),%xmm0
movupd %xmm0,(%rcx)
mov    0x48(%rsp),%r14
add    $0x1,%r14
add    $0x3,%rbp
cmp    0x28(%rsp),%r14
lea    0x10(%rsp),%rdi
je     1331 <nbody_eq+0x1f1>
lea    (%r14,%r14,2),%r15d
mov    0x30(%rsp),%rax
lea    (%rax,%r15,8),%rax
mov    %rax,0x40(%rsp)
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
lea    (%r14,%r14,2),%eax
add    $0x1,%eax
mov    %rax,0x60(%rsp)
mov    %r14,0x48(%rsp)
lea    (%r14,%r14,2),%eax
add    $0x2,%eax
mov    %rax,0x58(%rsp)
mov    0x38(%rsp),%r14
xor    %r13d,%r13d
mov    %rbp,0x50(%rsp)
jmp    1221 <nbody_eq+0xe1>
nop
add    $0x3,%r13
add    $0x8,%r14
cmp    %r13,%r12
je     1190 <nbody_eq+0x50>
cmp    %r13,%rbp
je     1210 <nbody_eq+0xd0>
mov    %r13d,%ebp
movsd  (%rbx,%rbp,8),%xmm0
subsd  (%rbx,%r15,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x1(%r13),%eax
movsd  (%rbx,%rax,8),%xmm0
mov    0x60(%rsp),%rax
subsd  (%rbx,%rax,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x2(%r13),%eax
movsd  (%rbx,%rax,8),%xmm0
mov    0x58(%rsp),%rax
subsd  (%rbx,%rax,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
addsd  0x8(%rsp),%xmm0
ucomisd 0xd68(%rip),%xmm0
jb     12a0 <nbody_eq+0x160>
sqrtsd %xmm0,%xmm0
jmp    12a5 <nbody_eq+0x165>
call   1060 <sqrt@plt>
mov    $0x3,%edi
call   1050 <pow@plt>
ucomisd 0xd49(%rip),%xmm0
jne    12bb <nbody_eq+0x17b>
jnp    131e <nbody_eq+0x1de>
movsd  (%r14),%xmm1
movupd (%rbx,%rbp,8),%xmm2
movupd (%rbx,%r15,8),%xmm3
subpd  %xmm3,%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
divpd  %xmm3,%xmm2
movapd %xmm1,%xmm3
unpcklpd %xmm1,%xmm3
mulpd  %xmm2,%xmm3
addpd  0x10(%rsp),%xmm3
movapd %xmm3,0x10(%rsp)
movsd  0x10(%rbx,%rbp,8),%xmm2
subsd  0x10(%rbx,%r15,8),%xmm2
divsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
addsd  0x20(%rsp),%xmm2
movsd  %xmm2,0x20(%rsp)
mov    0x50(%rsp),%rbp
jmp    1210 <nbody_eq+0xd0>
lea    0xce3(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
jmp    1333 <nbody_eq+0x1f3>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Division by zero!\0A\00"
define i32 @nbody_eq(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca [3 x double]
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
%15 = bitcast [3 x double]* %10 to i8*
store i32 0, i32* %12
br label %16
16: ; preds = %148, %4
%17 = load i32, i32* %12
%18 = load i32, i32* %9
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %151
20: ; preds = %16
%21 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%22 = call i32 @memset(double* %21, i32 0, i32 24)
store i32 0, i32* %13
br label %23
23: ; preds = %125, %20
%24 = load i32, i32* %13
%25 = load i32, i32* %9
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %128
27: ; preds = %23
%28 = load i32, i32* %13
%29 = load i32, i32* %12
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
br label %125
32: ; preds = %27
%33 = load double*, double** %7
%34 = load i32, i32* %13
%35 = mul nsw i32 %34, 3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %33, i64 %36
%38 = load double, double* %37
%39 = load double*, double** %7
%40 = load i32, i32* %12
%41 = mul nsw i32 %40, 3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %39, i64 %42
%44 = load double, double* %43
%45 = fsub double %38, %44
%46 = call double @pow(double %45, i32 2)
%47 = load double*, double** %7
%48 = load i32, i32* %13
%49 = mul nsw i32 %48, 3
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %47, i64 %51
%53 = load double, double* %52
%54 = load double*, double** %7
%55 = load i32, i32* %12
%56 = mul nsw i32 %55, 3
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %54, i64 %58
%60 = load double, double* %59
%61 = fsub double %53, %60
%62 = call double @pow(double %61, i32 2)
%63 = fadd double %46, %62
%64 = load double*, double** %7
%65 = load i32, i32* %13
%66 = mul nsw i32 %65, 3
%67 = add nsw i32 %66, 2
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %64, i64 %68
%70 = load double, double* %69
%71 = load double*, double** %7
%72 = load i32, i32* %12
%73 = mul nsw i32 %72, 3
%74 = add nsw i32 %73, 2
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %71, i64 %75
%77 = load double, double* %76
%78 = fsub double %70, %77
%79 = call double @pow(double %78, i32 2)
%80 = fadd double %63, %79
%81 = call double @sqrt(double %80)
%82 = call double @pow(double %81, i32 3)
store double %82, double* %11
%83 = load double, double* %11
%84 = fcmp oeq double %83, 0.000000e+00
br i1 %84, label %85, label %87
85: ; preds = %32
%86 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %152
87: ; preds = %32
store i32 0, i32* %14
br label %88
88: ; preds = %121, %87
%89 = load i32, i32* %14
%90 = icmp slt i32 %89, 3
br i1 %90, label %91, label %124
91: ; preds = %88
%92 = load double*, double** %7
%93 = load i32, i32* %13
%94 = mul nsw i32 %93, 3
%95 = load i32, i32* %14
%96 = add nsw i32 %94, %95
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %92, i64 %97
%99 = load double, double* %98
%100 = load double*, double** %7
%101 = load i32, i32* %12
%102 = mul nsw i32 %101, 3
%103 = load i32, i32* %14
%104 = add nsw i32 %102, %103
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds double, double* %100, i64 %105
%107 = load double, double* %106
%108 = fsub double %99, %107
%109 = load double, double* %11
%110 = fdiv double %108, %109
%111 = load double*, double** %8
%112 = load i32, i32* %13
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
%115 = load double, double* %114
%116 = load i32, i32* %14
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %117
%119 = load double, double* %118
%120 = call double @llvm.fmuladd.f64(double %110, double %115, double %119)
store double %120, double* %118
br label %121
121: ; preds = %91
%122 = load i32, i32* %14
%123 = add nsw i32 %122, 1
store i32 %123, i32* %14
br label %88
124: ; preds = %88
br label %125
125: ; preds = %124, %31
%126 = load i32, i32* %13
%127 = add nsw i32 %126, 1
store i32 %127, i32* %13
br label %23
128: ; preds = %23
store i32 0, i32* %14
br label %129
129: ; preds = %144, %128
%130 = load i32, i32* %14
%131 = icmp slt i32 %130, 3
br i1 %131, label %132, label %147
132: ; preds = %129
%133 = load i32, i32* %14
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %134
%136 = load double, double* %135
%137 = load double*, double** %6
%138 = load i32, i32* %12
%139 = mul nsw i32 %138, 3
%140 = load i32, i32* %14
%141 = add nsw i32 %139, %140
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds double, double* %137, i64 %142
store double %136, double* %143
br label %144
144: ; preds = %132
%145 = load i32, i32* %14
%146 = add nsw i32 %145, 1
store i32 %146, i32* %14
br label %129
147: ; preds = %129
br label %148
148: ; preds = %147
%149 = load i32, i32* %12
%150 = add nsw i32 %149, 1
store i32 %150, i32* %12
br label %16
151: ; preds = %16
store i32 0, i32* %5
br label %152
152: ; preds = %151, %85
%153 = load i32, i32* %5
ret i32 %153
}

LLVM IR (-O2):
@str = [18 x i8] c"Division by zero!\00"
define i32 @nbody_eq(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = alloca [3 x double]
%6 = bitcast [3 x double]* %5 to i8*
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %93
8: ; preds = %4
%9 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%10 = zext i32 %3 to i64
%11 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%12 = bitcast [3 x double]* %5 to <2 x double>*
%13 = bitcast [3 x double]* %5 to <2 x double>*
br label %14
14: ; preds = %32, %8
%15 = phi i64 [ 0, %8 ], [ %33, %32 ]
%16 = trunc i64 %15 to i32
%17 = mul i32 %16, 3
%18 = zext i32 %17 to i64
%19 = getelementptr double, double* %0, i64 %18
%20 = bitcast double* %19 to i8*
%21 = call i32 @memset(double* %9, i32 0, i32 24)
%22 = getelementptr inbounds double, double* %1, i64 %18
%23 = add nuw nsw i32 %17, 1
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds double, double* %1, i64 %24
%26 = add nuw nsw i32 %17, 2
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds double, double* %1, i64 %27
%29 = add nuw nsw i64 %18, 2
%30 = getelementptr inbounds double, double* %1, i64 %29
%31 = bitcast double* %22 to <2 x double>*
br label %35
32: ; preds = %90
%33 = add nuw nsw i64 %15, 1
%34 = icmp eq i64 %33, %10
br i1 %34, label %93, label %14
35: ; preds = %14, %90
%36 = phi i64 [ 0, %14 ], [ %91, %90 ]
%37 = icmp eq i64 %36, %15
br i1 %37, label %90, label %38
38: ; preds = %35
%39 = trunc i64 %36 to i32
%40 = mul nsw i32 %39, 3
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds double, double* %1, i64 %41
%43 = load double, double* %42
%44 = load double, double* %22
%45 = fsub double %43, %44
%46 = call double @pow(double %45, i32 2)
%47 = add nuw nsw i32 %40, 1
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds double, double* %1, i64 %48
%50 = load double, double* %49
%51 = load double, double* %25
%52 = fsub double %50, %51
%53 = call double @pow(double %52, i32 2)
%54 = fadd double %46, %53
%55 = add nuw nsw i32 %40, 2
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds double, double* %1, i64 %56
%58 = load double, double* %57
%59 = load double, double* %28
%60 = fsub double %58, %59
%61 = call double @pow(double %60, i32 2)
%62 = fadd double %54, %61
%63 = call double @sqrt(double %62)
%64 = call double @pow(double %63, i32 3)
%65 = fcmp oeq double %64, 0.000000e+00
br i1 %65, label %88, label %66
66: ; preds = %38
%67 = getelementptr inbounds double, double* %2, i64 %36
%68 = load double, double* %67
%69 = bitcast double* %42 to <2 x double>*
%70 = load <2 x double>, <2 x double>* %69
%71 = load <2 x double>, <2 x double>* %31
%72 = fsub <2 x double> %70, %71
%73 = insertelement <2 x double> poison, double %64, i64 0
%74 = shufflevector <2 x double> %73, <2 x double> poison, <2 x i32> zeroinitializer
%75 = fdiv <2 x double> %72, %74
%76 = load <2 x double>, <2 x double>* %12
%77 = insertelement <2 x double> poison, double %68, i64 0
%78 = shufflevector <2 x double> %77, <2 x double> poison, <2 x i32> zeroinitializer
%79 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %75, <2 x double> %78, <2 x double> %76)
store <2 x double> %79, <2 x double>* %13
%80 = add nuw nsw i64 %41, 2
%81 = getelementptr inbounds double, double* %1, i64 %80
%82 = load double, double* %81
%83 = load double, double* %30
%84 = fsub double %82, %83
%85 = fdiv double %84, %64
%86 = load double, double* %11
%87 = call double @llvm.fmuladd.f64(double %85, double %68, double %86)
store double %87, double* %11
br label %90
88: ; preds = %38
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %93
90: ; preds = %66, %35
%91 = add nuw nsw i64 %36, 1
%92 = icmp eq i64 %91, %10
br i1 %92, label %32, label %35
93: ; preds = %32, %4, %88
%94 = phi i32 [ -1, %88 ], [ 0, %4 ], [ 0, %32 ]
ret i32 %94
}