; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/levelset.ll (ZN8LevelSet25_minDistToTriangleSquaredEN5vmath4vec3EiPS1_)

; 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.vmath::vec3" = type { float, float, float }
%class.LevelSet = type { i32, i32, i32, double, i32, %class.TriangleMesh, %class.Array3d.20, %class.Array3d.22, %class.Array3d.24, %"class.std::vector.10", double, i32, %class.Array3d.24 }
%class.TriangleMesh = type { %"class.std::vector", %"class.std::vector", %"class.std::vector", %"class.std::vector.0", i32, i32, i32, double, %"class.std::vector.5", %"class.std::vector.10", %class.Array3d }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<vmath::vec3, std::allocator<vmath::vec3>>::_Vector_impl" }
%"struct.std::_Vector_base<vmath::vec3, std::allocator<vmath::vec3>>::_Vector_impl" = type { %"struct.std::_Vector_base<vmath::vec3, std::allocator<vmath::vec3>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vmath::vec3, std::allocator<vmath::vec3>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<Triangle, std::allocator<Triangle>>::_Vector_impl" }
%"struct.std::_Vector_base<Triangle, std::allocator<Triangle>>::_Vector_impl" = type { %"struct.std::_Vector_base<Triangle, std::allocator<Triangle>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Triangle, std::allocator<Triangle>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<std::vector<int>, std::allocator<std::vector<int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<int>, std::allocator<std::vector<int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<int>, std::allocator<std::vector<int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<int>, std::allocator<std::vector<int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.Array3d = type <{ i32, i32, i32, [4 x i8], ptr, i8, [7 x i8], %"class.std::vector.15", i32, [4 x i8] }>
%"class.std::vector.15" = type { %"struct.std::_Vector_base.16" }
%"struct.std::_Vector_base.16" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.Array3d.20 = type <{ i32, i32, i32, [4 x i8], ptr, i8, [3 x i8], float, i32, [4 x i8] }>
%class.Array3d.22 = type <{ i32, i32, i32, [4 x i8], ptr, i8, [3 x i8], i32, i32, [4 x i8] }>
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.Array3d.24 = type { i32, i32, i32, ptr, i8, i8, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

declare void @_ZN5vmath4vec3C1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3

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

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

declare void @_ZN5vmathmiERKNS_4vec3ES2_(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN5vmath3dotERKNS_4vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #4 align 2

declare void @_ZN12TriangleMesh19getTrianglePositionEjPN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232), i32 noundef, ptr noundef) #2

declare void @_ZN9Collision26findClosestPointOnTriangleEN5vmath4vec3ES1_S1_S1_(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN8LevelSet25_minDistToTriangleSquaredEN5vmath4vec3EiPS1_(ptr noundef nonnull align 8 dereferenceable(448) %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #6 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [3 x %"class.vmath::vec3"], align 16
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.vmath::vec3", align 4
  %14 = alloca %"class.vmath::vec3", align 4
  %15 = alloca %"class.vmath::vec3", align 4
  %16 = alloca %"class.vmath::vec3", align 4
  %17 = alloca %"class.vmath::vec3", align 4
  %18 = alloca %"class.vmath::vec3", align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %29, label %22

22:                                               ; preds = %4
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds %class.LevelSet, ptr %19, i32 0, i32 5
  %26 = getelementptr inbounds %class.TriangleMesh, ptr %25, i32 0, i32 3
  %27 = call noundef i64 @_ZNKSt6vectorI8TriangleSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %26) #7
  %28 = icmp ugt i64 %24, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %22, %4
  %30 = call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #7
  store double %30, ptr %5, align 8
  br label %97

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 36, ptr %10) #7
  %32 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %10, i32 0, i32 0
  %33 = getelementptr inbounds %"class.vmath::vec3", ptr %32, i64 3
  br label %34

34:                                               ; preds = %36, %31
  %35 = phi ptr [ %32, %31 ], [ %37, %36 ]
  invoke void @_ZN5vmath4vec3C1Ev(ptr noundef nonnull align 4 dereferenceable(12) %35)
          to label %36 unwind label %55

36:                                               ; preds = %34
  %37 = getelementptr inbounds %"class.vmath::vec3", ptr %35, i64 1
  %38 = icmp eq ptr %37, %33
  br i1 %38, label %39, label %34

39:                                               ; preds = %36
  %40 = getelementptr inbounds %class.LevelSet, ptr %19, i32 0, i32 5
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %10, i64 0, i64 0
  invoke void @_ZN12TriangleMesh19getTrianglePositionEjPN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232) %40, i32 noundef %41, ptr noundef %42)
          to label %43 unwind label %65

43:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %1, i64 12, i1 false), !tbaa.struct !11
  %44 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %10, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 16 %44, i64 12, i1 false), !tbaa.struct !11
  %45 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %10, i64 0, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %45, i64 12, i1 false), !tbaa.struct !11
  %46 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %10, i64 0, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 8 %46, i64 12, i1 false), !tbaa.struct !11
  invoke void @_ZN9Collision26findClosestPointOnTriangleEN5vmath4vec3ES1_S1_S1_(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4 %13, ptr noundef %14, ptr noundef %15, ptr noundef %16, ptr noundef %17)
          to label %47 unwind label %69

47:                                               ; preds = %43
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %17) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %16) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %15) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %14) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #7
  invoke void @_ZN5vmathmiERKNS_4vec3ES2_(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4 %18, ptr noundef nonnull align 4 dereferenceable(12) %13, ptr noundef nonnull align 4 dereferenceable(12) %1)
          to label %48 unwind label %73

48:                                               ; preds = %47
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %13, i64 12, i1 false), !tbaa.struct !11
  %50 = invoke noundef float @_ZN5vmath3dotERKNS_4vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %18, ptr noundef nonnull align 4 dereferenceable(12) %18)
          to label %51 unwind label %77

51:                                               ; preds = %48
  %52 = fpext float %50 to double
  store double %52, ptr %5, align 8
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %18) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %13) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #7
  %53 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %10, i32 0, i32 0
  %54 = getelementptr inbounds %"class.vmath::vec3", ptr %53, i64 3
  br label %83

55:                                               ; preds = %34
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %11, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %12, align 4
  %59 = icmp eq ptr %32, %35
  br i1 %59, label %64, label %60

60:                                               ; preds = %60, %55
  %61 = phi ptr [ %35, %55 ], [ %62, %60 ]
  %62 = getelementptr inbounds %"class.vmath::vec3", ptr %61, i64 -1
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %62) #7
  %63 = icmp eq ptr %62, %32
  br i1 %63, label %64, label %60

64:                                               ; preds = %60, %55
  br label %96

65:                                               ; preds = %39
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %11, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %12, align 4
  br label %88

69:                                               ; preds = %43
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %11, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %12, align 4
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %17) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %16) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %15) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %14) #7
  br label %82

73:                                               ; preds = %47
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %11, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %12, align 4
  br label %81

77:                                               ; preds = %48
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %11, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %12, align 4
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %18) #7
  br label %81

81:                                               ; preds = %77, %73
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %13) #7
  br label %82

82:                                               ; preds = %81, %69
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #7
  br label %88

83:                                               ; preds = %83, %51
  %84 = phi ptr [ %54, %51 ], [ %85, %83 ]
  %85 = getelementptr inbounds %"class.vmath::vec3", ptr %84, i64 -1
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %85) #7
  %86 = icmp eq ptr %85, %53
  br i1 %86, label %87, label %83

87:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 36, ptr %10) #7
  br label %97

88:                                               ; preds = %82, %65
  %89 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %10, i32 0, i32 0
  %90 = getelementptr inbounds %"class.vmath::vec3", ptr %89, i64 3
  br label %91

91:                                               ; preds = %91, %88
  %92 = phi ptr [ %90, %88 ], [ %93, %91 ]
  %93 = getelementptr inbounds %"class.vmath::vec3", ptr %92, i64 -1
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %93) #7
  %94 = icmp eq ptr %93, %89
  br i1 %94, label %95, label %91

95:                                               ; preds = %91
  br label %96

96:                                               ; preds = %95, %64
  call void @llvm.lifetime.end.p0(i64 36, ptr %10) #7
  br label %99

97:                                               ; preds = %87, %29
  %98 = load double, ptr %5, align 8
  ret double %98

99:                                               ; preds = %96
  %100 = load ptr, ptr %11, align 8
  %101 = load i32, ptr %12, align 4
  %102 = insertvalue { ptr, i32 } poison, ptr %100, 0
  %103 = insertvalue { ptr, i32 } %102, i32 %101, 1
  resume { ptr, i32 } %103
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 "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 = { 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 #5 = { inlinehint 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 #6 = { 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 #7 = { 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 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, 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"

%"class.vmath::vec3" = type { float, float, float }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

declare void @_ZN5vmath4vec3C1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3

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

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

declare void @_ZN5vmathmiERKNS_4vec3ES2_(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN5vmath3dotERKNS_4vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE8infinityEv() local_unnamed_addr #4 align 2

declare void @_ZN12TriangleMesh19getTrianglePositionEjPN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232), i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN9Collision26findClosestPointOnTriangleEN5vmath4vec3ES1_S1_S1_(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN8LevelSet25_minDistToTriangleSquaredEN5vmath4vec3EiPS1_(ptr noundef nonnull align 8 dereferenceable(448) %0, ptr noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca [3 x %"class.vmath::vec3"], align 16
  %6 = alloca %"class.vmath::vec3", align 4
  %7 = alloca %"class.vmath::vec3", align 4
  %8 = alloca %"class.vmath::vec3", align 4
  %9 = alloca %"class.vmath::vec3", align 4
  %10 = alloca %"class.vmath::vec3", align 4
  %11 = alloca %"class.vmath::vec3", align 4
  %12 = icmp slt i32 %2, 0
  br i1 %12, label %19, label %13

13:                                               ; preds = %4
  %14 = zext nneg i32 %2 to i64
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %16 = getelementptr inbounds i8, ptr %0, i64 104
  %17 = tail call noundef i64 @_ZNKSt6vectorI8TriangleSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #7
  %18 = icmp ult i64 %17, %14
  br i1 %18, label %19, label %21

19:                                               ; preds = %13, %4
  %20 = tail call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #7
  br label %43

21:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %5) #7
  call void @_ZN5vmath4vec3C1Ev(ptr noundef nonnull align 4 dereferenceable(12) %5)
  %.ptr.1 = getelementptr inbounds i8, ptr %5, i64 12
  invoke void @_ZN5vmath4vec3C1Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
          to label %22 unwind label %.preheader.preheader

22:                                               ; preds = %21
  %.ptr.2 = getelementptr inbounds i8, ptr %5, i64 24
  invoke void @_ZN5vmath4vec3C1Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
          to label %23 unwind label %.preheader.preheader

23:                                               ; preds = %22
  invoke void @_ZN12TriangleMesh19getTrianglePositionEjPN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232) %15, i32 noundef %2, ptr noundef nonnull %5)
          to label %24 unwind label %34

24:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 16 dereferenceable(12) %5, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 8 dereferenceable(12) %.ptr.2, i64 12, i1 false), !tbaa.struct !5
  invoke void @_ZN9Collision26findClosestPointOnTriangleEN5vmath4vec3ES1_S1_S1_(ptr dead_on_unwind nonnull writable sret(%"class.vmath::vec3") align 4 %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %10)
          to label %25 unwind label %36

25:                                               ; preds = %24
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %10) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %9) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %8) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #7
  invoke void @_ZN5vmathmiERKNS_4vec3ES2_(ptr dead_on_unwind nonnull writable sret(%"class.vmath::vec3") align 4 %11, ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %1)
          to label %26 unwind label %38

26:                                               ; preds = %25
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %6, i64 12, i1 false), !tbaa.struct !5
  %27 = call noundef float @_ZN5vmath3dotERKNS_4vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %11)
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %11) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %6) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #7
  %28 = getelementptr inbounds i8, ptr %5, i64 24
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %28) #7
  %29 = getelementptr inbounds i8, ptr %5, i64 12
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %29) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #7
  %30 = fpext float %27 to double
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %5) #7
  br label %43

.preheader.preheader:                             ; preds = %21, %22
  %.ptr.lcssa.ph = phi ptr [ %.ptr.2, %22 ], [ %.ptr.1, %21 ]
  %lpad.thr_comm = landingpad { ptr, i32 }
          cleanup
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %31 = phi ptr [ %32, %.preheader ], [ %.ptr.lcssa.ph, %.preheader.preheader ]
  %32 = getelementptr inbounds i8, ptr %31, i64 -12
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %32) #7
  %33 = icmp eq ptr %32, %5
  br i1 %33, label %.loopexit, label %.preheader

34:                                               ; preds = %23
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.loopexit

36:                                               ; preds = %24
  %37 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %10) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %9) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %8) #7
  br label %40

38:                                               ; preds = %25
  %39 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #7
  br label %40

40:                                               ; preds = %38, %36
  %.sink = phi ptr [ %6, %38 ], [ %7, %36 ]
  %.pn = phi { ptr, i32 } [ %39, %38 ], [ %37, %36 ]
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %.sink) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #7
  br label %.loopexit.loopexit

.loopexit.loopexit:                               ; preds = %40, %34
  %.pn.pn = phi { ptr, i32 } [ %.pn, %40 ], [ %35, %34 ]
  %41 = getelementptr inbounds i8, ptr %5, i64 24
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %41) #7
  %42 = getelementptr inbounds i8, ptr %5, i64 12
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %42) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #7
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %.loopexit.loopexit
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %.loopexit.loopexit ], [ %lpad.thr_comm, %.preheader ]
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %5) #7
  resume { ptr, i32 } %.pn.pn.pn

43:                                               ; preds = %26, %19
  %.010 = phi double [ %20, %19 ], [ %30, %26 ]
  ret double %.010
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 "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 = { 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 #5 = { inlinehint 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 #6 = { 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 #7 = { 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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