; 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.std::array" = type { [4 x %"struct.vox::Point.0"] }
%"struct.vox::Point.0" = type { i64, i64 }
%"struct.std::array.1" = type { [4 x double] }
%"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::Size2" = type { i64, i64 }
%"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
declare dso_local noundef double @_ZNK3vox21CollocatedVectorGrid221divergenceAtDataPointEmm(ptr noundef nonnull align 8 dereferenceable(240), i64 noundef, i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK3vox21CollocatedVectorGrid210divergenceERKNS_5PointIdLm2EEE(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.std::array", align 8
  %6 = alloca %"struct.std::array.1", align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr %5) #6
  call void @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEC2Ev(ptr noundef nonnull align 8 dereferenceable(64) %5)
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #6
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 32, i1 false)
  %10 = getelementptr inbounds %"class.vox::CollocatedVectorGrid2", ptr %9, i32 0, i32 2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZNK3vox18LinearArraySamplerINS_6VectorIdLm2EEEdLm2EE24getCoordinatesAndWeightsERKNS_5PointIdLm2EEEPSt5arrayINS4_ImLm2EEELm4EEPS8_IdLm4EE(ptr noundef nonnull align 8 dereferenceable(72) %10, ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %5, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %34, %2
  %13 = load i32, ptr %8, align 4, !tbaa !11
  %14 = icmp slt i32 %13, 4
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %37

16:                                               ; preds = %12
  %17 = load i32, ptr %8, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm4EEixEm(ptr noundef nonnull align 8 dereferenceable(32) %6, i64 noundef %18) #6
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = load i32, ptr %8, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %5, i64 noundef %22) #6
  %24 = getelementptr inbounds %"struct.vox::Point.0", ptr %23, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !13
  %26 = load i32, ptr %8, align 4, !tbaa !11
  %27 = sext i32 %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %5, i64 noundef %27) #6
  %29 = getelementptr inbounds %"struct.vox::Point.0", ptr %28, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !16
  %31 = call noundef double @_ZNK3vox21CollocatedVectorGrid221divergenceAtDataPointEmm(ptr noundef nonnull align 8 dereferenceable(240) %9, i64 noundef %25, i64 noundef %30)
  %32 = load double, ptr %7, align 8, !tbaa !9
  %33 = call double @llvm.fmuladd.f64(double %20, double %31, double %32)
  store double %33, ptr %7, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %16
  %35 = load i32, ptr %8, align 4, !tbaa !11
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %8, align 4, !tbaa !11
  br label %12, !llvm.loop !17

37:                                               ; preds = %15
  %38 = load double, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %5) #6
  ret double %38
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEC2Ev(ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3vox18LinearArraySamplerINS_6VectorIdLm2EEEdLm2EE24getCoordinatesAndWeightsERKNS_5PointIdLm2EEEPSt5arrayINS4_ImLm2EEELm4EEPS8_IdLm4EE(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64), i64 noundef) #4 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #5

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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTSN3vox5PointImLm2EEE", !15, i64 0, !15, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !15, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%"struct.std::array" = type { [4 x %"struct.vox::Point.0"] }
%"struct.vox::Point.0" = type { i64, i64 }
%"struct.std::array.1" = type { [4 x double] }

; 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
declare dso_local noundef double @_ZNK3vox21CollocatedVectorGrid221divergenceAtDataPointEmm(ptr noundef nonnull align 8 dereferenceable(240), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK3vox21CollocatedVectorGrid210divergenceERKNS_5PointIdLm2EEE(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) unnamed_addr #1 align 2 {
  %3 = alloca %"struct.std::array", align 8
  %4 = alloca %"struct.std::array.1", align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #6
  call void @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEC2Ev(ptr noundef nonnull align 8 dereferenceable(64) %3)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %4, i8 0, i64 32, i1 false)
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  call void @_ZNK3vox18LinearArraySamplerINS_6VectorIdLm2EEEdLm2EE24getCoordinatesAndWeightsERKNS_5PointIdLm2EEEPSt5arrayINS4_ImLm2EEELm4EEPS8_IdLm4EE(ptr noundef nonnull align 8 dereferenceable(72) %5, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %6 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm4EEixEm(ptr noundef nonnull align 8 dereferenceable(32) %4, i64 noundef 0) #6
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 0) #6
  %9 = load i64, ptr %8, align 8, !tbaa !9
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 0) #6
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !12
  %13 = call noundef double @_ZNK3vox21CollocatedVectorGrid221divergenceAtDataPointEmm(ptr noundef nonnull align 8 dereferenceable(240) %0, i64 noundef %9, i64 noundef %12)
  %14 = call double @llvm.fmuladd.f64(double %7, double %13, double 0.000000e+00)
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm4EEixEm(ptr noundef nonnull align 8 dereferenceable(32) %4, i64 noundef 1) #6
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 1) #6
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 1) #6
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !12
  %22 = call noundef double @_ZNK3vox21CollocatedVectorGrid221divergenceAtDataPointEmm(ptr noundef nonnull align 8 dereferenceable(240) %0, i64 noundef %18, i64 noundef %21)
  %23 = call double @llvm.fmuladd.f64(double %16, double %22, double %14)
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm4EEixEm(ptr noundef nonnull align 8 dereferenceable(32) %4, i64 noundef 2) #6
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 2) #6
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 2) #6
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = load i64, ptr %29, align 8, !tbaa !12
  %31 = call noundef double @_ZNK3vox21CollocatedVectorGrid221divergenceAtDataPointEmm(ptr noundef nonnull align 8 dereferenceable(240) %0, i64 noundef %27, i64 noundef %30)
  %32 = call double @llvm.fmuladd.f64(double %25, double %31, double %23)
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5arrayIdLm4EEixEm(ptr noundef nonnull align 8 dereferenceable(32) %4, i64 noundef 3) #6
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 3) #6
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEixEm(ptr noundef nonnull align 8 dereferenceable(64) %3, i64 noundef 3) #6
  %38 = getelementptr inbounds i8, ptr %37, i64 8
  %39 = load i64, ptr %38, align 8, !tbaa !12
  %40 = call noundef double @_ZNK3vox21CollocatedVectorGrid221divergenceAtDataPointEmm(ptr noundef nonnull align 8 dereferenceable(240) %0, i64 noundef %36, i64 noundef %39)
  %41 = call double @llvm.fmuladd.f64(double %34, double %40, double %32)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #6
  ret double %41
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNSt5arrayIN3vox5PointImLm2EEELm4EEC2Ev(ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3vox18LinearArraySamplerINS_6VectorIdLm2EEEdLm2EE24getCoordinatesAndWeightsERKNS_5PointIdLm2EEEPSt5arrayINS4_ImLm2EEELm4EEPS8_IdLm4EE(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #5

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 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN3vox5PointImLm2EEE", !11, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SROAPass,SimplifyCFGPass