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

; 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
define dso_local noundef i32 @_ZN7fastjet23VoronoiDiagramGenerator8PQbucketEPNS_8HalfedgeE(ptr noundef nonnull align 8 dereferenceable(352) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.fastjet::Halfedge", ptr %8, i32 0, i32 6
  %10 = load volatile double, ptr %9, align 8, !tbaa !9
  store double %10, ptr %6, align 8, !tbaa !13
  %11 = load double, ptr %6, align 8, !tbaa !13
  %12 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 13
  %13 = load double, ptr %12, align 8, !tbaa !14
  %14 = fcmp olt double %11, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %48

16:                                               ; preds = %2
  %17 = load double, ptr %6, align 8, !tbaa !13
  %18 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 14
  %19 = load double, ptr %18, align 8, !tbaa !18
  %20 = fcmp oge double %17, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %16
  %22 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 26
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %24 = sub nsw i32 %23, 1
  store i32 %24, ptr %5, align 4, !tbaa !17
  br label %47

25:                                               ; preds = %16
  %26 = load double, ptr %6, align 8, !tbaa !13
  %27 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 13
  %28 = load double, ptr %27, align 8, !tbaa !14
  %29 = fsub double %26, %28
  %30 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 16
  %31 = load double, ptr %30, align 8, !tbaa !20
  %32 = fdiv double %29, %31
  %33 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 26
  %34 = load i32, ptr %33, align 8, !tbaa !19
  %35 = sitofp i32 %34 to double
  %36 = fmul double %32, %35
  %37 = fptosi double %36 to i32
  store i32 %37, ptr %5, align 4, !tbaa !17
  %38 = load i32, ptr %5, align 4, !tbaa !17
  %39 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 26
  %40 = load i32, ptr %39, align 8, !tbaa !19
  %41 = icmp sge i32 %38, %40
  br i1 %41, label %42, label %46

42:                                               ; preds = %25
  %43 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 26
  %44 = load i32, ptr %43, align 8, !tbaa !19
  %45 = sub nsw i32 %44, 1
  store i32 %45, ptr %5, align 4, !tbaa !17
  br label %46

46:                                               ; preds = %42, %25
  br label %47

47:                                               ; preds = %46, %21
  br label %48

48:                                               ; preds = %47, %15
  %49 = load i32, ptr %5, align 4, !tbaa !17
  %50 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 29
  %51 = load i32, ptr %50, align 4, !tbaa !21
  %52 = icmp slt i32 %49, %51
  br i1 %52, label %53, label %56

53:                                               ; preds = %48
  %54 = load i32, ptr %5, align 4, !tbaa !17
  %55 = getelementptr inbounds %"class.fastjet::VoronoiDiagramGenerator", ptr %7, i32 0, i32 29
  store i32 %54, ptr %55, align 4, !tbaa !21
  br label %56

56:                                               ; preds = %53, %48
  %57 = load i32, ptr %5, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %57
}

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


; 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 nofree norecurse nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local noundef i32 @_ZN7fastjet23VoronoiDiagramGenerator8PQbucketEPNS_8HalfedgeE(ptr nocapture noundef nonnull align 8 dereferenceable(352) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 40
  %4 = load volatile double, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  %6 = load double, ptr %5, align 8, !tbaa !12
  %7 = fcmp olt double %4, %6
  br i1 %7, label %27, label %8

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  %10 = load double, ptr %9, align 8, !tbaa !15
  %11 = fcmp ult double %4, %10
  br i1 %11, label %16, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %0, i64 200
  %14 = load i32, ptr %13, align 8, !tbaa !16
  %15 = add nsw i32 %14, -1
  br label %27

16:                                               ; preds = %8
  %17 = fsub double %4, %6
  %18 = getelementptr inbounds i8, ptr %0, i64 120
  %19 = load double, ptr %18, align 8, !tbaa !17
  %20 = fdiv double %17, %19
  %21 = getelementptr inbounds i8, ptr %0, i64 200
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = sitofp i32 %22 to double
  %24 = fmul double %20, %23
  %25 = fptosi double %24 to i32
  %.not = icmp sgt i32 %22, %25
  %26 = add nsw i32 %22, -1
  %spec.select = select i1 %.not, i32 %25, i32 %26
  br label %27

27:                                               ; preds = %16, %2, %12
  %.0 = phi i32 [ %15, %12 ], [ 0, %2 ], [ %spec.select, %16 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 220
  %29 = load i32, ptr %28, align 4, !tbaa !18
  %30 = icmp slt i32 %.0, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  store i32 %.0, ptr %28, align 4, !tbaa !18
  br label %32

32:                                               ; preds = %31, %27
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) 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, !11, i64 40}
!6 = !{!"_ZTSN7fastjet8HalfedgeE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !8, i64 28, !7, i64 32, !11, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!13, !11, i64 96}
!13 = !{!"_ZTSN7fastjet23VoronoiDiagramGeneratorE", !7, i64 0, !10, i64 8, !7, i64 16, !14, i64 24, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !7, i64 128, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !14, i64 152, !7, i64 168, !10, i64 176, !14, i64 184, !10, i64 200, !7, i64 208, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !11, i64 232, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !10, i64 272, !11, i64 280, !11, i64 288, !11, i64 296, !11, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !11, i64 344}
!14 = !{!"_ZTSN7fastjet8FreelistE", !7, i64 0, !10, i64 8}
!15 = !{!13, !11, i64 104}
!16 = !{!13, !10, i64 200}
!17 = !{!13, !11, i64 120}
!18 = !{!13, !10, i64 220}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass