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


x86 assembly (clang, -O0):
<plummer_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),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%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):
<plummer_gradient>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0x10(%rsi),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  (%rdi),%xmm2
movsd  0x10(%rdi),%xmm3
mulsd  %xmm3,%xmm3
mulsd  0x8(%rdi),%xmm2
addsd  %xmm1,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jb     1168 <plummer_gradient+0x58>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    1189 <plummer_gradient+0x79>
movapd %xmm3,%xmm0
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
call   1030 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
divsd  %xmm3,%xmm2
movsd  (%rbx),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rbx),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%r14)
mulsd  0x10(%rbx),%xmm2
movsd  %xmm2,0x10(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @plummer_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 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 2
%35 = load double, double* %34
%36 = call double @llvm.fmuladd.f64(double %32, double %35, double %29)
store double %36, double* %7
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = fmul double %39, %42
%44 = load double, double* %7
%45 = call double @sqrt(double %44)
%46 = fdiv double %43, %45
%47 = load double, double* %7
%48 = fdiv double %46, %47
store double %48, double* %8
%49 = load double, double* %8
%50 = load double*, double** %5
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load double, double* %51
%53 = fmul double %49, %52
%54 = load double*, double** %6
%55 = getelementptr inbounds double, double* %54, i64 0
store double %53, double* %55
%56 = load double, double* %8
%57 = load double*, double** %5
%58 = getelementptr inbounds double, double* %57, i64 1
%59 = load double, double* %58
%60 = fmul double %56, %59
%61 = load double*, double** %6
%62 = getelementptr inbounds double, double* %61, i64 1
store double %60, double* %62
%63 = load double, double* %8
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 2
%66 = load double, double* %65
%67 = fmul double %63, %66
%68 = load double*, double** %6
%69 = getelementptr inbounds double, double* %68, i64 2
store double %67, double* %69
ret void
}

LLVM IR (-O2):
define void @plummer_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 = getelementptr inbounds double, double* %0, i64 2
%13 = load double, double* %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %11)
%15 = load double, double* %0
%16 = getelementptr inbounds double, double* %0, i64 1
%17 = load double, double* %16
%18 = fmul double %15, %17
%19 = tail call double @sqrt(double %14)
%20 = fdiv double %18, %19
%21 = fdiv double %20, %14
%22 = load double, double* %1
%23 = fmul double %22, %21
store double %23, double* %2
%24 = load double, double* %5
%25 = fmul double %21, %24
%26 = getelementptr inbounds double, double* %2, i64 1
store double %25, double* %26
%27 = load double, double* %9
%28 = fmul double %21, %27
%29 = getelementptr inbounds double, double* %2, i64 2
store double %28, double* %29
ret void
}