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

; 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::VoronoiDiagramGenerator" = type { ptr, i32, ptr, %"class.fastjet::Freelist", ptr, ptr, i32, i32, i32, i32, i32, double, double, double, double, double, double, ptr, i32, i32, i32, i32, %"class.fastjet::Freelist", ptr, i32, %"class.fastjet::Freelist", i32, ptr, i32, i32, i32, i32, double, double, double, double, double, i32, double, double, double, double, ptr, ptr, ptr, ptr, double }
%"class.fastjet::Freelist" = type { ptr, i32 }
%"class.fastjet::Halfedge" = type { ptr, ptr, ptr, i32, i8, ptr, double, ptr }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7fastjet23VoronoiDiagramGenerator7myallocEj(ptr noundef nonnull align 8 dereferenceable(352), i32 noundef) #1 align 2

; 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 noundef zeroext i1 @_ZN7fastjet23VoronoiDiagramGenerator12PQinitializeEv(ptr noundef nonnull align 8 dereferenceable(352) %0) #2 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %7 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 28
  store i32 0, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 29
  store i32 0, ptr %8, align 4, !tbaa !14
  %9 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 20
  %10 = load i32, ptr %9, align 8, !tbaa !15
  %11 = mul nsw i32 4, %10
  %12 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 26
  store i32 %11, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 26
  %14 = load i32, ptr %13, align 8, !tbaa !16
  %15 = sext i32 %14 to i64
  %16 = mul i64 %15, 56
  %17 = trunc i64 %16 to i32
  %18 = call noundef ptr @_ZN7fastjet23VoronoiDiagramGenerator7myallocEj(ptr noundef nonnull align 8 dereferenceable(352) %6, i32 noundef %17)
  %19 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 27
  store ptr %18, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 27
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %41

24:                                               ; preds = %1
  store i32 0, ptr %4, align 4, !tbaa !18
  br label %25

25:                                               ; preds = %37, %24
  %26 = load i32, ptr %4, align 4, !tbaa !18
  %27 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 26
  %28 = load i32, ptr %27, align 8, !tbaa !16
  %29 = icmp slt i32 %26, %28
  br i1 %29, label %30, label %40

30:                                               ; preds = %25
  %31 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %6, i32 0, i32 27
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = load i32, ptr %4, align 4, !tbaa !18
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %32, i64 %34
  %36 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %35, i32 0, i32 7
  store ptr null, ptr %36, align 8, !tbaa !19
  br label %37

37:                                               ; preds = %30
  %38 = load i32, ptr %4, align 4, !tbaa !18
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !18
  br label %25, !llvm.loop !21

40:                                               ; preds = %25
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %41

41:                                               ; preds = %40, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %42 = load i1, ptr %2, align 1
  ret i1 %42
}

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 = { 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, !11, i64 216}
!10 = !{!"_ZTSN7fastjet23VoronoiDiagramGeneratorE", !6, i64 0, !11, i64 8, !6, i64 16, !12, i64 24, !6, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !6, i64 128, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !12, i64 152, !6, i64 168, !11, i64 176, !12, i64 184, !11, i64 200, !6, i64 208, !11, i64 216, !11, i64 220, !11, i64 224, !11, i64 228, !13, i64 232, !13, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !11, i64 272, !13, i64 280, !13, i64 288, !13, i64 296, !13, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !13, i64 344}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN7fastjet8FreelistE", !6, i64 0, !11, i64 8}
!13 = !{!"double", !7, i64 0}
!14 = !{!10, !11, i64 220}
!15 = !{!10, !11, i64 144}
!16 = !{!10, !11, i64 200}
!17 = !{!10, !6, i64 208}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !6, i64 48}
!20 = !{!"_ZTSN7fastjet8HalfedgeE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !7, i64 28, !6, i64 32, !13, i64 40, !6, i64 48}
!21 = distinct !{!21, !22}
!22 = !{!"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.fastjet::Halfedge" = type { ptr, ptr, ptr, i32, i8, ptr, double, ptr }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN7fastjet23VoronoiDiagramGenerator12PQinitializeEv(ptr noundef nonnull align 8 dereferenceable(352) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 216
  store i32 0, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 220
  store i32 0, ptr %3, align 4, !tbaa !13
  %4 = getelementptr inbounds i8, ptr %0, i64 144
  %5 = load i32, ptr %4, align 8, !tbaa !14
  %6 = shl nsw i32 %5, 2
  %7 = getelementptr inbounds i8, ptr %0, i64 200
  store i32 %6, ptr %7, align 8, !tbaa !15
  %8 = mul i32 %5, 224
  %9 = tail call noundef ptr @_ZN7fastjet23VoronoiDiagramGenerator7myallocEj(ptr noundef nonnull align 8 dereferenceable(352) %0, i32 noundef %8)
  %10 = getelementptr inbounds i8, ptr %0, i64 208
  store ptr %9, ptr %10, align 8, !tbaa !16
  %11 = icmp ne ptr %9, null
  br i1 %11, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %1
  %12 = load i32, ptr %7, align 8, !tbaa !15
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %12 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %14 = icmp ult i32 %12, 4
  br i1 %14, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %15 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %9, i64 %indvars.iv, i32 7
  store ptr null, ptr %15, align 8, !tbaa !17
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %16 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %9, i64 %indvars.iv.next, i32 7
  store ptr null, ptr %16, align 8, !tbaa !17
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %17 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %9, i64 %indvars.iv.next.1, i32 7
  store ptr null, ptr %17, align 8, !tbaa !17
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %18 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %9, i64 %indvars.iv.next.2, i32 7
  store ptr null, ptr %18, align 8, !tbaa !17
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !19

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %19 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %9, i64 %indvars.iv.epil, i32 7
  store ptr null, ptr %19, align 8, !tbaa !17
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.lr.ph.epil, !llvm.loop !21

.loopexit:                                        ; preds = %.loopexit.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader, %1
  ret i1 %11
}

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

!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 216}
!6 = !{!"_ZTSN7fastjet23VoronoiDiagramGeneratorE", !7, i64 0, !10, i64 8, !7, i64 16, !11, i64 24, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !7, i64 128, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !11, i64 152, !7, i64 168, !10, i64 176, !11, i64 184, !10, i64 200, !7, i64 208, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !12, i64 232, !12, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !10, i64 272, !12, i64 280, !12, i64 288, !12, i64 296, !12, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !12, i64 344}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSN7fastjet8FreelistE", !7, i64 0, !10, i64 8}
!12 = !{!"double", !8, i64 0}
!13 = !{!6, !10, i64 220}
!14 = !{!6, !10, i64 144}
!15 = !{!6, !10, i64 200}
!16 = !{!6, !7, i64 208}
!17 = !{!18, !7, i64 48}
!18 = !{!"_ZTSN7fastjet8HalfedgeE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !8, i64 28, !7, i64 32, !12, i64 40, !7, i64 48}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.unroll.disable"}


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