double CalcYDisplace(YPos, newXpos, oldXpos, ZPos, xax, yax, zax, sign, ProfRot,
                     ProfDim, profileArray, ProfAmp, CylIndex)
double YPos, newXpos, oldXpos, ZPos, xax, yax, zax;
double sign, ProfRot, ProfDim;
float *profileArray;
double ProfAmp, CylIndex;
{
  double oldposvec[2], newposvec[2];
  double oldY, newY;
  double Ydis;
  ProfilePosition(oldXpos, ZPos, ProfRot, ProfDim, oldposvec);
  ProfilePosition(newXpos, ZPos, ProfRot, ProfDim, newposvec);
  oldY = OneYdisplace(oldposvec, profileArray, ProfDim, ProfAmp, CylIndex);
  newY = OneYdisplace(newposvec, profileArray, ProfDim, ProfAmp, CylIndex);
  Ydis = YPos - (newY - oldY);
  return (Ydis);
}


x86 assembly (clang, -O0):
<CalcYDisplace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  0x28(%rbp),%xmm8
movsd  0x20(%rbp),%xmm8
movsd  0x18(%rbp),%xmm8
movsd  0x10(%rbp),%xmm8
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
mov    %rdi,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0x10(%rbp),%xmm2
movsd  0x18(%rbp),%xmm3
lea    -0x60(%rbp),%rdi
mov    $0x4,%al
call   1030 <ProfilePosition@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0x10(%rbp),%xmm2
movsd  0x18(%rbp),%xmm3
lea    -0x70(%rbp),%rdi
mov    $0x4,%al
call   1030 <ProfilePosition@plt>
lea    -0x60(%rbp),%rdi
mov    -0x48(%rbp),%rsi
movsd  0x18(%rbp),%xmm0
movsd  0x20(%rbp),%xmm1
movsd  0x28(%rbp),%xmm2
mov    $0x3,%al
call   1040 <OneYdisplace@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x48(%rbp),%rsi
movsd  0x18(%rbp),%xmm0
movsd  0x20(%rbp),%xmm1
movsd  0x28(%rbp),%xmm2
mov    $0x3,%al
call   1040 <OneYdisplace@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcYDisplace>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
movaps %xmm3,%xmm4
movsd  %xmm3,0x10(%rsp)
movaps %xmm2,%xmm5
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
movsd  0x60(%rsp),%xmm2
movsd  0x68(%rsp),%xmm3
lea    0x30(%rsp),%r14
movaps %xmm5,%xmm0
movaps %xmm4,%xmm1
mov    %r14,%rdi
mov    $0x4,%al
call   1030 <ProfilePosition@plt>
lea    0x20(%rsp),%r15
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x60(%rsp),%xmm2
movsd  0x68(%rsp),%xmm3
mov    %r15,%rdi
mov    $0x4,%al
call   1030 <ProfilePosition@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  0x68(%rsp),%xmm0
movsd  0x70(%rsp),%xmm1
movsd  0x78(%rsp),%xmm2
mov    $0x3,%al
call   1040 <OneYdisplace@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
movsd  0x68(%rsp),%xmm0
movsd  0x70(%rsp),%xmm1
movsd  0x78(%rsp),%xmm2
mov    $0x3,%al
call   1040 <OneYdisplace@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @CalcYDisplace(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, float* %10, double %11, double %12) {
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca float*
%25 = alloca double
%26 = alloca double
%27 = alloca [2 x double]
%28 = alloca [2 x double]
%29 = alloca double
%30 = alloca double
%31 = alloca double
store double %0, double* %14
store double %1, double* %15
store double %2, double* %16
store double %3, double* %17
store double %4, double* %18
store double %5, double* %19
store double %6, double* %20
store double %7, double* %21
store double %8, double* %22
store double %9, double* %23
store float* %10, float** %24
store double %11, double* %25
store double %12, double* %26
%32 = load double, double* %16
%33 = load double, double* %17
%34 = load double, double* %22
%35 = load double, double* %23
%36 = getelementptr inbounds [2 x double], [2 x double]* %27, i64 0, i64 0
%37 = call i32 (double, double, double, double, double*, ...) bitcast (i32 (...)* @ProfilePosition to i32 (double, double, double, double, double*, ...)*)(double %32, double %33, double %34, double %35, double* %36)
%38 = load double, double* %15
%39 = load double, double* %17
%40 = load double, double* %22
%41 = load double, double* %23
%42 = getelementptr inbounds [2 x double], [2 x double]* %28, i64 0, i64 0
%43 = call i32 (double, double, double, double, double*, ...) bitcast (i32 (...)* @ProfilePosition to i32 (double, double, double, double, double*, ...)*)(double %38, double %39, double %40, double %41, double* %42)
%44 = getelementptr inbounds [2 x double], [2 x double]* %27, i64 0, i64 0
%45 = load float*, float** %24
%46 = load double, double* %23
%47 = load double, double* %25
%48 = load double, double* %26
%49 = call i32 (double*, float*, double, double, double, ...) bitcast (i32 (...)* @OneYdisplace to i32 (double*, float*, double, double, double, ...)*)(double* %44, float* %45, double %46, double %47, double %48)
%50 = sitofp i32 %49 to double
store double %50, double* %29
%51 = getelementptr inbounds [2 x double], [2 x double]* %28, i64 0, i64 0
%52 = load float*, float** %24
%53 = load double, double* %23
%54 = load double, double* %25
%55 = load double, double* %26
%56 = call i32 (double*, float*, double, double, double, ...) bitcast (i32 (...)* @OneYdisplace to i32 (double*, float*, double, double, double, ...)*)(double* %51, float* %52, double %53, double %54, double %55)
%57 = sitofp i32 %56 to double
store double %57, double* %30
%58 = load double, double* %14
%59 = load double, double* %30
%60 = load double, double* %29
%61 = fsub double %59, %60
%62 = fsub double %58, %61
store double %62, double* %31
%63 = load double, double* %31
ret double %63
}

LLVM IR (-O2):
define double @CalcYDisplace(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, float* %10, double %11, double %12) {
%14 = alloca [2 x double]
%15 = alloca [2 x double]
%16 = bitcast [2 x double]* %14 to i8*
%17 = bitcast [2 x double]* %15 to i8*
%18 = getelementptr inbounds [2 x double], [2 x double]* %14, i64 0, i64 0
%19 = call i32 (double, double, double, double, double*, ...) bitcast (i32 (...)* @ProfilePosition to i32 (double, double, double, double, double*, ...)*)(double %2, double %3, double %8, double %9, double* %18)
%20 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 0
%21 = call i32 (double, double, double, double, double*, ...) bitcast (i32 (...)* @ProfilePosition to i32 (double, double, double, double, double*, ...)*)(double %1, double %3, double %8, double %9, double* %20)
%22 = call i32 (double*, float*, double, double, double, ...) bitcast (i32 (...)* @OneYdisplace to i32 (double*, float*, double, double, double, ...)*)(double* %18, float* %10, double %9, double %11, double %12)
%23 = sitofp i32 %22 to double
%24 = call i32 (double*, float*, double, double, double, ...) bitcast (i32 (...)* @OneYdisplace to i32 (double*, float*, double, double, double, ...)*)(double* %20, float* %10, double %9, double %11, double %12)
%25 = sitofp i32 %24 to double
%26 = fsub double %25, %23
%27 = fsub double %0, %26
ret double %27
}