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

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

%"class.std::vector.19" = type { %"struct.std::_Vector_base.20" }
%"struct.std::_Vector_base.20" = type { %"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl" }
%"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl" = type { %"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl_data" }
%"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.ASF = type { %struct.functiondata, %struct.functiondata, %struct.functiondata, %"class.std::vector", %"class.std::vector.14", %"class.std::vector.19", i32, i32, i32, double, double }
%struct.functiondata = type { [500 x double], [500 x double] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl" }
%"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl" = type { %"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl_data" }
%"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl" }
%"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl" = type { %"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl_data" }
%"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.peak = type { double, double, double, double, i32 }

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3ASF15GetPeaksMinPromEdd(ptr dead_on_unwind noalias writable sret(%"class.std::vector.19") align 8 %0, ptr noundef nonnull align 8 dereferenceable(24104) %1, double noundef %2, double noundef %3) #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i1, align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !9
  %13 = load ptr, ptr %6, align 8
  store i1 false, ptr %9, align 1
  call void @_ZNSt6vectorI4peakSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %49, %4
  %15 = load i32, ptr %10, align 4, !tbaa !11
  %16 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 6
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %52

20:                                               ; preds = %14
  %21 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 5
  %22 = load i32, ptr %10, align 4, !tbaa !11
  %23 = sext i32 %22 to i64
  %24 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %23) #3
  %25 = getelementptr inbounds %struct.peak, ptr %24, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !28
  %27 = load double, ptr %7, align 8, !tbaa !9
  %28 = fcmp oge double %26, %27
  br i1 %28, label %29, label %48

29:                                               ; preds = %20
  %30 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 5
  %31 = load i32, ptr %10, align 4, !tbaa !11
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %32) #3
  %34 = getelementptr inbounds %struct.peak, ptr %33, i32 0, i32 0
  %35 = load double, ptr %34, align 8, !tbaa !30
  %36 = load double, ptr %8, align 8, !tbaa !9
  %37 = fcmp oge double %35, %36
  br i1 %37, label %38, label %48

38:                                               ; preds = %29
  %39 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 5
  %40 = load i32, ptr %10, align 4, !tbaa !11
  %41 = sext i32 %40 to i64
  %42 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %41) #3
  invoke void @_ZNSt6vectorI4peakSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(40) %42)
          to label %43 unwind label %44

43:                                               ; preds = %38
  br label %48

44:                                               ; preds = %38
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %11, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @_ZNSt6vectorI4peakSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  br label %56

48:                                               ; preds = %43, %29, %20
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %10, align 4, !tbaa !11
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %10, align 4, !tbaa !11
  br label %14, !llvm.loop !31

52:                                               ; preds = %19
  store i1 true, ptr %9, align 1
  %53 = load i1, ptr %9, align 1
  br i1 %53, label %55, label %54

54:                                               ; preds = %52
  call void @_ZNSt6vectorI4peakSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  br label %55

55:                                               ; preds = %54, %52
  ret void

56:                                               ; preds = %44
  %57 = load ptr, ptr %11, align 8
  %58 = load i32, ptr %12, align 4
  %59 = insertvalue { ptr, i32 } poison, ptr %57, 0
  %60 = insertvalue { ptr, i32 } %59, i32 %58, 1
  resume { ptr, i32 } %60
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 24072}
!14 = !{!"_ZTS3ASF", !15, i64 0, !15, i64 8000, !15, i64 16000, !16, i64 24000, !20, i64 24024, !24, i64 24048, !12, i64 24072, !12, i64 24076, !12, i64 24080, !10, i64 24088, !10, i64 24096}
!15 = !{!"_ZTS12functiondata", !7, i64 0, !7, i64 4000}
!16 = !{!"_ZTSSt6vectorIN7fastjet9PseudoJetESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTSSt6vectorI12particlepairSaIS0_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseI12particlepairSaIS0_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseI12particlepairSaIS0_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseI12particlepairSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"_ZTSSt6vectorI4peakSaIS0_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseI4peakSaIS0_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseI4peakSaIS0_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseI4peakSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!29, !10, i64 16}
!29 = !{!"_ZTS4peak", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !12, i64 32}
!30 = !{!29, !10, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"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"

%"class.std::vector.19" = type { %"struct.std::_Vector_base.20" }
%"struct.std::_Vector_base.20" = type { %"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl" }
%"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl" = type { %"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl_data" }
%"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3ASF15GetPeaksMinPromEdd(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::vector.19") align 8 %0, ptr noundef nonnull align 8 dereferenceable(24104) %1, double noundef %2, double noundef %3) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZNSt6vectorI4peakSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %5 = getelementptr inbounds i8, ptr %1, i64 24072
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %8 = getelementptr inbounds i8, ptr %1, i64 24048
  br label %9

9:                                                ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %10 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %indvars.iv) #2
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %12 = load double, ptr %11, align 8, !tbaa !25
  %13 = fcmp ult double %12, %2
  br i1 %13, label %22, label %14

14:                                               ; preds = %9
  %15 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %indvars.iv) #2
  %16 = load double, ptr %15, align 8, !tbaa !27
  %17 = fcmp ult double %16, %3
  br i1 %17, label %22, label %18

18:                                               ; preds = %14
  %19 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %indvars.iv) #2
  invoke void @_ZNSt6vectorI4peakSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(40) %19)
          to label %22 unwind label %20

20:                                               ; preds = %18
  %21 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZNSt6vectorI4peakSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  resume { ptr, i32 } %21

22:                                               ; preds = %9, %14, %18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %5, align 8, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %9, label %._crit_edge, !llvm.loop !28

._crit_edge:                                      ; preds = %22, %4
  ret void
}

attributes #0 = { 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 #1 = { 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 #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, !23, i64 24072}
!6 = !{!"_ZTS3ASF", !7, i64 0, !7, i64 8000, !7, i64 16000, !10, i64 24000, !15, i64 24024, !19, i64 24048, !23, i64 24072, !23, i64 24076, !23, i64 24080, !24, i64 24088, !24, i64 24096}
!7 = !{!"_ZTS12functiondata", !8, i64 0, !8, i64 4000}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIN7fastjet9PseudoJetESaIS1_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTSSt6vectorI12particlepairSaIS0_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseI12particlepairSaIS0_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseI12particlepairSaIS0_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseI12particlepairSaIS0_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!19 = !{!"_ZTSSt6vectorI4peakSaIS0_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseI4peakSaIS0_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseI4peakSaIS0_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseI4peakSaIS0_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!23 = !{!"int", !8, i64 0}
!24 = !{!"double", !8, i64 0}
!25 = !{!26, !24, i64 16}
!26 = !{!"_ZTS4peak", !24, i64 0, !24, i64 8, !24, i64 16, !24, i64 24, !23, i64 32}
!27 = !{!26, !24, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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