; LLVM IR from mickypaganini/SSI2016-jet-clustering :: spartyjet-4.0.2_mac/External/fastjet-3.0.0/plugins/GridJet (GridJetPlugin)

; 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::GridJetPlugin" = type { %"class.fastjet::JetDefinition::Plugin", double, double, double, double, double, i32, i32, i32, %"class.fastjet::JetDefinition" }
%"class.fastjet::JetDefinition::Plugin" = type { ptr }
%"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 }

@.str.1 = external hidden unnamed_addr constant [146 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE = external hidden unnamed_addr constant [59 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(88) %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call noundef double @_ZNK7fastjet9PseudoJet3rapEv(ptr noundef nonnull align 8 dereferenceable(88) %11)
  %13 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 1
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = fsub double %12, %14
  %16 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 3
  %17 = load double, ptr %16, align 8, !tbaa !22
  %18 = fdiv double %15, %17
  %19 = call double @llvm.floor.f64(double %18)
  %20 = fptosi double %19 to i32
  store i32 %20, ptr %6, align 4, !tbaa !23
  %21 = load i32, ptr %6, align 4, !tbaa !23
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %28, label %23

23:                                               ; preds = %2
  %24 = load i32, ptr %6, align 4, !tbaa !23
  %25 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 6
  %26 = load i32, ptr %25, align 8, !tbaa !24
  %27 = icmp sge i32 %24, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %23, %2
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %78

29:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call noundef double @_ZNK7fastjet9PseudoJet3phiEv(ptr noundef nonnull align 8 dereferenceable(88) %30)
  %32 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 4
  %33 = load double, ptr %32, align 8, !tbaa !25
  %34 = fdiv double %31, %33
  %35 = fptosi double %34 to i32
  store i32 %35, ptr %8, align 4, !tbaa !23
  %36 = load i32, ptr %8, align 4, !tbaa !23
  %37 = icmp sge i32 %36, 0
  br i1 %37, label %38, label %43

38:                                               ; preds = %29
  %39 = load i32, ptr %8, align 4, !tbaa !23
  %40 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 7
  %41 = load i32, ptr %40, align 4, !tbaa !26
  %42 = icmp sle i32 %39, %41
  br label %43

43:                                               ; preds = %38, %29
  %44 = phi i1 [ false, %29 ], [ %42, %38 ]
  br i1 %44, label %45, label %46

45:                                               ; preds = %43
  br label %48

46:                                               ; preds = %43
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 103, ptr noundef @__PRETTY_FUNCTION__._ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE) #6
  unreachable

47:                                               ; No predecessors!
  br label %48

48:                                               ; preds = %47, %45
  %49 = load i32, ptr %8, align 4, !tbaa !23
  %50 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 7
  %51 = load i32, ptr %50, align 4, !tbaa !26
  %52 = icmp eq i32 %49, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  store i32 0, ptr %8, align 4, !tbaa !23
  br label %54

54:                                               ; preds = %53, %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %55 = load i32, ptr %6, align 4, !tbaa !23
  %56 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 7
  %57 = load i32, ptr %56, align 4, !tbaa !26
  %58 = mul nsw i32 %55, %57
  %59 = load i32, ptr %8, align 4, !tbaa !23
  %60 = add nsw i32 %58, %59
  store i32 %60, ptr %9, align 4, !tbaa !23
  %61 = load i32, ptr %9, align 4, !tbaa !23
  %62 = icmp sge i32 %61, 0
  br i1 %62, label %63, label %71

63:                                               ; preds = %54
  %64 = load i32, ptr %9, align 4, !tbaa !23
  %65 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 6
  %66 = load i32, ptr %65, align 8, !tbaa !24
  %67 = getelementptr inbounds %"class.fastjet::GridJetPlugin", ptr %10, i32 0, i32 7
  %68 = load i32, ptr %67, align 4, !tbaa !26
  %69 = mul nsw i32 %66, %68
  %70 = icmp slt i32 %64, %69
  br label %71

71:                                               ; preds = %63, %54
  %72 = phi i1 [ false, %54 ], [ %70, %63 ]
  br i1 %72, label %73, label %74

73:                                               ; preds = %71
  br label %76

74:                                               ; preds = %71
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 107, ptr noundef @__PRETTY_FUNCTION__._ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE) #6
  unreachable

75:                                               ; No predecessors!
  br label %76

76:                                               ; preds = %75, %73
  %77 = load i32, ptr %9, align 4, !tbaa !23
  store i32 %77, ptr %3, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %78

78:                                               ; preds = %76, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %79 = load i32, ptr %3, align 4
  ret i32 %79
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7fastjet9PseudoJet3rapEv(ptr noundef nonnull align 8 dereferenceable(88)) #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK7fastjet9PseudoJet3phiEv(ptr noundef nonnull align 8 dereferenceable(88)) #3 align 2

attributes #0 = { noreturn nounwind "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 willreturn memory(argmem: readwrite) }
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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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 8}
!10 = !{!"_ZTSN7fastjet13GridJetPluginE", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !13, i64 48, !13, i64 52, !13, i64 56, !14, i64 64}
!11 = !{!"_ZTSN7fastjet13JetDefinition6PluginE"}
!12 = !{!"double", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN7fastjet13JetDefinitionE", !15, i64 0, !12, i64 8, !12, i64 16, !16, i64 24, !6, i64 32, !17, i64 40, !18, i64 48, !6, i64 64, !21, i64 72}
!15 = !{!"_ZTSN7fastjet12JetAlgorithmE", !7, i64 0}
!16 = !{!"_ZTSN7fastjet8StrategyE", !7, i64 0}
!17 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition6PluginEEE", !6, i64 0}
!18 = !{!"_ZTSN7fastjet13JetDefinition17DefaultRecombinerE", !19, i64 0, !20, i64 8}
!19 = !{!"_ZTSN7fastjet13JetDefinition10RecombinerE"}
!20 = !{!"_ZTSN7fastjet19RecombinationSchemeE", !7, i64 0}
!21 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition10RecombinerEEE", !6, i64 0}
!22 = !{!10, !12, i64 24}
!23 = !{!13, !13, i64 0}
!24 = !{!10, !13, i64 48}
!25 = !{!10, !12, i64 32}
!26 = !{!10, !13, i64 52}


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

@.str.1 = external hidden unnamed_addr constant [146 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE = external hidden unnamed_addr constant [59 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -1, -2147483648) i32 @_ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(88) %1) local_unnamed_addr #1 align 2 {
  %3 = tail call noundef double @_ZNK7fastjet9PseudoJet3rapEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fsub double %3, %5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load double, ptr %7, align 8, !tbaa !21
  %9 = fdiv double %6, %8
  %10 = tail call double @llvm.floor.f64(double %9)
  %11 = fptosi double %10 to i32
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %33, label %13

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = load i32, ptr %14, align 8, !tbaa !22
  %.not = icmp sgt i32 %15, %11
  br i1 %.not, label %16, label %33

16:                                               ; preds = %13
  %17 = tail call noundef double @_ZNK7fastjet9PseudoJet3phiEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = load double, ptr %18, align 8, !tbaa !23
  %20 = fdiv double %17, %19
  %21 = fptosi double %20 to i32
  %22 = icmp sgt i32 %21, -1
  br i1 %22, label %23, label %.critedge

23:                                               ; preds = %16
  %24 = getelementptr inbounds i8, ptr %0, i64 52
  %25 = load i32, ptr %24, align 4, !tbaa !24
  %.not19 = icmp slt i32 %25, %21
  br i1 %.not19, label %.critedge, label %26

.critedge:                                        ; preds = %16, %23
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 103, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE) #4
  unreachable

26:                                               ; preds = %23
  %27 = icmp eq i32 %25, %21
  %spec.store.select = select i1 %27, i32 0, i32 %21
  %28 = mul nsw i32 %25, %11
  %29 = add nuw nsw i32 %spec.store.select, %28
  %30 = load i32, ptr %14, align 8, !tbaa !22
  %31 = mul nsw i32 %30, %25
  %32 = icmp slt i32 %29, %31
  br i1 %32, label %33, label %.critedge2

.critedge2:                                       ; preds = %26
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 107, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK7fastjet13GridJetPlugin5igridERKNS_9PseudoJetE) #4
  unreachable

33:                                               ; preds = %26, %2, %13
  %.0 = phi i32 [ -1, %13 ], [ -1, %2 ], [ %29, %26 ]
  ret i32 %.0
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

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

attributes #0 = { noreturn nounwind "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 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { noreturn 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, !8, i64 8}
!6 = !{!"_ZTSN7fastjet13GridJetPluginE", !7, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !12, i64 64}
!7 = !{!"_ZTSN7fastjet13JetDefinition6PluginE"}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTSN7fastjet13JetDefinitionE", !13, i64 0, !8, i64 8, !8, i64 16, !14, i64 24, !15, i64 32, !16, i64 40, !17, i64 48, !15, i64 64, !20, i64 72}
!13 = !{!"_ZTSN7fastjet12JetAlgorithmE", !9, i64 0}
!14 = !{!"_ZTSN7fastjet8StrategyE", !9, i64 0}
!15 = !{!"any pointer", !9, i64 0}
!16 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition6PluginEEE", !15, i64 0}
!17 = !{!"_ZTSN7fastjet13JetDefinition17DefaultRecombinerE", !18, i64 0, !19, i64 8}
!18 = !{!"_ZTSN7fastjet13JetDefinition10RecombinerE"}
!19 = !{!"_ZTSN7fastjet19RecombinationSchemeE", !9, i64 0}
!20 = !{!"_ZTSN7fastjet9SharedPtrIKNS_13JetDefinition10RecombinerEEE", !15, i64 0}
!21 = !{!6, !8, i64 24}
!22 = !{!6, !11, i64 48}
!23 = !{!6, !8, i64 32}
!24 = !{!6, !11, i64 52}


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