#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*/ norm(double *);
double pow(int /*<<< orphan*/, int);
void force_gravity(double r1[2], double r2[2], double m1, double m2,
                   double F[2]) {
  double r[2];
  for (int i = 0; i < 2; i++)
    r[i] = r1[i] - r2[i];
  for (int i = 0; i < 2; i++)
    F[i] += -6.67e-11 * m1 * m2 * pow(norm(r), -1) * r[i];
  return;
}


x86 assembly (clang, -O0):
<force_gravity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jge    1181 <force_gravity+0x61>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x44(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1145 <force_gravity+0x25>
movl   $0x0,-0x48(%rbp)
cmpl   $0x2,-0x48(%rbp)
jge    11fc <force_gravity+0xdc>
movsd  0xe66(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <norm@plt>
mov    %eax,%edi
mov    $0xffffffff,%esi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movslq -0x48(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm2
mov    -0x28(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1188 <force_gravity+0x68>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<force_gravity>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
movupd (%rdi),%xmm3
movupd (%rsi),%xmm2
subpd  %xmm2,%xmm3
movapd %xmm3,0x10(%rsp)
mulsd  0xebc(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <norm@plt>
mov    %eax,%edi
mov    $0xffffffff,%esi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  (%rbx),%xmm0
movsd  %xmm0,(%rbx)
mov    %r14,%rdi
call   1030 <norm@plt>
mov    %eax,%edi
mov    $0xffffffff,%esi
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%rbx)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @force_gravity(double* %0, double* %1, double %2, double %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca [2 x double]
%12 = alloca i32
%13 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store double %3, double* %9
store double* %4, double** %10
store i32 0, i32* %12
br label %14
14: ; preds = %32, %5
%15 = load i32, i32* %12
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %35
17: ; preds = %14
%18 = load double*, double** %6
%19 = load i32, i32* %12
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load double*, double** %7
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fsub double %22, %27
%29 = load i32, i32* %12
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 %30
store double %28, double* %31
br label %32
32: ; preds = %17
%33 = load i32, i32* %12
%34 = add nsw i32 %33, 1
store i32 %34, i32* %12
br label %14
35: ; preds = %14
store i32 0, i32* %13
br label %36
36: ; preds = %58, %35
%37 = load i32, i32* %13
%38 = icmp slt i32 %37, 2
br i1 %38, label %39, label %61
39: ; preds = %36
%40 = load double, double* %8
%41 = fmul double -6.670000e-11, %40
%42 = load double, double* %9
%43 = fmul double %41, %42
%44 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%45 = call i32 @norm(double* %44)
%46 = call double @pow(i32 %45, i32 -1)
%47 = fmul double %43, %46
%48 = load i32, i32* %13
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 %49
%51 = load double, double* %50
%52 = load double*, double** %10
%53 = load i32, i32* %13
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = call double @llvm.fmuladd.f64(double %47, double %51, double %56)
store double %57, double* %55
br label %58
58: ; preds = %39
%59 = load i32, i32* %13
%60 = add nsw i32 %59, 1
store i32 %60, i32* %13
br label %36
61: ; preds = %36
ret void
}

LLVM IR (-O2):
define void @force_gravity(double* nocapture %0, double* nocapture %1, double %2, double %3, double* nocapture %4) {
%6 = alloca <2 x double>
%7 = bitcast <2 x double>* %6 to i8*
%8 = getelementptr inbounds <2 x double>, <2 x double>* %6, i64 0, i64 0
%9 = bitcast double* %0 to <2 x double>*
%10 = load <2 x double>, <2 x double>* %9
%11 = bitcast double* %1 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = fsub <2 x double> %10, %12
%14 = getelementptr inbounds <2 x double>, <2 x double>* %6, i64 0, i64 1
store <2 x double> %13, <2 x double>* %6
%15 = fmul double %2, -6.670000e-11
%16 = fmul double %15, %3
%17 = call i32 @norm(double* %8)
%18 = call double @pow(i32 %17, i32 -1)
%19 = fmul double %16, %18
%20 = load double, double* %8
%21 = load double, double* %4
%22 = call double @llvm.fmuladd.f64(double %19, double %20, double %21)
store double %22, double* %4
%23 = call i32 @norm(double* %8)
%24 = call double @pow(i32 %23, i32 -1)
%25 = fmul double %16, %24
%26 = load double, double* %14
%27 = getelementptr inbounds double, double* %4, i64 1
%28 = load double, double* %27
%29 = call double @llvm.fmuladd.f64(double %25, double %26, double %28)
store double %29, double* %27
ret void
}