#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 nbodyC(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(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. / 2.);
      if (rnorm3 == 0.0) {
        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):
<nbodyC>:
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   1030 <memset@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    133e <nbodyC+0x21e>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12ef <nbodyC+0x1cf>
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jne    118e <nbodyC+0x6e>
jmp    12e1 <nbodyC+0x1c1>
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   1040 <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   1040 <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   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    $0x1,%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    126d <nbodyC+0x14d>
jp     126d <nbodyC+0x14d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1345 <nbodyC+0x225>
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jge    12dc <nbodyC+0x1bc>
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    1274 <nbodyC+0x154>
jmp    12e1 <nbodyC+0x1c1>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1171 <nbodyC+0x51>
movl   $0x0,-0x54(%rbp)
cmpl   $0x3,-0x54(%rbp)
jge    132b <nbodyC+0x20b>
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    12f6 <nbodyC+0x1d6>
jmp    1330 <nbodyC+0x210>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    114e <nbodyC+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbodyC>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,0x40(%rsp)
mov    %rdi,0x38(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
test   %ecx,%ecx
jle    1305 <nbodyC+0x1e5>
mov    %rsi,%r12
mov    %ecx,%eax
mov    %rax,0x30(%rsp)
lea    (%rax,%rax,2),%rbx
xor    %r15d,%r15d
lea    0x10(%rsp),%rdi
xor    %ebp,%ebp
jmp    11a5 <nbodyC+0x85>
nopl   (%rax)
mov    0x20(%rsp),%rax
mov    0x48(%rsp),%rcx
mov    %rax,0x10(%rcx)
movapd 0x10(%rsp),%xmm0
movupd %xmm0,(%rcx)
mov    0x50(%rsp),%rbp
add    $0x1,%rbp
add    $0x3,%r15
cmp    0x30(%rsp),%rbp
lea    0x10(%rsp),%rdi
je     1305 <nbodyC+0x1e5>
lea    0x0(%rbp,%rbp,2),%ecx
mov    0x38(%rsp),%rax
mov    %rcx,0x70(%rsp)
lea    (%rax,%rcx,8),%rax
mov    %rax,0x48(%rsp)
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
lea    0x1(%rbp,%rbp,2),%eax
mov    %rax,0x68(%rsp)
mov    %rbp,0x50(%rsp)
lea    0x2(%rbp,%rbp,2),%eax
mov    %rax,0x60(%rsp)
mov    0x40(%rsp),%r14
xor    %r13d,%r13d
mov    %r15,0x58(%rsp)
jmp    1264 <nbodyC+0x144>
xchg   %ax,%ax
movsd  (%r14),%xmm1
movupd (%r12,%rbp,8),%xmm2
movupd (%r12,%rbx,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(%r12,%rbp,8),%xmm2
subsd  0x10(%r12,%rbx,8),%xmm2
divsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
addsd  0x20(%rsp),%xmm2
movsd  %xmm2,0x20(%rsp)
mov    %r15,%rbx
mov    0x58(%rsp),%r15
add    $0x3,%r13
add    $0x8,%r14
cmp    %r13,%rbx
je     1170 <nbodyC+0x50>
cmp    %r13,%r15
je     1253 <nbodyC+0x133>
mov    %rbx,%r15
mov    %r13d,%ebp
movsd  (%r12,%rbp,8),%xmm0
mov    0x70(%rsp),%rbx
subsd  (%r12,%rbx,8),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x1(%r13),%eax
movsd  (%r12,%rax,8),%xmm0
mov    0x68(%rsp),%rax
subsd  (%r12,%rax,8),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x2(%r13),%eax
movsd  (%r12,%rax,8),%xmm0
mov    0x60(%rsp),%rax
subsd  (%r12,%rax,8),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
addsd  0x8(%rsp),%xmm0
mov    $0x1,%edi
call   1040 <pow@plt>
ucomisd 0xd0e(%rip),%xmm0
jne    11f0 <nbodyC+0xd0>
jp     11f0 <nbodyC+0xd0>
mov    $0xffffffff,%eax
jmp    1307 <nbodyC+0x1e7>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @nbodyC(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 = %146, %4
%17 = load i32, i32* %12
%18 = load i32, i32* %9
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %149
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 = %123, %20
%24 = load i32, i32* %13
%25 = load i32, i32* %9
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %126
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 %123
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 @pow(double %80, i32 1)
store double %81, double* %11
%82 = load double, double* %11
%83 = fcmp oeq double %82, 0.000000e+00
br i1 %83, label %84, label %85
84: ; preds = %32
store i32 -1, i32* %5
br label %150
85: ; preds = %32
store i32 0, i32* %14
br label %86
86: ; preds = %119, %85
%87 = load i32, i32* %14
%88 = icmp slt i32 %87, 3
br i1 %88, label %89, label %122
89: ; preds = %86
%90 = load double*, double** %7
%91 = load i32, i32* %13
%92 = mul nsw i32 %91, 3
%93 = load i32, i32* %14
%94 = add nsw i32 %92, %93
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %90, i64 %95
%97 = load double, double* %96
%98 = load double*, double** %7
%99 = load i32, i32* %12
%100 = mul nsw i32 %99, 3
%101 = load i32, i32* %14
%102 = add nsw i32 %100, %101
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %98, i64 %103
%105 = load double, double* %104
%106 = fsub double %97, %105
%107 = load double, double* %11
%108 = fdiv double %106, %107
%109 = load double*, double** %8
%110 = load i32, i32* %13
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = load i32, i32* %14
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %115
%117 = load double, double* %116
%118 = call double @llvm.fmuladd.f64(double %108, double %113, double %117)
store double %118, double* %116
br label %119
119: ; preds = %89
%120 = load i32, i32* %14
%121 = add nsw i32 %120, 1
store i32 %121, i32* %14
br label %86
122: ; preds = %86
br label %123
123: ; preds = %122, %31
%124 = load i32, i32* %13
%125 = add nsw i32 %124, 1
store i32 %125, i32* %13
br label %23
126: ; preds = %23
store i32 0, i32* %14
br label %127
127: ; preds = %142, %126
%128 = load i32, i32* %14
%129 = icmp slt i32 %128, 3
br i1 %129, label %130, label %145
130: ; preds = %127
%131 = load i32, i32* %14
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %132
%134 = load double, double* %133
%135 = load double*, double** %6
%136 = load i32, i32* %12
%137 = mul nsw i32 %136, 3
%138 = load i32, i32* %14
%139 = add nsw i32 %137, %138
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds double, double* %135, i64 %140
store double %134, double* %141
br label %142
142: ; preds = %130
%143 = load i32, i32* %14
%144 = add nsw i32 %143, 1
store i32 %144, i32* %14
br label %127
145: ; preds = %127
br label %146
146: ; preds = %145
%147 = load i32, i32* %12
%148 = add nsw i32 %147, 1
store i32 %148, i32* %12
br label %16
149: ; preds = %16
store i32 0, i32* %5
br label %150
150: ; preds = %149, %84
%151 = load i32, i32* %5
ret i32 %151
}

LLVM IR (-O2):
define i32 @nbodyC(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 %90
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 = %87
%33 = add nuw nsw i64 %15, 1
%34 = icmp eq i64 %33, %10
br i1 %34, label %90, label %14
35: ; preds = %14, %87
%36 = phi i64 [ 0, %14 ], [ %88, %87 ]
%37 = icmp eq i64 %36, %15
br i1 %37, label %87, 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 @pow(double %62, i32 1)
%64 = fcmp oeq double %63, 0.000000e+00
br i1 %64, label %90, label %65
65: ; preds = %38
%66 = getelementptr inbounds double, double* %2, i64 %36
%67 = load double, double* %66
%68 = bitcast double* %42 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = load <2 x double>, <2 x double>* %31
%71 = fsub <2 x double> %69, %70
%72 = insertelement <2 x double> poison, double %63, i64 0
%73 = shufflevector <2 x double> %72, <2 x double> poison, <2 x i32> zeroinitializer
%74 = fdiv <2 x double> %71, %73
%75 = load <2 x double>, <2 x double>* %12
%76 = insertelement <2 x double> poison, double %67, i64 0
%77 = shufflevector <2 x double> %76, <2 x double> poison, <2 x i32> zeroinitializer
%78 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %74, <2 x double> %77, <2 x double> %75)
store <2 x double> %78, <2 x double>* %13
%79 = add nuw nsw i64 %41, 2
%80 = getelementptr inbounds double, double* %1, i64 %79
%81 = load double, double* %80
%82 = load double, double* %30
%83 = fsub double %81, %82
%84 = fdiv double %83, %63
%85 = load double, double* %11
%86 = call double @llvm.fmuladd.f64(double %84, double %67, double %85)
store double %86, double* %11
br label %87
87: ; preds = %65, %35
%88 = add nuw nsw i64 %36, 1
%89 = icmp eq i64 %88, %10
br i1 %89, label %32, label %35
90: ; preds = %32, %38, %4
%91 = phi i32 [ 0, %4 ], [ -1, %38 ], [ 0, %32 ]
ret i32 %91
}