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

; 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: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN4voro16voronoicell_base19total_edge_distanceEv(ptr noundef nonnull align 8 dereferenceable(160) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i32 0, ptr %3, align 4, !tbaa !11
  br label %11

11:                                               ; preds = %108, %1
  %12 = load i32, ptr %3, align 4, !tbaa !11
  %13 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 5
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = sub nsw i32 %14, 1
  %16 = icmp slt i32 %12, %15
  br i1 %16, label %17, label %111

17:                                               ; preds = %11
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %104, %17
  %19 = load i32, ptr %4, align 4, !tbaa !11
  %20 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 8
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load i32, ptr %3, align 4, !tbaa !11
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %21, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = icmp slt i32 %19, %25
  br i1 %26, label %27, label %107

27:                                               ; preds = %18
  %28 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 7
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = load i32, ptr %3, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds ptr, ptr %29, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr %33, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !11
  store i32 %37, ptr %5, align 4, !tbaa !11
  %38 = load i32, ptr %5, align 4, !tbaa !11
  %39 = load i32, ptr %3, align 4, !tbaa !11
  %40 = icmp sgt i32 %38, %39
  br i1 %40, label %41, label %103

41:                                               ; preds = %27
  %42 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 9
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = load i32, ptr %5, align 4, !tbaa !11
  %45 = mul nsw i32 3, %44
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %43, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 9
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = load i32, ptr %3, align 4, !tbaa !11
  %52 = mul nsw i32 3, %51
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %50, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !9
  %56 = fsub double %48, %55
  store double %56, ptr %7, align 8, !tbaa !9
  %57 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 9
  %58 = load ptr, ptr %57, align 8, !tbaa !17
  %59 = load i32, ptr %5, align 4, !tbaa !11
  %60 = mul nsw i32 3, %59
  %61 = add nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds double, ptr %58, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !9
  %65 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 9
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = load i32, ptr %3, align 4, !tbaa !11
  %68 = mul nsw i32 3, %67
  %69 = add nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %66, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = fsub double %64, %72
  store double %73, ptr %8, align 8, !tbaa !9
  %74 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 9
  %75 = load ptr, ptr %74, align 8, !tbaa !17
  %76 = load i32, ptr %5, align 4, !tbaa !11
  %77 = mul nsw i32 3, %76
  %78 = add nsw i32 %77, 2
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds double, ptr %75, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !9
  %82 = getelementptr inbounds %"class.voro::voronoicell_base", ptr %10, i32 0, i32 9
  %83 = load ptr, ptr %82, align 8, !tbaa !17
  %84 = load i32, ptr %3, align 4, !tbaa !11
  %85 = mul nsw i32 3, %84
  %86 = add nsw i32 %85, 2
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds double, ptr %83, i64 %87
  %89 = load double, ptr %88, align 8, !tbaa !9
  %90 = fsub double %81, %89
  store double %90, ptr %9, align 8, !tbaa !9
  %91 = load double, ptr %7, align 8, !tbaa !9
  %92 = load double, ptr %7, align 8, !tbaa !9
  %93 = load double, ptr %8, align 8, !tbaa !9
  %94 = load double, ptr %8, align 8, !tbaa !9
  %95 = fmul double %93, %94
  %96 = call double @llvm.fmuladd.f64(double %91, double %92, double %95)
  %97 = load double, ptr %9, align 8, !tbaa !9
  %98 = load double, ptr %9, align 8, !tbaa !9
  %99 = call double @llvm.fmuladd.f64(double %97, double %98, double %96)
  %100 = call double @sqrt(double noundef %99) #4
  %101 = load double, ptr %6, align 8, !tbaa !9
  %102 = fadd double %101, %100
  store double %102, ptr %6, align 8, !tbaa !9
  br label %103

103:                                              ; preds = %41, %27
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %4, align 4, !tbaa !11
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %4, align 4, !tbaa !11
  br label %18, !llvm.loop !18

107:                                              ; preds = %18
  br label %108

108:                                              ; preds = %107
  %109 = load i32, ptr %3, align 4, !tbaa !11
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %3, align 4, !tbaa !11
  br label %11, !llvm.loop !20

111:                                              ; preds = %11
  %112 = load double, ptr %6, align 8, !tbaa !9
  %113 = fmul double 5.000000e-01, %112
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret double %113
}

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 = { 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 #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 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 24}
!14 = !{!"_ZTSN4voro16voronoicell_baseE", !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, 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, !12, i64 112, !12, i64 116, !6, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152}
!15 = !{!14, !6, i64 40}
!16 = !{!14, !6, i64 32}
!17 = !{!14, !6, i64 48}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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_base19total_edge_distanceEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(160) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 1
  br i1 %4, label %.preheader.lr.ph, label %._crit_edge30

.preheader.lr.ph:                                 ; preds = %1
  %5 = add nsw i32 %3, -1
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load ptr, ptr %8, align 8
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = load ptr, ptr %10, align 8
  %wide.trip.count36 = zext nneg i32 %5 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvars.iv33 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next34, %._crit_edge ]
  %.02428 = phi double [ 0.000000e+00, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %12 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv33
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %15 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv33
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %.idx = mul i64 %indvars.iv33, 24
  %17 = getelementptr inbounds i8, ptr %11, i64 %.idx
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = getelementptr inbounds i8, ptr %17, i64 16
  %wide.trip.count = zext nneg i32 %13 to i64
  br label %20

20:                                               ; preds = %.lr.ph, %44
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %44 ]
  %.126 = phi double [ %.02428, %.lr.ph ], [ %.2, %44 ]
  %21 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv33, %23
  br i1 %24, label %25, label %44

25:                                               ; preds = %20
  %26 = mul nsw i32 %22, 3
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %11, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = load double, ptr %17, align 8, !tbaa !15
  %31 = fsub double %29, %30
  %32 = getelementptr i8, ptr %28, i64 8
  %33 = load double, ptr %32, align 8, !tbaa !15
  %34 = load double, ptr %18, align 8, !tbaa !15
  %35 = fsub double %33, %34
  %36 = getelementptr i8, ptr %28, i64 16
  %37 = load double, ptr %36, align 8, !tbaa !15
  %38 = load double, ptr %19, align 8, !tbaa !15
  %39 = fsub double %37, %38
  %40 = fmul double %35, %35
  %41 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %40)
  %42 = tail call double @llvm.fmuladd.f64(double %39, double %39, double %41)
  %sqrt = tail call double @llvm.sqrt.f64(double %42)
  %43 = fadd double %.126, %sqrt
  br label %44

44:                                               ; preds = %20, %25
  %.2 = phi double [ %43, %25 ], [ %.126, %20 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %20, !llvm.loop !16

._crit_edge:                                      ; preds = %44, %.preheader
  %.1.lcssa = phi double [ %.02428, %.preheader ], [ %.2, %44 ]
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next34, %wide.trip.count36
  br i1 %exitcond37.not, label %._crit_edge30.loopexit, label %.preheader, !llvm.loop !18

._crit_edge30.loopexit:                           ; preds = %._crit_edge
  %45 = fmul double %.1.lcssa, 5.000000e-01
  br label %._crit_edge30

._crit_edge30:                                    ; preds = %._crit_edge30.loopexit, %1
  %.024.lcssa = phi double [ 0.000000e+00, %1 ], [ %45, %._crit_edge30.loopexit ]
  ret double %.024.lcssa
}

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

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" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !7, i64 24}
!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, !10, i64 40}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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