#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 */
struct orbita_potential {
  int dummy;
};

/* Variables and functions */
int orbita_potential_evaluate_potential(struct orbita_potential *, double *,
                                        int);
double sqrt(double);
double _pseeker_x_vphi(struct orbita_potential *psi, double E_J,
                       double omega_sq, double R) {
  double pos_t[3] = {0., R, 0.};
  double vsq_t = 2. * E_J + (R * R) * omega_sq -
                 2. * orbita_potential_evaluate_potential(psi, pos_t, 0.);
  return sqrt(vsq_t);
}


x86 assembly (clang, -O0):
<_pseeker_x_vphi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1030 <orbita_potential_evaluate_potential@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <sqrt@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_pseeker_x_vphi>:
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movsd  %xmm2,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1030 <orbita_potential_evaluate_potential@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     118a <_pseeker_x_vphi+0x6a>
sqrtsd %xmm0,%xmm0
add    $0x28,%rsp
ret
call   1040 <sqrt@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.orbita_potential = type { i32 }
define double @_pseeker_x_vphi(%struct.orbita_potential* %0, double %1, double %2, double %3) {
%5 = alloca %struct.orbita_potential*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca [3 x double]
%10 = alloca double
store %struct.orbita_potential* %0, %struct.orbita_potential** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%11 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
store double 0.000000e+00, double* %11
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %8
store double %13, double* %12
%14 = getelementptr inbounds double, double* %12, i64 1
store double 0.000000e+00, double* %14
%15 = load double, double* %6
%16 = load double, double* %8
%17 = load double, double* %8
%18 = fmul double %16, %17
%19 = load double, double* %7
%20 = fmul double %18, %19
%21 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %15, double %20)
%22 = load %struct.orbita_potential*, %struct.orbita_potential** %5
%23 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%24 = call i32 @orbita_potential_evaluate_potential(%struct.orbita_potential* %22, double* %23, i32 0)
%25 = sitofp i32 %24 to double
%26 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %25, double %21)
store double %26, double* %10
%27 = load double, double* %10
%28 = call double @sqrt(double %27)
ret double %28
}

LLVM IR (-O2):
%struct.orbita_potential = type { i32 }
define double @_pseeker_x_vphi(%struct.orbita_potential* %0, double %1, double %2, double %3) {
%5 = alloca [3 x double]
%6 = bitcast [3 x double]* %5 to i8*
%7 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
store double 0.000000e+00, double* %7
%8 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
store double %3, double* %8
%9 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double 0.000000e+00, double* %9
%10 = fmul double %3, %3
%11 = fmul double %10, %2
%12 = tail call double @llvm.fmuladd.f64(double %1, double 2.000000e+00, double %11)
%13 = call i32 @orbita_potential_evaluate_potential(%struct.orbita_potential* %0, double* %7, i32 0)
%14 = sitofp i32 %13 to double
%15 = call double @llvm.fmuladd.f64(double %14, double -2.000000e+00, double %12)
%16 = call double @sqrt(double %15)
ret double %16
}