#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 const exp(double const);
void sheng_phi2_value(const double r, const double *p, double *f) {
  double y = r - p[3];
  double z = p[2] * p[2] + y * y;
  *f = p[0] * exp(-p[1] * r * r) + p[2] / z;
}


x86 assembly (clang, -O0):
<sheng_phi2_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
divsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sheng_phi2_value>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movapd %xmm0,%xmm1
subsd  0x18(%rdi),%xmm1
movsd  0x10(%rdi),%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  (%rdi),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rdi),%xmm1
xorpd  0xeac(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  0x10(%rbx),%xmm1
divsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @sheng_phi2_value(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* %4
%10 = load double*, double** %5
%11 = getelementptr inbounds double, double* %10, i64 3
%12 = load double, double* %11
%13 = fsub double %9, %12
store double %13, double* %7
%14 = load double*, double** %5
%15 = getelementptr inbounds double, double* %14, i64 2
%16 = load double, double* %15
%17 = load double*, double** %5
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
%20 = load double, double* %7
%21 = load double, double* %7
%22 = fmul double %20, %21
%23 = call double @llvm.fmuladd.f64(double %16, double %19, double %22)
store double %23, double* %8
%24 = load double*, double** %5
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = fneg double %29
%31 = load double, double* %4
%32 = fmul double %30, %31
%33 = load double, double* %4
%34 = fmul double %32, %33
%35 = call double @exp(double %34)
%36 = load double*, double** %5
%37 = getelementptr inbounds double, double* %36, i64 2
%38 = load double, double* %37
%39 = load double, double* %8
%40 = fdiv double %38, %39
%41 = call double @llvm.fmuladd.f64(double %26, double %35, double %40)
%42 = load double*, double** %6
store double %41, double* %42
ret void
}

LLVM IR (-O2):
define void @sheng_phi2_value(double %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %1, i64 3
%5 = load double, double* %4
%6 = fsub double %0, %5
%7 = getelementptr inbounds double, double* %1, i64 2
%8 = load double, double* %7
%9 = fmul double %6, %6
%10 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %9)
%11 = load double, double* %1
%12 = getelementptr inbounds double, double* %1, i64 1
%13 = load double, double* %12
%14 = fneg double %13
%15 = fmul double %14, %0
%16 = fmul double %15, %0
%17 = tail call double @exp(double %16)
%18 = load double, double* %7
%19 = fdiv double %18, %10
%20 = tail call double @llvm.fmuladd.f64(double %11, double %17, double %19)
store double %20, double* %2
ret void
}