; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src (utils)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.AABB = type { %"class.vmath::vec3", double, double, double }
%"class.vmath::vec3" = type { float, float, float }
%struct.GridIndex = type { i32, i32, i32 }
%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.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 = 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 }

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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 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) #3

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5utils31getCellsInsideTriangleMeshSubd2ER12TriangleMeshiiidRSt6vectorI9GridIndexSaIS3_EERS2_IhSaIhEE(ptr noundef nonnull align 8 dereferenceable(232), i32 noundef, i32 noundef, i32 noundef, double noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #5

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5utils31getCellsInsideTriangleMeshSubd2E12TriangleMeshdRSt6vectorI9GridIndexSaIS2_EERS1_IhSaIhEE(ptr noundef %0, double noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %3) #5 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %class.AABB, align 8
  %10 = alloca %struct.GridIndex, align 4
  %11 = alloca %"class.vmath::vec3", align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca { i64, i32 }, align 8
  %15 = alloca %"class.vmath::vec3", align 4
  %16 = alloca %struct.GridIndex, align 4
  %17 = alloca { i64, i32 }, align 4
  %18 = alloca %"class.vmath::vec3", align 4
  %19 = alloca i32, align 4
  %20 = alloca %struct.GridIndex, align 4
  %21 = alloca %struct.GridIndex, align 4
  %22 = alloca %class.AABB, align 8
  %23 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #7
  %24 = getelementptr inbounds %class.TriangleMesh, ptr %0, i32 0, i32 0
  call void @_ZN4AABBC1ERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(40) %9, ptr noundef nonnull align 8 dereferenceable(24) %24)
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #7
  %25 = getelementptr inbounds %class.AABB, ptr %9, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %25, i64 12, i1 false), !tbaa.struct !11
  %26 = load double, ptr %6, align 8, !tbaa !9
  %27 = invoke { i64, i32 } @_ZN6Grid3d19positionToGridIndexEN5vmath4vec3Ed(ptr noundef %11, double noundef %26)
          to label %28 unwind label %68

28:                                               ; preds = %4
  store { i64, i32 } %27, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %14, i64 12, i1 false)
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %11) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %15) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %10, i64 12, i1 false), !tbaa.struct !14
  %29 = load double, ptr %6, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %16, i64 12, i1 false)
  %30 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 0
  %31 = load i64, ptr %30, align 4
  %32 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 1
  %33 = load i32, ptr %32, align 4
  invoke void @_ZN6Grid3d19GridIndexToPositionE9GridIndexd(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4 %15, i64 %31, i32 %33, double noundef %29)
          to label %34 unwind label %72

34:                                               ; preds = %28
  invoke void @_ZN5vmathngERKNS_4vec3E(ptr dead_on_unwind writable sret(%"class.vmath::vec3") align 4 %18, ptr noundef nonnull align 4 dereferenceable(12) %15)
          to label %35 unwind label %76

35:                                               ; preds = %34
  invoke void @_ZN12TriangleMesh9translateEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef %18)
          to label %36 unwind label %80

36:                                               ; preds = %35
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %18) #7
  %37 = getelementptr inbounds %class.AABB, ptr %9, i32 0, i32 0
  %38 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN5vmathmIERNS_4vec3ERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %37, ptr noundef nonnull align 4 dereferenceable(12) %15)
          to label %39 unwind label %76

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  %40 = call noundef i32 @_ZNSt14numeric_limitsIiE3maxEv() #7
  store i32 %40, ptr %19, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 12, ptr %20) #7
  invoke void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %20)
          to label %41 unwind label %84

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

42:                                               ; preds = %41
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %22, ptr align 8 %9, i64 40, i1 false), !tbaa.struct !17
  %43 = load double, ptr %6, align 8, !tbaa !9
  %44 = load i32, ptr %19, align 4, !tbaa !15
  %45 = load i32, ptr %19, align 4, !tbaa !15
  %46 = load i32, ptr %19, align 4, !tbaa !15
  invoke void @_ZN6Grid3d18getGridIndexBoundsE4AABBdiiiP9GridIndexS2_(ptr noundef %22, double noundef %43, i32 noundef %44, i32 noundef %45, i32 noundef %46, ptr noundef %20, ptr noundef %21)
          to label %47 unwind label %92

47:                                               ; preds = %42
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %22) #7
  %48 = getelementptr inbounds %struct.GridIndex, ptr %21, i32 0, i32 0
  %49 = load i32, ptr %48, align 4, !tbaa !18
  %50 = add nsw i32 %49, 1
  %51 = getelementptr inbounds %struct.GridIndex, ptr %21, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !20
  %53 = add nsw i32 %52, 1
  %54 = getelementptr inbounds %struct.GridIndex, ptr %21, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !21
  %56 = add nsw i32 %55, 1
  %57 = load double, ptr %6, align 8, !tbaa !9
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  invoke void @_ZN5utils31getCellsInsideTriangleMeshSubd2ER12TriangleMeshiiidRSt6vectorI9GridIndexSaIS3_EERS2_IhSaIhEE(ptr noundef nonnull align 8 dereferenceable(232) %0, i32 noundef %50, i32 noundef %53, i32 noundef %56, double noundef %57, ptr noundef nonnull align 8 dereferenceable(24) %58, ptr noundef nonnull align 8 dereferenceable(24) %59)
          to label %60 unwind label %88

60:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 0, ptr %23, align 4, !tbaa !15
  br label %61

61:                                               ; preds = %139, %60
  %62 = load i32, ptr %23, align 4, !tbaa !15
  %63 = zext i32 %62 to i64
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = call noundef i64 @_ZNKSt6vectorI9GridIndexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %64) #7
  %66 = icmp ult i64 %63, %65
  br i1 %66, label %96, label %67

67:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  br label %142

68:                                               ; preds = %4
  %69 = landingpad { ptr, i32 }
          cleanup
  %70 = extractvalue { ptr, i32 } %69, 0
  store ptr %70, ptr %12, align 8
  %71 = extractvalue { ptr, i32 } %69, 1
  store i32 %71, ptr %13, align 4
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %11) #7
  br label %147

72:                                               ; preds = %28
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %12, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %13, align 4
  br label %146

76:                                               ; preds = %36, %34
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %12, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %13, align 4
  br label %145

80:                                               ; preds = %35
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %12, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %13, align 4
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %18) #7
  br label %145

84:                                               ; preds = %39
  %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 %144

88:                                               ; preds = %47, %41
  %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 %143

92:                                               ; preds = %42
  %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
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %22) #7
  br label %143

96:                                               ; preds = %61
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = load i32, ptr %23, align 4, !tbaa !15
  %99 = zext i32 %98 to i64
  %100 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %97, i64 noundef %99) #7
  %101 = getelementptr inbounds %struct.GridIndex, ptr %100, i32 0, i32 0
  %102 = load i32, ptr %101, align 4, !tbaa !18
  %103 = getelementptr inbounds %struct.GridIndex, ptr %10, i32 0, i32 0
  %104 = load i32, ptr %103, align 4, !tbaa !18
  %105 = add nsw i32 %102, %104
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = load i32, ptr %23, align 4, !tbaa !15
  %108 = zext i32 %107 to i64
  %109 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %106, i64 noundef %108) #7
  %110 = getelementptr inbounds %struct.GridIndex, ptr %109, i32 0, i32 0
  store i32 %105, ptr %110, align 4, !tbaa !18
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = load i32, ptr %23, align 4, !tbaa !15
  %113 = zext i32 %112 to i64
  %114 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %111, i64 noundef %113) #7
  %115 = getelementptr inbounds %struct.GridIndex, ptr %114, i32 0, i32 1
  %116 = load i32, ptr %115, align 4, !tbaa !20
  %117 = getelementptr inbounds %struct.GridIndex, ptr %10, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !20
  %119 = add nsw i32 %116, %118
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  %121 = load i32, ptr %23, align 4, !tbaa !15
  %122 = zext i32 %121 to i64
  %123 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %120, i64 noundef %122) #7
  %124 = getelementptr inbounds %struct.GridIndex, ptr %123, i32 0, i32 1
  store i32 %119, ptr %124, align 4, !tbaa !20
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = load i32, ptr %23, align 4, !tbaa !15
  %127 = zext i32 %126 to i64
  %128 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %125, i64 noundef %127) #7
  %129 = getelementptr inbounds %struct.GridIndex, ptr %128, i32 0, i32 2
  %130 = load i32, ptr %129, align 4, !tbaa !21
  %131 = getelementptr inbounds %struct.GridIndex, ptr %10, i32 0, i32 2
  %132 = load i32, ptr %131, align 4, !tbaa !21
  %133 = add nsw i32 %130, %132
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  %135 = load i32, ptr %23, align 4, !tbaa !15
  %136 = zext i32 %135 to i64
  %137 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %134, i64 noundef %136) #7
  %138 = getelementptr inbounds %struct.GridIndex, ptr %137, i32 0, i32 2
  store i32 %133, ptr %138, align 4, !tbaa !21
  br label %139

139:                                              ; preds = %96
  %140 = load i32, ptr %23, align 4, !tbaa !15
  %141 = add i32 %140, 1
  store i32 %141, ptr %23, align 4, !tbaa !15
  br label %61, !llvm.loop !22

142:                                              ; preds = %67
  call void @llvm.lifetime.end.p0(i64 12, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %15) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #7
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %9) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #7
  ret void

143:                                              ; preds = %92, %88
  call void @llvm.lifetime.end.p0(i64 12, ptr %21) #7
  br label %144

144:                                              ; preds = %143, %84
  call void @llvm.lifetime.end.p0(i64 12, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %145

145:                                              ; preds = %144, %80, %76
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %15) #7
  br label %146

146:                                              ; preds = %145, %72
  call void @llvm.lifetime.end.p0(i64 12, ptr %15) #7
  br label %147

147:                                              ; preds = %146, %68
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #7
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %9) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #7
  br label %148

148:                                              ; preds = %147
  %149 = load ptr, ptr %12, align 8
  %150 = load i32, ptr %13, align 4
  %151 = insertvalue { ptr, i32 } poison, ptr %149, 0
  %152 = insertvalue { ptr, i32 } %151, i32 %150, 1
  resume { ptr, i32 } %152
}

declare void @_ZN4AABBC1ERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #6

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZN6Grid3d19positionToGridIndexEN5vmath4vec3Ed(ptr noundef, double noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6Grid3d19GridIndexToPositionE9GridIndexd(ptr dead_on_unwind noalias writable sret(%"class.vmath::vec3") align 4, i64, i32, double noundef) #4

declare void @_ZN12TriangleMesh9translateEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) #6

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

declare noundef nonnull align 4 dereferenceable(12) ptr @_ZN5vmathmIERNS_4vec3ERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt14numeric_limitsIiE3maxEv() #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { "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 = !{!"double", !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}
!14 = !{i64 0, i64 4, !15, i64 4, i64 4, !15, i64 8, i64 4, !15}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 4, !12, i64 16, i64 8, !9, i64 24, i64 8, !9, i64 32, i64 8, !9}
!18 = !{!19, !16, i64 0}
!19 = !{!"_ZTS9GridIndex", !16, i64 0, !16, i64 4, !16, i64 8}
!20 = !{!19, !16, i64 4}
!21 = !{!19, !16, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"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.AABB = type { %"class.vmath::vec3", double, double, double }
%"class.vmath::vec3" = type { float, float, float }
%struct.GridIndex = type { i32, i32, i32 }

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6Grid3d18getGridIndexBoundsE4AABBdiiiP9GridIndexS2_(ptr noundef, double noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5utils31getCellsInsideTriangleMeshSubd2ER12TriangleMeshiiidRSt6vectorI9GridIndexSaIS3_EERS2_IhSaIhEE(ptr noundef nonnull align 8 dereferenceable(232), i32 noundef, i32 noundef, i32 noundef, double noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #5

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5utils31getCellsInsideTriangleMeshSubd2E12TriangleMeshdRSt6vectorI9GridIndexSaIS2_EERS1_IhSaIhEE(ptr noundef nonnull %0, double noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %3) local_unnamed_addr #5 personality ptr @__gxx_personality_v0 {
  %5 = alloca %class.AABB, align 8
  %6 = alloca %"class.vmath::vec3", align 4
  %7 = alloca %"class.vmath::vec3", align 4
  %8 = alloca %"class.vmath::vec3", align 4
  %9 = alloca %struct.GridIndex, align 4
  %10 = alloca %struct.GridIndex, align 4
  %11 = alloca %class.AABB, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #7
  call void @_ZN4AABBC1ERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(40) %5, ptr noundef nonnull align 8 dereferenceable(24) %0)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 8 dereferenceable(12) %5, i64 12, i1 false), !tbaa.struct !5
  %12 = invoke { i64, i32 } @_ZN6Grid3d19positionToGridIndexEN5vmath4vec3Ed(ptr noundef nonnull %6, double noundef %1)
          to label %13 unwind label %30

13:                                               ; preds = %4
  %.fca.0.extract = extractvalue { i64, i32 } %12, 0
  %.fca.1.extract = extractvalue { i64, i32 } %12, 1
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %6) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #7
  invoke void @_ZN6Grid3d19GridIndexToPositionE9GridIndexd(ptr dead_on_unwind nonnull writable sret(%"class.vmath::vec3") align 4 %7, i64 %.fca.0.extract, i32 %.fca.1.extract, double noundef %1)
          to label %14 unwind label %32

14:                                               ; preds = %13
  invoke void @_ZN5vmathngERKNS_4vec3E(ptr dead_on_unwind nonnull writable sret(%"class.vmath::vec3") align 4 %8, ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %15 unwind label %34

15:                                               ; preds = %14
  invoke void @_ZN12TriangleMesh9translateEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef nonnull %8)
          to label %16 unwind label %36

16:                                               ; preds = %15
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %8) #7
  %17 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN5vmathmIERNS_4vec3ERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %7)
          to label %18 unwind label %34

18:                                               ; preds = %16
  %19 = call noundef i32 @_ZNSt14numeric_limitsIiE3maxEv() #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #7
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #7
  call void @_ZN9GridIndexC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %11, ptr noundef nonnull align 8 dereferenceable(40) %5, i64 40, i1 false), !tbaa.struct !10
  invoke void @_ZN6Grid3d18getGridIndexBoundsE4AABBdiiiP9GridIndexS2_(ptr noundef nonnull %11, double noundef %1, i32 noundef %19, i32 noundef %19, i32 noundef %19, ptr noundef nonnull %9, ptr noundef nonnull %10)
          to label %20 unwind label %40

20:                                               ; preds = %18
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #7
  %21 = load i32, ptr %10, align 4, !tbaa !13
  %22 = add nsw i32 %21, 1
  %23 = getelementptr inbounds i8, ptr %10, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !16
  %25 = add nsw i32 %24, 1
  %26 = getelementptr inbounds i8, ptr %10, i64 8
  %27 = load i32, ptr %26, align 4, !tbaa !17
  %28 = add nsw i32 %27, 1
  invoke void @_ZN5utils31getCellsInsideTriangleMeshSubd2ER12TriangleMeshiiidRSt6vectorI9GridIndexSaIS3_EERS2_IhSaIhEE(ptr noundef nonnull align 8 dereferenceable(232) %0, i32 noundef %22, i32 noundef %25, i32 noundef %28, double noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %3)
          to label %.preheader unwind label %38

.preheader:                                       ; preds = %20
  %29 = call noundef i64 @_ZNKSt6vectorI9GridIndexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #7
  %.not = icmp eq i64 %29, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %.sroa.016.0.extract.trunc = trunc i64 %.fca.0.extract to i32
  %.sroa.016.4.extract.shift = lshr i64 %.fca.0.extract, 32
  %.sroa.016.4.extract.trunc = trunc nuw i64 %.sroa.016.4.extract.shift to i32
  br label %42

._crit_edge:                                      ; preds = %42, %.preheader
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #7
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %5) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #7
  ret void

30:                                               ; preds = %4
  %31 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %6) #7
  br label %67

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

34:                                               ; preds = %16, %14
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %65

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

38:                                               ; preds = %20
  %39 = landingpad { ptr, i32 }
          cleanup
  br label %64

40:                                               ; preds = %18
  %41 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #7
  br label %64

42:                                               ; preds = %.lr.ph, %42
  %43 = phi i64 [ 0, %.lr.ph ], [ %61, %42 ]
  %.042 = phi i32 [ 0, %.lr.ph ], [ %60, %42 ]
  %44 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %43) #7
  %45 = load i32, ptr %44, align 4, !tbaa !13
  %46 = add nsw i32 %45, %.sroa.016.0.extract.trunc
  %47 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %43) #7
  store i32 %46, ptr %47, align 4, !tbaa !13
  %48 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %43) #7
  %49 = getelementptr inbounds i8, ptr %48, i64 4
  %50 = load i32, ptr %49, align 4, !tbaa !16
  %51 = add nsw i32 %50, %.sroa.016.4.extract.trunc
  %52 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %43) #7
  %53 = getelementptr inbounds i8, ptr %52, i64 4
  store i32 %51, ptr %53, align 4, !tbaa !16
  %54 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %43) #7
  %55 = getelementptr inbounds i8, ptr %54, i64 8
  %56 = load i32, ptr %55, align 4, !tbaa !17
  %57 = add nsw i32 %56, %.fca.1.extract
  %58 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI9GridIndexSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %43) #7
  %59 = getelementptr inbounds i8, ptr %58, i64 8
  store i32 %57, ptr %59, align 4, !tbaa !17
  %60 = add i32 %.042, 1
  %61 = zext i32 %60 to i64
  %62 = call noundef i64 @_ZNKSt6vectorI9GridIndexSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #7
  %63 = icmp ugt i64 %62, %61
  br i1 %63, label %42, label %._crit_edge, !llvm.loop !18

64:                                               ; preds = %40, %38
  %.pn = phi { ptr, i32 } [ %39, %38 ], [ %41, %40 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #7
  br label %65

65:                                               ; preds = %64, %36, %34
  %.pn.pn = phi { ptr, i32 } [ %.pn, %64 ], [ %35, %34 ], [ %37, %36 ]
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #7
  br label %66

66:                                               ; preds = %65, %32
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %65 ], [ %33, %32 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  br label %67

67:                                               ; preds = %66, %30
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %66 ], [ %31, %30 ]
  call void @_ZN4AABBD1Ev(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.pn.pn
}

declare void @_ZN4AABBC1ERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #6

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZN6Grid3d19positionToGridIndexEN5vmath4vec3Ed(ptr noundef, double noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6Grid3d19GridIndexToPositionE9GridIndexd(ptr dead_on_unwind noalias writable sret(%"class.vmath::vec3") align 4, i64, i32, double noundef) local_unnamed_addr #4

declare void @_ZN12TriangleMesh9translateEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) local_unnamed_addr #6

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

declare noundef nonnull align 4 dereferenceable(12) ptr @_ZN5vmathmIERNS_4vec3ERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt14numeric_limitsIiE3maxEv() local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { "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"}
!10 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 16, i64 8, !11, i64 24, i64 8, !11, i64 32, i64 8, !11}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTS9GridIndex", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"int", !8, i64 0}
!16 = !{!14, !15, i64 4}
!17 = !{!14, !15, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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