; LLVM IR from fcimeson/cbTSP :: cbLKH/SRC (Distance)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.Node = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double, double, double, double, double, double, i8, i8, i8 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @Distance_GEO_MEEUS(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.Node, ptr %9, i32 0, i32 46
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = fptosi double %11 to i32
  %13 = sitofp i32 %12 to double
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Node, ptr %14, i32 0, i32 46
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Node, ptr %17, i32 0, i32 46
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = fptosi double %19 to i32
  %21 = sitofp i32 %20 to double
  %22 = fsub double %16, %21
  %23 = fmul double 5.000000e+00, %22
  %24 = fdiv double %23, 3.000000e+00
  %25 = fadd double %13, %24
  %26 = fmul double 0x400921FB54442D18, %25
  %27 = fdiv double %26, 1.800000e+02
  store double %27, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.Node, ptr %28, i32 0, i32 47
  %30 = load double, ptr %29, align 8, !tbaa !14
  %31 = fptosi double %30 to i32
  %32 = sitofp i32 %31 to double
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.Node, ptr %33, i32 0, i32 47
  %35 = load double, ptr %34, align 8, !tbaa !14
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Node, ptr %36, i32 0, i32 47
  %38 = load double, ptr %37, align 8, !tbaa !14
  %39 = fptosi double %38 to i32
  %40 = sitofp i32 %39 to double
  %41 = fsub double %35, %40
  %42 = fmul double 5.000000e+00, %41
  %43 = fdiv double %42, 3.000000e+00
  %44 = fadd double %32, %43
  %45 = fmul double 0x400921FB54442D18, %44
  %46 = fdiv double %45, 1.800000e+02
  store double %46, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.Node, ptr %47, i32 0, i32 46
  %49 = load double, ptr %48, align 8, !tbaa !9
  %50 = fptosi double %49 to i32
  %51 = sitofp i32 %50 to double
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Node, ptr %52, i32 0, i32 46
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Node, ptr %55, i32 0, i32 46
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = fptosi double %57 to i32
  %59 = sitofp i32 %58 to double
  %60 = fsub double %54, %59
  %61 = fmul double 5.000000e+00, %60
  %62 = fdiv double %61, 3.000000e+00
  %63 = fadd double %51, %62
  %64 = fmul double 0x400921FB54442D18, %63
  %65 = fdiv double %64, 1.800000e+02
  store double %65, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Node, ptr %66, i32 0, i32 47
  %68 = load double, ptr %67, align 8, !tbaa !14
  %69 = fptosi double %68 to i32
  %70 = sitofp i32 %69 to double
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Node, ptr %71, i32 0, i32 47
  %73 = load double, ptr %72, align 8, !tbaa !14
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.Node, ptr %74, i32 0, i32 47
  %76 = load double, ptr %75, align 8, !tbaa !14
  %77 = fptosi double %76 to i32
  %78 = sitofp i32 %77 to double
  %79 = fsub double %73, %78
  %80 = fmul double 5.000000e+00, %79
  %81 = fdiv double %80, 3.000000e+00
  %82 = fadd double %70, %81
  %83 = fmul double 0x400921FB54442D18, %82
  %84 = fdiv double %83, 1.800000e+02
  store double %84, ptr %8, align 8, !tbaa !13
  %85 = load double, ptr %5, align 8, !tbaa !13
  %86 = load double, ptr %6, align 8, !tbaa !13
  %87 = load double, ptr %7, align 8, !tbaa !13
  %88 = load double, ptr %8, align 8, !tbaa !13
  %89 = call double @Meeus(double noundef %85, double noundef %86, double noundef %87, double noundef %88)
  %90 = fadd double %89, 5.000000e-01
  %91 = fptosi double %90 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret i32 %91
}

; Function Attrs: nounwind uwtable
declare hidden double @Meeus(double noundef, double noundef, double noundef, double noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 312}
!10 = !{!"Node", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !12, i64 312, !12, i64 320, !12, i64 328, !12, i64 336, !12, i64 344, !12, i64 352, !7, i64 360, !7, i64 361, !7, i64 362}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 320}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
define dso_local i32 @Distance_GEO_MEEUS(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 312
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fptosi double %4 to i32
  %6 = sitofp i32 %5 to double
  %7 = fsub double %4, %6
  %8 = fmul double %7, 5.000000e+00
  %9 = fdiv double %8, 3.000000e+00
  %10 = fadd double %9, %6
  %11 = fmul double %10, 0x400921FB54442D18
  %12 = fdiv double %11, 1.800000e+02
  %13 = getelementptr inbounds i8, ptr %0, i64 320
  %14 = load double, ptr %13, align 8, !tbaa !12
  %15 = fptosi double %14 to i32
  %16 = sitofp i32 %15 to double
  %17 = fsub double %14, %16
  %18 = fmul double %17, 5.000000e+00
  %19 = fdiv double %18, 3.000000e+00
  %20 = fadd double %19, %16
  %21 = fmul double %20, 0x400921FB54442D18
  %22 = fdiv double %21, 1.800000e+02
  %23 = getelementptr inbounds i8, ptr %1, i64 312
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fptosi double %24 to i32
  %26 = sitofp i32 %25 to double
  %27 = fsub double %24, %26
  %28 = fmul double %27, 5.000000e+00
  %29 = fdiv double %28, 3.000000e+00
  %30 = fadd double %29, %26
  %31 = fmul double %30, 0x400921FB54442D18
  %32 = fdiv double %31, 1.800000e+02
  %33 = getelementptr inbounds i8, ptr %1, i64 320
  %34 = load double, ptr %33, align 8, !tbaa !12
  %35 = fptosi double %34 to i32
  %36 = sitofp i32 %35 to double
  %37 = fsub double %34, %36
  %38 = fmul double %37, 5.000000e+00
  %39 = fdiv double %38, 3.000000e+00
  %40 = fadd double %39, %36
  %41 = fmul double %40, 0x400921FB54442D18
  %42 = fdiv double %41, 1.800000e+02
  %43 = tail call double @Meeus(double noundef %12, double noundef %22, double noundef %32, double noundef %42)
  %44 = fadd double %43, 5.000000e-01
  %45 = fptosi double %44 to i32
  ret i32 %45
}

; Function Attrs: nounwind uwtable
declare hidden double @Meeus(double noundef, double noundef, double noundef, double noundef) local_unnamed_addr #0

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !11, i64 312}
!6 = !{!"Node", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !11, i64 312, !11, i64 320, !11, i64 328, !11, i64 336, !11, i64 344, !11, i64 352, !8, i64 360, !8, i64 361, !8, i64 362}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !11, i64 320}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass