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

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

@.str.2 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [146 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7fastjet23BackgroundEstimatorBase11_percentileERKSt6vectorIdSaIdEEddb = external hidden unnamed_addr constant [123 x i8], align 1

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

; 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 nounwind uwtable
define dso_local noundef double @_ZNK7fastjet23BackgroundEstimatorBase11_percentileERKSt6vectorIdSaIdEEddb(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, double noundef %2, double noundef %3, i1 noundef zeroext %4) #0 align 2 {
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store double %2, ptr %9, align 8, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !9
  %18 = zext i1 %4 to i8
  store i8 %18, ptr %11, align 1, !tbaa !11
  %19 = load ptr, ptr %7, align 8
  %20 = load double, ptr %9, align 8, !tbaa !9
  %21 = fcmp oge double %20, 0.000000e+00
  br i1 %21, label %22, label %25

22:                                               ; preds = %5
  %23 = load double, ptr %9, align 8, !tbaa !9
  %24 = fcmp ole double %23, 1.000000e+00
  br label %25

25:                                               ; preds = %22, %5
  %26 = phi i1 [ false, %5 ], [ %24, %22 ]
  br i1 %26, label %27, label %28

27:                                               ; preds = %25
  br label %30

28:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 98, ptr noundef @__PRETTY_FUNCTION__._ZNK7fastjet23BackgroundEstimatorBase11_percentileERKSt6vectorIdSaIdEEddb) #4
  unreachable

29:                                               ; No predecessors!
  br label %30

30:                                               ; preds = %29, %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %31) #5
  %33 = trunc i64 %32 to i32
  store i32 %33, ptr %12, align 4, !tbaa !13
  %34 = load i32, ptr %12, align 4, !tbaa !13
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store double 0.000000e+00, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %118

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %38 = load i32, ptr %12, align 4, !tbaa !13
  %39 = sitofp i32 %38 to double
  %40 = load double, ptr %10, align 8, !tbaa !9
  %41 = fadd double %39, %40
  store double %41, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %42 = load i8, ptr %11, align 1, !tbaa !11, !range !15, !noundef !16
  %43 = trunc i8 %42 to i1
  br i1 %43, label %44, label %51

44:                                               ; preds = %37
  %45 = load double, ptr %14, align 8, !tbaa !9
  %46 = fsub double %45, 1.000000e+00
  %47 = load double, ptr %9, align 8, !tbaa !9
  %48 = load double, ptr %10, align 8, !tbaa !9
  %49 = fneg double %48
  %50 = call double @llvm.fmuladd.f64(double %46, double %47, double %49)
  store double %50, ptr %15, align 8, !tbaa !9
  br label %58

51:                                               ; preds = %37
  %52 = load double, ptr %14, align 8, !tbaa !9
  %53 = load double, ptr %9, align 8, !tbaa !9
  %54 = load double, ptr %10, align 8, !tbaa !9
  %55 = fneg double %54
  %56 = call double @llvm.fmuladd.f64(double %52, double %53, double %55)
  %57 = fsub double %56, 5.000000e-01
  store double %57, ptr %15, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %51, %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %59 = load double, ptr %15, align 8, !tbaa !9
  %60 = fcmp oge double %59, 0.000000e+00
  br i1 %60, label %61, label %101

61:                                               ; preds = %58
  %62 = load i32, ptr %12, align 4, !tbaa !13
  %63 = icmp sgt i32 %62, 1
  br i1 %63, label %64, label %101

64:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %65 = load double, ptr %15, align 8, !tbaa !9
  %66 = fptosi double %65 to i32
  store i32 %66, ptr %17, align 4, !tbaa !13
  %67 = load i32, ptr %17, align 4, !tbaa !13
  %68 = add nsw i32 %67, 1
  %69 = load i32, ptr %12, align 4, !tbaa !13
  %70 = sub nsw i32 %69, 1
  %71 = icmp sgt i32 %68, %70
  br i1 %71, label %72, label %78

72:                                               ; preds = %64
  %73 = load i32, ptr %12, align 4, !tbaa !13
  %74 = sub nsw i32 %73, 2
  store i32 %74, ptr %17, align 4, !tbaa !13
  %75 = load i32, ptr %12, align 4, !tbaa !13
  %76 = sub nsw i32 %75, 1
  %77 = sitofp i32 %76 to double
  store double %77, ptr %15, align 8, !tbaa !9
  br label %78

78:                                               ; preds = %72, %64
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load i32, ptr %17, align 4, !tbaa !13
  %81 = sext i32 %80 to i64
  %82 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %79, i64 noundef %81) #5
  %83 = load double, ptr %82, align 8, !tbaa !9
  %84 = load i32, ptr %17, align 4, !tbaa !13
  %85 = add nsw i32 %84, 1
  %86 = sitofp i32 %85 to double
  %87 = load double, ptr %15, align 8, !tbaa !9
  %88 = fsub double %86, %87
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load i32, ptr %17, align 4, !tbaa !13
  %91 = add nsw i32 %90, 1
  %92 = sext i32 %91 to i64
  %93 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %89, i64 noundef %92) #5
  %94 = load double, ptr %93, align 8, !tbaa !9
  %95 = load double, ptr %15, align 8, !tbaa !9
  %96 = load i32, ptr %17, align 4, !tbaa !13
  %97 = sitofp i32 %96 to double
  %98 = fsub double %95, %97
  %99 = fmul double %94, %98
  %100 = call double @llvm.fmuladd.f64(double %83, double %88, double %99)
  store double %100, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %116

101:                                              ; preds = %61, %58
  %102 = load double, ptr %15, align 8, !tbaa !9
  %103 = fcmp ogt double %102, -5.000000e-01
  br i1 %103, label %104, label %114

104:                                              ; preds = %101
  %105 = load i32, ptr %12, align 4, !tbaa !13
  %106 = icmp sge i32 %105, 1
  br i1 %106, label %107, label %114

107:                                              ; preds = %104
  %108 = load i8, ptr %11, align 1, !tbaa !11, !range !15, !noundef !16
  %109 = trunc i8 %108 to i1
  br i1 %109, label %114, label %110

110:                                              ; preds = %107
  %111 = load ptr, ptr %8, align 8, !tbaa !5
  %112 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %111, i64 noundef 0) #5
  %113 = load double, ptr %112, align 8, !tbaa !9
  store double %113, ptr %16, align 8, !tbaa !9
  br label %115

114:                                              ; preds = %107, %104, %101
  store double 0.000000e+00, ptr %16, align 8, !tbaa !9
  br label %115

115:                                              ; preds = %114, %110
  br label %116

116:                                              ; preds = %115, %78
  %117 = load double, ptr %16, align 8, !tbaa !9
  store double %117, ptr %6, align 8
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %118

118:                                              ; preds = %116, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %119 = load double, ptr %6, align 8
  ret double %119
}

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

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

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

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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { noreturn nounwind }
attributes #5 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{i8 0, i8 2}
!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"

@.str.2 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [146 x i8], align 1
@__PRETTY_FUNCTION__._ZNK7fastjet23BackgroundEstimatorBase11_percentileERKSt6vectorIdSaIdEEddb = external hidden unnamed_addr constant [123 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK7fastjet23BackgroundEstimatorBase11_percentileERKSt6vectorIdSaIdEEddb(ptr nocapture noundef nonnull readnone align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, double noundef %2, double noundef %3, i1 noundef zeroext %4) local_unnamed_addr #0 align 2 {
  %6 = fcmp oge double %2, 0.000000e+00
  %7 = fcmp ole double %2, 1.000000e+00
  %8 = and i1 %6, %7
  br i1 %8, label %10, label %9

9:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 98, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK7fastjet23BackgroundEstimatorBase11_percentileERKSt6vectorIdSaIdEEddb) #3
  unreachable

10:                                               ; preds = %5
  %11 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %12 = trunc i64 %11 to i32
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %52, label %14

14:                                               ; preds = %10
  %15 = sitofp i32 %12 to double
  %16 = fadd double %15, %3
  br i1 %4, label %17, label %21

17:                                               ; preds = %14
  %18 = fadd double %16, -1.000000e+00
  %19 = fneg double %3
  %20 = tail call double @llvm.fmuladd.f64(double %18, double %2, double %19)
  br label %25

21:                                               ; preds = %14
  %22 = fneg double %3
  %23 = tail call double @llvm.fmuladd.f64(double %16, double %2, double %22)
  %24 = fadd double %23, -5.000000e-01
  br label %25

25:                                               ; preds = %21, %17
  %.038 = phi double [ %20, %17 ], [ %24, %21 ]
  %26 = fcmp oge double %.038, 0.000000e+00
  %27 = icmp sgt i32 %12, 1
  %or.cond = and i1 %27, %26
  br i1 %or.cond, label %28, label %46

28:                                               ; preds = %25
  %29 = fptosi double %.038 to i32
  %30 = add nsw i32 %12, -1
  %.not = icmp sgt i32 %30, %29
  %31 = add nsw i32 %12, -2
  %32 = uitofp nneg i32 %30 to double
  %.1 = select i1 %.not, double %.038, double %32
  %.0 = select i1 %.not, i32 %29, i32 %31
  %33 = sext i32 %.0 to i64
  %34 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %33) #4
  %35 = load double, ptr %34, align 8, !tbaa !5
  %36 = add nsw i32 %.0, 1
  %37 = sitofp i32 %36 to double
  %38 = fsub double %37, %.1
  %39 = sext i32 %36 to i64
  %40 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %39) #4
  %41 = load double, ptr %40, align 8, !tbaa !5
  %42 = sitofp i32 %.0 to double
  %43 = fsub double %.1, %42
  %44 = fmul double %43, %41
  %45 = tail call double @llvm.fmuladd.f64(double %35, double %38, double %44)
  br label %52

46:                                               ; preds = %25
  %47 = fcmp ule double %.038, -5.000000e-01
  %48 = icmp slt i32 %12, 1
  %or.cond3.not45 = or i1 %48, %47
  %brmerge = or i1 %or.cond3.not45, %4
  br i1 %brmerge, label %52, label %49

49:                                               ; preds = %46
  %50 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #4
  %51 = load double, ptr %50, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %28, %49, %46, %10
  %.039 = phi double [ 0.000000e+00, %10 ], [ %45, %28 ], [ %51, %49 ], [ 0.000000e+00, %46 ]
  ret double %.039
}

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

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

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

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { noreturn nounwind }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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