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

@_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE = external hidden global i64, align 8

; 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 uwtable
define dso_local void @_ZN11alglib_impl12rmatrixrank1EllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, ptr noundef %9) #1 {
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca double, align 8
  %23 = alloca i32, align 4
  store i64 %0, ptr %11, align 8, !tbaa !5
  store i64 %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !9
  store i64 %3, ptr %14, align 8, !tbaa !5
  store i64 %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !9
  store i64 %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !9
  store i64 %8, ptr %19, align 8, !tbaa !5
  store ptr %9, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  %24 = load i64, ptr %11, align 8, !tbaa !5
  %25 = icmp sle i64 %24, 0
  br i1 %25, label %29, label %26

26:                                               ; preds = %10
  %27 = load i64, ptr %12, align 8, !tbaa !5
  %28 = icmp sle i64 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %26, %10
  store i32 1, ptr %23, align 4
  br label %106

30:                                               ; preds = %26
  %31 = load i64, ptr %11, align 8, !tbaa !5
  %32 = load i64, ptr @_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE, align 8, !tbaa !5
  %33 = icmp sgt i64 %31, %32
  br i1 %33, label %34, label %52

34:                                               ; preds = %30
  %35 = load i64, ptr %12, align 8, !tbaa !5
  %36 = load i64, ptr @_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE, align 8, !tbaa !5
  %37 = icmp sgt i64 %35, %36
  br i1 %37, label %38, label %52

38:                                               ; preds = %34
  %39 = load i64, ptr %11, align 8, !tbaa !5
  %40 = load i64, ptr %12, align 8, !tbaa !5
  %41 = load ptr, ptr %13, align 8, !tbaa !9
  %42 = load i64, ptr %14, align 8, !tbaa !5
  %43 = load i64, ptr %15, align 8, !tbaa !5
  %44 = load ptr, ptr %16, align 8, !tbaa !9
  %45 = load i64, ptr %17, align 8, !tbaa !5
  %46 = load ptr, ptr %18, align 8, !tbaa !9
  %47 = load i64, ptr %19, align 8, !tbaa !5
  %48 = load ptr, ptr %20, align 8, !tbaa !9
  %49 = call noundef zeroext i1 @_ZN11alglib_impl15rmatrixrank1mklEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %39, i64 noundef %40, ptr noundef %41, i64 noundef %42, i64 noundef %43, ptr noundef %44, i64 noundef %45, ptr noundef %46, i64 noundef %47, ptr noundef %48)
  br i1 %49, label %50, label %51

50:                                               ; preds = %38
  store i32 1, ptr %23, align 4
  br label %106

51:                                               ; preds = %38
  br label %52

52:                                               ; preds = %51, %34, %30
  %53 = load i64, ptr %11, align 8, !tbaa !5
  %54 = load i64, ptr %12, align 8, !tbaa !5
  %55 = load ptr, ptr %13, align 8, !tbaa !9
  %56 = load i64, ptr %14, align 8, !tbaa !5
  %57 = load i64, ptr %15, align 8, !tbaa !5
  %58 = load ptr, ptr %16, align 8, !tbaa !9
  %59 = load i64, ptr %17, align 8, !tbaa !5
  %60 = load ptr, ptr %18, align 8, !tbaa !9
  %61 = load i64, ptr %19, align 8, !tbaa !5
  %62 = load ptr, ptr %20, align 8, !tbaa !9
  %63 = call noundef zeroext i1 @_ZN11alglib_impl13rmatrixrank1fEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %53, i64 noundef %54, ptr noundef %55, i64 noundef %56, i64 noundef %57, ptr noundef %58, i64 noundef %59, ptr noundef %60, i64 noundef %61, ptr noundef %62)
  br i1 %63, label %64, label %65

64:                                               ; preds = %52
  store i32 1, ptr %23, align 4
  br label %106

65:                                               ; preds = %52
  store i64 0, ptr %21, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %102, %65
  %67 = load i64, ptr %21, align 8, !tbaa !5
  %68 = load i64, ptr %11, align 8, !tbaa !5
  %69 = sub nsw i64 %68, 1
  %70 = icmp sle i64 %67, %69
  br i1 %70, label %71, label %105

71:                                               ; preds = %66
  %72 = load ptr, ptr %16, align 8, !tbaa !9
  %73 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %72, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !11
  %75 = load i64, ptr %17, align 8, !tbaa !5
  %76 = load i64, ptr %21, align 8, !tbaa !5
  %77 = add nsw i64 %75, %76
  %78 = getelementptr inbounds double, ptr %74, i64 %77
  %79 = load double, ptr %78, align 8, !tbaa !12
  store double %79, ptr %22, align 8, !tbaa !12
  %80 = load ptr, ptr %13, align 8, !tbaa !9
  %81 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %80, i32 0, i32 6
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = load i64, ptr %14, align 8, !tbaa !5
  %84 = load i64, ptr %21, align 8, !tbaa !5
  %85 = add nsw i64 %83, %84
  %86 = getelementptr inbounds ptr, ptr %82, i64 %85
  %87 = load ptr, ptr %86, align 8, !tbaa !9
  %88 = load i64, ptr %15, align 8, !tbaa !5
  %89 = getelementptr inbounds double, ptr %87, i64 %88
  %90 = load ptr, ptr %18, align 8, !tbaa !9
  %91 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %90, i32 0, i32 4
  %92 = load ptr, ptr %91, align 8, !tbaa !11
  %93 = load i64, ptr %19, align 8, !tbaa !5
  %94 = getelementptr inbounds double, ptr %92, i64 %93
  %95 = load i64, ptr %15, align 8, !tbaa !5
  %96 = load i64, ptr %15, align 8, !tbaa !5
  %97 = load i64, ptr %12, align 8, !tbaa !5
  %98 = add nsw i64 %96, %97
  %99 = sub nsw i64 %98, 1
  %100 = call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef %95, i64 noundef %99)
  %101 = load double, ptr %22, align 8, !tbaa !12
  call void @_ZN11alglib_impl9ae_v_adddEPdlPKdlld(ptr noundef %89, i64 noundef 1, ptr noundef %94, i64 noundef 1, i64 noundef %100, double noundef %101)
  br label %102

102:                                              ; preds = %71
  %103 = load i64, ptr %21, align 8, !tbaa !5
  %104 = add nsw i64 %103, 1
  store i64 %104, ptr %21, align 8, !tbaa !5
  br label %66, !llvm.loop !14

105:                                              ; preds = %66
  store i32 0, ptr %23, align 4
  br label %106

106:                                              ; preds = %105, %64, %50, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  %107 = load i32, ptr %23, align 4
  switch i32 %107, label %109 [
    i32 0, label %108
    i32 1, label %108
  ]

108:                                              ; preds = %106, %106
  ret void

109:                                              ; preds = %106
  unreachable
}

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

declare void @_ZN11alglib_impl9ae_v_adddEPdlPKdlld(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, double noundef) #2

declare noundef zeroext i1 @_ZN11alglib_impl15rmatrixrank1mklEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #2

declare noundef zeroext i1 @_ZN11alglib_impl13rmatrixrank1fEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

@_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE = external hidden local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl12rmatrixrank1EllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, ptr noundef %9) local_unnamed_addr #0 {
  %11 = icmp slt i64 %0, 1
  %12 = icmp slt i64 %1, 1
  %or.cond = or i1 %11, %12
  br i1 %or.cond, label %.loopexit, label %13

13:                                               ; preds = %10
  %14 = load i64, ptr @_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE, align 8, !tbaa !5
  %15 = icmp slt i64 %14, %0
  %16 = icmp slt i64 %14, %1
  %or.cond43 = and i1 %15, %16
  br i1 %or.cond43, label %17, label %19

17:                                               ; preds = %13
  %18 = tail call noundef zeroext i1 @_ZN11alglib_impl15rmatrixrank1mklEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, ptr noundef %9)
  br i1 %18, label %.loopexit, label %19

19:                                               ; preds = %17, %13
  %20 = tail call noundef zeroext i1 @_ZN11alglib_impl13rmatrixrank1fEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, ptr noundef %9)
  br i1 %20, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %19
  %21 = getelementptr inbounds i8, ptr %5, i64 56
  %22 = getelementptr inbounds i8, ptr %2, i64 72
  %23 = getelementptr inbounds i8, ptr %7, i64 56
  %24 = add nsw i64 %1, -1
  %25 = add i64 %24, %4
  br label %26

26:                                               ; preds = %.lr.ph, %26
  %.045 = phi i64 [ 0, %.lr.ph ], [ %39, %26 ]
  %27 = load ptr, ptr %21, align 8, !tbaa !9
  %28 = getelementptr double, ptr %27, i64 %.045
  %29 = getelementptr double, ptr %28, i64 %6
  %30 = load double, ptr %29, align 8, !tbaa !10
  %31 = load ptr, ptr %22, align 8, !tbaa !9
  %32 = getelementptr ptr, ptr %31, i64 %.045
  %33 = getelementptr ptr, ptr %32, i64 %3
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = getelementptr inbounds double, ptr %34, i64 %4
  %36 = load ptr, ptr %23, align 8, !tbaa !9
  %37 = getelementptr inbounds double, ptr %36, i64 %8
  %38 = tail call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef %4, i64 noundef %25)
  tail call void @_ZN11alglib_impl9ae_v_adddEPdlPKdlld(ptr noundef %35, i64 noundef 1, ptr noundef %37, i64 noundef 1, i64 noundef %38, double noundef %30)
  %39 = add nuw nsw i64 %.045, 1
  %exitcond.not = icmp eq i64 %39, %0
  br i1 %exitcond.not, label %.loopexit, label %26, !llvm.loop !14

.loopexit:                                        ; preds = %26, %19, %17, %10
  ret void
}

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

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

declare noundef zeroext i1 @_ZN11alglib_impl15rmatrixrank1mklEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN11alglib_impl13rmatrixrank1fEllPNS_9ae_matrixEllPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

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

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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