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

; 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.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_Vector_impl" }
%"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_Vector_impl" = type { %"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_Vector_impl_data" }
%"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_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<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 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16SpatialPointGrid6insertERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr dead_on_unwind noalias writable sret(%"class.std::vector.5") align 8, ptr noundef nonnull align 8 dereferenceable(152), ptr noundef nonnull align 1) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16SpatialPointGrid6insertER16FragmentedVectorIN5vmath4vec3EE(ptr dead_on_unwind noalias writable sret(%"class.std::vector.5") align 8 %0, ptr noundef nonnull align 8 dereferenceable(152) %1, ptr noundef nonnull align 8 dereferenceable(48) %2) #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.std::vector.10", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  call void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = invoke noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %12)
          to label %14 unwind label %24

14:                                               ; preds = %3
  %15 = zext i32 %13 to i64
  invoke void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %15)
          to label %16 unwind label %24

16:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %38, %16
  %18 = load i32, ptr %10, align 4, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = invoke noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %19)
          to label %21 unwind label %28

21:                                               ; preds = %17
  %22 = icmp ult i32 %18, %20
  br i1 %22, label %32, label %23

23:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %41

24:                                               ; preds = %41, %14, %3
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %8, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %9, align 4
  br label %43

28:                                               ; preds = %36, %32, %17
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %8, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %43

32:                                               ; preds = %21
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48) %33, i32 noundef %34)
          to label %36 unwind label %28

36:                                               ; preds = %32
  invoke void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 4 dereferenceable(12) %35)
          to label %37 unwind label %28

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = add i32 %39, 1
  store i32 %40, ptr %10, align 4, !tbaa !9
  br label %17, !llvm.loop !11

41:                                               ; preds = %23
  invoke void @_ZN16SpatialPointGrid6insertERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr dead_on_unwind writable sret(%"class.std::vector.5") align 8 %0, ptr noundef nonnull align 8 dereferenceable(152) %11, ptr noundef nonnull align 8 dereferenceable(24) %7)
          to label %42 unwind label %24

42:                                               ; preds = %41
  call void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  ret void

43:                                               ; preds = %28, %24
  call void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %8, align 8
  %46 = load i32, ptr %9, align 4
  %47 = insertvalue { ptr, i32 } poison, ptr %45, 0
  %48 = insertvalue { ptr, i32 } %47, i32 %46, 1
  resume { ptr, i32 } %48
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 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 nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 }

!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 = distinct !{!11, !12}
!12 = !{!"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.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_Vector_impl" }
%"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_Vector_impl" = type { %"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_Vector_impl_data" }
%"struct.std::_Vector_base<GridPointReference, std::allocator<GridPointReference>>::_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<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 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16SpatialPointGrid6insertERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr dead_on_unwind noalias writable sret(%"class.std::vector.5") align 8, ptr noundef nonnull align 8 dereferenceable(152), ptr noundef nonnull align 1) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16SpatialPointGrid6insertER16FragmentedVectorIN5vmath4vec3EE(ptr dead_on_unwind noalias writable sret(%"class.std::vector.5") align 8 %0, ptr noundef nonnull align 8 dereferenceable(152) %1, ptr noundef nonnull align 8 dereferenceable(48) %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::vector.10", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  call void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  %5 = call noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %6 = zext i32 %5 to i64
  invoke void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %6)
          to label %.preheader unwind label %8

.preheader:                                       ; preds = %3
  %7 = call noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %14, %.preheader
  invoke void @_ZN16SpatialPointGrid6insertERSt6vectorIN5vmath4vec3ESaIS2_EE(ptr dead_on_unwind writable sret(%"class.std::vector.5") align 8 %0, ptr noundef nonnull align 8 dereferenceable(152) %1, ptr noundef nonnull align 8 dereferenceable(24) %4)
          to label %18 unwind label %8

8:                                                ; preds = %._crit_edge, %3
  %9 = landingpad { ptr, i32 }
          cleanup
  br label %19

10:                                               ; preds = %13, %.lr.ph
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %19

.lr.ph:                                           ; preds = %.preheader, %14
  %.011 = phi i32 [ %15, %14 ], [ 0, %.preheader ]
  %12 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48) %2, i32 noundef %.011)
          to label %13 unwind label %10

13:                                               ; preds = %.lr.ph
  invoke void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 4 dereferenceable(12) %12)
          to label %14 unwind label %10

14:                                               ; preds = %13
  %15 = add nuw i32 %.011, 1
  %16 = call noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %17 = icmp ult i32 %15, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !5

18:                                               ; preds = %._crit_edge
  call void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  ret void

19:                                               ; preds = %10, %8
  %.pn = phi { ptr, i32 } [ %11, %10 ], [ %9, %8 ]
  call void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  resume { ptr, i32 } %.pn
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef) local_unnamed_addr #0 align 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: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN5vmath4vec3ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 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 = { 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 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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass