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

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

@_ZN7fastjet8fwrapper4jetsE = external dso_local global %"class.std::vector", align 8

; 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 @_ZN7fastjet8fwrapper13transfer_jetsEPdRi(ptr noundef %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #1 {
  %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 = call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN7fastjet8fwrapper4jetsE) #4
  %9 = trunc i64 %8 to i32
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 %9, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %35, %2
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %31, %17
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = icmp sle i32 %19, 3
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %18
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 8 dereferenceable(88) ptr @_ZNSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZN7fastjet8fwrapper4jetsE, i64 noundef %24) #4
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = call noundef double @_ZNK7fastjet9PseudoJetixEi(ptr noundef nonnull align 8 dereferenceable(88) %25, i32 noundef %26)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  store double %27, ptr %28, align 8, !tbaa !11
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i32 1
  store ptr %30, ptr %3, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %22
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %7, align 4, !tbaa !9
  br label %18, !llvm.loop !13

34:                                               ; preds = %21
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !15

38:                                               ; preds = %16
  ret void
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7fastjet9PseudoJetixEi(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef) #3 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 = { inlinehint 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 #4 = { 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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@_ZN7fastjet8fwrapper4jetsE = external dso_local global %"class.std::vector", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7fastjet8fwrapper13transfer_jetsEPdRi(ptr nocapture noundef writeonly %0, ptr nocapture noundef nonnull align 4 dereferenceable(4) %1) local_unnamed_addr #0 {
  %3 = tail call noundef i64 @_ZNKSt6vectorIN7fastjet9PseudoJetESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN7fastjet8fwrapper4jetsE) #3
  %4 = trunc i64 %3 to i32
  store i32 %4, ptr %1, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.preheader, label %._crit_edge

.preheader:                                       ; preds = %2, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %2 ]
  %.01013 = phi ptr [ %17, %.preheader ], [ %0, %2 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(88) ptr @_ZNSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZN7fastjet8fwrapper4jetsE, i64 noundef %indvars.iv) #3
  %7 = tail call noundef double @_ZNK7fastjet9PseudoJetixEi(ptr noundef nonnull align 8 dereferenceable(88) %6, i32 noundef 0)
  store double %7, ptr %.01013, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %.01013, i64 8
  %9 = tail call noundef nonnull align 8 dereferenceable(88) ptr @_ZNSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZN7fastjet8fwrapper4jetsE, i64 noundef %indvars.iv) #3
  %10 = tail call noundef double @_ZNK7fastjet9PseudoJetixEi(ptr noundef nonnull align 8 dereferenceable(88) %9, i32 noundef 1)
  store double %10, ptr %8, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %.01013, i64 16
  %12 = tail call noundef nonnull align 8 dereferenceable(88) ptr @_ZNSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZN7fastjet8fwrapper4jetsE, i64 noundef %indvars.iv) #3
  %13 = tail call noundef double @_ZNK7fastjet9PseudoJetixEi(ptr noundef nonnull align 8 dereferenceable(88) %12, i32 noundef 2)
  store double %13, ptr %11, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %.01013, i64 24
  %15 = tail call noundef nonnull align 8 dereferenceable(88) ptr @_ZNSt6vectorIN7fastjet9PseudoJetESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @_ZN7fastjet8fwrapper4jetsE, i64 noundef %indvars.iv) #3
  %16 = tail call noundef double @_ZNK7fastjet9PseudoJetixEi(ptr noundef nonnull align 8 dereferenceable(88) %15, i32 noundef 3)
  store double %16, ptr %14, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %.01013, i64 32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.preheader, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.preheader, %2
  ret void
}

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

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

attributes #0 = { 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 #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 = { inlinehint 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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