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

; 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"

%struct.Triangle = type { [3 x i32] }
%class.GridIndexVector = type { i32, i32, i32, %"class.std::vector.15" }
%"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 }
%struct.GridIndex = type { i32, i32, i32 }
%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.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: mustprogress uwtable
declare dso_local void @_ZN8LevelSet27_getTriangleGridCellOverlapE8TriangleR15GridIndexVector(ptr noundef nonnull align 8 dereferenceable(448), i64, i32, ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

; 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) #1

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

declare void @_ZN15GridIndexVectorC1Eiii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3

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

declare { i64, i32 } @_ZN15GridIndexVectorixEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #3

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

; Function Attrs: nounwind
declare void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8LevelSet37_calculateDistancesSquaredForTriangleEi(ptr noundef nonnull align 8 dereferenceable(448) %0, i32 noundef %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.Triangle, align 4
  %6 = alloca %class.GridIndexVector, align 8
  %7 = alloca %struct.Triangle, align 4
  %8 = alloca { i64, i32 }, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct.GridIndex, align 4
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca %struct.GridIndex, align 4
  %15 = alloca { i64, i32 }, align 8
  %16 = alloca %struct.GridIndex, align 4
  %17 = alloca { i64, i32 }, align 4
  %18 = alloca %struct.GridIndex, align 4
  %19 = alloca { i64, i32 }, align 4
  %20 = alloca %struct.GridIndex, align 4
  %21 = alloca { i64, i32 }, align 4
  %22 = alloca %struct.GridIndex, align 4
  %23 = alloca { i64, i32 }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %24 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #7
  %25 = getelementptr inbounds %class.LevelSet, ptr %24, i32 0, i32 5
  %26 = getelementptr inbounds %class.TriangleMesh, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI8TriangleSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %28) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %29, i64 12, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 40, ptr %6) #7
  %30 = getelementptr inbounds %class.LevelSet, ptr %24, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds %class.LevelSet, ptr %24, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !43
  %34 = getelementptr inbounds %class.LevelSet, ptr %24, i32 0, i32 2
  %35 = load i32, ptr %34, align 8, !tbaa !44
  call void @_ZN15GridIndexVectorC1Eiii(ptr noundef nonnull align 8 dereferenceable(40) %6, i32 noundef %31, i32 noundef %33, i32 noundef %35)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %5, i64 12, i1 false), !tbaa.struct !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %7, i64 12, i1 false)
  %36 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  %37 = load i64, ptr %36, align 4
  %38 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  %39 = load i32, ptr %38, align 4
  invoke void @_ZN8LevelSet27_getTriangleGridCellOverlapE8TriangleR15GridIndexVector(ptr noundef nonnull align 8 dereferenceable(448) %24, i64 %37, i32 %39, ptr noundef nonnull align 8 dereferenceable(40) %6)
          to label %40 unwind label %49

40:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #7
  invoke void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %11)
          to label %41 unwind label %53

41:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %103, %41
  %43 = load i32, ptr %13, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = invoke noundef i64 @_ZN15GridIndexVector4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %6)
          to label %46 unwind label %57

46:                                               ; preds = %42
  %47 = icmp ult i64 %44, %45
  br i1 %47, label %61, label %48

48:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %107

49:                                               ; preds = %2
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %9, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %10, align 4
  br label %109

53:                                               ; preds = %40
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %9, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %10, align 4
  br label %108

57:                                               ; preds = %90, %79, %71, %64, %42
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %9, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %10, align 4
  br label %106

61:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #7
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = invoke { i64, i32 } @_ZN15GridIndexVectorixEi(ptr noundef nonnull align 8 dereferenceable(40) %6, i32 noundef %62)
          to label %64 unwind label %98

64:                                               ; preds = %61
  store { i64, i32 } %63, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %15, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %14, i64 12, i1 false), !tbaa.struct !45
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %11, i64 12, i1 false), !tbaa.struct !45
  %65 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %16, i64 12, i1 false)
  %66 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 0
  %67 = load i64, ptr %66, align 4
  %68 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 1
  %69 = load i32, ptr %68, align 4
  %70 = invoke noundef double @_ZN8LevelSet25_minDistToTriangleSquaredE9GridIndexi(ptr noundef nonnull align 8 dereferenceable(448) %24, i64 %67, i32 %69, i32 noundef %65)
          to label %71 unwind label %57

71:                                               ; preds = %64
  store double %70, ptr %12, align 8, !tbaa !46
  %72 = getelementptr inbounds %class.LevelSet, ptr %24, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %11, i64 12, i1 false), !tbaa.struct !45
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %18, i64 12, i1 false)
  %73 = getelementptr inbounds { i64, i32 }, ptr %19, i32 0, i32 0
  %74 = load i64, ptr %73, align 4
  %75 = getelementptr inbounds { i64, i32 }, ptr %19, i32 0, i32 1
  %76 = load i32, ptr %75, align 4
  %77 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %72, i64 %74, i32 %76)
          to label %78 unwind label %57

78:                                               ; preds = %71
  br i1 %77, label %79, label %90

79:                                               ; preds = %78
  %80 = load double, ptr %12, align 8, !tbaa !46
  %81 = getelementptr inbounds %class.LevelSet, ptr %24, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %11, i64 12, i1 false), !tbaa.struct !45
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %20, i64 12, i1 false)
  %82 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 0
  %83 = load i64, ptr %82, align 4
  %84 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 1
  %85 = load i32, ptr %84, align 4
  %86 = invoke noundef float @_ZN7Array3dIfEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(36) %81, i64 %83, i32 %85)
          to label %87 unwind label %57

87:                                               ; preds = %79
  %88 = fpext float %86 to double
  %89 = fcmp olt double %80, %88
  br i1 %89, label %90, label %102

90:                                               ; preds = %87, %78
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %11, i64 12, i1 false), !tbaa.struct !45
  %91 = load double, ptr %12, align 8, !tbaa !46
  %92 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %22, i64 12, i1 false)
  %93 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 0
  %94 = load i64, ptr %93, align 4
  %95 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 1
  %96 = load i32, ptr %95, align 4
  invoke void @_ZN8LevelSet16_setLevelSetCellE9GridIndexdi(ptr noundef nonnull align 8 dereferenceable(448) %24, i64 %94, i32 %96, double noundef %91, i32 noundef %92)
          to label %97 unwind label %57

97:                                               ; preds = %90
  br label %102

98:                                               ; preds = %61
  %99 = landingpad { ptr, i32 }
          cleanup
  %100 = extractvalue { ptr, i32 } %99, 0
  store ptr %100, ptr %9, align 8
  %101 = extractvalue { ptr, i32 } %99, 1
  store i32 %101, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #7
  br label %106

102:                                              ; preds = %97, %87
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %13, align 4, !tbaa !9
  %105 = add i32 %104, 1
  store i32 %105, ptr %13, align 4, !tbaa !9
  br label %42, !llvm.loop !47

106:                                              ; preds = %98, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %108

107:                                              ; preds = %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #7
  call void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #7
  ret void

108:                                              ; preds = %106, %53
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #7
  br label %109

109:                                              ; preds = %108, %49
  call void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #7
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %9, align 8
  %112 = load i32, ptr %10, align 4
  %113 = insertvalue { ptr, i32 } poison, ptr %111, 0
  %114 = insertvalue { ptr, i32 } %113, i32 %112, 1
  resume { ptr, i32 } %114
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #6 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN8LevelSet25_minDistToTriangleSquaredE9GridIndexi(ptr noundef nonnull align 8 dereferenceable(448), i64, i32, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32), i64, i32) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN7Array3dIfEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(36), i64, i32) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8LevelSet16_setLevelSetCellE9GridIndexdi(ptr noundef nonnull align 8 dereferenceable(448), i64, i32, double noundef, i32 noundef) #0 align 2

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 #5 = { 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 #6 = { 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 #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 12, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS8LevelSet", !10, i64 0, !10, i64 4, !10, i64 8, !15, i64 16, !10, i64 24, !16, i64 32, !39, i64 264, !41, i64 304, !42, i64 344, !29, i64 376, !15, i64 400, !10, i64 408, !42, i64 416}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTS12TriangleMesh", !17, i64 0, !17, i64 24, !17, i64 48, !21, i64 72, !10, i64 96, !10, i64 100, !10, i64 104, !15, i64 112, !25, i64 120, !29, i64 144, !33, i64 168}
!17 = !{!"_ZTSSt6vectorIN5vmath4vec3ESaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN5vmath4vec3ESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSSt6vectorI8TriangleSaIS0_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseI8TriangleSaIS0_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"_ZTSSt6vectorIS_IiSaIiEESaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE12_Vector_implE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!29 = !{!"_ZTSSt6vectorIdSaIdEE", !30, i64 0}
!30 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!33 = !{!"_ZTS7Array3dISt6vectorIiSaIiEEE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !34, i64 24, !35, i64 32, !10, i64 56}
!34 = !{!"bool", !7, i64 0}
!35 = !{!"_ZTSSt6vectorIiSaIiEE", !36, i64 0}
!36 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !37, i64 0}
!37 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !38, i64 0}
!38 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!39 = !{!"_ZTS7Array3dIfE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !34, i64 24, !40, i64 28, !10, i64 32}
!40 = !{!"float", !7, i64 0}
!41 = !{!"_ZTS7Array3dIiE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !34, i64 24, !10, i64 28, !10, i64 32}
!42 = !{!"_ZTS7Array3dIbE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !34, i64 24, !34, i64 25, !10, i64 28}
!43 = !{!14, !10, i64 4}
!44 = !{!14, !10, i64 8}
!45 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9}
!46 = !{!15, !15, i64 0}
!47 = distinct !{!47, !48}
!48 = !{!"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"

%class.GridIndexVector = type { i32, i32, i32, %"class.std::vector.15" }
%"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 }
%struct.GridIndex = type { i32, i32, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8LevelSet27_getTriangleGridCellOverlapE8TriangleR15GridIndexVector(ptr noundef nonnull align 8 dereferenceable(448), i64, i32, ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

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

declare void @_ZN15GridIndexVectorC1Eiii(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN15GridIndexVector4sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #3 align 2

declare { i64, i32 } @_ZN15GridIndexVectorixEi(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind
declare void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8LevelSet37_calculateDistancesSquaredForTriangleEi(ptr noundef nonnull align 8 dereferenceable(448) %0, i32 noundef %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.GridIndexVector, align 8
  %4 = alloca %struct.GridIndex, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 104
  %6 = sext i32 %1 to i64
  %7 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI8TriangleSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %6) #6
  %.sroa.027.0.copyload = load i64, ptr %7, align 4
  %.sroa.528.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  %.sroa.528.0.copyload = load i32, ptr %.sroa.528.0..sroa_idx, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #6
  %8 = load i32, ptr %0, align 8, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !40
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !41
  call void @_ZN15GridIndexVectorC1Eiii(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef %8, i32 noundef %10, i32 noundef %12)
  invoke void @_ZN8LevelSet27_getTriangleGridCellOverlapE8TriangleR15GridIndexVector(ptr noundef nonnull align 8 dereferenceable(448) %0, i64 %.sroa.027.0.copyload, i32 %.sroa.528.0.copyload, ptr noundef nonnull align 8 dereferenceable(40) %3)
          to label %13 unwind label %17

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #6
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %4)
  %14 = call noundef i64 @_ZN15GridIndexVector4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %3)
  %.not = icmp eq i64 %14, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %13
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  %15 = getelementptr inbounds i8, ptr %0, i64 344
  %16 = getelementptr inbounds i8, ptr %0, i64 264
  br label %21

._crit_edge:                                      ; preds = %36, %13
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #6
  call void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %3) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #6
  ret void

17:                                               ; preds = %2
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %42

19:                                               ; preds = %33, %28, %25, %23
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %41

21:                                               ; preds = %.lr.ph, %36
  %.03538 = phi i32 [ 0, %.lr.ph ], [ %37, %36 ]
  %22 = invoke { i64, i32 } @_ZN15GridIndexVectorixEi(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef %.03538)
          to label %23 unwind label %34

23:                                               ; preds = %21
  %.fca.0.extract = extractvalue { i64, i32 } %22, 0
  %.fca.1.extract = extractvalue { i64, i32 } %22, 1
  store i64 %.fca.0.extract, ptr %4, align 8
  store i32 %.fca.1.extract, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !42
  %24 = invoke noundef double @_ZN8LevelSet25_minDistToTriangleSquaredE9GridIndexi(ptr noundef nonnull align 8 dereferenceable(448) %0, i64 %.fca.0.extract, i32 %.fca.1.extract, i32 noundef %1)
          to label %25 unwind label %19

25:                                               ; preds = %23
  %.sroa.09.0.copyload = load i64, ptr %4, align 8
  %.sroa.210.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !42
  %26 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %15, i64 %.sroa.09.0.copyload, i32 %.sroa.210.0.copyload)
          to label %27 unwind label %19

27:                                               ; preds = %25
  br i1 %26, label %28, label %33

28:                                               ; preds = %27
  %.sroa.05.0.copyload = load i64, ptr %4, align 8
  %.sroa.26.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !42
  %29 = invoke noundef float @_ZN7Array3dIfEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(36) %16, i64 %.sroa.05.0.copyload, i32 %.sroa.26.0.copyload)
          to label %30 unwind label %19

30:                                               ; preds = %28
  %31 = fpext float %29 to double
  %32 = fcmp olt double %24, %31
  br i1 %32, label %33, label %36

33:                                               ; preds = %30, %27
  %.sroa.01.0.copyload = load i64, ptr %4, align 8
  %.sroa.22.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !42
  invoke void @_ZN8LevelSet16_setLevelSetCellE9GridIndexdi(ptr noundef nonnull align 8 dereferenceable(448) %0, i64 %.sroa.01.0.copyload, i32 %.sroa.22.0.copyload, double noundef %24, i32 noundef %1)
          to label %36 unwind label %19

34:                                               ; preds = %21
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %41

36:                                               ; preds = %30, %33
  %37 = add i32 %.03538, 1
  %38 = zext i32 %37 to i64
  %39 = call noundef i64 @_ZN15GridIndexVector4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %3)
  %40 = icmp ugt i64 %39, %38
  br i1 %40, label %21, label %._crit_edge, !llvm.loop !43

41:                                               ; preds = %34, %19
  %.pn = phi { ptr, i32 } [ %20, %19 ], [ %35, %34 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #6
  br label %42

42:                                               ; preds = %41, %17
  %.pn.pn = phi { ptr, i32 } [ %.pn, %41 ], [ %18, %17 ]
  call void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %3) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #6
  resume { ptr, i32 } %.pn.pn
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN8LevelSet25_minDistToTriangleSquaredE9GridIndexi(ptr noundef nonnull align 8 dereferenceable(448), i64, i32, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32), i64, i32) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN7Array3dIfEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(36), i64, i32) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8LevelSet16_setLevelSetCellE9GridIndexdi(ptr noundef nonnull align 8 dereferenceable(448), i64, i32, double noundef, i32 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #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 = { 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 #4 = { 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 #5 = { 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTS8LevelSet", !10, i64 0, !10, i64 4, !10, i64 8, !11, i64 16, !10, i64 24, !12, i64 32, !36, i64 264, !38, i64 304, !39, i64 344, !26, i64 376, !11, i64 400, !10, i64 408, !39, i64 416}
!10 = !{!"int", !6, i64 0}
!11 = !{!"double", !6, i64 0}
!12 = !{!"_ZTS12TriangleMesh", !13, i64 0, !13, i64 24, !13, i64 48, !18, i64 72, !10, i64 96, !10, i64 100, !10, i64 104, !11, i64 112, !22, i64 120, !26, i64 144, !30, i64 168}
!13 = !{!"_ZTSSt6vectorIN5vmath4vec3ESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN5vmath4vec3ESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !6, i64 0}
!18 = !{!"_ZTSSt6vectorI8TriangleSaIS0_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseI8TriangleSaIS0_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!22 = !{!"_ZTSSt6vectorIS_IiSaIiEESaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!26 = !{!"_ZTSSt6vectorIdSaIdEE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!30 = !{!"_ZTS7Array3dISt6vectorIiSaIiEEE", !10, i64 0, !10, i64 4, !10, i64 8, !17, i64 16, !31, i64 24, !32, i64 32, !10, i64 56}
!31 = !{!"bool", !6, i64 0}
!32 = !{!"_ZTSSt6vectorIiSaIiEE", !33, i64 0}
!33 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!36 = !{!"_ZTS7Array3dIfE", !10, i64 0, !10, i64 4, !10, i64 8, !17, i64 16, !31, i64 24, !37, i64 28, !10, i64 32}
!37 = !{!"float", !6, i64 0}
!38 = !{!"_ZTS7Array3dIiE", !10, i64 0, !10, i64 4, !10, i64 8, !17, i64 16, !31, i64 24, !10, i64 28, !10, i64 32}
!39 = !{!"_ZTS7Array3dIbE", !10, i64 0, !10, i64 4, !10, i64 8, !17, i64 16, !31, i64 24, !31, i64 25, !10, i64 28}
!40 = !{!9, !10, i64 4}
!41 = !{!9, !10, i64 8}
!42 = !{!10, !10, i64 0}
!43 = distinct !{!43, !44}
!44 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass