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

; 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_matrix" = type { i64, i64, 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_vector" = type { 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

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

19:                                               ; preds = %6
  %20 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -1, ptr %20, align 8, !tbaa !9
  store i32 1, ptr %15, align 4
  br label %66

21:                                               ; preds = %6
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %56, %21
  %23 = load i64, ptr %13, align 8, !tbaa !9
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = sub nsw i64 %24, 1
  %26 = icmp sle i64 %23, %25
  br i1 %26, label %27, label %59

27:                                               ; preds = %22
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %28, i32 0, i32 6
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = load i64, ptr %13, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %30, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load i64, ptr %13, align 8, !tbaa !9
  %35 = getelementptr inbounds double, ptr %33, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !12
  %37 = call noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef %36, double noundef 0.000000e+00)
  br i1 %37, label %38, label %55

38:                                               ; preds = %27
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %50, %38
  %40 = load i64, ptr %14, align 8, !tbaa !9
  %41 = load i64, ptr %9, align 8, !tbaa !9
  %42 = sub nsw i64 %41, 1
  %43 = icmp sle i64 %40, %42
  br i1 %43, label %44, label %53

44:                                               ; preds = %39
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = load i64, ptr %14, align 8, !tbaa !9
  %49 = getelementptr inbounds double, ptr %47, i64 %48
  store double 0.000000e+00, ptr %49, align 8, !tbaa !12
  br label %50

50:                                               ; preds = %44
  %51 = load i64, ptr %14, align 8, !tbaa !9
  %52 = add nsw i64 %51, 1
  store i64 %52, ptr %14, align 8, !tbaa !9
  br label %39, !llvm.loop !14

53:                                               ; preds = %39
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -3, ptr %54, align 8, !tbaa !9
  store i32 1, ptr %15, align 4
  br label %66

55:                                               ; preds = %27
  br label %56

56:                                               ; preds = %55
  %57 = load i64, ptr %13, align 8, !tbaa !9
  %58 = add nsw i64 %57, 1
  store i64 %58, ptr %13, align 8, !tbaa !9
  br label %22, !llvm.loop !16

59:                                               ; preds = %22
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load i64, ptr %9, align 8, !tbaa !9
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZN11alglib_implL32directdensesolvers_rbasiclusolveEPNS_9ae_matrixEPNS_9ae_vectorElS3_PNS_8ae_stateE(ptr noundef %60, ptr noundef %61, i64 noundef %62, ptr noundef %63, ptr noundef %64)
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 1, ptr %65, align 8, !tbaa !9
  store i32 0, ptr %15, align 4
  br label %66

66:                                               ; preds = %59, %53, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %67 = load i32, ptr %15, align 4
  switch i32 %67, label %69 [
    i32 0, label %68
    i32 1, label %68
  ]

68:                                               ; preds = %66, %66
  ret void

69:                                               ; preds = %66
  unreachable
}

declare noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef, double noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN11alglib_implL32directdensesolvers_rbasiclusolveEPNS_9ae_matrixEPNS_9ae_vectorElS3_PNS_8ae_stateE(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #1

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 = !{!"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"}
!16 = distinct !{!16, !15}


; 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 uwtable
define dso_local void @_ZN11alglib_impl18rmatrixlusolvefastEPNS_9ae_matrixEPNS_9ae_vectorElS3_PlPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr nocapture noundef writeonly %4, ptr noundef %5) local_unnamed_addr #0 {
  store i64 0, ptr %4, align 8, !tbaa !5
  %7 = icmp slt i64 %2, 1
  br i1 %7, label %._crit_edge, label %.preheader24

.preheader24:                                     ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 72
  br label %11

9:                                                ; preds = %11
  %10 = add nuw nsw i64 %.02025, 1
  %exitcond.not = icmp eq i64 %10, %2
  br i1 %exitcond.not, label %33, label %11, !llvm.loop !9

11:                                               ; preds = %.preheader24, %9
  %.02025 = phi i64 [ 0, %.preheader24 ], [ %10, %9 ]
  %12 = load ptr, ptr %8, align 8, !tbaa !11
  %13 = getelementptr inbounds ptr, ptr %12, i64 %.02025
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = getelementptr inbounds double, ptr %14, i64 %.02025
  %16 = load double, ptr %15, align 8, !tbaa !14
  %17 = tail call noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef %16, double noundef 0.000000e+00)
  br i1 %17, label %.lr.ph, label %9

.lr.ph:                                           ; preds = %11
  %18 = getelementptr inbounds i8, ptr %3, i64 56
  %xtraiter = and i64 %2, 3
  %19 = icmp ult i64 %2, 4
  br i1 %19, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %2, 9223372036854775804
  br label %20

20:                                               ; preds = %20, %.lr.ph.new
  %.027 = phi i64 [ 0, %.lr.ph.new ], [ %32, %20 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %20 ]
  %21 = load ptr, ptr %18, align 8, !tbaa !11
  %22 = getelementptr inbounds double, ptr %21, i64 %.027
  store double 0.000000e+00, ptr %22, align 8, !tbaa !14
  %23 = or disjoint i64 %.027, 1
  %24 = load ptr, ptr %18, align 8, !tbaa !11
  %25 = getelementptr inbounds double, ptr %24, i64 %23
  store double 0.000000e+00, ptr %25, align 8, !tbaa !14
  %26 = or disjoint i64 %.027, 2
  %27 = load ptr, ptr %18, align 8, !tbaa !11
  %28 = getelementptr inbounds double, ptr %27, i64 %26
  store double 0.000000e+00, ptr %28, align 8, !tbaa !14
  %29 = or disjoint i64 %.027, 3
  %30 = load ptr, ptr %18, align 8, !tbaa !11
  %31 = getelementptr inbounds double, ptr %30, i64 %29
  store double 0.000000e+00, ptr %31, align 8, !tbaa !14
  %32 = add nuw nsw i64 %.027, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %20, !llvm.loop !16

33:                                               ; preds = %9
  tail call void @_ZN11alglib_implL32directdensesolvers_rbasiclusolveEPNS_9ae_matrixEPNS_9ae_vectorElS3_PNS_8ae_stateE(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %5)
  br label %._crit_edge

._crit_edge.loopexit.unr-lcssa:                   ; preds = %20, %.lr.ph
  %.027.unr = phi i64 [ 0, %.lr.ph ], [ %32, %20 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %.027.epil = phi i64 [ %36, %.epil.preheader ], [ %.027.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %34 = load ptr, ptr %18, align 8, !tbaa !11
  %35 = getelementptr inbounds double, ptr %34, i64 %.027.epil
  store double 0.000000e+00, ptr %35, align 8, !tbaa !14
  %36 = add nuw nsw i64 %.027.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !17

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %6, %33
  %.sink = phi i64 [ 1, %33 ], [ -1, %6 ], [ -3, %.epil.preheader ], [ -3, %._crit_edge.loopexit.unr-lcssa ]
  store i64 %.sink, ptr %4, align 8, !tbaa !5
  ret void
}

declare noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN11alglib_implL32directdensesolvers_rbasiclusolveEPNS_9ae_matrixEPNS_9ae_vectorElS3_PNS_8ae_stateE(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.unroll.disable"}


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