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

; 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.GridIndex = type { i32, i32, 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 }
%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: 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 @_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)) #3 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40), i64, i32) #4 align 2

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

; 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 zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32), i64, i32) #7 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) #7 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64, i32, i32 noundef, i32 noundef, i32 noundef) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN15GridIndexVector5emptyEv(ptr noundef nonnull align 8 dereferenceable(40)) #3 align 2

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

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

46:                                               ; preds = %4
  %47 = getelementptr inbounds %class.LevelSet, ptr %35, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %5, i64 12, i1 false), !tbaa.struct !43
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %14, i64 12, i1 false)
  %48 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 0
  %49 = load i64, ptr %48, align 4
  %50 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 1
  %51 = load i32, ptr %50, align 4
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %47, i64 %49, i32 %51, i1 noundef zeroext true)
          to label %52 unwind label %84

52:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 12, ptr %16) #8
  invoke void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %16)
          to label %53 unwind label %88

53:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 72, ptr %17) #8
  %54 = getelementptr inbounds [6 x %struct.GridIndex], ptr %17, i32 0, i32 0
  %55 = getelementptr inbounds %struct.GridIndex, ptr %54, i64 6
  br label %56

56:                                               ; preds = %58, %53
  %57 = phi ptr [ %54, %53 ], [ %59, %58 ]
  invoke void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %57)
          to label %58 unwind label %92

58:                                               ; preds = %56
  %59 = getelementptr inbounds %struct.GridIndex, ptr %57, i64 1
  %60 = icmp eq ptr %59, %55
  br i1 %60, label %61, label %56

61:                                               ; preds = %58
  br label %62

62:                                               ; preds = %159, %61
  %63 = invoke noundef zeroext i1 @_ZN15GridIndexVector5emptyEv(ptr noundef nonnull align 8 dereferenceable(40) %9)
          to label %64 unwind label %92

64:                                               ; preds = %62
  %65 = xor i1 %63, true
  br i1 %65, label %66, label %160

66:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #8
  %67 = invoke noundef i64 @_ZN15GridIndexVector4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %9)
          to label %68 unwind label %96

68:                                               ; preds = %66
  %69 = trunc i64 %67 to i32
  %70 = sub nsw i32 %69, 1
  %71 = invoke { i64, i32 } @_ZN15GridIndexVectorixEi(ptr noundef nonnull align 8 dereferenceable(40) %9, i32 noundef %70)
          to label %72 unwind label %96

72:                                               ; preds = %68
  store { i64, i32 } %71, ptr %19, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 8 %19, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %18, i64 12, i1 false), !tbaa.struct !43
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #8
  invoke void @_ZN15GridIndexVector8pop_backEv(ptr noundef nonnull align 8 dereferenceable(40) %9)
          to label %73 unwind label %92

73:                                               ; preds = %72
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %16, i64 12, i1 false), !tbaa.struct !43
  %74 = getelementptr inbounds [6 x %struct.GridIndex], ptr %17, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %20, i64 12, i1 false)
  %75 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 0
  %76 = load i64, ptr %75, align 4
  %77 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 1
  %78 = load i32, ptr %77, align 4
  invoke void @_ZN6Grid3d24getNeighbourGridIndices6E9GridIndexPS0_(i64 %76, i32 %78, ptr noundef %74)
          to label %79 unwind label %92

79:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #8
  store i32 0, ptr %22, align 4, !tbaa !44
  br label %80

80:                                               ; preds = %150, %79
  %81 = load i32, ptr %22, align 4, !tbaa !44
  %82 = icmp slt i32 %81, 6
  br i1 %82, label %100, label %83

83:                                               ; preds = %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  br label %153

84:                                               ; preds = %46, %4
  %85 = landingpad { ptr, i32 }
          cleanup
  %86 = extractvalue { ptr, i32 } %85, 0
  store ptr %86, ptr %12, align 8
  %87 = extractvalue { ptr, i32 } %85, 1
  store i32 %87, ptr %13, align 4
  br label %163

88:                                               ; preds = %52
  %89 = landingpad { ptr, i32 }
          cleanup
  %90 = extractvalue { ptr, i32 } %89, 0
  store ptr %90, ptr %12, align 8
  %91 = extractvalue { ptr, i32 } %89, 1
  store i32 %91, ptr %13, align 4
  br label %162

92:                                               ; preds = %153, %73, %72, %62, %56
  %93 = landingpad { ptr, i32 }
          cleanup
  %94 = extractvalue { ptr, i32 } %93, 0
  store ptr %94, ptr %12, align 8
  %95 = extractvalue { ptr, i32 } %93, 1
  store i32 %95, ptr %13, align 4
  br label %161

96:                                               ; preds = %68, %66
  %97 = landingpad { ptr, i32 }
          cleanup
  %98 = extractvalue { ptr, i32 } %97, 0
  store ptr %98, ptr %12, align 8
  %99 = extractvalue { ptr, i32 } %97, 1
  store i32 %99, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #8
  br label %161

100:                                              ; preds = %80
  %101 = load i32, ptr %22, align 4, !tbaa !44
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [6 x %struct.GridIndex], ptr %17, i64 0, i64 %102
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %103, i64 12, i1 false), !tbaa.struct !43
  %104 = getelementptr inbounds %class.LevelSet, ptr %35, i32 0, i32 0
  %105 = load i32, ptr %104, align 8, !tbaa !11
  %106 = getelementptr inbounds %class.LevelSet, ptr %35, i32 0, i32 1
  %107 = load i32, ptr %106, align 4, !tbaa !41
  %108 = getelementptr inbounds %class.LevelSet, ptr %35, i32 0, i32 2
  %109 = load i32, ptr %108, align 8, !tbaa !42
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %23, i64 12, i1 false)
  %110 = getelementptr inbounds { i64, i32 }, ptr %24, i32 0, i32 0
  %111 = load i64, ptr %110, align 4
  %112 = getelementptr inbounds { i64, i32 }, ptr %24, i32 0, i32 1
  %113 = load i32, ptr %112, align 4
  %114 = invoke noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64 %111, i32 %113, i32 noundef %105, i32 noundef %107, i32 noundef %109)
          to label %115 unwind label %145

115:                                              ; preds = %100
  br i1 %114, label %116, label %149

116:                                              ; preds = %115
  %117 = getelementptr inbounds %class.LevelSet, ptr %35, i32 0, i32 8
  %118 = load i32, ptr %22, align 4, !tbaa !44
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [6 x %struct.GridIndex], ptr %17, i64 0, i64 %119
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %120, i64 12, i1 false), !tbaa.struct !43
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %25, i64 12, i1 false)
  %121 = getelementptr inbounds { i64, i32 }, ptr %26, i32 0, i32 0
  %122 = load i64, ptr %121, align 4
  %123 = getelementptr inbounds { i64, i32 }, ptr %26, i32 0, i32 1
  %124 = load i32, ptr %123, align 4
  %125 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %117, i64 %122, i32 %124)
          to label %126 unwind label %145

126:                                              ; preds = %116
  br i1 %125, label %149, label %127

127:                                              ; preds = %126
  %128 = load i32, ptr %22, align 4, !tbaa !44
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [6 x %struct.GridIndex], ptr %17, i64 0, i64 %129
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %130, i64 12, i1 false), !tbaa.struct !43
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %27, i64 12, i1 false)
  %131 = getelementptr inbounds { i64, i32 }, ptr %28, i32 0, i32 0
  %132 = load i64, ptr %131, align 4
  %133 = getelementptr inbounds { i64, i32 }, ptr %28, i32 0, i32 1
  %134 = load i32, ptr %133, align 4
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %9, i64 %132, i32 %134)
          to label %135 unwind label %145

135:                                              ; preds = %127
  %136 = getelementptr inbounds %class.LevelSet, ptr %35, i32 0, i32 8
  %137 = load i32, ptr %22, align 4, !tbaa !44
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [6 x %struct.GridIndex], ptr %17, i64 0, i64 %138
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %29, ptr align 4 %139, i64 12, i1 false), !tbaa.struct !43
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 4 %29, i64 12, i1 false)
  %140 = getelementptr inbounds { i64, i32 }, ptr %30, i32 0, i32 0
  %141 = load i64, ptr %140, align 4
  %142 = getelementptr inbounds { i64, i32 }, ptr %30, i32 0, i32 1
  %143 = load i32, ptr %142, align 4
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %136, i64 %141, i32 %143, i1 noundef zeroext true)
          to label %144 unwind label %145

144:                                              ; preds = %135
  br label %149

145:                                              ; preds = %135, %127, %116, %100
  %146 = landingpad { ptr, i32 }
          cleanup
  %147 = extractvalue { ptr, i32 } %146, 0
  store ptr %147, ptr %12, align 8
  %148 = extractvalue { ptr, i32 } %146, 1
  store i32 %148, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #8
  br label %161

149:                                              ; preds = %144, %126, %115
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %22, align 4, !tbaa !44
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %22, align 4, !tbaa !44
  br label %80, !llvm.loop !45

153:                                              ; preds = %83
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %31, ptr align 4 %16, i64 12, i1 false), !tbaa.struct !43
  %154 = load double, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 4 %31, i64 12, i1 false)
  %155 = getelementptr inbounds { i64, i32 }, ptr %32, i32 0, i32 0
  %156 = load i64, ptr %155, align 4
  %157 = getelementptr inbounds { i64, i32 }, ptr %32, i32 0, i32 1
  %158 = load i32, ptr %157, align 4
  invoke void @_ZN8LevelSet16_setLevelSetCellE9GridIndexdi(ptr noundef nonnull align 8 dereferenceable(448) %35, i64 %156, i32 %158, double noundef %154, i32 noundef -1)
          to label %159 unwind label %92

159:                                              ; preds = %153
  br label %62, !llvm.loop !47

160:                                              ; preds = %64
  call void @llvm.lifetime.end.p0(i64 72, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #8
  call void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %9) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #8
  ret void

161:                                              ; preds = %145, %96, %92
  call void @llvm.lifetime.end.p0(i64 72, ptr %17) #8
  br label %162

162:                                              ; preds = %161, %88
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #8
  br label %163

163:                                              ; preds = %162, %84
  call void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %9) #8
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #8
  br label %164

164:                                              ; preds = %163
  %165 = load ptr, ptr %12, align 8
  %166 = load i32, ptr %13, align 4
  %167 = insertvalue { ptr, i32 } poison, ptr %165, 0
  %168 = insertvalue { ptr, i32 } %167, i32 %166, 1
  resume { ptr, i32 } %168
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6Grid3d24getNeighbourGridIndices6E9GridIndexPS0_(i64, i32, ptr noundef) #4

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 = { 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 = { inlinehint 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 #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 = { 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 #8 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS8LevelSet", !13, i64 0, !13, i64 4, !13, i64 8, !10, i64 16, !13, i64 24, !14, i64 32, !37, i64 264, !39, i64 304, !40, i64 344, !27, i64 376, !10, i64 400, !13, i64 408, !40, i64 416}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS12TriangleMesh", !15, i64 0, !15, i64 24, !15, i64 48, !19, i64 72, !13, i64 96, !13, i64 100, !13, i64 104, !10, i64 112, !23, i64 120, !27, i64 144, !31, i64 168}
!15 = !{!"_ZTSSt6vectorIN5vmath4vec3ESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN5vmath4vec3ESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"_ZTSSt6vectorI8TriangleSaIS0_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseI8TriangleSaIS0_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!"_ZTSSt6vectorIS_IiSaIiEESaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!27 = !{!"_ZTSSt6vectorIdSaIdEE", !28, i64 0}
!28 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!31 = !{!"_ZTS7Array3dISt6vectorIiSaIiEEE", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !32, i64 24, !33, i64 32, !13, i64 56}
!32 = !{!"bool", !7, i64 0}
!33 = !{!"_ZTSSt6vectorIiSaIiEE", !34, i64 0}
!34 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !36, i64 0}
!36 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!37 = !{!"_ZTS7Array3dIfE", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !32, i64 24, !38, i64 28, !13, i64 32}
!38 = !{!"float", !7, i64 0}
!39 = !{!"_ZTS7Array3dIiE", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !32, i64 24, !13, i64 28, !13, i64 32}
!40 = !{!"_ZTS7Array3dIbE", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !32, i64 24, !32, i64 25, !13, i64 28}
!41 = !{!12, !13, i64 4}
!42 = !{!12, !13, i64 8}
!43 = !{i64 0, i64 4, !44, i64 4, i64 4, !44, i64 8, i64 4, !44}
!44 = !{!13, !13, i64 0}
!45 = distinct !{!45, !46}
!46 = !{!"llvm.loop.mustprogress"}
!47 = distinct !{!47, !46}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

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

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

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

; 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 zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32), i64, i32) local_unnamed_addr #6 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 #6 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64, i32, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN15GridIndexVector5emptyEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8LevelSet22_floodFillWithDistanceE9GridIndexd(ptr noundef nonnull align 8 dereferenceable(448) %0, i64 %1, i32 %2, double noundef %3) local_unnamed_addr #6 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.GridIndexVector, align 8
  %6 = alloca %struct.GridIndex, align 8
  %7 = alloca [6 x %struct.GridIndex], align 16
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #7
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !39
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !40
  call void @_ZN15GridIndexVectorC1Eiii(ptr noundef nonnull align 8 dereferenceable(40) %5, i32 noundef %8, i32 noundef %10, i32 noundef %12)
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %5, i64 %1, i32 %2)
          to label %13 unwind label %28

13:                                               ; preds = %4
  %14 = getelementptr inbounds i8, ptr %0, i64 344
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %1, i32 %2, i1 noundef zeroext true)
          to label %.preheader53 unwind label %28

.preheader53:                                     ; preds = %13
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #7
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %6)
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %7) #7
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %7)
  %.ptr.1 = getelementptr inbounds i8, ptr %7, i64 12
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %7, i64 24
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %.ptr.3 = getelementptr inbounds i8, ptr %7, i64 36
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.3)
  %.ptr.4 = getelementptr inbounds i8, ptr %7, i64 48
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.4)
  %.ptr.5 = getelementptr inbounds i8, ptr %7, i64 60
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.5)
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  %.sroa.218.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  %.sroa.218.0..sroa_idx.1 = getelementptr inbounds i8, ptr %7, i64 20
  %.sroa.218.0..sroa_idx.2 = getelementptr inbounds i8, ptr %7, i64 32
  %.sroa.218.0..sroa_idx.3 = getelementptr inbounds i8, ptr %7, i64 44
  %.sroa.218.0..sroa_idx.4 = getelementptr inbounds i8, ptr %7, i64 56
  %.sroa.218.0..sroa_idx.5 = getelementptr inbounds i8, ptr %7, i64 68
  br label %15

15:                                               ; preds = %.preheader53, %86
  %16 = call noundef zeroext i1 @_ZN15GridIndexVector5emptyEv(ptr noundef nonnull align 8 dereferenceable(40) %5)
  br i1 %16, label %87, label %17

17:                                               ; preds = %15
  %18 = call noundef i64 @_ZN15GridIndexVector4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %5)
  %19 = trunc i64 %18 to i32
  %20 = add nsw i32 %19, -1
  %21 = invoke { i64, i32 } @_ZN15GridIndexVectorixEi(ptr noundef nonnull align 8 dereferenceable(40) %5, i32 noundef %20)
          to label %22 unwind label %32

22:                                               ; preds = %17
  %.fca.0.extract = extractvalue { i64, i32 } %21, 0
  %.fca.1.extract = extractvalue { i64, i32 } %21, 1
  store i64 %.fca.0.extract, ptr %6, align 8
  store i32 %.fca.1.extract, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !41
  invoke void @_ZN15GridIndexVector8pop_backEv(ptr noundef nonnull align 8 dereferenceable(40) %5)
          to label %23 unwind label %30

23:                                               ; preds = %22
  %.sroa.026.0.copyload = load i64, ptr %6, align 8
  %.sroa.227.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !41
  invoke void @_ZN6Grid3d24getNeighbourGridIndices6E9GridIndexPS0_(i64 %.sroa.026.0.copyload, i32 %.sroa.227.0.copyload, ptr noundef nonnull %7)
          to label %.preheader.preheader unwind label %30

.preheader.preheader:                             ; preds = %23
  %.sroa.017.0.copyload = load i64, ptr %7, align 16
  %.sroa.218.0.copyload = load i32, ptr %.sroa.218.0..sroa_idx, align 8, !tbaa !41
  %24 = load i32, ptr %0, align 8, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !39
  %26 = load i32, ptr %11, align 8, !tbaa !40
  %27 = call noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64 %.sroa.017.0.copyload, i32 %.sroa.218.0.copyload, i32 noundef %24, i32 noundef %25, i32 noundef %26)
  br i1 %27, label %34, label %.preheader.1

28:                                               ; preds = %13, %4
  %29 = landingpad { ptr, i32 }
          cleanup
  br label %89

30:                                               ; preds = %86, %23, %22
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %88

32:                                               ; preds = %17
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %88

34:                                               ; preds = %.preheader.preheader
  %.sroa.013.0.copyload = load i64, ptr %7, align 16
  %.sroa.214.0.copyload = load i32, ptr %.sroa.218.0..sroa_idx, align 8, !tbaa !41
  %35 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.013.0.copyload, i32 %.sroa.214.0.copyload)
          to label %36 unwind label %39

36:                                               ; preds = %34
  br i1 %35, label %.preheader.1, label %37

37:                                               ; preds = %36
  %.sroa.09.0.copyload = load i64, ptr %7, align 16
  %.sroa.210.0.copyload = load i32, ptr %.sroa.218.0..sroa_idx, align 8, !tbaa !41
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %5, i64 %.sroa.09.0.copyload, i32 %.sroa.210.0.copyload)
          to label %38 unwind label %39

38:                                               ; preds = %37
  %.sroa.05.0.copyload = load i64, ptr %7, align 16
  %.sroa.26.0.copyload = load i32, ptr %.sroa.218.0..sroa_idx, align 8, !tbaa !41
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.05.0.copyload, i32 %.sroa.26.0.copyload, i1 noundef zeroext true)
          to label %.preheader.1 unwind label %39

39:                                               ; preds = %85, %84, %81, %76, %75, %72, %67, %66, %63, %58, %57, %54, %49, %48, %45, %38, %37, %34
  %40 = landingpad { ptr, i32 }
          cleanup
  br label %88

.preheader.1:                                     ; preds = %.preheader.preheader, %36, %38
  %.sroa.017.0.copyload.1 = load i64, ptr %.ptr.1, align 4
  %.sroa.218.0.copyload.1 = load i32, ptr %.sroa.218.0..sroa_idx.1, align 4, !tbaa !41
  %41 = load i32, ptr %0, align 8, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !39
  %43 = load i32, ptr %11, align 8, !tbaa !40
  %44 = call noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64 %.sroa.017.0.copyload.1, i32 %.sroa.218.0.copyload.1, i32 noundef %41, i32 noundef %42, i32 noundef %43)
  br i1 %44, label %45, label %.preheader.2

45:                                               ; preds = %.preheader.1
  %.sroa.013.0.copyload.1 = load i64, ptr %.ptr.1, align 4
  %.sroa.214.0.copyload.1 = load i32, ptr %.sroa.218.0..sroa_idx.1, align 4, !tbaa !41
  %46 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.013.0.copyload.1, i32 %.sroa.214.0.copyload.1)
          to label %47 unwind label %39

47:                                               ; preds = %45
  br i1 %46, label %.preheader.2, label %48

48:                                               ; preds = %47
  %.sroa.09.0.copyload.1 = load i64, ptr %.ptr.1, align 4
  %.sroa.210.0.copyload.1 = load i32, ptr %.sroa.218.0..sroa_idx.1, align 4, !tbaa !41
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %5, i64 %.sroa.09.0.copyload.1, i32 %.sroa.210.0.copyload.1)
          to label %49 unwind label %39

49:                                               ; preds = %48
  %.sroa.05.0.copyload.1 = load i64, ptr %.ptr.1, align 4
  %.sroa.26.0.copyload.1 = load i32, ptr %.sroa.218.0..sroa_idx.1, align 4, !tbaa !41
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.05.0.copyload.1, i32 %.sroa.26.0.copyload.1, i1 noundef zeroext true)
          to label %.preheader.2 unwind label %39

.preheader.2:                                     ; preds = %49, %47, %.preheader.1
  %.sroa.017.0.copyload.2 = load i64, ptr %.ptr.2, align 8
  %.sroa.218.0.copyload.2 = load i32, ptr %.sroa.218.0..sroa_idx.2, align 16, !tbaa !41
  %50 = load i32, ptr %0, align 8, !tbaa !5
  %51 = load i32, ptr %9, align 4, !tbaa !39
  %52 = load i32, ptr %11, align 8, !tbaa !40
  %53 = call noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64 %.sroa.017.0.copyload.2, i32 %.sroa.218.0.copyload.2, i32 noundef %50, i32 noundef %51, i32 noundef %52)
  br i1 %53, label %54, label %.preheader.3

54:                                               ; preds = %.preheader.2
  %.sroa.013.0.copyload.2 = load i64, ptr %.ptr.2, align 8
  %.sroa.214.0.copyload.2 = load i32, ptr %.sroa.218.0..sroa_idx.2, align 16, !tbaa !41
  %55 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.013.0.copyload.2, i32 %.sroa.214.0.copyload.2)
          to label %56 unwind label %39

56:                                               ; preds = %54
  br i1 %55, label %.preheader.3, label %57

57:                                               ; preds = %56
  %.sroa.09.0.copyload.2 = load i64, ptr %.ptr.2, align 8
  %.sroa.210.0.copyload.2 = load i32, ptr %.sroa.218.0..sroa_idx.2, align 16, !tbaa !41
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %5, i64 %.sroa.09.0.copyload.2, i32 %.sroa.210.0.copyload.2)
          to label %58 unwind label %39

58:                                               ; preds = %57
  %.sroa.05.0.copyload.2 = load i64, ptr %.ptr.2, align 8
  %.sroa.26.0.copyload.2 = load i32, ptr %.sroa.218.0..sroa_idx.2, align 16, !tbaa !41
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.05.0.copyload.2, i32 %.sroa.26.0.copyload.2, i1 noundef zeroext true)
          to label %.preheader.3 unwind label %39

.preheader.3:                                     ; preds = %58, %56, %.preheader.2
  %.sroa.017.0.copyload.3 = load i64, ptr %.ptr.3, align 4
  %.sroa.218.0.copyload.3 = load i32, ptr %.sroa.218.0..sroa_idx.3, align 4, !tbaa !41
  %59 = load i32, ptr %0, align 8, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !39
  %61 = load i32, ptr %11, align 8, !tbaa !40
  %62 = call noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64 %.sroa.017.0.copyload.3, i32 %.sroa.218.0.copyload.3, i32 noundef %59, i32 noundef %60, i32 noundef %61)
  br i1 %62, label %63, label %.preheader.4

63:                                               ; preds = %.preheader.3
  %.sroa.013.0.copyload.3 = load i64, ptr %.ptr.3, align 4
  %.sroa.214.0.copyload.3 = load i32, ptr %.sroa.218.0..sroa_idx.3, align 4, !tbaa !41
  %64 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.013.0.copyload.3, i32 %.sroa.214.0.copyload.3)
          to label %65 unwind label %39

65:                                               ; preds = %63
  br i1 %64, label %.preheader.4, label %66

66:                                               ; preds = %65
  %.sroa.09.0.copyload.3 = load i64, ptr %.ptr.3, align 4
  %.sroa.210.0.copyload.3 = load i32, ptr %.sroa.218.0..sroa_idx.3, align 4, !tbaa !41
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %5, i64 %.sroa.09.0.copyload.3, i32 %.sroa.210.0.copyload.3)
          to label %67 unwind label %39

67:                                               ; preds = %66
  %.sroa.05.0.copyload.3 = load i64, ptr %.ptr.3, align 4
  %.sroa.26.0.copyload.3 = load i32, ptr %.sroa.218.0..sroa_idx.3, align 4, !tbaa !41
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.05.0.copyload.3, i32 %.sroa.26.0.copyload.3, i1 noundef zeroext true)
          to label %.preheader.4 unwind label %39

.preheader.4:                                     ; preds = %67, %65, %.preheader.3
  %.sroa.017.0.copyload.4 = load i64, ptr %.ptr.4, align 16
  %.sroa.218.0.copyload.4 = load i32, ptr %.sroa.218.0..sroa_idx.4, align 8, !tbaa !41
  %68 = load i32, ptr %0, align 8, !tbaa !5
  %69 = load i32, ptr %9, align 4, !tbaa !39
  %70 = load i32, ptr %11, align 8, !tbaa !40
  %71 = call noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64 %.sroa.017.0.copyload.4, i32 %.sroa.218.0.copyload.4, i32 noundef %68, i32 noundef %69, i32 noundef %70)
  br i1 %71, label %72, label %.preheader.5

72:                                               ; preds = %.preheader.4
  %.sroa.013.0.copyload.4 = load i64, ptr %.ptr.4, align 16
  %.sroa.214.0.copyload.4 = load i32, ptr %.sroa.218.0..sroa_idx.4, align 8, !tbaa !41
  %73 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.013.0.copyload.4, i32 %.sroa.214.0.copyload.4)
          to label %74 unwind label %39

74:                                               ; preds = %72
  br i1 %73, label %.preheader.5, label %75

75:                                               ; preds = %74
  %.sroa.09.0.copyload.4 = load i64, ptr %.ptr.4, align 16
  %.sroa.210.0.copyload.4 = load i32, ptr %.sroa.218.0..sroa_idx.4, align 8, !tbaa !41
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %5, i64 %.sroa.09.0.copyload.4, i32 %.sroa.210.0.copyload.4)
          to label %76 unwind label %39

76:                                               ; preds = %75
  %.sroa.05.0.copyload.4 = load i64, ptr %.ptr.4, align 16
  %.sroa.26.0.copyload.4 = load i32, ptr %.sroa.218.0..sroa_idx.4, align 8, !tbaa !41
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.05.0.copyload.4, i32 %.sroa.26.0.copyload.4, i1 noundef zeroext true)
          to label %.preheader.5 unwind label %39

.preheader.5:                                     ; preds = %76, %74, %.preheader.4
  %.sroa.017.0.copyload.5 = load i64, ptr %.ptr.5, align 4
  %.sroa.218.0.copyload.5 = load i32, ptr %.sroa.218.0..sroa_idx.5, align 4, !tbaa !41
  %77 = load i32, ptr %0, align 8, !tbaa !5
  %78 = load i32, ptr %9, align 4, !tbaa !39
  %79 = load i32, ptr %11, align 8, !tbaa !40
  %80 = call noundef zeroext i1 @_ZN6Grid3d18isGridIndexInRangeE9GridIndexiii(i64 %.sroa.017.0.copyload.5, i32 %.sroa.218.0.copyload.5, i32 noundef %77, i32 noundef %78, i32 noundef %79)
  br i1 %80, label %81, label %86

81:                                               ; preds = %.preheader.5
  %.sroa.013.0.copyload.5 = load i64, ptr %.ptr.5, align 4
  %.sroa.214.0.copyload.5 = load i32, ptr %.sroa.218.0..sroa_idx.5, align 4, !tbaa !41
  %82 = invoke noundef zeroext i1 @_ZN7Array3dIbEclE9GridIndex(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.013.0.copyload.5, i32 %.sroa.214.0.copyload.5)
          to label %83 unwind label %39

83:                                               ; preds = %81
  br i1 %82, label %86, label %84

84:                                               ; preds = %83
  %.sroa.09.0.copyload.5 = load i64, ptr %.ptr.5, align 4
  %.sroa.210.0.copyload.5 = load i32, ptr %.sroa.218.0..sroa_idx.5, align 4, !tbaa !41
  invoke void @_ZN15GridIndexVector9push_backE9GridIndex(ptr noundef nonnull align 8 dereferenceable(40) %5, i64 %.sroa.09.0.copyload.5, i32 %.sroa.210.0.copyload.5)
          to label %85 unwind label %39

85:                                               ; preds = %84
  %.sroa.05.0.copyload.5 = load i64, ptr %.ptr.5, align 4
  %.sroa.26.0.copyload.5 = load i32, ptr %.sroa.218.0..sroa_idx.5, align 4, !tbaa !41
  invoke void @_ZN7Array3dIbE3setE9GridIndexb(ptr noundef nonnull align 8 dereferenceable(32) %14, i64 %.sroa.05.0.copyload.5, i32 %.sroa.26.0.copyload.5, i1 noundef zeroext true)
          to label %86 unwind label %39

86:                                               ; preds = %85, %83, %.preheader.5
  %.sroa.01.0.copyload = load i64, ptr %6, align 8
  %.sroa.22.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 8, !tbaa !41
  invoke void @_ZN8LevelSet16_setLevelSetCellE9GridIndexdi(ptr noundef nonnull align 8 dereferenceable(448) %0, i64 %.sroa.01.0.copyload, i32 %.sroa.22.0.copyload, double noundef %3, i32 noundef -1)
          to label %15 unwind label %30, !llvm.loop !42

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

88:                                               ; preds = %39, %32, %30
  %.pn = phi { ptr, i32 } [ %40, %39 ], [ %31, %30 ], [ %33, %32 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #7
  br label %89

89:                                               ; preds = %88, %28
  %.pn.pn = phi { ptr, i32 } [ %.pn, %88 ], [ %29, %28 ]
  call void @_ZN15GridIndexVectorD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %5) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #7
  resume { ptr, i32 } %.pn.pn
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6Grid3d24getNeighbourGridIndices6E9GridIndexPS0_(i64, i32, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { inlinehint 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 #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 = { 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, !7, i64 0}
!6 = !{!"_ZTS8LevelSet", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !7, i64 24, !11, i64 32, !35, i64 264, !37, i64 304, !38, i64 344, !25, i64 376, !10, i64 400, !7, i64 408, !38, i64 416}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTS12TriangleMesh", !12, i64 0, !12, i64 24, !12, i64 48, !17, i64 72, !7, i64 96, !7, i64 100, !7, i64 104, !10, i64 112, !21, i64 120, !25, i64 144, !29, i64 168}
!12 = !{!"_ZTSSt6vectorIN5vmath4vec3ESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIN5vmath4vec3ESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN5vmath4vec3ESaIS1_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"_ZTSSt6vectorI8TriangleSaIS0_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseI8TriangleSaIS0_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseI8TriangleSaIS0_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!21 = !{!"_ZTSSt6vectorIS_IiSaIiEESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseISt6vectorIiSaIiEESaIS2_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!25 = !{!"_ZTSSt6vectorIdSaIdEE", !26, i64 0}
!26 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!29 = !{!"_ZTS7Array3dISt6vectorIiSaIiEEE", !7, i64 0, !7, i64 4, !7, i64 8, !16, i64 16, !30, i64 24, !31, i64 32, !7, i64 56}
!30 = !{!"bool", !8, i64 0}
!31 = !{!"_ZTSSt6vectorIiSaIiEE", !32, i64 0}
!32 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!35 = !{!"_ZTS7Array3dIfE", !7, i64 0, !7, i64 4, !7, i64 8, !16, i64 16, !30, i64 24, !36, i64 28, !7, i64 32}
!36 = !{!"float", !8, i64 0}
!37 = !{!"_ZTS7Array3dIiE", !7, i64 0, !7, i64 4, !7, i64 8, !16, i64 16, !30, i64 24, !7, i64 28, !7, i64 32}
!38 = !{!"_ZTS7Array3dIbE", !7, i64 0, !7, i64 4, !7, i64 8, !16, i64 16, !30, i64 24, !30, i64 25, !7, i64 28}
!39 = !{!6, !7, i64 4}
!40 = !{!6, !7, i64 8}
!41 = !{!7, !7, i64 0}
!42 = distinct !{!42, !43}
!43 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass