; 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_complex" = type { double, double }
%"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 }

@.str.200 = external hidden unnamed_addr constant [2 x i8], align 1
@_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_impl12cmatrixrank1EllPNS_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 %"struct.alglib_impl::ae_complex", align 8
  %23 = alloca i32, align 4
  %24 = alloca %"struct.alglib_impl::ae_complex", align 8
  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) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %22) #4
  %25 = load i64, ptr %11, align 8, !tbaa !5
  %26 = icmp sle i64 %25, 0
  br i1 %26, label %30, label %27

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

30:                                               ; preds = %27, %10
  store i32 1, ptr %23, align 4
  br label %109

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

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

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

51:                                               ; preds = %39
  store i32 1, ptr %23, align 4
  br label %109

52:                                               ; preds = %39
  br label %53

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

65:                                               ; preds = %53
  store i32 1, ptr %23, align 4
  br label %109

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

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

72:                                               ; preds = %67
  %73 = load ptr, ptr %16, align 8, !tbaa !9
  %74 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !11
  %76 = load i64, ptr %17, align 8, !tbaa !5
  %77 = load i64, ptr %21, align 8, !tbaa !5
  %78 = add nsw i64 %76, %77
  %79 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %75, i64 %78
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %22, ptr align 8 %79, i64 16, i1 false), !tbaa.struct !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 %"struct.alglib_impl::ae_complex", 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 %"struct.alglib_impl::ae_complex", 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)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %24, ptr align 8 %22, i64 16, i1 false), !tbaa.struct !12
  %101 = getelementptr inbounds { double, double }, ptr %24, i32 0, i32 0
  %102 = load double, ptr %101, align 8
  %103 = getelementptr inbounds { double, double }, ptr %24, i32 0, i32 1
  %104 = load double, ptr %103, align 8
  call void @_ZN11alglib_impl10ae_v_caddcEPNS_10ae_complexElPKS0_lPKclS0_(ptr noundef %89, i64 noundef 1, ptr noundef %94, i64 noundef 1, ptr noundef @.str.200, i64 noundef %100, double %102, double %104)
  br label %105

105:                                              ; preds = %72
  %106 = load i64, ptr %21, align 8, !tbaa !5
  %107 = add nsw i64 %106, 1
  store i64 %107, ptr %21, align 8, !tbaa !5
  br label %67, !llvm.loop !15

108:                                              ; preds = %67
  store i32 0, ptr %23, align 4
  br label %109

109:                                              ; preds = %108, %65, %51, %30
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  %110 = load i32, ptr %23, align 4
  switch i32 %110, label %112 [
    i32 0, label %111
    i32 1, label %111
  ]

111:                                              ; preds = %109, %109
  ret void

112:                                              ; preds = %109
  unreachable
}

; 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) #2

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

declare noundef zeroext i1 @_ZN11alglib_impl15cmatrixrank1mklEllPNS_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) #3

declare noundef zeroext i1 @_ZN11alglib_impl13cmatrixrank1fEllPNS_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) #3

declare void @_ZN11alglib_impl10ae_v_caddcEPNS_10ae_complexElPKS0_lPKclS0_(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, double, double) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = !{!"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 = !{i64 0, i64 8, !13, i64 8, i64 8, !13}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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.alglib_impl::ae_complex" = type { double, double }

@.str.200 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE = external hidden local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl12cmatrixrank1EllPNS_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_impl15cmatrixrank1mklEllPNS_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_impl13cmatrixrank1fEllPNS_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 ], [ %38, %26 ]
  %27 = load ptr, ptr %21, align 8, !tbaa !9
  %28 = getelementptr %"struct.alglib_impl::ae_complex", ptr %27, i64 %.045
  %29 = getelementptr %"struct.alglib_impl::ae_complex", ptr %28, i64 %6
  %.sroa.02.0.copyload = load double, ptr %29, align 8, !tbaa !10
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %29, i64 8
  %.sroa.4.0.copyload = load double, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !10
  %30 = load ptr, ptr %22, align 8, !tbaa !9
  %31 = getelementptr ptr, ptr %30, i64 %.045
  %32 = getelementptr ptr, ptr %31, i64 %3
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %34 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %33, i64 %4
  %35 = load ptr, ptr %23, align 8, !tbaa !9
  %36 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %35, i64 %8
  %37 = tail call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef %4, i64 noundef %25)
  tail call void @_ZN11alglib_impl10ae_v_caddcEPNS_10ae_complexElPKS0_lPKclS0_(ptr noundef %34, i64 noundef 1, ptr noundef %36, i64 noundef 1, ptr noundef nonnull @.str.200, i64 noundef %37, double %.sroa.02.0.copyload, double %.sroa.4.0.copyload)
  %38 = add nuw nsw i64 %.045, 1
  %exitcond.not = icmp eq i64 %38, %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 noundef zeroext i1 @_ZN11alglib_impl15cmatrixrank1mklEllPNS_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_impl13cmatrixrank1fEllPNS_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 void @_ZN11alglib_impl10ae_v_caddcEPNS_10ae_complexElPKS0_lPKclS0_(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, double, double) 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