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

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

; 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: mustprogress uwtable
define dso_local void @_ZN3ASF14SetProminencesEv(ptr noundef nonnull align 8 dereferenceable(24104) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %47, %1
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.ASF, ptr %7, i32 0, i32 6
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp slt i32 %9, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %15 = getelementptr inbounds %class.ASF, ptr %7, i32 0, i32 5
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %17) #3
  %19 = getelementptr inbounds %struct.peak, ptr %18, i32 0, i32 1
  %20 = load double, ptr %19, align 8, !tbaa !27
  store double %20, ptr %4, align 8, !tbaa !29
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %21 = load double, ptr %4, align 8, !tbaa !29
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = call noundef double @_ZN3ASF12KeyColToLeftEi(ptr noundef nonnull align 8 dereferenceable(24104) %7, i32 noundef %22)
  %24 = fsub double %21, %23
  store double %24, ptr %5, align 8, !tbaa !29
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %25 = load double, ptr %4, align 8, !tbaa !29
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = call noundef double @_ZN3ASF13KeyColToRightEi(ptr noundef nonnull align 8 dereferenceable(24104) %7, i32 noundef %26)
  %28 = fsub double %25, %27
  store double %28, ptr %6, align 8, !tbaa !29
  %29 = load double, ptr %5, align 8, !tbaa !29
  %30 = load double, ptr %6, align 8, !tbaa !29
  %31 = fcmp olt double %29, %30
  br i1 %31, label %32, label %39

32:                                               ; preds = %14
  %33 = load double, ptr %5, align 8, !tbaa !29
  %34 = getelementptr inbounds %class.ASF, ptr %7, i32 0, i32 5
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %34, i64 noundef %36) #3
  %38 = getelementptr inbounds %struct.peak, ptr %37, i32 0, i32 2
  store double %33, ptr %38, align 8, !tbaa !30
  br label %46

39:                                               ; preds = %14
  %40 = load double, ptr %6, align 8, !tbaa !29
  %41 = getelementptr inbounds %class.ASF, ptr %7, i32 0, i32 5
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %41, i64 noundef %43) #3
  %45 = getelementptr inbounds %struct.peak, ptr %44, i32 0, i32 2
  store double %40, ptr %45, align 8, !tbaa !30
  br label %46

46:                                               ; preds = %39, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %3, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %3, align 4, !tbaa !9
  br label %8, !llvm.loop !31

50:                                               ; preds = %13
  ret void
}

; 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) #2 align 2

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3ASF14SetProminencesEv(ptr noundef nonnull align 8 dereferenceable(24104) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24072
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24048
  br label %6

._crit_edge:                                      ; preds = %6, %1
  ret void

6:                                                ; preds = %.lr.ph, %6
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %6 ]
  %7 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv) #1
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !25
  %10 = trunc nuw nsw i64 %indvars.iv to i32
  %11 = tail call noundef double @_ZN3ASF12KeyColToLeftEi(ptr noundef nonnull align 8 dereferenceable(24104) %0, i32 noundef %10)
  %12 = fsub double %9, %11
  %13 = tail call noundef double @_ZN3ASF13KeyColToRightEi(ptr noundef nonnull align 8 dereferenceable(24104) %0, i32 noundef %10)
  %14 = fsub double %9, %13
  %15 = fcmp olt double %12, %14
  %16 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv) #1
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %. = select i1 %15, double %12, double %14
  store double %., ptr %17, align 8, !tbaa !27
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr %2, align 8, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %6, label %._crit_edge, !llvm.loop !28
}

; 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 nounwind uwtable
declare dso_local noundef double @_ZN3ASF12KeyColToLeftEi(ptr noundef nonnull align 8 dereferenceable(24104), i32 noundef) local_unnamed_addr #0 align 2

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

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 = { 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 8}
!26 = !{!"_ZTS4peak", !24, i64 0, !24, i64 8, !24, i64 16, !24, i64 24, !23, i64 32}
!27 = !{!26, !24, i64 16}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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