#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 */
double sqrt(double);
void kepler_gradient(double *pars, double *r, double *grad) {
  double R, fac;
  R = sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);
  fac = pars[0] * pars[1] / (R * R * R);
  grad[0] = fac * r[0];
  grad[1] = fac * r[1];
  grad[2] = fac * r[2];
}


x86 assembly (clang, -O0):
<kepler_gradient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kepler_gradient>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rsi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1150 <kepler_gradient+0x40>
sqrtsd %xmm0,%xmm0
jmp    1155 <kepler_gradient+0x45>
call   1030 <sqrt@plt>
movsd  (%r15),%xmm1
mulsd  0x8(%r15),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm2,%xmm1
movsd  (%rbx),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rbx),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r14)
mulsd  0x10(%rbx),%xmm1
movsd  %xmm1,0x10(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @kepler_gradient(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%9 = load double*, double** %5
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = load double*, double** %5
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fmul double %17, %20
%22 = call double @llvm.fmuladd.f64(double %11, double %14, double %21)
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 2
%28 = load double, double* %27
%29 = call double @llvm.fmuladd.f64(double %25, double %28, double %22)
%30 = call double @sqrt(double %29)
store double %30, double* %7
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = load double*, double** %4
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
%37 = fmul double %33, %36
%38 = load double, double* %7
%39 = load double, double* %7
%40 = fmul double %38, %39
%41 = load double, double* %7
%42 = fmul double %40, %41
%43 = fdiv double %37, %42
store double %43, double* %8
%44 = load double, double* %8
%45 = load double*, double** %5
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = fmul double %44, %47
%49 = load double*, double** %6
%50 = getelementptr inbounds double, double* %49, i64 0
store double %48, double* %50
%51 = load double, double* %8
%52 = load double*, double** %5
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = fmul double %51, %54
%56 = load double*, double** %6
%57 = getelementptr inbounds double, double* %56, i64 1
store double %55, double* %57
%58 = load double, double* %8
%59 = load double*, double** %5
%60 = getelementptr inbounds double, double* %59, i64 2
%61 = load double, double* %60
%62 = fmul double %58, %61
%63 = load double*, double** %6
%64 = getelementptr inbounds double, double* %63, i64 2
store double %62, double* %64
ret void
}

LLVM IR (-O2):
define void @kepler_gradient(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = load double, double* %1
%5 = getelementptr inbounds double, double* %1, i64 1
%6 = load double, double* %5
%7 = fmul double %6, %6
%8 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %7)
%9 = getelementptr inbounds double, double* %1, i64 2
%10 = load double, double* %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %8)
%12 = tail call double @sqrt(double %11)
%13 = load double, double* %0
%14 = getelementptr inbounds double, double* %0, i64 1
%15 = load double, double* %14
%16 = fmul double %13, %15
%17 = fmul double %12, %12
%18 = fmul double %12, %17
%19 = fdiv double %16, %18
%20 = load double, double* %1
%21 = fmul double %20, %19
store double %21, double* %2
%22 = load double, double* %5
%23 = fmul double %19, %22
%24 = getelementptr inbounds double, double* %2, i64 1
store double %23, double* %24
%25 = load double, double* %9
%26 = fmul double %19, %25
%27 = getelementptr inbounds double, double* %2, i64 2
store double %26, double* %27
ret void
}