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

; 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_nxpool" = type { i64, i64, i64, i64, %"struct.alglib_impl::ae_dyn_block", %"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::ae_dyn_block" = type { ptr, ptr, ptr, ptr }

; Function Attrs: noreturn nounwind
declare void @abort() #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11alglib_impl14ae_check_zerosEPKvl(ptr noundef, i64 noundef) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl10ae_db_initEPNS_12ae_dyn_blockElPNS_8ae_stateEb(ptr noundef, i64 noundef, ptr noundef, i1 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl12ae_init_lockEPNS_7ae_lockEPNS_8ae_stateEb(ptr noundef, ptr noundef, i1 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl14ae_nxpool_initEPNS_9ae_nxpoolElPNS_8ae_stateEb(ptr noundef %0, i64 noundef %1, ptr noundef %2, i1 noundef zeroext %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %9 = zext i1 %3 to i8
  store i8 %9, ptr %8, align 1, !tbaa !11
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %4
  call void @abort() #3
  unreachable

13:                                               ; preds = %4
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noundef zeroext i1 @_ZN11alglib_impl14ae_check_zerosEPKvl(ptr noundef %14, i64 noundef 144)
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @abort() #3
  unreachable

17:                                               ; preds = %13
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %18, i32 0, i32 6
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %19, i32 0, i32 1
  store ptr @_ZN11alglib_impl17ae_nxpool_destroyEPNS_9ae_nxpoolE, ptr %20, align 8, !tbaa !13
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %22, i32 0, i32 6
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %23, i32 0, i32 2
  store volatile ptr %21, ptr %24, align 8, !tbaa !17
  %25 = load i8, ptr %8, align 1, !tbaa !11, !range !18, !noundef !19
  %26 = trunc i8 %25 to i1
  br i1 %26, label %27, label %31

27:                                               ; preds = %17
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %28, i32 0, i32 6
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef %29, ptr noundef %30)
  br label %31

31:                                               ; preds = %27, %17
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %32, i32 0, i32 4
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl10ae_db_initEPNS_12ae_dyn_blockElPNS_8ae_stateEb(ptr noundef %33, i64 noundef 0, ptr noundef %34, i1 noundef zeroext false)
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %36, i32 0, i32 0
  store i64 %35, ptr %37, align 8, !tbaa !20
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %38, i32 0, i32 1
  store i64 0, ptr %39, align 8, !tbaa !21
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %40, i32 0, i32 2
  store i64 0, ptr %41, align 8, !tbaa !22
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %42, i32 0, i32 3
  store i64 0, ptr %43, align 8, !tbaa !23
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.alglib_impl::ae_nxpool", ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_init_lockEPNS_7ae_lockEPNS_8ae_stateEb(ptr noundef %45, ptr noundef %46, i1 noundef zeroext false)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl17ae_nxpool_destroyEPNS_9ae_nxpoolE(ptr noundef) #2

attributes #0 = { noreturn nounwind "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" }
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 = { noreturn 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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !6, i64 120}
!14 = !{!"_ZTSN11alglib_impl9ae_nxpoolE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !15, i64 32, !16, i64 64, !15, i64 112}
!15 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"_ZTSN11alglib_impl7ae_lockE", !6, i64 0, !15, i64 8, !12, i64 40}
!17 = !{!14, !6, i64 128}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!14, !10, i64 0}
!21 = !{!14, !10, i64 8}
!22 = !{!14, !10, i64 16}
!23 = !{!14, !10, i64 24}


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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl10ae_db_initEPNS_12ae_dyn_blockElPNS_8ae_stateEb(ptr noundef, i64 noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl14ae_nxpool_initEPNS_9ae_nxpoolElPNS_8ae_stateEb(ptr noundef %0, i64 noundef %1, ptr noundef %2, i1 noundef zeroext %3) local_unnamed_addr #2 {
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %4
  tail call void @abort() #4
  unreachable

6:                                                ; preds = %4
  %7 = tail call noundef zeroext i1 @_ZN11alglib_impl14ae_check_zerosEPKvl(ptr noundef %0, i64 noundef 144)
  br i1 %7, label %9, label %8

8:                                                ; preds = %6
  tail call void @abort() #4
  unreachable

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr @_ZN11alglib_impl17ae_nxpool_destroyEPNS_9ae_nxpoolE, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 128
  store volatile ptr %0, ptr %11, align 8, !tbaa !14
  br i1 %3, label %12, label %14

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  tail call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef nonnull %13, ptr noundef nonnull %2)
  br label %14

14:                                               ; preds = %12, %9
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZN11alglib_impl10ae_db_initEPNS_12ae_dyn_blockElPNS_8ae_stateEb(ptr noundef nonnull %15, i64 noundef 0, ptr noundef nonnull %2, i1 noundef zeroext false)
  store i64 %1, ptr %0, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %16, i8 0, i64 24, i1 false)
  tail call void @_ZN11alglib_impl12ae_init_lockEPNS_7ae_lockEPNS_8ae_stateEb(ptr noundef nonnull %17, ptr noundef nonnull %2, i1 noundef zeroext false)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl17ae_nxpool_destroyEPNS_9ae_nxpoolE(ptr noundef) #2

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

attributes #0 = { noreturn nounwind "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" }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { noreturn 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, !11, i64 120}
!6 = !{!"_ZTSN11alglib_impl9ae_nxpoolE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !12, i64 64, !10, i64 112}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTSN11alglib_impl7ae_lockE", !11, i64 0, !10, i64 8, !13, i64 40}
!13 = !{!"bool", !8, i64 0}
!14 = !{!6, !11, i64 128}
!15 = !{!6, !7, i64 0}


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