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

; 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.jet_distance = type { double, i32, i32 }
%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 }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN5Qjets4d_ijERKN7fastjet9PseudoJetES3_(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(88)) #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Qjets19ComputeAllDistancesERKSt6vectorIN7fastjet9PseudoJetESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.jet_distance, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %55, %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = zext i32 %11 to i64
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #3
  %15 = sub i64 %14, 1
  %16 = icmp ult i64 %12, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %10
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %58

18:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = add i32 %19, 1
  store i32 %20, ptr %7, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %51, %18
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %24) #3
  %26 = icmp ult i64 %23, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %21
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %54

28:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = getelementptr inbounds %struct.jet_distance, ptr %8, i32 0, i32 1
  store i32 %29, ptr %30, align 8, !tbaa !11
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = getelementptr inbounds %struct.jet_distance, ptr %8, i32 0, i32 2
  store i32 %31, ptr %32, align 4, !tbaa !14
  %33 = getelementptr inbounds %struct.jet_distance, ptr %8, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.jet_distance, ptr %8, i32 0, i32 2
  %36 = load i32, ptr %35, align 4, !tbaa !14
  %37 = icmp ne i32 %34, %36
  br i1 %37, label %38, label %50

38:                                               ; preds = %28
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %41) #3
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %43, i64 noundef %45) #3
  %47 = call noundef double @_ZN5Qjets4d_ijERKN7fastjet9PseudoJetES3_(ptr noundef nonnull align 8 dereferenceable(96) %9, ptr noundef nonnull align 8 dereferenceable(88) %42, ptr noundef nonnull align 8 dereferenceable(88) %46)
  %48 = getelementptr inbounds %struct.jet_distance, ptr %8, i32 0, i32 0
  store double %47, ptr %48, align 8, !tbaa !15
  %49 = getelementptr inbounds %class.Qjets, ptr %9, i32 0, i32 7
  call void @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %49, ptr noundef nonnull align 8 dereferenceable(16) %8)
  br label %50

50:                                               ; preds = %38, %28
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = add i32 %52, 1
  store i32 %53, ptr %7, align 4, !tbaa !9
  br label %21, !llvm.loop !16

54:                                               ; preds = %27
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = add i32 %56, 1
  store i32 %57, ptr %5, align 4, !tbaa !9
  br label %10, !llvm.loop !18

58:                                               ; preds = %17
  ret void
}

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


; 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.jet_distance = type { double, i32, i32 }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN5Qjets4d_ijERKN7fastjet9PseudoJetES3_(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Qjets19ComputeAllDistancesERKSt6vectorIN7fastjet9PseudoJetESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %struct.jet_distance, align 8
  %4 = tail call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %.not19 = icmp eq i64 %4, 1
  br i1 %.not19, label %._crit_edge, label %.lr.ph18

.lr.ph18:                                         ; preds = %2
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %6 = getelementptr inbounds i8, ptr %3, i64 12
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  br label %11

.loopexit:                                        ; preds = %22, %11
  %8 = call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %9 = add i64 %8, -1
  %10 = icmp ugt i64 %9, %14
  br i1 %10, label %11, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.loopexit, %2
  ret void

11:                                               ; preds = %.lr.ph18, %.loopexit
  %12 = phi i64 [ 0, %.lr.ph18 ], [ %14, %.loopexit ]
  %.01317 = phi i32 [ 0, %.lr.ph18 ], [ %13, %.loopexit ]
  %13 = add i32 %.01317, 1
  %14 = zext i32 %13 to i64
  %15 = call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %16 = icmp ugt i64 %15, %14
  br i1 %16, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %11, %22
  %17 = phi i64 [ %24, %22 ], [ %14, %11 ]
  %.016 = phi i32 [ %23, %22 ], [ %13, %11 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  store i32 %.01317, ptr %5, align 8, !tbaa !7
  store i32 %.016, ptr %6, align 4, !tbaa !13
  %.not = icmp eq i32 %.01317, %.016
  br i1 %.not, label %22, label %18

18:                                               ; preds = %.lr.ph
  %19 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %12) #3
  %20 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %17) #3
  %21 = call noundef double @_ZN5Qjets4d_ijERKN7fastjet9PseudoJetES3_(ptr noundef nonnull align 8 dereferenceable(96) %0, ptr noundef nonnull align 8 dereferenceable(88) %19, ptr noundef nonnull align 8 dereferenceable(88) %20)
  store double %21, ptr %3, align 8, !tbaa !14
  call void @_ZNSt7__cxx114listI12jet_distanceSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(16) %3)
  br label %22

22:                                               ; preds = %18, %.lr.ph
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  %23 = add i32 %.016, 1
  %24 = zext i32 %23 to i64
  %25 = call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %26 = icmp ugt i64 %25, %24
  br i1 %26, label %.lr.ph, label %.loopexit, !llvm.loop !15
}

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


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