; LLVM IR from robotics-upo/Heuristic_path_planners :: include/voro++-0.4.6/src/cell.ll (ZN4voro16voronoicell_base18max_radius_squaredEv)

; 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.voro::voronoicell_base" = type { ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, double, double, double, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN4voro16voronoicell_base18max_radius_squaredEv(ptr noundef nonnull align 8 dereferenceable(160) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %8 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds double, ptr %9, i64 3
  store ptr %10, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 5
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = mul nsw i32 3, %14
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds double, ptr %12, i64 %16
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = load double, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds double, ptr %25, i64 1
  %27 = load double, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds double, ptr %29, i64 1
  %31 = load double, ptr %30, align 8, !tbaa !14
  %32 = fmul double %27, %31
  %33 = call double @llvm.fmuladd.f64(double %20, double %23, double %32)
  %34 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = getelementptr inbounds double, ptr %35, i64 2
  %37 = load double, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %7, i32 0, i32 9
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds double, ptr %39, i64 2
  %41 = load double, ptr %40, align 8, !tbaa !14
  %42 = call double @llvm.fmuladd.f64(double %37, double %41, double %33)
  store double %42, ptr %3, align 8, !tbaa !14
  br label %43

43:                                               ; preds = %76, %1
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = icmp ult ptr %44, %45
  br i1 %46, label %47, label %77

47:                                               ; preds = %43
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load double, ptr %48, align 8, !tbaa !14
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load double, ptr %50, align 8, !tbaa !14
  %52 = fmul double %49, %51
  store double %52, ptr %4, align 8, !tbaa !14
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds double, ptr %53, i32 1
  store ptr %54, ptr %5, align 8, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load double, ptr %55, align 8, !tbaa !14
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load double, ptr %57, align 8, !tbaa !14
  %59 = load double, ptr %4, align 8, !tbaa !14
  %60 = call double @llvm.fmuladd.f64(double %56, double %58, double %59)
  store double %60, ptr %4, align 8, !tbaa !14
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %61, i32 1
  store ptr %62, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load double, ptr %63, align 8, !tbaa !14
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load double, ptr %65, align 8, !tbaa !14
  %67 = load double, ptr %4, align 8, !tbaa !14
  %68 = call double @llvm.fmuladd.f64(double %64, double %66, double %67)
  store double %68, ptr %4, align 8, !tbaa !14
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds double, ptr %69, i32 1
  store ptr %70, ptr %5, align 8, !tbaa !5
  %71 = load double, ptr %4, align 8, !tbaa !14
  %72 = load double, ptr %3, align 8, !tbaa !14
  %73 = fcmp ogt double %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %47
  %75 = load double, ptr %4, align 8, !tbaa !14
  store double %75, ptr %3, align 8, !tbaa !14
  br label %76

76:                                               ; preds = %74, %47
  br label %43, !llvm.loop !15

77:                                               ; preds = %43
  %78 = load double, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %78
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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, !6, i64 48}
!10 = !{!"_ZTSN4voro16voronoicell_baseE", !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !11, i64 116, !6, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!10, !11, i64 24}
!14 = !{!12, !12, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef double @_ZN4voro16voronoicell_base18max_radius_squaredEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(160) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i32, ptr %4, align 8, !tbaa !12
  %6 = mul nsw i32 %5, 3
  %7 = sext i32 %6 to i64
  %.idx = shl nsw i64 %7, 3
  %8 = getelementptr inbounds i8, ptr %3, i64 %.idx
  %9 = load double, ptr %3, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !13
  %12 = fmul double %11, %11
  %13 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %12)
  %14 = getelementptr inbounds i8, ptr %3, i64 16
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %13)
  %17 = icmp sgt i32 %5, 1
  br i1 %17, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %1
  %.01820 = getelementptr inbounds i8, ptr %3, i64 24
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.01823 = phi ptr [ %.018, %.lr.ph ], [ %.01820, %.lr.ph.preheader ]
  %.022 = phi double [ %.1, %.lr.ph ], [ %16, %.lr.ph.preheader ]
  %.pn21 = phi ptr [ %.01823, %.lr.ph ], [ %3, %.lr.ph.preheader ]
  %18 = load double, ptr %.01823, align 8, !tbaa !13
  %19 = fmul double %18, %18
  %20 = getelementptr inbounds i8, ptr %.pn21, i64 32
  %21 = load double, ptr %20, align 8, !tbaa !13
  %22 = tail call double @llvm.fmuladd.f64(double %21, double %21, double %19)
  %23 = getelementptr inbounds i8, ptr %.pn21, i64 40
  %24 = load double, ptr %23, align 8, !tbaa !13
  %25 = tail call double @llvm.fmuladd.f64(double %24, double %24, double %22)
  %26 = fcmp ogt double %25, %.022
  %.1 = select i1 %26, double %25, double %.022
  %.018 = getelementptr inbounds i8, ptr %.01823, i64 24
  %27 = icmp ult ptr %.018, %8
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.0.lcssa = phi double [ %16, %1 ], [ %.1, %.lr.ph ]
  ret double %.0.lcssa
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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, !10, i64 48}
!6 = !{!"_ZTSN4voro16voronoicell_baseE", !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !7, i64 112, !7, i64 116, !10, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 24}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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