#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 */
int /*<<< orphan*/ CalGuassFromLB(double, double, double *, double *, int);
scalar_t__ sqrt(double);
double CalculateLength_Guass(double dX1, double dY1, double dX2, double dY2) {
  double dLength = 0;
  double x1 = 0, x2 = 0, y1 = 0, y2 = 0;
  int nCenterL = ((int)dX1 / 6 + 1) * 6 - 3;
  CalGuassFromLB(dX1, dY1, &x1, &y1, nCenterL);
  CalGuassFromLB(dX2, dY2, &x2, &y2, nCenterL);
  dLength += sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  return dLength;
}


x86 assembly (clang, -O0):
<CalculateLength_Guass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
imul   $0x6,%eax,%eax
sub    $0x3,%eax
mov    %eax,-0x4c(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x4c(%rbp),%edx
lea    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <CalGuassFromLB@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x4c(%rbp),%edx
lea    -0x38(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1030 <CalGuassFromLB@plt>
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
subsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
subsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm3
subsd  -0x48(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateLength_Guass>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm3,0x28(%rsp)
movsd  %xmm2,0x20(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
cvttsd2si %xmm0,%eax
movq   $0x0,(%rsp)
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
lea    (%rax,%rax,1),%ebx
add    $0x3,%ebx
lea    0x18(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %ebx,%edx
call   1030 <CalGuassFromLB@plt>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mov    %ebx,%edx
call   1030 <CalGuassFromLB@plt>
movsd  0x18(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @CalculateLength_Guass(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
%15 = load double, double* %5
%16 = fptosi double %15 to i32
%17 = sdiv i32 %16, 6
%18 = add nsw i32 %17, 1
%19 = mul nsw i32 %18, 6
%20 = sub nsw i32 %19, 3
store i32 %20, i32* %14
%21 = load double, double* %5
%22 = load double, double* %6
%23 = load i32, i32* %14
%24 = call i32 @CalGuassFromLB(double %21, double %22, double* %10, double* %12, i32 %23)
%25 = load double, double* %7
%26 = load double, double* %8
%27 = load i32, i32* %14
%28 = call i32 @CalGuassFromLB(double %25, double %26, double* %11, double* %13, i32 %27)
%29 = load double, double* %10
%30 = load double, double* %11
%31 = fsub double %29, %30
%32 = load double, double* %10
%33 = load double, double* %11
%34 = fsub double %32, %33
%35 = load double, double* %12
%36 = load double, double* %13
%37 = fsub double %35, %36
%38 = load double, double* %12
%39 = load double, double* %13
%40 = fsub double %38, %39
%41 = fmul double %37, %40
%42 = call double @llvm.fmuladd.f64(double %31, double %34, double %41)
%43 = call i64 @sqrt(double %42)
%44 = sitofp i64 %43 to double
%45 = load double, double* %9
%46 = fadd double %45, %44
store double %46, double* %9
%47 = load double, double* %9
ret double %47
}

LLVM IR (-O2):
define double @CalculateLength_Guass(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%10 = bitcast double* %6 to i8*
store double 0.000000e+00, double* %6
%11 = bitcast double* %7 to i8*
store double 0.000000e+00, double* %7
%12 = bitcast double* %8 to i8*
store double 0.000000e+00, double* %8
%13 = fptosi double %0 to i32
%14 = srem i32 %13, 6
%15 = sub i32 %13, %14
%16 = add i32 %15, 3
%17 = call i32 @CalGuassFromLB(double %0, double %1, double* %5, double* %7, i32 %16)
%18 = call i32 @CalGuassFromLB(double %2, double %3, double* %6, double* %8, i32 %16)
%19 = load double, double* %5
%20 = load double, double* %6
%21 = fsub double %19, %20
%22 = load double, double* %7
%23 = load double, double* %8
%24 = fsub double %22, %23
%25 = fmul double %24, %24
%26 = call double @llvm.fmuladd.f64(double %21, double %21, double %25)
%27 = call i64 @sqrt(double %26)
%28 = sitofp i64 %27 to double
ret double %28
}