; LLVM IR from mickypaganini/SSI2016-jet-clustering :: spartyjet-4.0.2_mac/ExternalTools/Qjets/Qjets.ll (ZN5Qjets22ComputeMinimumDistanceEv)

; 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.std::_List_iterator" = type { ptr }
%"struct.std::_List_const_iterator" = type { ptr }
%class.Qjets = type { double, double, double, double, double, double, %"class.std::vector", %"class.std::__cxx11::list" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<jet_distance, std::allocator<jet_distance>>::_List_impl" }
%"struct.std::__cxx11::_List_base<jet_distance, std::allocator<jet_distance>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }
%struct.jet_distance = type { double, i32, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5Qjets12JetsUnmergedER12jet_distance(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN5Qjets22ComputeMinimumDistanceEv(ptr noundef nonnull align 8 dereferenceable(96) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca %"struct.std::_List_iterator", align 8
  %5 = alloca %"struct.std::_List_iterator", align 8
  %6 = alloca %"struct.std::_List_iterator", align 8
  %7 = alloca %"struct.std::_List_iterator", align 8
  %8 = alloca %"struct.std::_List_const_iterator", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store double -1.000000e+00, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %10 = getelementptr inbounds %class.Qjets, ptr %9, i32 0, i32 7
  %11 = call ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  %12 = getelementptr inbounds %"struct.std::_List_iterator", ptr %4, i32 0, i32 0
  store ptr %11, ptr %12, align 8
  br label %13

13:                                               ; preds = %44, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %14 = getelementptr inbounds %class.Qjets, ptr %9, i32 0, i32 7
  %15 = call ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #4
  %16 = getelementptr inbounds %"struct.std::_List_iterator", ptr %5, i32 0, i32 0
  store ptr %15, ptr %16, align 8
  %17 = call noundef zeroext i1 @_ZStneRKSt14_List_iteratorI12jet_distanceES3_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %45

19:                                               ; preds = %13
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  %21 = call noundef zeroext i1 @_ZN5Qjets12JetsUnmergedER12jet_distance(ptr noundef nonnull align 8 dereferenceable(96) %9, ptr noundef nonnull align 8 dereferenceable(16) %20)
  br i1 %21, label %22, label %38

22:                                               ; preds = %19
  %23 = load double, ptr %3, align 8, !tbaa !9
  %24 = fcmp oeq double %23, -1.000000e+00
  br i1 %24, label %31, label %25

25:                                               ; preds = %22
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  %27 = getelementptr inbounds %struct.jet_distance, ptr %26, i32 0, i32 0
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = load double, ptr %3, align 8, !tbaa !9
  %30 = fcmp olt double %28, %29
  br i1 %30, label %31, label %35

31:                                               ; preds = %25, %22
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  %33 = getelementptr inbounds %struct.jet_distance, ptr %32, i32 0, i32 0
  %34 = load double, ptr %33, align 8, !tbaa !11
  store double %34, ptr %3, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %31, %25
  %36 = call ptr @_ZNSt14_List_iteratorI12jet_distanceEppEi(ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef 0) #4
  %37 = getelementptr inbounds %"struct.std::_List_iterator", ptr %6, i32 0, i32 0
  store ptr %36, ptr %37, align 8
  br label %44

38:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %39 = getelementptr inbounds %class.Qjets, ptr %9, i32 0, i32 7
  call void @_ZNSt20_List_const_iteratorI12jet_distanceEC2ERKSt14_List_iteratorIS0_E(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %4) #4
  %40 = getelementptr inbounds %"struct.std::_List_const_iterator", ptr %8, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8
  %42 = call ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5eraseESt20_List_const_iteratorIS1_E(ptr noundef nonnull align 8 dereferenceable(24) %39, ptr %41) #4
  %43 = getelementptr inbounds %"struct.std::_List_iterator", ptr %7, i32 0, i32 0
  store ptr %42, ptr %43, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %4, ptr align 8 %7, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %44

44:                                               ; preds = %38, %35
  br label %13, !llvm.loop !15

45:                                               ; preds = %18
  %46 = load double, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret double %46
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt14_List_iteratorI12jet_distanceES3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt14_List_iteratorI12jet_distanceEppEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5eraseESt20_List_const_iteratorIS1_E(ptr noundef nonnull align 8 dereferenceable(24), ptr) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt20_List_const_iteratorI12jet_distanceEC2ERKSt14_List_iteratorIS0_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { mustprogress 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 = { mustprogress 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS12jet_distance", !10, i64 0, !13, i64 8, !13, i64 12}
!13 = !{!"int", !7, i64 0}
!14 = !{i64 0, i64 8, !5}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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"

%"struct.std::_List_iterator" = type { ptr }
%"struct.std::_List_const_iterator" = type { ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5Qjets12JetsUnmergedER12jet_distance(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN5Qjets22ComputeMinimumDistanceEv(ptr noundef nonnull align 8 dereferenceable(96) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"struct.std::_List_iterator", align 8
  %3 = alloca %"struct.std::_List_iterator", align 8
  %4 = alloca %"struct.std::_List_const_iterator", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = tail call ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  store ptr %6, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %7 = tail call ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  store ptr %7, ptr %3, align 8
  %8 = call noundef zeroext i1 @_ZStneRKSt14_List_iteratorI12jet_distanceES3_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br i1 %8, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %25, %1
  %.0.lcssa = phi double [ -1.000000e+00, %1 ], [ %.2, %25 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret double %.0.lcssa

.lr.ph:                                           ; preds = %1, %25
  %.05 = phi double [ %.2, %25 ], [ -1.000000e+00, %1 ]
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #3
  %10 = call noundef zeroext i1 @_ZN5Qjets12JetsUnmergedER12jet_distance(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(16) %9)
  br i1 %10, label %11, label %22

11:                                               ; preds = %.lr.ph
  %12 = fcmp oeq double %.05, -1.000000e+00
  br i1 %12, label %17, label %13

13:                                               ; preds = %11
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #3
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fcmp olt double %15, %.05
  br i1 %16, label %17, label %20

17:                                               ; preds = %13, %11
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #3
  %19 = load double, ptr %18, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %17, %13
  %.1 = phi double [ %19, %17 ], [ %.05, %13 ]
  %21 = call ptr @_ZNSt14_List_iteratorI12jet_distanceEppEi(ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef 0) #3
  br label %25

22:                                               ; preds = %.lr.ph
  call void @_ZNSt20_List_const_iteratorI12jet_distanceEC2ERKSt14_List_iteratorIS0_E(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %2) #3
  %23 = load ptr, ptr %4, align 8
  %24 = call ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5eraseESt20_List_const_iteratorIS1_E(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr %23) #3
  store ptr %24, ptr %2, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %22, %20
  %.2 = phi double [ %.1, %20 ], [ %.05, %22 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %26 = call ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #3
  store ptr %26, ptr %3, align 8
  %27 = call noundef zeroext i1 @_ZStneRKSt14_List_iteratorI12jet_distanceES3_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt14_List_iteratorI12jet_distanceES3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt14_List_iteratorI12jet_distanceEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt14_List_iteratorI12jet_distanceEppEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE5eraseESt20_List_const_iteratorIS1_E(ptr noundef nonnull align 8 dereferenceable(24), ptr) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt20_List_const_iteratorI12jet_distanceEC2ERKSt14_List_iteratorIS0_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #3 = { 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, !7, i64 0}
!6 = !{!"_ZTS12jet_distance", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass