#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 log(int);
double sqrt(double);
double sphericalnfw_value(double *pars, double *r) {
  double u, v_h2;
  v_h2 = pars[0] * pars[0] / (log(2.) - 0.5);
  u = sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]) / pars[1];
  return -v_h2 * log(1 + u) / u;
}


x86 assembly (clang, -O0):
<sphericalnfw_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x2,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xea9(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%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   1040 <sqrt@plt>
mov    -0x8(%rbp),%rax
divsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe14(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sphericalnfw_value>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  (%rdi),%xmm0
movapd %xmm0,0x10(%rsp)
mov    $0x2,%edi
call   1030 <log@plt>
movapd %xmm0,%xmm2
addsd  0xeb3(%rip),%xmm2
movsd  (%rbx),%xmm1
movsd  0x8(%rbx),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rbx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     117f <sphericalnfw_value+0x5f>
sqrtsd %xmm0,%xmm0
jmp    118e <sphericalnfw_value+0x6e>
movapd %xmm2,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm2
movapd 0xe7a(%rip),%xmm3
movapd 0x10(%rsp),%xmm1
xorpd  %xmm1,%xmm3
mulsd  %xmm1,%xmm3
unpcklpd %xmm0,%xmm3
movhpd 0x8(%r14),%xmm2
divpd  %xmm2,%xmm3
movapd %xmm3,0x10(%rsp)
unpckhpd %xmm3,%xmm3
movapd %xmm3,(%rsp)
movsd  0xe3f(%rip),%xmm0
addsd  %xmm3,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
mulsd  0x10(%rsp),%xmm0
divsd  (%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @sphericalnfw_value(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%7 = load double*, double** %3
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = fmul double %9, %12
%14 = call double @log(i32 2)
%15 = fsub double %14, 5.000000e-01
%16 = fdiv double %13, %15
store double %16, double* %6
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 0
%22 = load double, double* %21
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = fmul double %25, %28
%30 = call double @llvm.fmuladd.f64(double %19, double %22, double %29)
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 2
%33 = load double, double* %32
%34 = load double*, double** %4
%35 = getelementptr inbounds double, double* %34, i64 2
%36 = load double, double* %35
%37 = call double @llvm.fmuladd.f64(double %33, double %36, double %30)
%38 = call double @sqrt(double %37)
%39 = load double*, double** %3
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = fdiv double %38, %41
store double %42, double* %5
%43 = load double, double* %6
%44 = fneg double %43
%45 = load double, double* %5
%46 = fadd double 1.000000e+00, %45
%47 = fptosi double %46 to i32
%48 = call double @log(i32 %47)
%49 = fmul double %44, %48
%50 = load double, double* %5
%51 = fdiv double %49, %50
ret double %51
}

LLVM IR (-O2):
define double @sphericalnfw_value(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = tail call double @log(i32 2)
%5 = fadd double %4, -5.000000e-01
%6 = load double, double* %1
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = fmul double %8, %8
%10 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %9)
%11 = getelementptr inbounds double, double* %1, i64 2
%12 = load double, double* %11
%13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %10)
%14 = tail call double @sqrt(double %13)
%15 = getelementptr inbounds double, double* %0, i64 1
%16 = load double, double* %15
%17 = fneg double %3
%18 = fmul double %3, %17
%19 = insertelement <2 x double> poison, double %18, i64 0
%20 = insertelement <2 x double> %19, double %14, i64 1
%21 = insertelement <2 x double> poison, double %5, i64 0
%22 = insertelement <2 x double> %21, double %16, i64 1
%23 = fdiv <2 x double> %20, %22
%24 = extractelement <2 x double> %23, i64 1
%25 = fadd double %24, 1.000000e+00
%26 = fptosi double %25 to i32
%27 = tail call double @log(i32 %26)
%28 = extractelement <2 x double> %23, i64 0
%29 = fmul double %28, %27
%30 = fdiv double %29, %24
ret double %30
}