; LLVM IR from yangfengzzz/Arche-webgpu :: vox.geometry/fdm_linear_system2.ll (ZN3vox8FdmBlas28lInfNormERKNS_5ArrayIdLm2EEE)

; 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 }

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN3vox8FdmBlas28lInfNormERKNS_5ArrayIdLm2EEE(ptr noundef nonnull align 8 dereferenceable(40) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.vox::Size2", align 8
  %4 = alloca double, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = call { i64, i64 } @_ZNK3vox5ArrayIdLm2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %8)
  %10 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 0
  %11 = extractvalue { i64, i64 } %9, 0
  store i64 %11, ptr %10, align 8
  %12 = getelementptr inbounds { i64, i64 }, ptr %3, i32 0, i32 1
  %13 = extractvalue { i64, i64 } %9, 1
  store i64 %13, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !11
  br label %14

14:                                               ; preds = %39, %1
  %15 = load i64, ptr %5, align 8, !tbaa !11
  %16 = getelementptr inbounds %"struct.vox::Size2", ptr %3, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = icmp ult i64 %15, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %42

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %35, %20
  %22 = load i64, ptr %7, align 8, !tbaa !11
  %23 = getelementptr inbounds %"struct.vox::Size2", ptr %3, i32 0, i32 0
  %24 = load i64, ptr %23, align 8, !tbaa !15
  %25 = icmp ult i64 %22, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %21
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %38

27:                                               ; preds = %21
  %28 = load double, ptr %4, align 8, !tbaa !9
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = load i64, ptr %7, align 8, !tbaa !11
  %31 = load i64, ptr %5, align 8, !tbaa !11
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox5ArrayIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(40) %29, i64 noundef %30, i64 noundef %31)
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = call noundef double @_ZN3vox6absmaxIdEET_S1_S1_(double noundef %28, double noundef %33)
  store double %34, ptr %4, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %27
  %36 = load i64, ptr %7, align 8, !tbaa !11
  %37 = add i64 %36, 1
  store i64 %37, ptr %7, align 8, !tbaa !11
  br label %21, !llvm.loop !16

38:                                               ; preds = %26
  br label %39

39:                                               ; preds = %38
  %40 = load i64, ptr %5, align 8, !tbaa !11
  %41 = add i64 %40, 1
  store i64 %41, ptr %5, align 8, !tbaa !11
  br label %14, !llvm.loop !18

42:                                               ; preds = %19
  %43 = load double, ptr %4, align 8, !tbaa !9
  %44 = call double @llvm.fabs.f64(double %43)
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #5
  ret double %44
}

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

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTSN3vox5Size2E", !12, i64 0, !12, i64 8}
!15 = !{!14, !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 } @_ZNK3vox5ArrayIdLm2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN3vox8FdmBlas28lInfNormERKNS_5ArrayIdLm2EEE(ptr noundef nonnull align 8 dereferenceable(40) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call { i64, i64 } @_ZNK3vox5ArrayIdLm2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  %3 = extractvalue { i64, i64 } %2, 0
  %4 = extractvalue { i64, i64 } %2, 1
  %.not = icmp eq i64 %4, 0
  %.not17 = icmp eq i64 %3, 0
  %or.cond = select i1 %.not, i1 true, i1 %.not17
  br i1 %or.cond, label %._crit_edge15, label %.preheader.us

.preheader.us:                                    ; preds = %1, %._crit_edge.us
  %.0914.us = phi i64 [ %10, %._crit_edge.us ], [ 0, %1 ]
  %.01013.us = phi double [ %8, %._crit_edge.us ], [ 0.000000e+00, %1 ]
  br label %5

5:                                                ; preds = %.preheader.us, %5
  %.012.us = phi i64 [ 0, %.preheader.us ], [ %9, %5 ]
  %.111.us = phi double [ %.01013.us, %.preheader.us ], [ %8, %5 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3vox5ArrayIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef %.012.us, i64 noundef %.0914.us)
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = tail call noundef double @_ZN3vox6absmaxIdEET_S1_S1_(double noundef %.111.us, double noundef %7)
  %9 = add nuw i64 %.012.us, 1
  %exitcond.not = icmp eq i64 %9, %3
  br i1 %exitcond.not, label %._crit_edge.us, label %5, !llvm.loop !9

._crit_edge.us:                                   ; preds = %5
  %10 = add nuw i64 %.0914.us, 1
  %exitcond19.not = icmp eq i64 %10, %4
  br i1 %exitcond19.not, label %._crit_edge15, label %.preheader.us, !llvm.loop !11

._crit_edge15:                                    ; preds = %._crit_edge.us, %1
  %.010.lcssa = phi double [ 0.000000e+00, %1 ], [ %8, %._crit_edge.us ]
  %11 = tail call double @llvm.fabs.f64(double %.010.lcssa)
  ret double %11
}

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

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

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" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass