; LLVM IR from chrr/libECP :: src (util)

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local double @gtoRadius(double noundef, double noundef, i32 noundef, double noundef) #3

; Function Attrs: nounwind uwtable
define dso_local double @shellRadius(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, double noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  store double %4, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %15 = load ptr, ptr %9, align 8, !tbaa !9
  %16 = getelementptr inbounds double, ptr %15, i64 0
  %17 = load double, ptr %16, align 8, !tbaa !11
  store double %17, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %18 = load ptr, ptr %8, align 8, !tbaa !9
  %19 = getelementptr inbounds double, ptr %18, i64 0
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = call double @llvm.fabs.f64(double %20)
  store double %21, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store double 0.000000e+00, ptr %14, align 8, !tbaa !11
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %54, %5
  %23 = load i32, ptr %11, align 4, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %57

26:                                               ; preds = %22
  %27 = load ptr, ptr %9, align 8, !tbaa !9
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = load double, ptr %12, align 8, !tbaa !11
  %33 = fcmp olt double %31, %32
  br i1 %33, label %34, label %53

34:                                               ; preds = %26
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !11
  %40 = fcmp une double %39, 0.000000e+00
  br i1 %40, label %41, label %53

41:                                               ; preds = %34
  %42 = load ptr, ptr %9, align 8, !tbaa !9
  %43 = load i32, ptr %11, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %42, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !11
  store double %46, ptr %12, align 8, !tbaa !11
  %47 = load ptr, ptr %8, align 8, !tbaa !9
  %48 = load i32, ptr %11, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds double, ptr %47, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !11
  %52 = call double @llvm.fabs.f64(double %51)
  store double %52, ptr %13, align 8, !tbaa !11
  br label %53

53:                                               ; preds = %41, %34, %26
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %11, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %11, align 4, !tbaa !5
  br label %22, !llvm.loop !13

57:                                               ; preds = %22
  %58 = load double, ptr %13, align 8, !tbaa !11
  %59 = load double, ptr %12, align 8, !tbaa !11
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = load double, ptr %10, align 8, !tbaa !11
  %62 = call double @gtoRadius(double noundef %58, double noundef %59, i32 noundef %60, double noundef %61)
  store double %62, ptr %14, align 8, !tbaa !11
  %63 = load double, ptr %14, align 8, !tbaa !11
  %64 = call double @sqrt(double noundef %63) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret double %64
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #0

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

; Function Attrs: nounwind uwtable
declare dso_local double @gtoRadius(double noundef, double noundef, i32 noundef, double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local double @shellRadius(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, double noundef %4) local_unnamed_addr #2 {
  %6 = load double, ptr %3, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = tail call double @llvm.fabs.f64(double %7)
  %9 = icmp sgt i32 %0, 1
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = zext nneg i32 %0 to i64
  %10 = add nsw i64 %wide.trip.count, -1
  %xtraiter = and i64 %10, 1
  %11 = icmp eq i32 %0, 2
  br i1 %11, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %10, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %30, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %30 ]
  %.025 = phi double [ %8, %.lr.ph.preheader.new ], [ %.1.1, %30 ]
  %.01824 = phi double [ %6, %.lr.ph.preheader.new ], [ %.119.1, %30 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %30 ]
  %12 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fcmp olt double %13, %.01824
  br i1 %14, label %15, label %.lr.ph.1

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = fcmp une double %17, 0.000000e+00
  br i1 %18, label %19, label %.lr.ph.1

19:                                               ; preds = %15
  %20 = tail call double @llvm.fabs.f64(double %17)
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.lr.ph, %15, %19
  %.119 = phi double [ %13, %19 ], [ %.01824, %15 ], [ %.01824, %.lr.ph ]
  %.1 = phi double [ %20, %19 ], [ %.025, %15 ], [ %.025, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = fcmp olt double %22, %.119
  br i1 %23, label %24, label %30

24:                                               ; preds = %.lr.ph.1
  %25 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fcmp une double %26, 0.000000e+00
  br i1 %27, label %28, label %30

28:                                               ; preds = %24
  %29 = tail call double @llvm.fabs.f64(double %26)
  br label %30

30:                                               ; preds = %28, %24, %.lr.ph.1
  %.119.1 = phi double [ %22, %28 ], [ %.119, %24 ], [ %.119, %.lr.ph.1 ]
  %.1.1 = phi double [ %29, %28 ], [ %.1, %24 ], [ %.1, %.lr.ph.1 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %30, %.lr.ph.preheader
  %.119.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %.119.1, %30 ]
  %.1.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %.1.1, %30 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.1, %30 ]
  %.025.unr = phi double [ %8, %.lr.ph.preheader ], [ %.1.1, %30 ]
  %.01824.unr = phi double [ %6, %.lr.ph.preheader ], [ %.119.1, %30 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %31 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.unr
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fcmp olt double %32, %.01824.unr
  br i1 %33, label %34, label %._crit_edge

34:                                               ; preds = %.lr.ph.epil
  %35 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.unr
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = fcmp une double %36, 0.000000e+00
  br i1 %37, label %38, label %._crit_edge

38:                                               ; preds = %34
  %39 = tail call double @llvm.fabs.f64(double %36)
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %38, %34, %.lr.ph.epil, %5
  %.018.lcssa = phi double [ %6, %5 ], [ %.119.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %32, %38 ], [ %.01824.unr, %34 ], [ %.01824.unr, %.lr.ph.epil ]
  %.0.lcssa = phi double [ %8, %5 ], [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %39, %38 ], [ %.025.unr, %34 ], [ %.025.unr, %.lr.ph.epil ]
  %40 = tail call double @gtoRadius(double noundef %.0.lcssa, double noundef %.018.lcssa, i32 noundef %1, double noundef %4)
  %41 = tail call double @sqrt(double noundef %40) #3
  ret double %41
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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