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

; 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 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon = 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_impl27ae_serializer_serialize_intEPNS_13ae_serializerElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl21serializebooleanarrayEPNS_13ae_serializerEPKNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %12, label %16

12:                                               ; preds = %4
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %13, i32 0, i32 0
  %15 = load i64, ptr %14, align 8, !tbaa !11
  store i64 %15, ptr %7, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %12, %4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN11alglib_impl27ae_serializer_serialize_intEPNS_13ae_serializerElPNS_8ae_stateE(ptr noundef %17, i64 noundef %18, ptr noundef %19)
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %35, %16
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = sub nsw i64 %22, 1
  %24 = icmp sle i64 %21, %23
  br i1 %24, label %25, label %38

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !16, !range !17, !noundef !18
  %33 = trunc i8 %32 to i1
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN11alglib_impl28ae_serializer_serialize_boolEPNS_13ae_serializerEbPNS_8ae_stateE(ptr noundef %26, i1 noundef zeroext %33, ptr noundef %34)
  br label %35

35:                                               ; preds = %25
  %36 = load i64, ptr %9, align 8, !tbaa !9
  %37 = add nsw i64 %36, 1
  store i64 %37, ptr %9, align 8, !tbaa !9
  br label %20, !llvm.loop !19

38:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

declare void @_ZN11alglib_impl28ae_serializer_serialize_boolEPNS_13ae_serializerEbPNS_8ae_stateE(ptr noundef, i1 noundef zeroext, ptr noundef) #1

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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN11alglib_impl9ae_vectorE", !10, i64 0, !10, i64 8, !13, i64 16, !14, i64 24, !7, i64 56}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!7, !7, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !20}
!20 = !{!"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_impl27ae_serializer_serialize_intEPNS_13ae_serializerElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl21serializebooleanarrayEPNS_13ae_serializerEPKNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = icmp slt i64 %2, 0
  br i1 %5, label %6, label %8

6:                                                ; preds = %4
  %7 = load i64, ptr %1, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %6, %4
  %.011 = phi i64 [ %7, %6 ], [ %2, %4 ]
  tail call void @_ZN11alglib_impl27ae_serializer_serialize_intEPNS_13ae_serializerElPNS_8ae_stateE(ptr noundef %0, i64 noundef %.011, ptr noundef %3)
  %.not.not13 = icmp sgt i64 %.011, 0
  br i1 %.not.not13, label %.lr.ph, label %._crit_edge

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

10:                                               ; preds = %.lr.ph, %10
  %.014 = phi i64 [ 0, %.lr.ph ], [ %15, %10 ]
  %11 = load ptr, ptr %9, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %11, i64 %.014
  %13 = load i8, ptr %12, align 1, !tbaa !14, !range !15, !noundef !16
  %14 = trunc nuw i8 %13 to i1
  tail call void @_ZN11alglib_impl28ae_serializer_serialize_boolEPNS_13ae_serializerEbPNS_8ae_stateE(ptr noundef %0, i1 noundef zeroext %14, ptr noundef %3)
  %15 = add nuw nsw i64 %.014, 1
  %exitcond.not = icmp eq i64 %15, %.011
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !17

._crit_edge:                                      ; preds = %10, %8
  ret void
}

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

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_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 = !{!8, !8, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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