; 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
declare double @sqrt(double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #1

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

; Function Attrs: nounwind
declare double @sin(double noundef) #1

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local i32 @Distance_GEOM(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 312
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 312
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = insertelement <2 x double> poison, double %4, i64 0
  %8 = insertelement <2 x double> %7, double %6, i64 1
  %9 = fdiv <2 x double> %8, <double 1.800000e+02, double 1.800000e+02>
  %10 = fmul <2 x double> %9, <double 0x400921FB54442D18, double 0x400921FB54442D18>
  %11 = getelementptr inbounds i8, ptr %0, i64 320
  %12 = load double, ptr %11, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %1, i64 320
  %14 = load double, ptr %13, align 8, !tbaa !12
  %15 = insertelement <2 x double> poison, double %12, i64 0
  %16 = insertelement <2 x double> %15, double %14, i64 1
  %17 = fdiv <2 x double> %16, <double 1.800000e+02, double 1.800000e+02>
  %18 = fmul <2 x double> %17, <double 0x400921FB54442D18, double 0x400921FB54442D18>
  %19 = extractelement <2 x double> %10, i64 1
  %20 = tail call double @cos(double noundef %19) #4
  %shift = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %21 = fsub <2 x double> %18, %shift
  %22 = extractelement <2 x double> %21, i64 0
  %23 = tail call double @sin(double noundef %22) #4
  %24 = fmul double %20, %23
  %25 = fmul double %22, 5.000000e-01
  %26 = tail call double @sin(double noundef %25) #4
  %27 = tail call double @cos(double noundef %25) #4
  %28 = extractelement <2 x double> %10, i64 0
  %29 = fadd double %28, %19
  %30 = tail call double @sin(double noundef %29) #4
  %31 = fmul double %26, %30
  %32 = fsub double %28, %19
  %33 = tail call double @sin(double noundef %32) #4
  %34 = fneg double %33
  %35 = fmul double %27, %34
  %36 = fmul double %27, %35
  %37 = tail call double @llvm.fmuladd.f64(double %31, double %26, double %36)
  %38 = tail call double @cos(double noundef %32) #4
  %39 = fmul double %27, %38
  %40 = tail call double @cos(double noundef %29) #4
  %41 = fneg double %40
  %42 = fmul double %26, %41
  %43 = fmul double %26, %42
  %44 = tail call double @llvm.fmuladd.f64(double %39, double %27, double %43)
  %45 = fmul double %37, %37
  %46 = tail call double @llvm.fmuladd.f64(double %24, double %24, double %45)
  %sqrt = tail call double @llvm.sqrt.f64(double %46)
  %47 = tail call double @atan2(double noundef %sqrt, double noundef %44) #4
  %48 = tail call double @llvm.fmuladd.f64(double %47, double 0x415854E500000000, double 1.000000e+00)
  %49 = fptosi double %48 to i32
  ret i32 %49
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !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: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass