#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);
double _orbita_potential_miyamoto_disk_psi(const void *par, const double *pos) {
  double M = ((double *)par)[0], A = ((double *)par)[1],
         B_sq = ((double *)par)[2], x_sq = pos[0] * pos[0],
         y_sq = pos[1] * pos[1], z_sq = pos[2] * pos[2];
  return -M / sqrt(x_sq + y_sq +
                   ((A + sqrt(B_sq + z_sq)) * (A + sqrt(B_sq + z_sq))));
}


x86 assembly (clang, -O0):
<_orbita_potential_miyamoto_disk_psi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x50(%rbp),%xmm0
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_orbita_potential_miyamoto_disk_psi>:
sub    $0x58,%rsp
movsd  0x8(%rdi),%xmm2
movupd (%rsi),%xmm1
mulpd  %xmm1,%xmm1
movsd  0x10(%rsi),%xmm4
mulsd  %xmm4,%xmm4
movsd  (%rdi),%xmm0
movapd %xmm1,%xmm6
unpckhpd %xmm1,%xmm6
addsd  0x10(%rdi),%xmm4
sqrtsd %xmm4,%xmm5
xorpd  %xmm7,%xmm7
ucomisd %xmm7,%xmm4
movapd %xmm5,%xmm3
movsd  %xmm2,0x8(%rsp)
jae    11a4 <_orbita_potential_miyamoto_disk_psi+0x94>
movapd %xmm0,0x20(%rsp)
movapd %xmm4,%xmm0
movapd %xmm1,0x10(%rsp)
movsd  %xmm4,(%rsp)
movsd  %xmm5,0x38(%rsp)
movapd %xmm6,0x40(%rsp)
call   1030 <sqrt@plt>
xorpd  %xmm7,%xmm7
movapd 0x40(%rsp),%xmm6
movsd  0x38(%rsp),%xmm5
movsd  (%rsp),%xmm4
movsd  0x8(%rsp),%xmm2
movapd 0x10(%rsp),%xmm1
movapd %xmm0,%xmm3
movapd 0x20(%rsp),%xmm0
xorpd  0xe54(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
addsd  %xmm6,%xmm1
addsd  %xmm2,%xmm3
ucomisd %xmm7,%xmm4
jae    11e9 <_orbita_potential_miyamoto_disk_psi+0xd9>
movapd %xmm4,%xmm0
movapd %xmm1,0x10(%rsp)
movsd  %xmm3,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movapd 0x10(%rsp),%xmm1
movapd %xmm0,%xmm5
addsd  %xmm5,%xmm2
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jb     1208 <_orbita_potential_miyamoto_disk_psi+0xf8>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    1211 <_orbita_potential_miyamoto_disk_psi+0x101>
movapd %xmm3,%xmm0
call   1030 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @_orbita_potential_miyamoto_disk_psi(i8* %0, double* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i8* %0, i8** %3
store double* %1, double** %4
%11 = load i8*, i8** %3
%12 = bitcast i8* %11 to double*
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
store double %14, double* %5
%15 = load i8*, i8** %3
%16 = bitcast i8* %15 to double*
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
store double %18, double* %6
%19 = load i8*, i8** %3
%20 = bitcast i8* %19 to double*
%21 = getelementptr inbounds double, double* %20, i64 2
%22 = load double, double* %21
store double %22, double* %7
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = fmul double %25, %28
store double %29, double* %8
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 1
%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
store double %36, double* %9
%37 = load double*, double** %4
%38 = getelementptr inbounds double, double* %37, i64 2
%39 = load double, double* %38
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 2
%42 = load double, double* %41
%43 = fmul double %39, %42
store double %43, double* %10
%44 = load double, double* %5
%45 = fneg double %44
%46 = load double, double* %8
%47 = load double, double* %9
%48 = fadd double %46, %47
%49 = load double, double* %6
%50 = load double, double* %7
%51 = load double, double* %10
%52 = fadd double %50, %51
%53 = call double @sqrt(double %52)
%54 = fadd double %49, %53
%55 = load double, double* %6
%56 = load double, double* %7
%57 = load double, double* %10
%58 = fadd double %56, %57
%59 = call double @sqrt(double %58)
%60 = fadd double %55, %59
%61 = call double @llvm.fmuladd.f64(double %54, double %60, double %48)
%62 = call double @sqrt(double %61)
%63 = fdiv double %45, %62
ret double %63
}

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