; LLVM IR from yangfengzzz/Arche-webgpu :: vox.geometry (collocated_vector_grid2)

; 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.vox::Size2" = type { i64, i64 }
%class.anon.12 = type { ptr, ptr }
%"class.vox::CollocatedVectorGrid2" = type { %"class.vox::VectorGrid2", %"class.vox::Array", %"class.vox::LinearArraySampler", %"class.std::function" }
%"class.vox::VectorGrid2" = type { %"class.vox::VectorField2", %"class.vox::Grid2" }
%"class.vox::VectorField2" = type { %"class.vox::Field2" }
%"class.vox::Field2" = type { ptr }
%"class.vox::Grid2" = type { ptr, %"struct.vox::Size2", %"struct.vox::Vector", %"struct.vox::Point", %"struct.vox::BoundingBox" }
%"struct.vox::Vector" = type { double, double }
%"struct.vox::Point" = type { double, double }
%"struct.vox::BoundingBox" = type { %"struct.vox::Point", %"struct.vox::Point" }
%"class.vox::Array" = type { %"struct.vox::Size2", %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<vox::Vector<double, 2>, std::allocator<vox::Vector<double, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<vox::Vector<double, 2>, std::allocator<vox::Vector<double, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<vox::Vector<double, 2>, std::allocator<vox::Vector<double, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vox::Vector<double, 2>, std::allocator<vox::Vector<double, 2>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.vox::LinearArraySampler" = type { %"struct.vox::Vector", %"struct.vox::Vector", %"struct.vox::Point", %"class.vox::ConstArrayAccessor" }
%"class.vox::ConstArrayAccessor" = type { %"struct.vox::Size2", ptr }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3vox21CollocatedVectorGrid27getDataEPSt6vectorIdSaIdEE(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca %"struct.vox::Size2", align 8
  %7 = alloca %"struct.vox::Size2", align 8
  %8 = alloca i64, align 8
  %9 = alloca %class.anon.12, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #2
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds ptr, ptr %11, i64 10
  %13 = load ptr, ptr %12, align 8
  %14 = call { i64, i64 } %13(ptr noundef nonnull align 8 dereferenceable(240) %10)
  %15 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 0
  %16 = extractvalue { i64, i64 } %14, 0
  store i64 %16, ptr %15, align 8
  %17 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 1
  %18 = extractvalue { i64, i64 } %14, 1
  store i64 %18, ptr %17, align 8
  %19 = getelementptr inbounds %"struct.vox::Size2", ptr %6, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = mul i64 2, %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #2
  %22 = load ptr, ptr %10, align 8, !tbaa !9
  %23 = getelementptr inbounds ptr, ptr %22, i64 10
  %24 = load ptr, ptr %23, align 8
  %25 = call { i64, i64 } %24(ptr noundef nonnull align 8 dereferenceable(240) %10)
  %26 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %27 = extractvalue { i64, i64 } %25, 0
  store i64 %27, ptr %26, align 8
  %28 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %29 = extractvalue { i64, i64 } %25, 1
  store i64 %29, ptr %28, align 8
  %30 = getelementptr inbounds %"struct.vox::Size2", ptr %7, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !14
  %32 = mul i64 %21, %31
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #2
  store i64 %32, ptr %5, align 8, !tbaa !15
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i64, ptr %5, align 8, !tbaa !15
  call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %34)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store i64 0, ptr %8, align 8, !tbaa !15
  %35 = getelementptr inbounds %"class.vox::CollocatedVectorGrid2", ptr %10, i32 0, i32 1
  %36 = getelementptr inbounds %class.anon.12, ptr %9, i32 0, i32 0
  store ptr %4, ptr %36, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.anon.12, ptr %9, i32 0, i32 1
  store ptr %8, ptr %37, align 8, !tbaa !5
  %38 = getelementptr inbounds { ptr, ptr }, ptr %9, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8
  %40 = getelementptr inbounds { ptr, ptr }, ptr %9, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8
  call void @"_ZNK3vox5ArrayINS_6VectorIdLm2EEELm2EE7forEachIZNKS_21CollocatedVectorGrid27getDataEPSt6vectorIdSaIdEEE3$_0EEvT_"(ptr noundef nonnull align 8 dereferenceable(40) %35, ptr %39, ptr %41)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNK3vox5ArrayINS_6VectorIdLm2EEELm2EE7forEachIZNKS_21CollocatedVectorGrid27getDataEPSt6vectorIdSaIdEEE3$_0EEvT_"(ptr noundef nonnull align 8 dereferenceable(40), ptr, ptr) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN3vox5Size2E", !13, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!13, !13, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3vox21CollocatedVectorGrid27getDataEPSt6vectorIdSaIdEE(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %5, i64 80
  %7 = load ptr, ptr %6, align 8
  %8 = tail call { i64, i64 } %7(ptr noundef nonnull align 8 dereferenceable(240) %0)
  %9 = extractvalue { i64, i64 } %8, 0
  %10 = shl i64 %9, 1
  %11 = load ptr, ptr %0, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %11, i64 80
  %13 = load ptr, ptr %12, align 8
  %14 = tail call { i64, i64 } %13(ptr noundef nonnull align 8 dereferenceable(240) %0)
  %15 = extractvalue { i64, i64 } %14, 1
  %16 = mul i64 %10, %15
  tail call void @_ZNSt6vectorIdSaIdEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %16)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  store i64 0, ptr %4, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %0, i64 96
  call void @"_ZNK3vox5ArrayINS_6VectorIdLm2EEELm2EE7forEachIZNKS_21CollocatedVectorGrid27getDataEPSt6vectorIdSaIdEEE3$_0EEvT_"(ptr noundef nonnull align 8 dereferenceable(40) %17, ptr nonnull %3, ptr nonnull %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNK3vox5ArrayINS_6VectorIdLm2EEELm2EE7forEachIZNKS_21CollocatedVectorGrid27getDataEPSt6vectorIdSaIdEEE3$_0EEvT_"(ptr noundef nonnull align 8 dereferenceable(40), ptr, ptr) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass