; LLVM IR from mickypaganini/SSI2016-jet-clustering :: spartyjet-4.0.2_mac/ExternalTools (DetectorModel)

; 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.DetectorModel::RadialExpShapeEM" = type { %"class.DetectorModel::RadialShape", double }
%"class.DetectorModel::RadialShape" = type { ptr, double }

; 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: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK13DetectorModel16RadialExpShapeEM4evalEd(ptr noundef nonnull align 8 dereferenceable(24), double noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK13DetectorModel16RadialExpShapeEM11containmentEd(ptr noundef nonnull align 8 dereferenceable(24) %0, double noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds ptr, ptr %11, i64 5
  %13 = load ptr, ptr %12, align 8
  %14 = call noundef double %13(ptr noundef nonnull align 8 dereferenceable(16) %10)
  store double %14, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %15 = load double, ptr %5, align 8, !tbaa !9
  %16 = fdiv double %15, 1.000000e+02
  store double %16, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load double, ptr %4, align 8, !tbaa !9
  %18 = getelementptr inbounds %"class.DetectorModel::RadialExpShapeEM", ptr %10, i32 0, i32 1
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = fdiv double %17, %19
  store double %20, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store double 0.000000e+00, ptr %9, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %31, %2
  %22 = load double, ptr %7, align 8, !tbaa !9
  %23 = load double, ptr %5, align 8, !tbaa !9
  %24 = fcmp olt double %22, %23
  br i1 %24, label %25, label %29

25:                                               ; preds = %21
  %26 = load double, ptr %9, align 8, !tbaa !9
  %27 = load double, ptr %8, align 8, !tbaa !9
  %28 = fcmp olt double %26, %27
  br label %29

29:                                               ; preds = %25, %21
  %30 = phi i1 [ false, %21 ], [ %28, %25 ]
  br i1 %30, label %31, label %39

31:                                               ; preds = %29
  %32 = load double, ptr %7, align 8, !tbaa !9
  %33 = call noundef double @_ZNK13DetectorModel16RadialExpShapeEM4evalEd(ptr noundef nonnull align 8 dereferenceable(24) %10, double noundef %32)
  %34 = load double, ptr %9, align 8, !tbaa !9
  %35 = fadd double %34, %33
  store double %35, ptr %9, align 8, !tbaa !9
  %36 = load double, ptr %6, align 8, !tbaa !9
  %37 = load double, ptr %7, align 8, !tbaa !9
  %38 = fadd double %37, %36
  store double %38, ptr %7, align 8, !tbaa !9
  br label %21, !llvm.loop !16

39:                                               ; preds = %29
  %40 = load double, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %40
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTSN13DetectorModel16RadialExpShapeEME", !15, i64 0, !10, i64 16}
!15 = !{!"_ZTSN13DetectorModel11RadialShapeE", !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"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"

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK13DetectorModel16RadialExpShapeEM4evalEd(ptr noundef nonnull align 8 dereferenceable(24), double noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK13DetectorModel16RadialExpShapeEM11containmentEd(ptr noundef nonnull align 8 dereferenceable(24) %0, double noundef %1) local_unnamed_addr #1 align 2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 40
  %5 = load ptr, ptr %4, align 8
  %6 = tail call noundef double %5(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %7 = fdiv double %6, 1.000000e+02
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load double, ptr %8, align 8, !tbaa !8
  %10 = fdiv double %1, %9
  %11 = fcmp ogt double %6, 0.000000e+00
  %12 = fcmp ogt double %10, 0.000000e+00
  %13 = select i1 %11, i1 %12, i1 false
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.014 = phi double [ %15, %.lr.ph ], [ 0.000000e+00, %2 ]
  %.01213 = phi double [ %16, %.lr.ph ], [ 0.000000e+00, %2 ]
  %14 = tail call noundef double @_ZNK13DetectorModel16RadialExpShapeEM4evalEd(ptr noundef nonnull align 8 dereferenceable(24) %0, double noundef %.01213)
  %15 = fadd double %.014, %14
  %16 = fadd double %7, %.01213
  %17 = fcmp olt double %16, %6
  %18 = fcmp olt double %15, %10
  %19 = select i1 %17, i1 %18, i1 false
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.012.lcssa = phi double [ 0.000000e+00, %2 ], [ %16, %.lr.ph ]
  ret double %.012.lcssa
}

attributes #0 = { 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 #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" }

!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 = !{!9, !11, i64 16}
!9 = !{!"_ZTSN13DetectorModel16RadialExpShapeEME", !10, i64 0, !11, i64 16}
!10 = !{!"_ZTSN13DetectorModel11RadialShapeE", !11, i64 8}
!11 = !{!"double", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass