; 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_complex" = type { double, double }
%"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_impl18cmatrixlusolvefastEPNS_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
  %16 = alloca %"struct.alglib_impl::ae_complex", align 8
  %17 = alloca %"struct.alglib_impl::ae_complex", align 8
  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) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %18, align 8, !tbaa !9
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = icmp sle i64 %19, 0
  br i1 %20, label %21, label %23

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

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

24:                                               ; preds = %66, %23
  %25 = load i64, ptr %13, align 8, !tbaa !9
  %26 = load i64, ptr %9, align 8, !tbaa !9
  %27 = sub nsw i64 %26, 1
  %28 = icmp sle i64 %25, %27
  br i1 %28, label %29, label %69

29:                                               ; preds = %24
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %30, i32 0, i32 6
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load i64, ptr %13, align 8, !tbaa !9
  %34 = getelementptr inbounds ptr, ptr %32, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = load i64, ptr %13, align 8, !tbaa !9
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %35, i64 %36
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %37, i64 16, i1 false), !tbaa.struct !12
  %38 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 0
  %39 = load double, ptr %38, align 8
  %40 = getelementptr inbounds { double, double }, ptr %16, i32 0, i32 1
  %41 = load double, ptr %40, align 8
  %42 = call noundef zeroext i1 @_ZN11alglib_impl9ae_c_eq_dENS_10ae_complexEd(double %39, double %41, double noundef 0.000000e+00)
  br i1 %42, label %43, label %65

43:                                               ; preds = %29
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %60, %43
  %45 = load i64, ptr %14, align 8, !tbaa !9
  %46 = load i64, ptr %9, align 8, !tbaa !9
  %47 = sub nsw i64 %46, 1
  %48 = icmp sle i64 %45, %47
  br i1 %48, label %49, label %63

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  %50 = call { double, double } @_ZN11alglib_impl17ae_complex_from_dEd(double noundef 0.000000e+00)
  %51 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 0
  %52 = extractvalue { double, double } %50, 0
  store double %52, ptr %51, align 8
  %53 = getelementptr inbounds { double, double }, ptr %17, i32 0, i32 1
  %54 = extractvalue { double, double } %50, 1
  store double %54, ptr %53, align 8
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = load i64, ptr %14, align 8, !tbaa !9
  %59 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %57, i64 %58
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %59, ptr align 8 %17, i64 16, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  br label %60

60:                                               ; preds = %49
  %61 = load i64, ptr %14, align 8, !tbaa !9
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %14, align 8, !tbaa !9
  br label %44, !llvm.loop !15

63:                                               ; preds = %44
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -3, ptr %64, align 8, !tbaa !9
  store i32 1, ptr %15, align 4
  br label %76

65:                                               ; preds = %29
  br label %66

66:                                               ; preds = %65
  %67 = load i64, ptr %13, align 8, !tbaa !9
  %68 = add nsw i64 %67, 1
  store i64 %68, ptr %13, align 8, !tbaa !9
  br label %24, !llvm.loop !17

69:                                               ; preds = %24
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = load i64, ptr %9, align 8, !tbaa !9
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZN11alglib_implL32directdensesolvers_cbasiclusolveEPNS_9ae_matrixEPNS_9ae_vectorElS3_PNS_8ae_stateE(ptr noundef %70, ptr noundef %71, i64 noundef %72, ptr noundef %73, ptr noundef %74)
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 1, ptr %75, align 8, !tbaa !9
  store i32 0, ptr %15, align 4
  br label %76

76:                                               ; preds = %69, %63, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %77 = load i32, ptr %15, align 4
  switch i32 %77, label %79 [
    i32 0, label %78
    i32 1, label %78
  ]

78:                                               ; preds = %76, %76
  ret void

79:                                               ; preds = %76
  unreachable
}

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

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

declare { double, double } @_ZN11alglib_impl17ae_complex_from_dEd(double noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN11alglib_implL32directdensesolvers_cbasiclusolveEPNS_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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = !{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"}
!17 = distinct !{!17, !16}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl18cmatrixlusolvefastEPNS_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 %.preheader25

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

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

11:                                               ; preds = %.preheader25, %9
  %.026 = phi i64 [ 0, %.preheader25 ], [ %10, %9 ]
  %12 = load ptr, ptr %8, align 8, !tbaa !11
  %13 = getelementptr inbounds ptr, ptr %12, i64 %.026
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %14, i64 %.026
  %.sroa.01.0.copyload = load double, ptr %15, align 8, !tbaa !14
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %15, i64 8
  %.sroa.2.0.copyload = load double, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !14
  %16 = tail call noundef zeroext i1 @_ZN11alglib_impl9ae_c_eq_dENS_10ae_complexEd(double %.sroa.01.0.copyload, double %.sroa.2.0.copyload, double noundef 0.000000e+00)
  br i1 %16, label %.lr.ph, label %9

.lr.ph:                                           ; preds = %11
  %17 = getelementptr inbounds i8, ptr %3, i64 56
  br label %18

18:                                               ; preds = %.lr.ph, %18
  %.02128 = phi i64 [ 0, %.lr.ph ], [ %24, %18 ]
  %19 = tail call { double, double } @_ZN11alglib_impl17ae_complex_from_dEd(double noundef 0.000000e+00)
  %20 = extractvalue { double, double } %19, 0
  %21 = extractvalue { double, double } %19, 1
  %22 = load ptr, ptr %17, align 8, !tbaa !11
  %23 = getelementptr inbounds %"struct.alglib_impl::ae_complex", ptr %22, i64 %.02128
  store double %20, ptr %23, align 8, !tbaa !14
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %23, i64 8
  store double %21, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !14
  %24 = add nuw nsw i64 %.02128, 1
  %exitcond29.not = icmp eq i64 %24, %2
  br i1 %exitcond29.not, label %._crit_edge, label %18, !llvm.loop !16

25:                                               ; preds = %9
  tail call void @_ZN11alglib_implL32directdensesolvers_cbasiclusolveEPNS_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:                                      ; preds = %18, %6, %25
  %.sink = phi i64 [ 1, %25 ], [ -1, %6 ], [ -3, %18 ]
  store i64 %.sink, ptr %4, align 8, !tbaa !5
  ret void
}

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

declare { double, double } @_ZN11alglib_impl17ae_complex_from_dEd(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN11alglib_implL32directdensesolvers_cbasiclusolveEPNS_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}


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