; LLVM IR from robotics-upo/Heuristic_path_planners :: src/utils (geometry_utils)

; 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.Planners::utils::Vec3i" = type { i32, i32, i32 }

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

7:                                                ; preds = %71, %2
  %8 = load i64, ptr %6, align 8, !tbaa !11
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef i64 @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #3
  %11 = icmp ult i64 %8, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %74

13:                                               ; preds = %7
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load i64, ptr %6, align 8, !tbaa !11
  %16 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %15) #3
  %17 = getelementptr inbounds %"class.Planners::utils::Vec3i", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 4, !tbaa !13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i64, ptr %6, align 8, !tbaa !11
  %21 = sub i64 %20, 1
  %22 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %21) #3
  %23 = getelementptr inbounds %"class.Planners::utils::Vec3i", ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = sub nsw i32 %18, %24
  %26 = sitofp i32 %25 to double
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load double, ptr %27, align 8, !tbaa !16
  %29 = fmul double %26, %28
  %30 = call double @pow(double noundef %29, double noundef 2.000000e+00) #3
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i64, ptr %6, align 8, !tbaa !11
  %33 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef %32) #3
  %34 = getelementptr inbounds %"class.Planners::utils::Vec3i", ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !18
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load i64, ptr %6, align 8, !tbaa !11
  %38 = sub i64 %37, 1
  %39 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %38) #3
  %40 = getelementptr inbounds %"class.Planners::utils::Vec3i", ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !18
  %42 = sub nsw i32 %35, %41
  %43 = sitofp i32 %42 to double
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load double, ptr %44, align 8, !tbaa !16
  %46 = fmul double %43, %45
  %47 = call double @pow(double noundef %46, double noundef 2.000000e+00) #3
  %48 = fadd double %30, %47
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load i64, ptr %6, align 8, !tbaa !11
  %51 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef %50) #3
  %52 = getelementptr inbounds %"class.Planners::utils::Vec3i", ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 4, !tbaa !19
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = load i64, ptr %6, align 8, !tbaa !11
  %56 = sub i64 %55, 1
  %57 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %54, i64 noundef %56) #3
  %58 = getelementptr inbounds %"class.Planners::utils::Vec3i", ptr %57, i32 0, i32 2
  %59 = load i32, ptr %58, align 4, !tbaa !19
  %60 = sub nsw i32 %53, %59
  %61 = sitofp i32 %60 to double
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load double, ptr %62, align 8, !tbaa !16
  %64 = fmul double %61, %63
  %65 = call double @pow(double noundef %64, double noundef 2.000000e+00) #3
  %66 = fadd double %48, %65
  %67 = fptrunc double %66 to float
  %68 = call float @sqrtf(float noundef %67) #3
  %69 = load float, ptr %5, align 4, !tbaa !9
  %70 = fadd float %69, %68
  store float %70, ptr %5, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %13
  %72 = load i64, ptr %6, align 8, !tbaa !11
  %73 = add i64 %72, 1
  store i64 %73, ptr %6, align 8, !tbaa !11
  br label %7, !llvm.loop !20

74:                                               ; preds = %12
  %75 = load float, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float %75
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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

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

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTSN8Planners5utils5Vec3iE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!14, !15, i64 4}
!19 = !{!14, !15, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"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 nounwind uwtable
define dso_local noundef float @_ZN8Planners5utils8geometry19calculatePathLengthERKSt6vectorINS0_5Vec3iESaIS3_EERKd(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1) local_unnamed_addr #0 {
  %3 = tail call noundef i64 @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %4 = icmp ugt i64 %3, 1
  br i1 %4, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.019.lcssa = phi float [ 0.000000e+00, %2 ], [ %37, %.lr.ph ]
  ret float %.019.lcssa

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.023 = phi i64 [ %38, %.lr.ph ], [ 1, %2 ]
  %.01922 = phi float [ %37, %.lr.ph ], [ 0.000000e+00, %2 ]
  %5 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.023) #2
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = add i64 %.023, -1
  %8 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #2
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = sub nsw i32 %6, %9
  %11 = sitofp i32 %10 to double
  %12 = load double, ptr %1, align 8, !tbaa !10
  %13 = fmul double %12, %11
  %square = fmul double %13, %13
  %14 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.023) #2
  %15 = getelementptr inbounds i8, ptr %14, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #2
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  %19 = load i32, ptr %18, align 4, !tbaa !12
  %20 = sub nsw i32 %16, %19
  %21 = sitofp i32 %20 to double
  %22 = load double, ptr %1, align 8, !tbaa !10
  %23 = fmul double %22, %21
  %square20 = fmul double %23, %23
  %24 = fadd double %square, %square20
  %25 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.023) #2
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #2
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = load i32, ptr %29, align 4, !tbaa !13
  %31 = sub nsw i32 %27, %30
  %32 = sitofp i32 %31 to double
  %33 = load double, ptr %1, align 8, !tbaa !10
  %34 = fmul double %33, %32
  %square21 = fmul double %34, %34
  %35 = fadd double %24, %square21
  %36 = fptrunc double %35 to float
  %sqrt = tail call float @llvm.sqrt.f32(float %36)
  %37 = fadd float %.01922, %sqrt
  %38 = add nuw i64 %.023, 1
  %39 = tail call noundef i64 @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %40 = icmp ult i64 %38, %39
  br i1 %40, label %.lr.ph, label %._crit_edge, !llvm.loop !14
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN8Planners5utils5Vec3iESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #1

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


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