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

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

31:                                               ; preds = %28, %11
  store i32 1, ptr %25, align 4
  br label %112

32:                                               ; preds = %28
  %33 = load i64, ptr %12, align 8, !tbaa !5
  %34 = load i64, ptr @_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE, align 8, !tbaa !5
  %35 = icmp sgt i64 %33, %34
  br i1 %35, label %36, label %55

36:                                               ; preds = %32
  %37 = load i64, ptr %13, align 8, !tbaa !5
  %38 = load i64, ptr @_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE, align 8, !tbaa !5
  %39 = icmp sgt i64 %37, %38
  br i1 %39, label %40, label %55

40:                                               ; preds = %36
  %41 = load i64, ptr %12, align 8, !tbaa !5
  %42 = load i64, ptr %13, align 8, !tbaa !5
  %43 = load ptr, ptr %14, align 8, !tbaa !9
  %44 = load i64, ptr %15, align 8, !tbaa !5
  %45 = load i64, ptr %16, align 8, !tbaa !5
  %46 = load double, ptr %17, align 8, !tbaa !11
  %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 = load i64, ptr %21, align 8, !tbaa !5
  %51 = load ptr, ptr %22, align 8, !tbaa !9
  %52 = call noundef zeroext i1 @_ZN11alglib_impl13rmatrixgermklEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %41, i64 noundef %42, ptr noundef %43, i64 noundef %44, i64 noundef %45, double noundef %46, ptr noundef %47, i64 noundef %48, ptr noundef %49, i64 noundef %50, ptr noundef %51)
  br i1 %52, label %53, label %54

53:                                               ; preds = %40
  store i32 1, ptr %25, align 4
  br label %112

54:                                               ; preds = %40
  br label %55

55:                                               ; preds = %54, %36, %32
  %56 = load i64, ptr %12, align 8, !tbaa !5
  %57 = load i64, ptr %13, align 8, !tbaa !5
  %58 = load ptr, ptr %14, align 8, !tbaa !9
  %59 = load i64, ptr %15, align 8, !tbaa !5
  %60 = load i64, ptr %16, align 8, !tbaa !5
  %61 = load double, ptr %17, align 8, !tbaa !11
  %62 = load ptr, ptr %18, align 8, !tbaa !9
  %63 = load i64, ptr %19, align 8, !tbaa !5
  %64 = load ptr, ptr %20, align 8, !tbaa !9
  %65 = load i64, ptr %21, align 8, !tbaa !5
  %66 = load ptr, ptr %22, align 8, !tbaa !9
  %67 = call noundef zeroext i1 @_ZN11alglib_impl11rmatrixgerfEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %56, i64 noundef %57, ptr noundef %58, i64 noundef %59, i64 noundef %60, double noundef %61, ptr noundef %62, i64 noundef %63, ptr noundef %64, i64 noundef %65, ptr noundef %66)
  br i1 %67, label %68, label %69

68:                                               ; preds = %55
  store i32 1, ptr %25, align 4
  br label %112

69:                                               ; preds = %55
  store i64 0, ptr %23, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %108, %69
  %71 = load i64, ptr %23, align 8, !tbaa !5
  %72 = load i64, ptr %12, align 8, !tbaa !5
  %73 = sub nsw i64 %72, 1
  %74 = icmp sle i64 %71, %73
  br i1 %74, label %75, label %111

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

108:                                              ; preds = %75
  %109 = load i64, ptr %23, align 8, !tbaa !5
  %110 = add nsw i64 %109, 1
  store i64 %110, ptr %23, align 8, !tbaa !5
  br label %70, !llvm.loop !14

111:                                              ; preds = %70
  store i32 0, ptr %25, align 4
  br label %112

112:                                              ; preds = %111, %68, %53, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  %113 = load i32, ptr %25, align 4
  switch i32 %113, label %115 [
    i32 0, label %114
    i32 1, label %114
  ]

114:                                              ; preds = %112, %112
  ret void

115:                                              ; preds = %112
  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_impl13rmatrixgermklEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, double noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #2

declare noundef zeroext i1 @_ZN11alglib_impl11rmatrixgerfEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, double 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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!7, !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_impl10rmatrixgerEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, double noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10) local_unnamed_addr #0 {
  %12 = icmp slt i64 %0, 1
  %13 = icmp slt i64 %1, 1
  %or.cond = or i1 %12, %13
  br i1 %or.cond, label %.loopexit, label %14

14:                                               ; preds = %11
  %15 = load i64, ptr @_ZN11alglib_implL30ablas_blas2minvendorkernelsizeE, align 8, !tbaa !5
  %16 = icmp slt i64 %15, %0
  %17 = icmp slt i64 %15, %1
  %or.cond46 = and i1 %16, %17
  br i1 %or.cond46, label %18, label %20

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

20:                                               ; preds = %18, %14
  %21 = tail call noundef zeroext i1 @_ZN11alglib_impl11rmatrixgerfEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, double noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10)
  br i1 %21, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %20
  %22 = getelementptr inbounds i8, ptr %6, i64 56
  %23 = getelementptr inbounds i8, ptr %2, i64 72
  %24 = getelementptr inbounds i8, ptr %8, i64 56
  %25 = add nsw i64 %1, -1
  %26 = add i64 %25, %4
  br label %27

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

.loopexit:                                        ; preds = %27, %20, %18, %11
  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_impl13rmatrixgermklEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, double noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN11alglib_impl11rmatrixgerfEllPNS_9ae_matrixElldPNS_9ae_vectorElS3_lPNS_8ae_stateE(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef, double 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