; LLVM IR from Dimandragon/non-parametric-dsp :: alglib-cpp/src (ap)

; 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::qpxproblem" = type { i64, i8, double, i8, %"struct.alglib_impl::ae_vector", i8, %"struct.alglib_impl::ae_vector", i8, %"struct.alglib_impl::ae_vector", i8, %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", i8, %"struct.alglib_impl::sparsematrix", i8, %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", i64, %"struct.alglib_impl::sparsematrix", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", i64, %"struct.alglib_impl::xquadraticconstraints", i64, %"struct.alglib_impl::sparsematrix" }
%"struct.alglib_impl::xquadraticconstraints" = type { i64, %"struct.alglib_impl::ae_obj_array", %"struct.alglib_impl::ae_vector" }
%"struct.alglib_impl::ae_obj_array" = type { i64, i64, i8, ptr, ptr, ptr, ptr, %"struct.alglib_impl::ae_lock", %"struct.alglib_impl::ae_dyn_block" }
%"struct.alglib_impl::ae_lock" = type { ptr, %"struct.alglib_impl::ae_dyn_block", i8 }
%"struct.alglib_impl::sparsematrix" = type { %"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", i64, i64, i64, i64, i64, i64 }

@.str.161 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [39 x i8], align 1

; 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
declare dso_local void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef, ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl18qpxproblemsetscaleEPNS_10qpxproblemEPKNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = 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
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %8, i32 0, i32 0
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.alglib_impl::qpxproblem", ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = icmp sge i64 %10, %13
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %14, ptr noundef @.str.161, ptr noundef %15)
  store i64 0, ptr %7, align 8, !tbaa !21
  br label %16

16:                                               ; preds = %33, %3
  %17 = load i64, ptr %7, align 8, !tbaa !21
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.alglib_impl::qpxproblem", ptr %18, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = sub nsw i64 %20, 1
  %22 = icmp sle i64 %17, %21
  br i1 %22, label %23, label %36

23:                                               ; preds = %16
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !22
  %27 = load i64, ptr %7, align 8, !tbaa !21
  %28 = getelementptr inbounds double, ptr %26, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !23
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %29, ptr noundef %30)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %31, ptr noundef @.str.162, ptr noundef %32)
  br label %33

33:                                               ; preds = %23
  %34 = load i64, ptr %7, align 8, !tbaa !21
  %35 = add nsw i64 %34, 1
  store i64 %35, ptr %7, align 8, !tbaa !21
  br label %16, !llvm.loop !24

36:                                               ; preds = %16
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::qpxproblem", ptr %37, i32 0, i32 7
  store i8 1, ptr %38, align 8, !tbaa !26
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.alglib_impl::qpxproblem", ptr %39, i32 0, i32 0
  %41 = load i64, ptr %40, align 8, !tbaa !14
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.alglib_impl::qpxproblem", ptr %43, i32 0, i32 8
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl11rcopyallocvElPKNS_9ae_vectorEPS0_PNS_8ae_stateE(i64 noundef %41, ptr noundef %42, ptr noundef %44, ptr noundef %45)
  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 = { 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 = { mustprogress nounwind 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_impl9ae_vectorE", !11, i64 0, !11, i64 8, !12, i64 16, !13, i64 24, !7, i64 56}
!11 = !{!"long", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTSN11alglib_impl10qpxproblemE", !11, i64 0, !12, i64 8, !16, i64 16, !12, i64 24, !10, i64 32, !12, i64 96, !10, i64 104, !12, i64 168, !10, i64 176, !12, i64 240, !10, i64 248, !10, i64 312, !12, i64 376, !17, i64 384, !12, i64 752, !10, i64 760, !10, i64 824, !11, i64 888, !17, i64 896, !10, i64 1264, !10, i64 1328, !11, i64 1392, !18, i64 1400, !11, i64 1608, !17, i64 1616}
!16 = !{!"double", !7, i64 0}
!17 = !{!"_ZTSN11alglib_impl12sparsematrixE", !10, i64 0, !10, i64 64, !10, i64 128, !10, i64 192, !10, i64 256, !11, i64 320, !11, i64 328, !11, i64 336, !11, i64 344, !11, i64 352, !11, i64 360}
!18 = !{!"_ZTSN11alglib_impl21xquadraticconstraintsE", !11, i64 0, !19, i64 8, !10, i64 144}
!19 = !{!"_ZTSN11alglib_impl12ae_obj_arrayE", !11, i64 0, !11, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !20, i64 56, !13, i64 104}
!20 = !{!"_ZTSN11alglib_impl7ae_lockE", !6, i64 0, !13, i64 8, !12, i64 40}
!21 = !{!11, !11, i64 0}
!22 = !{!7, !7, i64 0}
!23 = !{!16, !16, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!15, !12, i64 168}


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

@.str.161 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl18qpxproblemsetscaleEPNS_10qpxproblemEPKNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = load i64, ptr %0, align 8, !tbaa !13
  %6 = icmp sge i64 %4, %5
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %6, ptr noundef nonnull @.str.161, ptr noundef %2)
  %7 = load i64, ptr %0, align 8, !tbaa !13
  %.not.not14 = icmp sgt i64 %7, 0
  br i1 %.not.not14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %1, i64 56
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %.015 = phi i64 [ 0, %.lr.ph ], [ %14, %9 ]
  %10 = load ptr, ptr %8, align 8, !tbaa !20
  %11 = getelementptr inbounds double, ptr %10, i64 %.015
  %12 = load double, ptr %11, align 8, !tbaa !21
  %13 = tail call noundef zeroext i1 @_ZN11alglib_impl11ae_isfiniteEdPNS_8ae_stateE(double noundef %12, ptr noundef %2)
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %13, ptr noundef nonnull @.str.162, ptr noundef %2)
  %14 = add nuw nsw i64 %.015, 1
  %15 = load i64, ptr %0, align 8, !tbaa !13
  %.not.not = icmp slt i64 %14, %15
  br i1 %.not.not, label %9, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %9, %3
  %.lcssa = phi i64 [ %7, %3 ], [ %15, %9 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 168
  store i8 1, ptr %16, align 8, !tbaa !24
  %17 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @_ZN11alglib_impl11rcopyallocvElPKNS_9ae_vectorEPS0_PNS_8ae_stateE(i64 noundef %.lcssa, ptr noundef nonnull %1, ptr noundef nonnull %17, ptr noundef %2)
  ret void
}

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 = { mustprogress nounwind 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_impl9ae_vectorE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !8, i64 56}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl10qpxproblemE", !7, i64 0, !10, i64 8, !15, i64 16, !10, i64 24, !6, i64 32, !10, i64 96, !6, i64 104, !10, i64 168, !6, i64 176, !10, i64 240, !6, i64 248, !6, i64 312, !10, i64 376, !16, i64 384, !10, i64 752, !6, i64 760, !6, i64 824, !7, i64 888, !16, i64 896, !6, i64 1264, !6, i64 1328, !7, i64 1392, !17, i64 1400, !7, i64 1608, !16, i64 1616}
!15 = !{!"double", !8, i64 0}
!16 = !{!"_ZTSN11alglib_impl12sparsematrixE", !6, i64 0, !6, i64 64, !6, i64 128, !6, i64 192, !6, i64 256, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360}
!17 = !{!"_ZTSN11alglib_impl21xquadraticconstraintsE", !7, i64 0, !18, i64 8, !6, i64 144}
!18 = !{!"_ZTSN11alglib_impl12ae_obj_arrayE", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !19, i64 56, !11, i64 104}
!19 = !{!"_ZTSN11alglib_impl7ae_lockE", !12, i64 0, !11, i64 8, !10, i64 40}
!20 = !{!8, !8, i64 0}
!21 = !{!15, !15, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!14, !10, i64 168}


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