#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 pow(double, double);
double sqrt(double);
void miyamotonagai_gradient(double *pars, double *r, double *grad) {
  double sqrtz, zd, fac;
  sqrtz = sqrt(r[2] * r[2] + pars[3] * pars[3]);
  zd = pars[2] + sqrtz;
  fac = pars[0] * pars[1] * pow(r[0] * r[0] + r[1] * r[1] + zd * zd, -1.5);
  grad[0] = fac * r[0];
  grad[1] = fac * r[1];
  grad[2] = fac * r[2] * (1. + pars[2] / sqrtz);
}


x86 assembly (clang, -O0):
<miyamotonagai_gradient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x18(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%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
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe31(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
divsd  -0x20(%rbp),%xmm2
movsd  0xdc3(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<miyamotonagai_gradient>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  0x10(%rsi),%xmm0
movsd  0x18(%rdi),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     115b <miyamotonagai_gradient+0x3b>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    1164 <miyamotonagai_gradient+0x44>
call   1040 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%r15),%xmm0
movsd  (%r15),%xmm2
mulsd  0x8(%r15),%xmm2
movsd  %xmm2,(%rsp)
addsd  %xmm1,%xmm0
movsd  (%rbx),%xmm1
movsd  0x8(%rbx),%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe57(%rip),%xmm1
call   1030 <pow@plt>
mulsd  (%rsp),%xmm0
movsd  (%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
mulsd  0x10(%rbx),%xmm0
movsd  0x10(%r15),%xmm1
divsd  0x8(%rsp),%xmm1
addsd  0xe20(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @miyamotonagai_gradient(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%10 = load double*, double** %5
%11 = getelementptr inbounds double, double* %10, i64 2
%12 = load double, double* %11
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i64 2
%15 = load double, double* %14
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 3
%18 = load double, double* %17
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 3
%21 = load double, double* %20
%22 = fmul double %18, %21
%23 = call double @llvm.fmuladd.f64(double %12, double %15, double %22)
%24 = call double @sqrt(double %23)
store double %24, double* %7
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 2
%27 = load double, double* %26
%28 = load double, double* %7
%29 = fadd double %27, %28
store double %29, double* %8
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = fmul double %32, %35
%37 = load double*, double** %5
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load double*, double** %5
%41 = getelementptr inbounds double, double* %40, i64 0
%42 = load double, double* %41
%43 = load double*, double** %5
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = load double*, double** %5
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
%49 = fmul double %45, %48
%50 = call double @llvm.fmuladd.f64(double %39, double %42, double %49)
%51 = load double, double* %8
%52 = load double, double* %8
%53 = call double @llvm.fmuladd.f64(double %51, double %52, double %50)
%54 = call double @pow(double %53, double -1.500000e+00)
%55 = fmul double %36, %54
store double %55, double* %9
%56 = load double, double* %9
%57 = load double*, double** %5
%58 = getelementptr inbounds double, double* %57, i64 0
%59 = load double, double* %58
%60 = fmul double %56, %59
%61 = load double*, double** %6
%62 = getelementptr inbounds double, double* %61, i64 0
store double %60, double* %62
%63 = load double, double* %9
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 1
%66 = load double, double* %65
%67 = fmul double %63, %66
%68 = load double*, double** %6
%69 = getelementptr inbounds double, double* %68, i64 1
store double %67, double* %69
%70 = load double, double* %9
%71 = load double*, double** %5
%72 = getelementptr inbounds double, double* %71, i64 2
%73 = load double, double* %72
%74 = fmul double %70, %73
%75 = load double*, double** %4
%76 = getelementptr inbounds double, double* %75, i64 2
%77 = load double, double* %76
%78 = load double, double* %7
%79 = fdiv double %77, %78
%80 = fadd double 1.000000e+00, %79
%81 = fmul double %74, %80
%82 = load double*, double** %6
%83 = getelementptr inbounds double, double* %82, i64 2
store double %81, double* %83
ret void
}

LLVM IR (-O2):
define void @miyamotonagai_gradient(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %1, i64 2
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %0, i64 3
%7 = load double, double* %6
%8 = fmul double %7, %7
%9 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %8)
%10 = tail call double @sqrt(double %9)
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = fadd double %10, %12
%14 = load double, double* %0
%15 = getelementptr inbounds double, double* %0, i64 1
%16 = load double, double* %15
%17 = fmul double %14, %16
%18 = load double, double* %1
%19 = getelementptr inbounds double, double* %1, i64 1
%20 = load double, double* %19
%21 = fmul double %20, %20
%22 = tail call double @llvm.fmuladd.f64(double %18, double %18, double %21)
%23 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %22)
%24 = tail call double @pow(double %23, double -1.500000e+00)
%25 = fmul double %17, %24
%26 = load double, double* %1
%27 = fmul double %25, %26
store double %27, double* %2
%28 = load double, double* %19
%29 = fmul double %25, %28
%30 = getelementptr inbounds double, double* %2, i64 1
store double %29, double* %30
%31 = load double, double* %4
%32 = fmul double %25, %31
%33 = load double, double* %11
%34 = fdiv double %33, %10
%35 = fadd double %34, 1.000000e+00
%36 = fmul double %32, %35
%37 = getelementptr inbounds double, double* %2, i64 2
store double %36, double* %37
ret void
}