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

; 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: nounwind uwtable
define dso_local i32 @Distance_SPECIAL(ptr noundef %0, ptr noundef %1) #0 {
  %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
  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
  store double 1.000000e+08, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Node, ptr %8, i32 0, i32 46
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.Node, ptr %11, i32 0, i32 46
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = fsub double %10, %13
  store double %14, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Node, ptr %15, i32 0, i32 47
  %17 = load double, ptr %16, align 8, !tbaa !14
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Node, ptr %18, i32 0, i32 47
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = fsub double %17, %20
  store double %21, ptr %7, align 8, !tbaa !9
  %22 = load double, ptr %6, align 8, !tbaa !9
  %23 = fcmp olt double %22, 0.000000e+00
  br i1 %23, label %24, label %27

24:                                               ; preds = %2
  %25 = load double, ptr %6, align 8, !tbaa !9
  %26 = fneg double %25
  store double %26, ptr %6, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %24, %2
  %28 = load double, ptr %7, align 8, !tbaa !9
  %29 = fcmp olt double %28, 0.000000e+00
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = load double, ptr %7, align 8, !tbaa !9
  %32 = fneg double %31
  store double %32, ptr %7, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %30, %27
  %34 = load double, ptr %6, align 8, !tbaa !9
  %35 = fsub double 1.000000e+08, %34
  %36 = load double, ptr %6, align 8, !tbaa !9
  %37 = fcmp olt double %35, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %33
  %39 = load double, ptr %6, align 8, !tbaa !9
  %40 = fsub double 1.000000e+08, %39
  store double %40, ptr %6, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %38, %33
  %42 = load double, ptr %7, align 8, !tbaa !9
  %43 = fsub double 1.000000e+08, %42
  %44 = load double, ptr %7, align 8, !tbaa !9
  %45 = fcmp olt double %43, %44
  br i1 %45, label %46, label %49

46:                                               ; preds = %41
  %47 = load double, ptr %7, align 8, !tbaa !9
  %48 = fsub double 1.000000e+08, %47
  store double %48, ptr %7, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %46, %41
  %50 = load double, ptr %6, align 8, !tbaa !9
  %51 = load double, ptr %6, align 8, !tbaa !9
  %52 = load double, ptr %7, align 8, !tbaa !9
  %53 = load double, ptr %7, align 8, !tbaa !9
  %54 = fmul double %52, %53
  %55 = call double @llvm.fmuladd.f64(double %50, double %51, double %54)
  %56 = call double @sqrt(double noundef %55) #4
  %57 = fadd double %56, 5.000000e-01
  %58 = fptosi double %57 to i32
  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 %58
}

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

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

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 312}
!12 = !{!"Node", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, 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, !10, i64 312, !10, i64 320, !10, i64 328, !10, i64 336, !10, i64 344, !10, i64 352, !7, i64 360, !7, i64 361, !7, i64 362}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, 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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @Distance_SPECIAL(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 312
  %4 = getelementptr inbounds i8, ptr %1, i64 312
  %5 = load <2 x double>, ptr %3, align 8, !tbaa !5
  %6 = load <2 x double>, ptr %4, align 8, !tbaa !5
  %7 = fsub <2 x double> %5, %6
  %8 = fcmp olt <2 x double> %7, zeroinitializer
  %9 = fneg <2 x double> %7
  %10 = select <2 x i1> %8, <2 x double> %9, <2 x double> %7
  %11 = fsub <2 x double> <double 1.000000e+08, double 1.000000e+08>, %10
  %12 = fcmp olt <2 x double> %11, %10
  %13 = extractelement <2 x i1> %12, i64 0
  %14 = extractelement <2 x double> %11, i64 0
  %15 = extractelement <2 x double> %10, i64 0
  %.119 = select i1 %13, double %14, double %15
  %16 = extractelement <2 x i1> %12, i64 1
  %17 = extractelement <2 x double> %11, i64 1
  %18 = extractelement <2 x double> %10, i64 1
  %.1 = select i1 %16, double %17, double %18
  %19 = fmul double %.1, %.1
  %20 = tail call double @llvm.fmuladd.f64(double %.119, double %.119, double %19)
  %sqrt = tail call double @llvm.sqrt.f64(double %20)
  %21 = fadd double %sqrt, 5.000000e-01
  %22 = fptosi double %21 to i32
  ret i32 %22
}

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

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass