#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 hernquist_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 + pars[2]) * (R + pars[2]) * R);
  grad[0] = fac * r[0];
  grad[1] = fac * r[1];
  grad[2] = fac * r[2];
}


x86 assembly (clang, -O0):
<hernquist_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
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm1
movsd  -0x20(%rbp),%xmm2
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm2
mulsd  %xmm2,%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):
<hernquist_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 <hernquist_gradient+0x40>
sqrtsd %xmm0,%xmm0
jmp    1155 <hernquist_gradient+0x45>
call   1030 <sqrt@plt>
movsd  (%r15),%xmm1
mulsd  0x8(%r15),%xmm1
movsd  0x10(%r15),%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm2,%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 @hernquist_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** %4
%40 = getelementptr inbounds double, double* %39, i64 2
%41 = load double, double* %40
%42 = fadd double %38, %41
%43 = load double, double* %7
%44 = load double*, double** %4
%45 = getelementptr inbounds double, double* %44, i64 2
%46 = load double, double* %45
%47 = fadd double %43, %46
%48 = fmul double %42, %47
%49 = load double, double* %7
%50 = fmul double %48, %49
%51 = fdiv double %37, %50
store double %51, double* %8
%52 = load double, double* %8
%53 = load double*, double** %5
%54 = getelementptr inbounds double, double* %53, i64 0
%55 = load double, double* %54
%56 = fmul double %52, %55
%57 = load double*, double** %6
%58 = getelementptr inbounds double, double* %57, i64 0
store double %56, double* %58
%59 = load double, double* %8
%60 = load double*, double** %5
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
%63 = fmul double %59, %62
%64 = load double*, double** %6
%65 = getelementptr inbounds double, double* %64, i64 1
store double %63, double* %65
%66 = load double, double* %8
%67 = load double*, double** %5
%68 = getelementptr inbounds double, double* %67, i64 2
%69 = load double, double* %68
%70 = fmul double %66, %69
%71 = load double*, double** %6
%72 = getelementptr inbounds double, double* %71, i64 2
store double %70, double* %72
ret void
}

LLVM IR (-O2):
define void @hernquist_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 = getelementptr inbounds double, double* %0, i64 2
%18 = load double, double* %17
%19 = fadd double %12, %18
%20 = fmul double %19, %19
%21 = fmul double %12, %20
%22 = fdiv double %16, %21
%23 = load double, double* %1
%24 = fmul double %23, %22
store double %24, double* %2
%25 = load double, double* %5
%26 = fmul double %25, %22
%27 = getelementptr inbounds double, double* %2, i64 1
store double %26, double* %27
%28 = load double, double* %9
%29 = fmul double %22, %28
%30 = getelementptr inbounds double, double* %2, i64 2
store double %29, double* %30
ret void
}