; LLVM IR from Dimandragon/non-parametric-dsp :: 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::varsfuncjac" = type { i64, i64, i8, %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_matrix", %"struct.alglib_impl::sparsematrix" }
%"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 }
%"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.337 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.338 = external hidden unnamed_addr constant [20 x i8], align 1

declare void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) #0

declare void @_ZN11alglib_impl7rallocvElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl14vfjallocsparseEllPNS_11varsfuncjacEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  %9 = load i64, ptr %5, align 8, !tbaa !5
  %10 = icmp sge i64 %9, 1
  %11 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %10, ptr noundef @.str.337, ptr noundef %11)
  %12 = load i64, ptr %6, align 8, !tbaa !5
  %13 = icmp sge i64 %12, 1
  %14 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %13, ptr noundef @.str.338, ptr noundef %14)
  %15 = load i64, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !9
  %17 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %16, i32 0, i32 0
  store i64 %15, ptr %17, align 8, !tbaa !11
  %18 = load i64, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !9
  %20 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %19, i32 0, i32 1
  store i64 %18, ptr %20, align 8, !tbaa !18
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %21, i32 0, i32 2
  store i8 0, ptr %22, align 8, !tbaa !19
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  %25 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZN11alglib_impl7rallocvElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef %23, ptr noundef %25, ptr noundef %26)
  %27 = load i64, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZN11alglib_impl7rallocvElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef %27, ptr noundef %29, ptr noundef %30)
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %31, i32 0, i32 6
  %33 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %32, i32 0, i32 5
  store i64 -1, ptr %33, align 8, !tbaa !20
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %34, i32 0, i32 6
  %36 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %35, i32 0, i32 6
  store i64 -1, ptr %36, align 8, !tbaa !21
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = getelementptr inbounds %"struct.alglib_impl::varsfuncjac", ptr %37, i32 0, i32 6
  %39 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %38, i32 0, i32 7
  store i64 -1, ptr %39, align 8, !tbaa !22
  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, !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, !6, i64 0}
!12 = !{!"_ZTSN11alglib_impl11varsfuncjacE", !6, i64 0, !6, i64 8, !13, i64 16, !14, i64 24, !14, i64 88, !16, i64 152, !17, i64 232}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl9ae_vectorE", !6, i64 0, !6, i64 8, !13, i64 16, !15, i64 24, !7, i64 56}
!15 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!16 = !{!"_ZTSN11alglib_impl9ae_matrixE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !15, i64 40, !7, i64 72}
!17 = !{!"_ZTSN11alglib_impl12sparsematrixE", !14, i64 0, !14, i64 64, !14, i64 128, !14, i64 192, !14, i64 256, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360}
!18 = !{!12, !6, i64 8}
!19 = !{!12, !13, i64 16}
!20 = !{!12, !6, i64 552}
!21 = !{!12, !6, i64 560}
!22 = !{!12, !6, i64 568}


; 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.337 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.338 = external hidden unnamed_addr constant [20 x i8], align 1

declare void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl14vfjallocsparseEllPNS_11varsfuncjacEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = icmp sgt i64 %0, 0
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %5, ptr noundef nonnull @.str.337, ptr noundef %3)
  %6 = icmp sgt i64 %1, 0
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %6, ptr noundef nonnull @.str.338, ptr noundef %3)
  store i64 %0, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  store i64 %1, ptr %7, align 8, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %2, i64 16
  store i8 0, ptr %8, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %2, i64 24
  tail call void @_ZN11alglib_impl7rallocvElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef %0, ptr noundef nonnull %9, ptr noundef %3)
  %10 = getelementptr inbounds i8, ptr %2, i64 88
  tail call void @_ZN11alglib_impl7rallocvElPNS_9ae_vectorEPNS_8ae_stateE(i64 noundef %1, ptr noundef nonnull %10, ptr noundef %3)
  %11 = getelementptr inbounds i8, ptr %2, i64 552
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %11, i8 -1, i64 24, i1 false)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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_impl11varsfuncjacE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !11, i64 88, !14, i64 152, !15, i64 232}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl9ae_vectorE", !7, i64 0, !7, i64 8, !10, i64 16, !12, i64 24, !8, i64 56}
!12 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"_ZTSN11alglib_impl9ae_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !12, i64 40, !8, i64 72}
!15 = !{!"_ZTSN11alglib_impl12sparsematrixE", !11, i64 0, !11, i64 64, !11, i64 128, !11, i64 192, !11, i64 256, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !10, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass