; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (linalg)

; 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.alglib_impl::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.0 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.0 = type { ptr }
%"struct.alglib_impl::ae_matrix" = type { i64, i64, i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.1 }
%union.anon.1 = type { ptr }

; 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

declare noundef i64 @_ZN11alglib_impl9ae_minintEllPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef) #1

declare noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl18generatereflectionEPNS_9ae_vectorElPdPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl27applyreflectionfromtherightEPNS_9ae_matrixEdPNS_9ae_vectorEllllS3_PNS_8ae_stateE(ptr noundef, double noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) #2

declare void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl17rmatrixlqbasecaseEPNS_9ae_matrixEllPNS_9ae_vectorES3_S3_PNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  store i64 %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = load i64, ptr %10, align 8, !tbaa !9
  %20 = load ptr, ptr %14, align 8, !tbaa !5
  %21 = call noundef i64 @_ZN11alglib_impl9ae_minintEllPNS_8ae_stateE(i64 noundef %18, i64 noundef %19, ptr noundef %20)
  store i64 %21, ptr %16, align 8, !tbaa !9
  store i64 0, ptr %15, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %97, %7
  %23 = load i64, ptr %15, align 8, !tbaa !9
  %24 = load i64, ptr %16, align 8, !tbaa !9
  %25 = sub nsw i64 %24, 1
  %26 = icmp sle i64 %23, %25
  br i1 %26, label %27, label %100

27:                                               ; preds = %22
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = getelementptr inbounds double, ptr %30, i64 1
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %32, i32 0, i32 6
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = load i64, ptr %15, align 8, !tbaa !9
  %36 = getelementptr inbounds ptr, ptr %34, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load i64, ptr %15, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %37, i64 %38
  %40 = load i64, ptr %10, align 8, !tbaa !9
  %41 = load i64, ptr %15, align 8, !tbaa !9
  %42 = sub nsw i64 %40, %41
  %43 = call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef 1, i64 noundef %42)
  call void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef %31, i64 noundef 1, ptr noundef %39, i64 noundef 1, i64 noundef %43)
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = load i64, ptr %10, align 8, !tbaa !9
  %46 = load i64, ptr %15, align 8, !tbaa !9
  %47 = sub nsw i64 %45, %46
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  call void @_ZN11alglib_impl18generatereflectionEPNS_9ae_vectorElPdPNS_8ae_stateE(ptr noundef %44, i64 noundef %47, ptr noundef %17, ptr noundef %48)
  %49 = load double, ptr %17, align 8, !tbaa !12
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %50, i32 0, i32 4
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = load i64, ptr %15, align 8, !tbaa !9
  %54 = getelementptr inbounds double, ptr %52, i64 %53
  store double %49, ptr %54, align 8, !tbaa !12
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = load i64, ptr %15, align 8, !tbaa !9
  %59 = getelementptr inbounds ptr, ptr %57, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = load i64, ptr %15, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %60, i64 %61
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !11
  %66 = getelementptr inbounds double, ptr %65, i64 1
  %67 = load i64, ptr %15, align 8, !tbaa !9
  %68 = load i64, ptr %10, align 8, !tbaa !9
  %69 = sub nsw i64 %68, 1
  %70 = call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef %67, i64 noundef %69)
  call void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef %62, i64 noundef 1, ptr noundef %66, i64 noundef 1, i64 noundef %70)
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %71, i32 0, i32 4
  %73 = load ptr, ptr %72, align 8, !tbaa !11
  %74 = getelementptr inbounds double, ptr %73, i64 1
  store double 1.000000e+00, ptr %74, align 8, !tbaa !12
  %75 = load i64, ptr %15, align 8, !tbaa !9
  %76 = load i64, ptr %10, align 8, !tbaa !9
  %77 = icmp slt i64 %75, %76
  br i1 %77, label %78, label %96

78:                                               ; preds = %27
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  %81 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %80, i32 0, i32 4
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = load i64, ptr %15, align 8, !tbaa !9
  %84 = getelementptr inbounds double, ptr %82, i64 %83
  %85 = load double, ptr %84, align 8, !tbaa !12
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = load i64, ptr %15, align 8, !tbaa !9
  %88 = add nsw i64 %87, 1
  %89 = load i64, ptr %9, align 8, !tbaa !9
  %90 = sub nsw i64 %89, 1
  %91 = load i64, ptr %15, align 8, !tbaa !9
  %92 = load i64, ptr %10, align 8, !tbaa !9
  %93 = sub nsw i64 %92, 1
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  %95 = load ptr, ptr %14, align 8, !tbaa !5
  call void @_ZN11alglib_impl27applyreflectionfromtherightEPNS_9ae_matrixEdPNS_9ae_vectorEllllS3_PNS_8ae_stateE(ptr noundef %79, double noundef %85, ptr noundef %86, i64 noundef %88, i64 noundef %90, i64 noundef %91, i64 noundef %93, ptr noundef %94, ptr noundef %95)
  br label %96

96:                                               ; preds = %78, %27
  br label %97

97:                                               ; preds = %96
  %98 = load i64, ptr %15, align 8, !tbaa !9
  %99 = add nsw i64 %98, 1
  store i64 %99, ptr %15, align 8, !tbaa !9
  br label %22, !llvm.loop !14

100:                                              ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  ret void
}

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

; 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

declare noundef i64 @_ZN11alglib_impl9ae_minintEllPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl18generatereflectionEPNS_9ae_vectorElPdPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl27applyreflectionfromtherightEPNS_9ae_matrixEdPNS_9ae_vectorEllllS3_PNS_8ae_stateE(ptr noundef, double noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl17rmatrixlqbasecaseEPNS_9ae_matrixEllPNS_9ae_vectorES3_S3_PNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef readonly %5, ptr noundef %6) local_unnamed_addr #2 {
  %8 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  %9 = tail call noundef i64 @_ZN11alglib_impl9ae_minintEllPNS_8ae_stateE(i64 noundef %1, i64 noundef %2, ptr noundef %6)
  %.not.not36 = icmp sgt i64 %9, 0
  br i1 %.not.not36, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7
  %10 = getelementptr inbounds i8, ptr %4, i64 56
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  %12 = getelementptr inbounds i8, ptr %5, i64 56
  %13 = add nsw i64 %2, -1
  %14 = add nsw i64 %1, -1
  br label %15

15:                                               ; preds = %.lr.ph, %42
  %.037 = phi i64 [ 0, %.lr.ph ], [ %.pre-phi, %42 ]
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = getelementptr inbounds ptr, ptr %18, i64 %.037
  %20 = load ptr, ptr %19, align 8, !tbaa !8
  %21 = getelementptr inbounds double, ptr %20, i64 %.037
  %22 = sub nsw i64 %2, %.037
  %23 = call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef 1, i64 noundef %22)
  call void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef nonnull %17, i64 noundef 1, ptr noundef %21, i64 noundef 1, i64 noundef %23)
  call void @_ZN11alglib_impl18generatereflectionEPNS_9ae_vectorElPdPNS_8ae_stateE(ptr noundef %4, i64 noundef %22, ptr noundef nonnull %8, ptr noundef %6)
  %24 = load double, ptr %8, align 8, !tbaa !10
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 %.037
  store double %24, ptr %26, align 8, !tbaa !10
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = getelementptr inbounds ptr, ptr %27, i64 %.037
  %29 = load ptr, ptr %28, align 8, !tbaa !8
  %30 = getelementptr inbounds double, ptr %29, i64 %.037
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %31, i64 8
  %33 = call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef %.037, i64 noundef %13)
  call void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef %30, i64 noundef 1, ptr noundef nonnull %32, i64 noundef 1, i64 noundef %33)
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  store double 1.000000e+00, ptr %35, align 8, !tbaa !10
  %36 = icmp slt i64 %.037, %2
  br i1 %36, label %37, label %._crit_edge38

._crit_edge38:                                    ; preds = %15
  %.pre = add nuw nsw i64 %.037, 1
  br label %42

37:                                               ; preds = %15
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 %.037
  %40 = load double, ptr %39, align 8, !tbaa !10
  %41 = add nuw nsw i64 %.037, 1
  call void @_ZN11alglib_impl27applyreflectionfromtherightEPNS_9ae_matrixEdPNS_9ae_vectorEllllS3_PNS_8ae_stateE(ptr noundef nonnull %0, double noundef %40, ptr noundef nonnull %4, i64 noundef %41, i64 noundef %14, i64 noundef %.037, i64 noundef %13, ptr noundef %3, ptr noundef %6)
  br label %42

42:                                               ; preds = %._crit_edge38, %37
  %.pre-phi = phi i64 [ %.pre, %._crit_edge38 ], [ %41, %37 ]
  %exitcond.not = icmp eq i64 %.pre-phi, %9
  br i1 %exitcond.not, label %._crit_edge, label %15, !llvm.loop !12

._crit_edge:                                      ; preds = %42, %7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  ret void
}

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


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