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

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

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13DetectorModel4Grid3addEdddd(ptr noundef nonnull align 8 dereferenceable(96) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4) unnamed_addr #3 align 2 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store double %1, ptr %8, align 8, !tbaa !9
  store double %2, ptr %9, align 8, !tbaa !9
  store double %3, ptr %10, align 8, !tbaa !9
  store double %4, ptr %11, align 8, !tbaa !9
  %17 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %18 = load double, ptr %8, align 8, !tbaa !9
  %19 = load double, ptr %8, align 8, !tbaa !9
  %20 = load double, ptr %9, align 8, !tbaa !9
  %21 = load double, ptr %9, align 8, !tbaa !9
  %22 = fmul double %20, %21
  %23 = call double @llvm.fmuladd.f64(double %18, double %19, double %22)
  store double %23, ptr %12, align 8, !tbaa !9
  %24 = load double, ptr %12, align 8, !tbaa !9
  %25 = fcmp oeq double %24, 0.000000e+00
  br i1 %25, label %26, label %27

26:                                               ; preds = %5
  store i1 false, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %60

27:                                               ; preds = %5
  %28 = load double, ptr %10, align 8, !tbaa !9
  %29 = fcmp oeq double %28, 0.000000e+00
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = load double, ptr %12, align 8, !tbaa !9
  %32 = fdiv double %31, 1.000000e+03
  store double %32, ptr %10, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %30, %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %34 = load double, ptr %12, align 8, !tbaa !9
  %35 = load double, ptr %10, align 8, !tbaa !9
  %36 = load double, ptr %10, align 8, !tbaa !9
  %37 = call double @llvm.fmuladd.f64(double %35, double %36, double %34)
  %38 = call double @sqrt(double noundef %37) #4
  store double %38, ptr %14, align 8, !tbaa !9
  %39 = load double, ptr %12, align 8, !tbaa !9
  %40 = call double @sqrt(double noundef %39) #4
  store double %40, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %41 = load double, ptr %14, align 8, !tbaa !9
  %42 = load double, ptr %10, align 8, !tbaa !9
  %43 = fadd double %41, %42
  %44 = load double, ptr %14, align 8, !tbaa !9
  %45 = load double, ptr %10, align 8, !tbaa !9
  %46 = fsub double %44, %45
  %47 = fdiv double %43, %46
  %48 = call double @log(double noundef %47) #4
  %49 = fmul double -5.000000e-01, %48
  store double %49, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %50 = load double, ptr %9, align 8, !tbaa !9
  %51 = load double, ptr %8, align 8, !tbaa !9
  %52 = call double @atan2(double noundef %50, double noundef %51) #4
  store double %52, ptr %16, align 8, !tbaa !9
  %53 = load double, ptr %11, align 8, !tbaa !9
  %54 = load double, ptr %15, align 8, !tbaa !9
  %55 = load double, ptr %16, align 8, !tbaa !9
  %56 = load ptr, ptr %17, align 8, !tbaa !11
  %57 = getelementptr inbounds ptr, ptr %56, i64 20
  %58 = load ptr, ptr %57, align 8
  %59 = call noundef zeroext i1 %58(ptr noundef nonnull align 8 dereferenceable(96) %17, double noundef %53, double noundef %54, double noundef %55)
  store i1 %59, ptr %6, align 1
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %60

60:                                               ; preds = %33, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %61 = load i1, ptr %6, align 1
  ret i1 %61
}

; Function Attrs: nounwind
declare double @log(double noundef) #1

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = { 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}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN13DetectorModel4Grid3addEdddd(ptr noundef nonnull align 8 dereferenceable(96) %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4) unnamed_addr #1 align 2 {
  %6 = fmul double %2, %2
  %7 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %6)
  %8 = fcmp oeq double %7, 0.000000e+00
  br i1 %8, label %23, label %9

9:                                                ; preds = %5
  %10 = fcmp oeq double %3, 0.000000e+00
  %11 = fdiv double %7, 1.000000e+03
  %.022 = select i1 %10, double %11, double %3
  %12 = tail call double @llvm.fmuladd.f64(double %.022, double %.022, double %7)
  %sqrt25 = tail call double @llvm.sqrt.f64(double %12)
  %13 = fadd double %.022, %sqrt25
  %14 = fsub double %sqrt25, %.022
  %15 = fdiv double %13, %14
  %16 = tail call double @log(double noundef %15) #4
  %17 = fmul double %16, -5.000000e-01
  %18 = tail call double @atan2(double noundef %2, double noundef %1) #4
  %19 = load ptr, ptr %0, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 160
  %21 = load ptr, ptr %20, align 8
  %22 = tail call noundef zeroext i1 %21(ptr noundef nonnull align 8 dereferenceable(96) %0, double noundef %4, double noundef %17, double noundef %18)
  br label %23

23:                                               ; preds = %5, %9
  %.0 = phi i1 [ %22, %9 ], [ false, %5 ]
  ret i1 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass