; LLVM IR from mickypaganini/SSI2016-jet-clustering :: spartyjet-4.0.2_mac/External/fastjet-3.0.0/src (ClusterSequence)

; 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.fastjet::ClusterSequence" = type <{ ptr, %"class.fastjet::JetDefinition", %"class.std::vector", %"class.std::vector.1", i8, [3 x i8], i32, double, double, double, double, i32, i32, %"class.fastjet::SharedPtr.6", i32, i8, i8, [2 x i8], %"class.fastjet::SharedPtr.7", %"class.std::vector.8", double, double, double, double, i32, i32, i32, [4 x i8] }>
%"class.fastjet::JetDefinition" = type { i32, double, double, i32, ptr, %"class.fastjet::SharedPtr", %"class.fastjet::JetDefinition::DefaultRecombiner", ptr, %"class.fastjet::SharedPtr.0" }
%"class.fastjet::SharedPtr" = type { ptr }
%"class.fastjet::JetDefinition::DefaultRecombiner" = type <{ %"class.fastjet::JetDefinition::Recombiner", i32, [4 x i8] }>
%"class.fastjet::JetDefinition::Recombiner" = type { ptr }
%"class.fastjet::SharedPtr.0" = type { ptr }
%"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.1" = type { %"struct.std::_Vector_base.2" }
%"struct.std::_Vector_base.2" = type { %"struct.std::_Vector_base<fastjet::ClusterSequence::history_element, std::allocator<fastjet::ClusterSequence::history_element>>::_Vector_impl" }
%"struct.std::_Vector_base<fastjet::ClusterSequence::history_element, std::allocator<fastjet::ClusterSequence::history_element>>::_Vector_impl" = type { %"struct.std::_Vector_base<fastjet::ClusterSequence::history_element, std::allocator<fastjet::ClusterSequence::history_element>>::_Vector_impl_data" }
%"struct.std::_Vector_base<fastjet::ClusterSequence::history_element, std::allocator<fastjet::ClusterSequence::history_element>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.fastjet::SharedPtr.6" = type { ptr }
%"class.fastjet::SharedPtr.7" = type { ptr }
%"class.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<fastjet::ClusterSequence::Tile, std::allocator<fastjet::ClusterSequence::Tile>>::_Vector_impl" }
%"struct.std::_Vector_base<fastjet::ClusterSequence::Tile, std::allocator<fastjet::ClusterSequence::Tile>>::_Vector_impl" = type { %"struct.std::_Vector_base<fastjet::ClusterSequence::Tile, std::allocator<fastjet::ClusterSequence::Tile>>::_Vector_impl_data" }
%"struct.std::_Vector_base<fastjet::ClusterSequence::Tile, std::allocator<fastjet::ClusterSequence::Tile>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.fastjet::ClusterSequence::history_element" = type { i32, i32, i32, i32, double, double }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK7fastjet15ClusterSequence16n_exclusive_jetsERKd(ptr noundef nonnull align 8 dereferenceable(276) %0, ptr noundef nonnull align 8 dereferenceable(8) %1) #1 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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %9 = getelementptr inbounds %"class.fastjet::ClusterSequence", ptr %8, i32 0, i32 3
  %10 = call noundef i64 @_ZNKSt6vectorIN7fastjet15ClusterSequence15history_elementESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #2
  %11 = sub i64 %10, 1
  %12 = trunc i64 %11 to i32
  store i32 %12, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %27, %2
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = icmp sge i32 %14, 0
  br i1 %15, label %16, label %30

16:                                               ; preds = %13
  %17 = getelementptr inbounds %"class.fastjet::ClusterSequence", ptr %8, i32 0, i32 3
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNKSt6vectorIN7fastjet15ClusterSequence15history_elementESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %19) #2
  %21 = getelementptr inbounds %"struct.fastjet::ClusterSequence::history_element", ptr %20, i32 0, i32 5
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = fcmp ole double %22, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %16
  br label %30

27:                                               ; preds = %16
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = add nsw i32 %28, -1
  store i32 %29, ptr %5, align 4, !tbaa !9
  br label %13, !llvm.loop !15

30:                                               ; preds = %26, %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %33 = getelementptr inbounds %"class.fastjet::ClusterSequence", ptr %8, i32 0, i32 6
  %34 = load i32, ptr %33, align 4, !tbaa !17
  %35 = mul nsw i32 2, %34
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = sub nsw i32 %35, %36
  store i32 %37, ptr %7, align 4, !tbaa !9
  %38 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %38
}

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 = { 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, !13, i64 24}
!12 = !{!"_ZTSN7fastjet15ClusterSequence15history_elementE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !13, i64 24}
!13 = !{!"double", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !10, i64 140}
!18 = !{!"_ZTSN7fastjet15ClusterSequenceE", !19, i64 8, !27, i64 88, !31, i64 112, !35, i64 136, !10, i64 140, !13, i64 144, !13, i64 152, !13, i64 160, !13, i64 168, !21, i64 176, !20, i64 180, !36, i64 184, !10, i64 192, !35, i64 196, !35, i64 197, !37, i64 200, !38, i64 208, !13, i64 232, !13, i64 240, !13, i64 248, !13, i64 256, !10, i64 264, !10, i64 268, !10, i64 272}
!19 = !{!"_ZTSN7fastjet13JetDefinitionE", !20, i64 0, !13, i64 8, !13, i64 16, !21, i64 24, !6, i64 32, !22, i64 40, !23, i64 48, !6, i64 64, !26, i64 72}
!20 = !{!"_ZTSN7fastjet12JetAlgorithmE", !7, i64 0}
!21 = !{!"_ZTSN7fastjet8StrategyE", !7, i64 0}
!22 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition6PluginEEE", !6, i64 0}
!23 = !{!"_ZTSN7fastjet13JetDefinition17DefaultRecombinerE", !24, i64 0, !25, i64 8}
!24 = !{!"_ZTSN7fastjet13JetDefinition10RecombinerE"}
!25 = !{!"_ZTSN7fastjet19RecombinationSchemeE", !7, i64 0}
!26 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition10RecombinerEEE", !6, i64 0}
!27 = !{!"_ZTSSt6vectorIN7fastjet9PseudoJetESaIS1_EE", !28, i64 0}
!28 = !{!"_ZTSSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE12_Vector_implE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!31 = !{!"_ZTSSt6vectorIN7fastjet15ClusterSequence15history_elementESaIS2_EE", !32, i64 0}
!32 = !{!"_ZTSSt12_Vector_baseIN7fastjet15ClusterSequence15history_elementESaIS2_EE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence15history_elementESaIS2_EE12_Vector_implE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence15history_elementESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!35 = !{!"bool", !7, i64 0}
!36 = !{!"_ZTSN7fastjet9SharedPtrINS_22PseudoJetStructureBaseEEE", !6, i64 0}
!37 = !{!"_ZTSN7fastjet9SharedPtrINS_15ClusterSequence6ExtrasEEE", !6, i64 0}
!38 = !{!"_ZTSSt6vectorIN7fastjet15ClusterSequence4TileESaIS2_EE", !39, i64 0}
!39 = !{!"_ZTSSt12_Vector_baseIN7fastjet15ClusterSequence4TileESaIS2_EE", !40, i64 0}
!40 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence4TileESaIS2_EE12_Vector_implE", !41, i64 0}
!41 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence4TileESaIS2_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"

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK7fastjet15ClusterSequence16n_exclusive_jetsERKd(ptr noundef nonnull align 8 dereferenceable(276) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 112
  %4 = tail call noundef i64 @_ZNKSt6vectorIN7fastjet15ClusterSequence15history_elementESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #2
  %5 = trunc i64 %4 to i32
  %6 = and i64 %4, 4294967295
  %7 = add i32 %5, -1
  %smin = tail call i32 @llvm.smin.i32(i32 %7, i32 -1)
  %8 = add nsw i32 %smin, 1
  br label %9

9:                                                ; preds = %12, %2
  %indvars.iv = phi i64 [ %indvars.iv.next, %12 ], [ %6, %2 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %10 = and i64 %indvars.iv.next, 2147483648
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %12, label %.split.loop.exit8

12:                                               ; preds = %9
  %13 = and i64 %indvars.iv.next, 2147483647
  %14 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNKSt6vectorIN7fastjet15ClusterSequence15history_elementESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %13) #2
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = load double, ptr %1, align 8, !tbaa !11
  %18 = fcmp ugt double %16, %17
  br i1 %18, label %9, label %.split.loop.exit, !llvm.loop !12

.split.loop.exit:                                 ; preds = %12
  %19 = trunc nuw i64 %indvars.iv to i32
  br label %.split.loop.exit8

.split.loop.exit8:                                ; preds = %9, %.split.loop.exit
  %.0.in.lcssa = phi i32 [ %19, %.split.loop.exit ], [ %8, %9 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 140
  %21 = load i32, ptr %20, align 4, !tbaa !14
  %22 = shl nsw i32 %21, 1
  %23 = sub nsw i32 %22, %.0.in.lcssa
  ret i32 %23
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #1

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 speculatable willreturn memory(none) }
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, !10, i64 24}
!6 = !{!"_ZTSN7fastjet15ClusterSequence15history_elementE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !7, i64 140}
!15 = !{!"_ZTSN7fastjet15ClusterSequenceE", !16, i64 8, !25, i64 88, !29, i64 112, !33, i64 136, !7, i64 140, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !18, i64 176, !17, i64 180, !34, i64 184, !7, i64 192, !33, i64 196, !33, i64 197, !35, i64 200, !36, i64 208, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !7, i64 264, !7, i64 268, !7, i64 272}
!16 = !{!"_ZTSN7fastjet13JetDefinitionE", !17, i64 0, !10, i64 8, !10, i64 16, !18, i64 24, !19, i64 32, !20, i64 40, !21, i64 48, !19, i64 64, !24, i64 72}
!17 = !{!"_ZTSN7fastjet12JetAlgorithmE", !8, i64 0}
!18 = !{!"_ZTSN7fastjet8StrategyE", !8, i64 0}
!19 = !{!"any pointer", !8, i64 0}
!20 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition6PluginEEE", !19, i64 0}
!21 = !{!"_ZTSN7fastjet13JetDefinition17DefaultRecombinerE", !22, i64 0, !23, i64 8}
!22 = !{!"_ZTSN7fastjet13JetDefinition10RecombinerE"}
!23 = !{!"_ZTSN7fastjet19RecombinationSchemeE", !8, i64 0}
!24 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition10RecombinerEEE", !19, i64 0}
!25 = !{!"_ZTSSt6vectorIN7fastjet9PseudoJetESaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE12_Vector_implE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIN7fastjet9PseudoJetESaIS1_EE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!29 = !{!"_ZTSSt6vectorIN7fastjet15ClusterSequence15history_elementESaIS2_EE", !30, i64 0}
!30 = !{!"_ZTSSt12_Vector_baseIN7fastjet15ClusterSequence15history_elementESaIS2_EE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence15history_elementESaIS2_EE12_Vector_implE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence15history_elementESaIS2_EE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!33 = !{!"bool", !8, i64 0}
!34 = !{!"_ZTSN7fastjet9SharedPtrINS_22PseudoJetStructureBaseEEE", !19, i64 0}
!35 = !{!"_ZTSN7fastjet9SharedPtrINS_15ClusterSequence6ExtrasEEE", !19, i64 0}
!36 = !{!"_ZTSSt6vectorIN7fastjet15ClusterSequence4TileESaIS2_EE", !37, i64 0}
!37 = !{!"_ZTSSt12_Vector_baseIN7fastjet15ClusterSequence4TileESaIS2_EE", !38, i64 0}
!38 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence4TileESaIS2_EE12_Vector_implE", !39, i64 0}
!39 = !{!"_ZTSNSt12_Vector_baseIN7fastjet15ClusterSequence4TileESaIS2_EE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}


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