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

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

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

9:                                                ; preds = %55, %1
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 499
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %58

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %14 = getelementptr inbounds %class.ASF, ptr %8, i32 0, i32 0
  %15 = getelementptr inbounds %struct.functiondata, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sub nsw i32 %16, 1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [500 x double], ptr %15, i64 0, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !11
  store double %20, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %21 = getelementptr inbounds %class.ASF, ptr %8, i32 0, i32 0
  %22 = getelementptr inbounds %struct.functiondata, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [500 x double], ptr %22, i64 0, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !11
  store double %26, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %27 = getelementptr inbounds %class.ASF, ptr %8, i32 0, i32 0
  %28 = getelementptr inbounds %struct.functiondata, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [500 x double], ptr %28, i64 0, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !11
  store double %33, ptr %7, align 8, !tbaa !11
  %34 = load double, ptr %5, align 8, !tbaa !11
  %35 = load double, ptr %6, align 8, !tbaa !11
  %36 = fcmp olt double %34, %35
  br i1 %36, label %37, label %54

37:                                               ; preds = %13
  %38 = load double, ptr %7, align 8, !tbaa !11
  %39 = load double, ptr %6, align 8, !tbaa !11
  %40 = fcmp olt double %38, %39
  br i1 %40, label %41, label %54

41:                                               ; preds = %37
  %42 = load double, ptr %6, align 8, !tbaa !11
  %43 = getelementptr inbounds %struct.peak, ptr %3, i32 0, i32 1
  store double %42, ptr %43, align 8, !tbaa !13
  %44 = getelementptr inbounds %class.ASF, ptr %8, i32 0, i32 0
  %45 = getelementptr inbounds %struct.functiondata, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [500 x double], ptr %45, i64 0, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = getelementptr inbounds %struct.peak, ptr %3, i32 0, i32 0
  store double %49, ptr %50, align 8, !tbaa !15
  %51 = load i32, ptr %4, align 4, !tbaa !9
  %52 = getelementptr inbounds %struct.peak, ptr %3, i32 0, i32 4
  store i32 %51, ptr %52, align 8, !tbaa !16
  %53 = getelementptr inbounds %class.ASF, ptr %8, i32 0, i32 5
  call void @_ZNSt6vectorI4peakSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %53, ptr noundef nonnull align 8 dereferenceable(40) %3)
  br label %54

54:                                               ; preds = %41, %37, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %55

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

58:                                               ; preds = %12
  %59 = getelementptr inbounds %class.ASF, ptr %8, i32 0, i32 5
  %60 = call noundef i64 @_ZNKSt6vectorI4peakSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %59) #3
  %61 = trunc i64 %60 to i32
  %62 = getelementptr inbounds %class.ASF, ptr %8, i32 0, i32 6
  store i32 %61, ptr %62, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 40, ptr %3) #3
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI4peakSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTS4peak", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !10, i64 32}
!15 = !{!14, !12, i64 0}
!16 = !{!14, !10, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !10, i64 24072}
!20 = !{!"_ZTS3ASF", !21, i64 0, !21, i64 8000, !21, i64 16000, !22, i64 24000, !26, i64 24024, !30, i64 24048, !10, i64 24072, !10, i64 24076, !10, i64 24080, !12, i64 24088, !12, i64 24096}
!21 = !{!"_ZTS12functiondata", !7, i64 0, !7, i64 4000}
!22 = !{!"_ZTSSt6vectorIN7fastjet9PseudoJetESaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!"_ZTSSt6vectorI12particlepairSaIS0_EE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseI12particlepairSaIS0_EE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseI12particlepairSaIS0_EE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseI12particlepairSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!30 = !{!"_ZTSSt6vectorI4peakSaIS0_EE", !31, i64 0}
!31 = !{!"_ZTSSt12_Vector_baseI4peakSaIS0_EE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseI4peakSaIS0_EE12_Vector_implE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseI4peakSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


; 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.peak = type { double, double, double, double, 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 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 @_ZN3ASF9FindPeaksEv(ptr noundef nonnull align 8 dereferenceable(24104) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %struct.peak, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 4000
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  %5 = getelementptr inbounds i8, ptr %2, i64 32
  %6 = getelementptr inbounds i8, ptr %0, i64 24048
  br label %11

7:                                                ; preds = %26
  %8 = call noundef i64 @_ZNKSt6vectorI4peakSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #3
  %9 = trunc i64 %8 to i32
  %10 = getelementptr inbounds i8, ptr %0, i64 24072
  store i32 %9, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %2) #3
  ret void

11:                                               ; preds = %1, %26
  %indvars.iv = phi i64 [ 1, %1 ], [ %indvars.iv.next, %26 ]
  %12 = add nsw i64 %indvars.iv, -1
  %13 = getelementptr inbounds [500 x double], ptr %3, i64 0, i64 %12
  %14 = load double, ptr %13, align 8, !tbaa !25
  %15 = getelementptr inbounds [500 x double], ptr %3, i64 0, i64 %indvars.iv
  %16 = load double, ptr %15, align 8, !tbaa !25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = fcmp olt double %14, %16
  br i1 %17, label %18, label %26

18:                                               ; preds = %11
  %19 = getelementptr inbounds [500 x double], ptr %3, i64 0, i64 %indvars.iv.next
  %20 = load double, ptr %19, align 8, !tbaa !25
  %21 = fcmp olt double %20, %16
  br i1 %21, label %22, label %26

22:                                               ; preds = %18
  store double %16, ptr %4, align 8, !tbaa !26
  %23 = getelementptr inbounds [500 x double], ptr %0, i64 0, i64 %indvars.iv
  %24 = load double, ptr %23, align 8, !tbaa !25
  store double %24, ptr %2, align 8, !tbaa !28
  %25 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %25, ptr %5, align 8, !tbaa !29
  call void @_ZNSt6vectorI4peakSaIS0_EE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(40) %2)
  br label %26

26:                                               ; preds = %22, %18, %11
  %exitcond.not = icmp eq i64 %indvars.iv.next, 499
  br i1 %exitcond.not, label %7, label %11, !llvm.loop !30
}

; 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI4peakSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass