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

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN8LevelSet25_minDistToTriangleSquaredEN5vmath4vec3Ei(ptr noundef nonnull align 8 dereferenceable(448) %0, ptr noundef %1, i32 noundef %2) #6 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca [3 x %"class.vmath::vec3"], align 16
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %"class.vmath::vec3", align 4
  %12 = alloca %"class.vmath::vec3", 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
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %17 = load ptr, ptr %5, align 8
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %27, label %20

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

27:                                               ; preds = %20, %3
  %28 = call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #7
  store double %28, ptr %4, align 8
  br label %94

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

32:                                               ; preds = %34, %29
  %33 = phi ptr [ %30, %29 ], [ %35, %34 ]
  invoke void @_ZN5vmath4vec3C1Ev(ptr noundef nonnull align 4 dereferenceable(12) %33)
          to label %34 unwind label %52

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

37:                                               ; preds = %34
  %38 = getelementptr inbounds %class.LevelSet, ptr %17, i32 0, i32 5
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %8, i64 0, i64 0
  invoke void @_ZN12TriangleMesh19getTrianglePositionEjPN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232) %38, i32 noundef %39, ptr noundef %40)
          to label %41 unwind label %62

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

45:                                               ; preds = %41
  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 @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %13) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %12) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %16) #7
  invoke void @_ZN5vmathmiERKNS_4vec3ES2_(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4 %16, ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %1)
          to label %46 unwind label %70

46:                                               ; preds = %45
  %47 = invoke noundef float @_ZN5vmath3dotERKNS_4vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %16, ptr noundef nonnull align 4 dereferenceable(12) %16)
          to label %48 unwind label %74

48:                                               ; preds = %46
  %49 = fpext float %47 to double
  store double %49, ptr %4, align 8
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %16) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %11) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #7
  %50 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %8, i32 0, i32 0
  %51 = getelementptr inbounds %"class.vmath::vec3", ptr %50, i64 3
  br label %80

52:                                               ; preds = %32
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %9, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %10, align 4
  %56 = icmp eq ptr %30, %33
  br i1 %56, label %61, label %57

57:                                               ; preds = %57, %52
  %58 = phi ptr [ %33, %52 ], [ %59, %57 ]
  %59 = getelementptr inbounds %"class.vmath::vec3", ptr %58, i64 -1
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %59) #7
  %60 = icmp eq ptr %59, %30
  br i1 %60, label %61, label %57

61:                                               ; preds = %57, %52
  br label %93

62:                                               ; preds = %37
  %63 = landingpad { ptr, i32 }
          cleanup
  %64 = extractvalue { ptr, i32 } %63, 0
  store ptr %64, ptr %9, align 8
  %65 = extractvalue { ptr, i32 } %63, 1
  store i32 %65, ptr %10, align 4
  br label %85

66:                                               ; preds = %41
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %9, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %10, align 4
  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 @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %13) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %12) #7
  br label %79

70:                                               ; preds = %45
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %9, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %10, align 4
  br label %78

74:                                               ; preds = %46
  %75 = landingpad { ptr, i32 }
          cleanup
  %76 = extractvalue { ptr, i32 } %75, 0
  store ptr %76, ptr %9, align 8
  %77 = extractvalue { ptr, i32 } %75, 1
  store i32 %77, ptr %10, align 4
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %16) #7
  br label %78

78:                                               ; preds = %74, %70
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %11) #7
  br label %79

79:                                               ; preds = %78, %66
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #7
  br label %85

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

84:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 36, ptr %8) #7
  br label %94

85:                                               ; preds = %79, %62
  %86 = getelementptr inbounds [3 x %"class.vmath::vec3"], ptr %8, i32 0, i32 0
  %87 = getelementptr inbounds %"class.vmath::vec3", ptr %86, i64 3
  br label %88

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

92:                                               ; preds = %88
  br label %93

93:                                               ; preds = %92, %61
  call void @llvm.lifetime.end.p0(i64 36, ptr %8) #7
  br label %96

94:                                               ; preds = %84, %27
  %95 = load double, ptr %4, align 8
  ret double %95

96:                                               ; preds = %93
  %97 = load ptr, ptr %9, align 8
  %98 = load i32, ptr %10, align 4
  %99 = insertvalue { ptr, i32 } poison, ptr %97, 0
  %100 = insertvalue { ptr, i32 } %99, i32 %98, 1
  resume { ptr, i32 } %100
}

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN8LevelSet25_minDistToTriangleSquaredEN5vmath4vec3Ei(ptr noundef nonnull align 8 dereferenceable(448) %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca [3 x %"class.vmath::vec3"], align 16
  %5 = alloca %"class.vmath::vec3", align 4
  %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 = icmp slt i32 %2, 0
  br i1 %11, label %18, label %12

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

18:                                               ; preds = %12, %3
  %19 = tail call noundef double @_ZNSt14numeric_limitsIdE8infinityEv() #7
  br label %42

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

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

22:                                               ; preds = %21
  invoke void @_ZN12TriangleMesh19getTrianglePositionEjPN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232) %14, i32 noundef %2, ptr noundef nonnull %4)
          to label %23 unwind label %33

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %6, 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) %7, ptr noundef nonnull align 16 dereferenceable(12) %4, 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 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) %9, 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 %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9)
          to label %24 unwind label %35

24:                                               ; preds = %23
  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 @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %6) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #7
  invoke void @_ZN5vmathmiERKNS_4vec3ES2_(ptr dead_on_unwind nonnull writable sret(%"class.vmath::vec3") align 4 %10, ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %1)
          to label %25 unwind label %37

25:                                               ; preds = %24
  %26 = call noundef float @_ZN5vmath3dotERKNS_4vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %10)
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #7
  %27 = getelementptr inbounds i8, ptr %4, i64 24
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %27) #7
  %28 = getelementptr inbounds i8, ptr %4, i64 12
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %28) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %4) #7
  %29 = fpext float %26 to double
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %4) #7
  br label %42

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

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

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

35:                                               ; preds = %23
  %36 = landingpad { ptr, i32 }
          cleanup
  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
  br label %39

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

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

.loopexit.loopexit:                               ; preds = %39, %33
  %.pn.pn = phi { ptr, i32 } [ %.pn, %39 ], [ %34, %33 ]
  %40 = getelementptr inbounds i8, ptr %4, i64 24
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %40) #7
  %41 = getelementptr inbounds i8, ptr %4, i64 12
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %41) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %4) #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 %4) #7
  resume { ptr, i32 } %.pn.pn.pn

42:                                               ; preds = %25, %18
  %.09 = phi double [ %19, %18 ], [ %29, %25 ]
  ret double %.09
}

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

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,SROAPass,SimplifyCFGPass,TailCallElimPass