; LLVM IR from yangfengzzz/Arche-webgpu :: vox.geometry (fdm_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"

%"struct.vox::Size2" = type { i64, i64 }
%"struct.vox::Vector" = type { double, double }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i64 } @_ZNK3vox18ConstArrayAccessorIdLm2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

; 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 noundef double @_ZN3vox10laplacian2ERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 noundef %2, i64 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  %10 = alloca %"struct.vox::Size2", align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load i64, ptr %8, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %16, i64 noundef %17)
  %19 = load double, ptr %18, align 8, !tbaa !11
  store double %19, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call { i64, i64 } @_ZNK3vox18ConstArrayAccessorIdLm2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %20)
  %22 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 0
  %23 = extractvalue { i64, i64 } %21, 0
  store i64 %23, ptr %22, align 8
  %24 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 1
  %25 = extractvalue { i64, i64 } %21, 1
  store i64 %25, ptr %24, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store double 0.000000e+00, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store double 0.000000e+00, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store double 0.000000e+00, ptr %14, align 8, !tbaa !11
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = icmp ugt i64 %26, 0
  br i1 %27, label %28, label %37

28:                                               ; preds = %4
  %29 = load double, ptr %9, align 8, !tbaa !11
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = sub i64 %31, 1
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %32, i64 noundef %33)
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = fsub double %29, %35
  store double %36, ptr %11, align 8, !tbaa !11
  br label %37

37:                                               ; preds = %28, %4
  %38 = load i64, ptr %7, align 8, !tbaa !9
  %39 = add i64 %38, 1
  %40 = getelementptr inbounds %"struct.vox::Size2", ptr %10, i32 0, i32 0
  %41 = load i64, ptr %40, align 8, !tbaa !13
  %42 = icmp ult i64 %39, %41
  br i1 %42, label %43, label %52

43:                                               ; preds = %37
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = add i64 %45, 1
  %47 = load i64, ptr %8, align 8, !tbaa !9
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %44, i64 noundef %46, i64 noundef %47)
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = load double, ptr %9, align 8, !tbaa !11
  %51 = fsub double %49, %50
  store double %51, ptr %12, align 8, !tbaa !11
  br label %52

52:                                               ; preds = %43, %37
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = icmp ugt i64 %53, 0
  br i1 %54, label %55, label %64

55:                                               ; preds = %52
  %56 = load double, ptr %9, align 8, !tbaa !11
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load i64, ptr %7, align 8, !tbaa !9
  %59 = load i64, ptr %8, align 8, !tbaa !9
  %60 = sub i64 %59, 1
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %57, i64 noundef %58, i64 noundef %60)
  %62 = load double, ptr %61, align 8, !tbaa !11
  %63 = fsub double %56, %62
  store double %63, ptr %13, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %55, %52
  %65 = load i64, ptr %8, align 8, !tbaa !9
  %66 = add i64 %65, 1
  %67 = getelementptr inbounds %"struct.vox::Size2", ptr %10, i32 0, i32 1
  %68 = load i64, ptr %67, align 8, !tbaa !15
  %69 = icmp ult i64 %66, %68
  br i1 %69, label %70, label %79

70:                                               ; preds = %64
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load i64, ptr %7, align 8, !tbaa !9
  %73 = load i64, ptr %8, align 8, !tbaa !9
  %74 = add i64 %73, 1
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %71, i64 noundef %72, i64 noundef %74)
  %76 = load double, ptr %75, align 8, !tbaa !11
  %77 = load double, ptr %9, align 8, !tbaa !11
  %78 = fsub double %76, %77
  store double %78, ptr %14, align 8, !tbaa !11
  br label %79

79:                                               ; preds = %70, %64
  %80 = load double, ptr %12, align 8, !tbaa !11
  %81 = load double, ptr %11, align 8, !tbaa !11
  %82 = fsub double %80, %81
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %"struct.vox::Vector", ptr %83, i32 0, i32 0
  %85 = load double, ptr %84, align 8, !tbaa !16
  %86 = call noundef double @_ZN3vox6squareIdEET_S1_(double noundef %85)
  %87 = fdiv double %82, %86
  %88 = load double, ptr %14, align 8, !tbaa !11
  %89 = load double, ptr %13, align 8, !tbaa !11
  %90 = fsub double %88, %89
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %"struct.vox::Vector", ptr %91, i32 0, i32 1
  %93 = load double, ptr %92, align 8, !tbaa !18
  %94 = call noundef double @_ZN3vox6squareIdEET_S1_(double noundef %93)
  %95 = fdiv double %90, %94
  %96 = fadd double %87, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret double %96
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3vox6squareIdEET_S1_(double noundef) #3

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


; 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 nounwind uwtable
declare dso_local { i64, i64 } @_ZNK3vox18ConstArrayAccessorIdLm2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN3vox10laplacian2ERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2, i64 noundef %3)
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = tail call { i64, i64 } @_ZNK3vox18ConstArrayAccessorIdLm2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %8 = extractvalue { i64, i64 } %7, 0
  %9 = extractvalue { i64, i64 } %7, 1
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %15, label %10

10:                                               ; preds = %4
  %11 = add i64 %2, -1
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %11, i64 noundef %3)
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fsub double %6, %13
  br label %15

15:                                               ; preds = %10, %4
  %.031 = phi double [ %14, %10 ], [ 0.000000e+00, %4 ]
  %16 = add i64 %2, 1
  %17 = icmp ult i64 %16, %8
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %16, i64 noundef %3)
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fsub double %20, %6
  br label %22

22:                                               ; preds = %18, %15
  %.030 = phi double [ %21, %18 ], [ 0.000000e+00, %15 ]
  %.not36 = icmp eq i64 %3, 0
  br i1 %.not36, label %28, label %23

23:                                               ; preds = %22
  %24 = add i64 %3, -1
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2, i64 noundef %24)
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fsub double %6, %26
  br label %28

28:                                               ; preds = %23, %22
  %.029 = phi double [ %27, %23 ], [ 0.000000e+00, %22 ]
  %29 = add i64 %3, 1
  %30 = icmp ult i64 %29, %9
  br i1 %30, label %31, label %35

31:                                               ; preds = %28
  %32 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2, i64 noundef %29)
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = fsub double %33, %6
  br label %35

35:                                               ; preds = %31, %28
  %.0 = phi double [ %34, %31 ], [ 0.000000e+00, %28 ]
  %36 = insertelement <2 x double> poison, double %.030, i64 0
  %37 = insertelement <2 x double> %36, double %.0, i64 1
  %38 = insertelement <2 x double> poison, double %.031, i64 0
  %39 = insertelement <2 x double> %38, double %.029, i64 1
  %40 = fsub <2 x double> %37, %39
  %41 = load double, ptr %1, align 8, !tbaa !9
  %42 = tail call noundef double @_ZN3vox6squareIdEET_S1_(double noundef %41)
  %43 = getelementptr inbounds i8, ptr %1, i64 8
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = tail call noundef double @_ZN3vox6squareIdEET_S1_(double noundef %44)
  %46 = insertelement <2 x double> poison, double %42, i64 0
  %47 = insertelement <2 x double> %46, double %45, i64 1
  %48 = fdiv <2 x double> %40, %47
  %shift = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %49 = fadd <2 x double> %48, %shift
  %50 = extractelement <2 x double> %49, i64 0
  ret double %50
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3vox6squareIdEET_S1_(double noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { alwaysinline 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" }

!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, !6, i64 0}
!10 = !{!"_ZTSN3vox6VectorIdLm2EEE", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass