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

; 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::convexquadraticmodel" = type { i64, i64, double, double, double, %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", double, double, %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", i64, i64, %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", double, %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_matrix", i8, i8, i8, i8 }
%"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 }

; 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

declare void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #1

declare noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef, double noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl11cqmgetdiagaEPNS_20convexquadraticmodelEPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.alglib_impl::convexquadraticmodel", ptr %9, i32 0, i32 0
  %11 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %11, ptr %7, align 8, !tbaa !17
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load i64, ptr %7, align 8, !tbaa !17
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %12, i64 noundef %13, ptr noundef %14)
  store i64 0, ptr %8, align 8, !tbaa !17
  br label %15

15:                                               ; preds = %48, %3
  %16 = load i64, ptr %8, align 8, !tbaa !17
  %17 = load i64, ptr %7, align 8, !tbaa !17
  %18 = sub nsw i64 %17, 1
  %19 = icmp sle i64 %16, %18
  br i1 %19, label %20, label %51

20:                                               ; preds = %15
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::convexquadraticmodel", ptr %21, i32 0, i32 2
  %23 = load double, ptr %22, align 8, !tbaa !18
  %24 = call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef %23, double noundef 0.000000e+00)
  br i1 %24, label %25, label %41

25:                                               ; preds = %20
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.alglib_impl::convexquadraticmodel", ptr %26, i32 0, i32 5
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %27, i32 0, i32 6
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  %30 = load i64, ptr %8, align 8, !tbaa !17
  %31 = getelementptr inbounds ptr, ptr %29, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load i64, ptr %8, align 8, !tbaa !17
  %34 = getelementptr inbounds double, ptr %32, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !20
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %36, i32 0, i32 4
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  %39 = load i64, ptr %8, align 8, !tbaa !17
  %40 = getelementptr inbounds double, ptr %38, i64 %39
  store double %35, ptr %40, align 8, !tbaa !20
  br label %47

41:                                               ; preds = %20
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = load i64, ptr %8, align 8, !tbaa !17
  %46 = getelementptr inbounds double, ptr %44, i64 %45
  store double 0.000000e+00, ptr %46, align 8, !tbaa !20
  br label %47

47:                                               ; preds = %41, %25
  br label %48

48:                                               ; preds = %47
  %49 = load i64, ptr %8, align 8, !tbaa !17
  %50 = add nsw i64 %49, 1
  store i64 %50, ptr %8, align 8, !tbaa !17
  br label %15, !llvm.loop !21

51:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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, !11, i64 0}
!10 = !{!"_ZTSN11alglib_impl20convexquadraticmodelE", !11, i64 0, !11, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !13, i64 40, !13, i64 120, !16, i64 200, !16, i64 264, !16, i64 328, !16, i64 392, !16, i64 456, !13, i64 520, !13, i64 600, !16, i64 680, !16, i64 744, !16, i64 808, !12, i64 872, !12, i64 880, !16, i64 888, !16, i64 952, !11, i64 1016, !11, i64 1024, !13, i64 1032, !13, i64 1112, !13, i64 1192, !16, i64 1272, !16, i64 1336, !12, i64 1400, !16, i64 1408, !16, i64 1472, !16, i64 1536, !13, i64 1600, !14, i64 1680, !14, i64 1681, !14, i64 1682, !14, i64 1683}
!11 = !{!"long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"_ZTSN11alglib_impl9ae_matrixE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !14, i64 32, !15, i64 40, !7, i64 72}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"_ZTSN11alglib_impl9ae_vectorE", !11, i64 0, !11, i64 8, !14, i64 16, !15, i64 24, !7, i64 56}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !12, i64 16}
!19 = !{!7, !7, i64 0}
!20 = !{!12, !12, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

declare void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl11cqmgetdiagaEPNS_20convexquadraticmodelEPNS_9ae_vectorEPNS_8ae_stateE(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = load i64, ptr %0, align 8, !tbaa !5
  tail call void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %1, i64 noundef %4, ptr noundef %2)
  %.not.not14 = icmp sgt i64 %4, 0
  br i1 %.not.not14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %1, i64 56
  %7 = getelementptr inbounds i8, ptr %0, i64 112
  br label %8

8:                                                ; preds = %.lr.ph, %17
  %.015 = phi i64 [ 0, %.lr.ph ], [ %20, %17 ]
  %9 = load double, ptr %5, align 8, !tbaa !16
  %10 = tail call noundef zeroext i1 @_ZN11alglib_impl13ae_fp_greaterEdd(double noundef %9, double noundef 0.000000e+00)
  br i1 %10, label %11, label %17

11:                                               ; preds = %8
  %12 = load ptr, ptr %7, align 8, !tbaa !17
  %13 = getelementptr inbounds ptr, ptr %12, i64 %.015
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  %15 = getelementptr inbounds double, ptr %14, i64 %.015
  %16 = load double, ptr %15, align 8, !tbaa !19
  br label %17

17:                                               ; preds = %8, %11
  %.sink = phi double [ %16, %11 ], [ 0.000000e+00, %8 ]
  %18 = load ptr, ptr %6, align 8, !tbaa !17
  %19 = getelementptr inbounds double, ptr %18, i64 %.015
  store double %.sink, ptr %19, align 8, !tbaa !19
  %20 = add nuw nsw i64 %.015, 1
  %exitcond.not = icmp eq i64 %20, %4
  br i1 %exitcond.not, label %._crit_edge, label %8, !llvm.loop !20

._crit_edge:                                      ; preds = %17, %3
  ret void
}

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

!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, !7, i64 0}
!6 = !{!"_ZTSN11alglib_impl20convexquadraticmodelE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !11, i64 120, !15, i64 200, !15, i64 264, !15, i64 328, !15, i64 392, !15, i64 456, !11, i64 520, !11, i64 600, !15, i64 680, !15, i64 744, !15, i64 808, !10, i64 872, !10, i64 880, !15, i64 888, !15, i64 952, !7, i64 1016, !7, i64 1024, !11, i64 1032, !11, i64 1112, !11, i64 1192, !15, i64 1272, !15, i64 1336, !10, i64 1400, !15, i64 1408, !15, i64 1472, !15, i64 1536, !11, i64 1600, !12, i64 1680, !12, i64 1681, !12, i64 1682, !12, i64 1683}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl9ae_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !12, i64 32, !13, i64 40, !8, i64 72}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTSN11alglib_impl9ae_vectorE", !7, i64 0, !7, i64 8, !12, i64 16, !13, i64 24, !8, i64 56}
!16 = !{!6, !10, i64 16}
!17 = !{!8, !8, i64 0}
!18 = !{!14, !14, i64 0}
!19 = !{!10, !10, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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