; LLVM IR from yangfengzzz/DigitalVox3 :: 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"

%"class.vox::geometry::Matrix" = type { double, double }
%"class.vox::geometry::Matrix.0" = 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 noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN3vox8geometry11divergence2ERKNS0_9ArrayViewIKNS0_6MatrixIdLm2ELm1EEELm2EEERS4_mm(ptr noundef nonnull align 8 dereferenceable(32) %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 ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = 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) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %14)
  store ptr %15, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = icmp ugt i64 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %4
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = sub i64 %20, 1
  br label %24

22:                                               ; preds = %4
  %23 = load i64, ptr %7, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %22, %19
  %25 = phi i64 [ %21, %19 ], [ %23, %22 ]
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %16, i64 noundef %25, i64 noundef %26)
  %28 = getelementptr inbounds %"class.vox::geometry::Matrix", ptr %27, i32 0, i32 0
  %29 = load double, ptr %28, align 8, !tbaa !11
  store double %29, ptr %10, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = add i64 %31, 1
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %"class.vox::geometry::Matrix.0", ptr %33, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !15
  %36 = icmp ult i64 %32, %35
  br i1 %36, label %37, label %40

37:                                               ; preds = %24
  %38 = load i64, ptr %7, align 8, !tbaa !9
  %39 = add i64 %38, 1
  br label %42

40:                                               ; preds = %24
  %41 = load i64, ptr %7, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %40, %37
  %43 = phi i64 [ %39, %37 ], [ %41, %40 ]
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %30, i64 noundef %43, i64 noundef %44)
  %46 = getelementptr inbounds %"class.vox::geometry::Matrix", ptr %45, i32 0, i32 0
  %47 = load double, ptr %46, align 8, !tbaa !11
  store double %47, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load i64, ptr %7, align 8, !tbaa !9
  %50 = load i64, ptr %8, align 8, !tbaa !9
  %51 = icmp ugt i64 %50, 0
  br i1 %51, label %52, label %55

52:                                               ; preds = %42
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = sub i64 %53, 1
  br label %57

55:                                               ; preds = %42
  %56 = load i64, ptr %8, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %55, %52
  %58 = phi i64 [ %54, %52 ], [ %56, %55 ]
  %59 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %48, i64 noundef %49, i64 noundef %58)
  %60 = getelementptr inbounds %"class.vox::geometry::Matrix", ptr %59, i32 0, i32 1
  %61 = load double, ptr %60, align 8, !tbaa !17
  store double %61, ptr %12, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load i64, ptr %7, align 8, !tbaa !9
  %64 = load i64, ptr %8, align 8, !tbaa !9
  %65 = add i64 %64, 1
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds %"class.vox::geometry::Matrix.0", ptr %66, i32 0, i32 1
  %68 = load i64, ptr %67, align 8, !tbaa !18
  %69 = icmp ult i64 %65, %68
  br i1 %69, label %70, label %73

70:                                               ; preds = %57
  %71 = load i64, ptr %8, align 8, !tbaa !9
  %72 = add i64 %71, 1
  br label %75

73:                                               ; preds = %57
  %74 = load i64, ptr %8, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %73, %70
  %76 = phi i64 [ %72, %70 ], [ %74, %73 ]
  %77 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %62, i64 noundef %63, i64 noundef %76)
  %78 = getelementptr inbounds %"class.vox::geometry::Matrix", ptr %77, i32 0, i32 1
  %79 = load double, ptr %78, align 8, !tbaa !17
  store double %79, ptr %13, align 8, !tbaa !14
  %80 = load double, ptr %11, align 8, !tbaa !14
  %81 = load double, ptr %10, align 8, !tbaa !14
  %82 = fsub double %80, %81
  %83 = fmul double 5.000000e-01, %82
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %"class.vox::geometry::Matrix", ptr %84, i32 0, i32 0
  %86 = load double, ptr %85, align 8, !tbaa !11
  %87 = fdiv double %83, %86
  %88 = load double, ptr %13, align 8, !tbaa !14
  %89 = load double, ptr %12, align 8, !tbaa !14
  %90 = fsub double %88, %89
  %91 = fmul double 5.000000e-01, %90
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %"class.vox::geometry::Matrix", ptr %92, i32 0, i32 1
  %94 = load double, ptr %93, align 8, !tbaa !17
  %95 = fdiv double %91, %94
  %96 = fadd double %87, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret double %96
}

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 = { 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, !13, i64 0}
!12 = !{!"_ZTSN3vox8geometry6MatrixIdLm2ELm1EEE", !13, i64 0, !13, i64 8}
!13 = !{!"double", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTSN3vox8geometry6MatrixImLm2ELm1EEE", !10, i64 0, !10, i64 8}
!17 = !{!12, !13, i64 8}
!18 = !{!16, !10, 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 noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN3vox8geometry11divergence2ERKNS0_9ArrayViewIKNS0_6MatrixIdLm2ELm1EEELm2EEERS4_mm(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #1 {
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %6 = tail call i64 @llvm.usub.sat.i64(i64 %2, i64 1)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %6, i64 noundef %3)
  %8 = load <2 x double>, ptr %7, align 8
  %9 = add i64 %2, 1
  %10 = load i64, ptr %5, align 8, !tbaa !5
  %11 = icmp ult i64 %9, %10
  %12 = select i1 %11, i64 %9, i64 %2
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %12, i64 noundef %3)
  %14 = load <2 x double>, ptr %13, align 8
  %15 = tail call i64 @llvm.usub.sat.i64(i64 %3, i64 1)
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %2, i64 noundef %15)
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load double, ptr %17, align 8, !tbaa !10
  %19 = add i64 %3, 1
  %20 = getelementptr inbounds i8, ptr %5, i64 8
  %21 = load i64, ptr %20, align 8, !tbaa !13
  %22 = icmp ult i64 %19, %21
  %23 = select i1 %22, i64 %19, i64 %3
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3vox8geometry9ArrayBaseIKNS0_6MatrixIdLm2ELm1EEELm2ENS0_9ArrayViewIS4_Lm2EEEEclIJmEEERS4_mDpT_(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %2, i64 noundef %23)
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  %26 = load double, ptr %25, align 8, !tbaa !10
  %27 = insertelement <2 x double> %14, double %26, i64 1
  %28 = insertelement <2 x double> %8, double %18, i64 1
  %29 = fsub <2 x double> %27, %28
  %30 = fmul <2 x double> %29, <double 5.000000e-01, double 5.000000e-01>
  %31 = load <2 x double>, ptr %1, align 8, !tbaa !14
  %32 = fdiv <2 x double> %30, %31
  %shift = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %33 = fadd <2 x double> %32, %shift
  %34 = extractelement <2 x double> %33, i64 0
  ret double %34
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.usub.sat.i64(i64, i64) #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 = { 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN3vox8geometry6MatrixImLm2ELm1EEE", !7, i64 0, !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !12, i64 8}
!11 = !{!"_ZTSN3vox8geometry6MatrixIdLm2ELm1EEE", !12, i64 0, !12, i64 8}
!12 = !{!"double", !8, i64 0}
!13 = !{!6, !7, i64 8}
!14 = !{!12, !12, i64 0}


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