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

; 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::RangeDefinition" = type { ptr, double, double, double, double, double, double, double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7fastjet15RangeDefinition21_numerical_total_areaEdi(ptr noundef nonnull align 8 dereferenceable(72) %0, double noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %15 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %16 = load i32, ptr %6, align 4, !tbaa !11
  %17 = sitofp i32 %16 to double
  %18 = fdiv double 0x401921FB54442D18, %17
  store double %18, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %19 = load double, ptr %5, align 8, !tbaa !9
  %20 = fmul double 2.000000e+00, %19
  %21 = load i32, ptr %6, align 4, !tbaa !11
  %22 = sitofp i32 %21 to double
  %23 = fdiv double %20, %22
  store double %23, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store double 0.000000e+00, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %58, %3
  %25 = load i32, ptr %11, align 4, !tbaa !11
  %26 = load i32, ptr %6, align 4, !tbaa !11
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %61

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %30 = load double, ptr %5, align 8, !tbaa !9
  %31 = fneg double %30
  store double %31, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %32

32:                                               ; preds = %51, %29
  %33 = load i32, ptr %14, align 4, !tbaa !11
  %34 = load i32, ptr %6, align 4, !tbaa !11
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %54

37:                                               ; preds = %32
  %38 = load double, ptr %13, align 8, !tbaa !9
  %39 = load double, ptr %10, align 8, !tbaa !9
  %40 = load ptr, ptr %15, align 8, !tbaa !13
  %41 = getelementptr inbounds ptr, ptr %40, i64 3
  %42 = load ptr, ptr %41, align 8
  %43 = call noundef zeroext i1 %42(ptr noundef nonnull align 8 dereferenceable(72) %15, double noundef %38, double noundef %39)
  br i1 %43, label %44, label %47

44:                                               ; preds = %37
  %45 = load i32, ptr %7, align 4, !tbaa !11
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %7, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %44, %37
  %48 = load double, ptr %9, align 8, !tbaa !9
  %49 = load double, ptr %13, align 8, !tbaa !9
  %50 = fadd double %49, %48
  store double %50, ptr %13, align 8, !tbaa !9
  br label %51

51:                                               ; preds = %47
  %52 = load i32, ptr %14, align 4, !tbaa !11
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %14, align 4, !tbaa !11
  br label %32, !llvm.loop !15

54:                                               ; preds = %36
  %55 = load double, ptr %8, align 8, !tbaa !9
  %56 = load double, ptr %10, align 8, !tbaa !9
  %57 = fadd double %56, %55
  store double %57, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  br label %58

58:                                               ; preds = %54
  %59 = load i32, ptr %11, align 4, !tbaa !11
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %11, align 4, !tbaa !11
  br label %24, !llvm.loop !17

61:                                               ; preds = %28
  %62 = load i32, ptr %7, align 4, !tbaa !11
  %63 = sitofp i32 %62 to double
  %64 = load i32, ptr %6, align 4, !tbaa !11
  %65 = load i32, ptr %6, align 4, !tbaa !11
  %66 = mul nsw i32 %64, %65
  %67 = sitofp i32 %66 to double
  %68 = fdiv double %63, %67
  %69 = fmul double %68, 2.000000e+00
  %70 = fmul double %69, 0x401921FB54442D18
  %71 = load double, ptr %5, align 8, !tbaa !9
  %72 = fmul double %70, %71
  %73 = getelementptr inbounds %"class.fastjet::RangeDefinition", ptr %15, i32 0, i32 1
  store double %72, ptr %73, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret void
}

; 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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!19, !10, i64 8}
!19 = !{!"_ZTSN7fastjet15RangeDefinitionE", !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}


; 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 uwtable
define dso_local void @_ZN7fastjet15RangeDefinition21_numerical_total_areaEdi(ptr noundef nonnull align 8 dereferenceable(72) %0, double noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = sitofp i32 %2 to double
  %5 = fdiv double 0x401921FB54442D18, %4
  %6 = fmul double %1, 2.000000e+00
  %7 = fdiv double %6, %4
  %8 = icmp sgt i32 %2, 0
  br i1 %8, label %.lr.ph34, label %._crit_edge35

.lr.ph34:                                         ; preds = %3
  %9 = fneg double %1
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %._crit_edge.us, %.lr.ph34
  %.02232.us = phi i32 [ 0, %.lr.ph34 ], [ %19, %._crit_edge.us ]
  %.02331.us = phi double [ 0.000000e+00, %.lr.ph34 ], [ %18, %._crit_edge.us ]
  %.02430.us = phi i32 [ 0, %.lr.ph34 ], [ %spec.select.us, %._crit_edge.us ]
  br label %10

10:                                               ; preds = %.lr.ph.us, %10
  %.029.us = phi i32 [ 0, %.lr.ph.us ], [ %17, %10 ]
  %.02128.us = phi double [ %9, %.lr.ph.us ], [ %16, %10 ]
  %.127.us = phi i32 [ %.02430.us, %.lr.ph.us ], [ %spec.select.us, %10 ]
  %11 = load ptr, ptr %0, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = load ptr, ptr %12, align 8
  %14 = tail call noundef zeroext i1 %13(ptr noundef nonnull align 8 dereferenceable(72) %0, double noundef %.02128.us, double noundef %.02331.us)
  %15 = zext i1 %14 to i32
  %spec.select.us = add nsw i32 %.127.us, %15
  %16 = fadd double %7, %.02128.us
  %17 = add nuw nsw i32 %.029.us, 1
  %exitcond.not = icmp eq i32 %17, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %10, !llvm.loop !8

._crit_edge.us:                                   ; preds = %10
  %18 = fadd double %5, %.02331.us
  %19 = add nuw nsw i32 %.02232.us, 1
  %exitcond37.not = icmp eq i32 %19, %2
  br i1 %exitcond37.not, label %._crit_edge35.loopexit, label %.lr.ph.us, !llvm.loop !10

._crit_edge35.loopexit:                           ; preds = %._crit_edge.us
  %20 = sitofp i32 %spec.select.us to double
  br label %._crit_edge35

._crit_edge35:                                    ; preds = %._crit_edge35.loopexit, %3
  %.024.lcssa = phi double [ 0.000000e+00, %3 ], [ %20, %._crit_edge35.loopexit ]
  %21 = mul nsw i32 %2, %2
  %22 = uitofp nneg i32 %21 to double
  %23 = fdiv double %.024.lcssa, %22
  %24 = fmul double %23, 2.000000e+00
  %25 = fmul double %24, 0x401921FB54442D18
  %26 = fmul double %25, %1
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  store double %26, ptr %27, align 8, !tbaa !11
  ret void
}

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTSN7fastjet15RangeDefinitionE", !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64}
!13 = !{!"double", !14, i64 0}
!14 = !{!"omnipotent char", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass