; LLVM IR from bqi343/cp-notebook :: Implementations/content/geometry (13)/3D (death_conveyor)

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

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5vrandv(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z3absRKSt5arrayIeLm4EE(ptr noundef nonnull align 16 dereferenceable(64)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZmlRKSt5arrayIS_IeLm3EELm3EERKS_IeLm4EE(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16, ptr noundef nonnull align 16 dereferenceable(144), ptr noundef nonnull align 16 dereferenceable(64)) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7flattenRKSt6vectorISt5arrayIeLm4EESaIS1_EES1_(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef byval(%"struct.std::array") align 16) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12findEigenvecRKSt6vectorISt5arrayIeLm4EESaIS1_EERKS0_IS0_IeLm3EELm3EE(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 16 dereferenceable(144) %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.std::array", align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::array", align 16
  %10 = alloca %"struct.std::array", align 16
  %11 = alloca %"struct.std::array", align 16
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z5vrandv(ptr dead_on_unwind writable sret(%"struct.std::array") align 16 %6)
  call void @_Z7flattenRKSt6vectorISt5arrayIeLm4EESaIS1_EES1_(ptr dead_on_unwind writable sret(%"struct.std::array") align 16 %0, ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef byval(%"struct.std::array") align 16 %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %28, %3
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = sitofp i32 %14 to double
  %16 = fcmp olt double %15, 1.000000e+05
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  store i32 2, ptr %8, align 4
  br label %31

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 64, ptr %9) #4
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZmlRKSt5arrayIS_IeLm3EELm3EERKS_IeLm4EE(ptr dead_on_unwind writable sret(%"struct.std::array") align 16 %9, ptr noundef nonnull align 16 dereferenceable(144) %19, ptr noundef nonnull align 16 dereferenceable(64) %0)
  %20 = call noundef x86_fp80 @_Z3absRKSt5arrayIeLm4EE(ptr noundef nonnull align 16 dereferenceable(64) %9)
  %21 = fcmp olt x86_fp80 %20, 0xK3FE189705F4136B4A800
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i32 1, ptr %8, align 4
  br label %25

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 64, ptr %10) #4
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %11, ptr align 16 %9, i64 64, i1 false), !tbaa.struct !11
  call void @_Z7flattenRKSt6vectorISt5arrayIeLm4EESaIS1_EES1_(ptr dead_on_unwind writable sret(%"struct.std::array") align 16 %10, ptr noundef nonnull align 8 dereferenceable(24) %24, ptr noundef byval(%"struct.std::array") align 16 %11)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %0, ptr align 16 %10, i64 64, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 64, ptr %10) #4
  store i32 0, ptr %8, align 4
  br label %25

25:                                               ; preds = %23, %22
  call void @llvm.lifetime.end.p0(i64 64, ptr %9) #4
  %26 = load i32, ptr %8, align 4
  switch i32 %26, label %31 [
    i32 0, label %27
  ]

27:                                               ; preds = %25
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %7, align 4, !tbaa !9
  br label %13, !llvm.loop !13

31:                                               ; preds = %25, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %32 = load i32, ptr %8, align 4
  switch i32 %32, label %35 [
    i32 2, label %33
    i32 1, label %34
  ]

33:                                               ; preds = %31
  br label %34

34:                                               ; preds = %33, %31
  ret void

35:                                               ; preds = %31
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 64, !12}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 x86_fp80] }

; 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 nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5vrandv(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef x86_fp80 @_Z3absRKSt5arrayIeLm4EE(ptr noundef nonnull align 16 dereferenceable(64)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZmlRKSt5arrayIS_IeLm3EELm3EERKS_IeLm4EE(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16, ptr noundef nonnull align 16 dereferenceable(144), ptr noundef nonnull align 16 dereferenceable(64)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7flattenRKSt6vectorISt5arrayIeLm4EESaIS1_EES1_(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef byval(%"struct.std::array") align 16) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12findEigenvecRKSt6vectorISt5arrayIeLm4EESaIS1_EERKS0_IS0_IeLm3EELm3EE(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 16 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 16 dereferenceable(144) %2) local_unnamed_addr #2 {
  %4 = alloca %"struct.std::array", align 16
  %5 = alloca %"struct.std::array", align 16
  %6 = alloca %"struct.std::array", align 16
  call void @_Z5vrandv(ptr dead_on_unwind nonnull writable sret(%"struct.std::array") align 16 %4)
  call void @_Z7flattenRKSt6vectorISt5arrayIeLm4EESaIS1_EES1_(ptr dead_on_unwind writable sret(%"struct.std::array") align 16 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull byval(%"struct.std::array") align 16 %4)
  br label %7

7:                                                ; preds = %3, %10
  %.056 = phi i32 [ 0, %3 ], [ %11, %10 ]
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #4
  call void @_ZmlRKSt5arrayIS_IeLm3EELm3EERKS_IeLm4EE(ptr dead_on_unwind nonnull writable sret(%"struct.std::array") align 16 %5, ptr noundef nonnull align 16 dereferenceable(144) %2, ptr noundef nonnull align 16 dereferenceable(64) %0)
  %8 = call noundef x86_fp80 @_Z3absRKSt5arrayIeLm4EE(ptr noundef nonnull align 16 dereferenceable(64) %5)
  %9 = fcmp uge x86_fp80 %8, 0xK3FE189705F4136B4A800
  br i1 %9, label %10, label %.critedge

10:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #4
  call void @_Z7flattenRKSt6vectorISt5arrayIeLm4EESaIS1_EES1_(ptr dead_on_unwind nonnull writable sret(%"struct.std::array") align 16 %6, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull byval(%"struct.std::array") align 16 %5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %0, ptr noundef nonnull align 16 dereferenceable(64) %6, i64 64, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #4
  %11 = add nuw nsw i32 %.056, 1
  %exitcond.not = icmp eq i32 %11, 100000
  br i1 %exitcond.not, label %.loopexit, label %7, !llvm.loop !9

.critedge:                                        ; preds = %7
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #4
  br label %.loopexit

.loopexit:                                        ; preds = %10, %.critedge
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{i64 0, i64 64, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass