; LLVM IR from Dimandragon/non-parametric-dsp :: alglib-cpp/src/ap.ll (ZN11alglib_impl17ae_obj_array_initEPNS_12ae_obj_arrayEPNS_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_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::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
define dso_local void @_ZN11alglib_impl17ae_obj_array_initEPNS_12ae_obj_arrayEPNS_8ae_stateEb(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %7 = zext i1 %2 to i8
  store i8 %7, ptr %6, align 1, !tbaa !9
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %11, label %10

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

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

14:                                               ; preds = %11
  call void @abort() #3
  unreachable

15:                                               ; preds = %11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %16, i32 0, i32 8
  %18 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %17, i32 0, i32 1
  store ptr @_ZN11alglib_impl20ae_obj_array_destroyEPNS_12ae_obj_arrayE, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %20, i32 0, i32 8
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %21, i32 0, i32 2
  store volatile ptr %19, ptr %22, align 8, !tbaa !16
  %23 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %29

25:                                               ; preds = %15
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %26, i32 0, i32 8
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef %27, ptr noundef %28)
  br label %29

29:                                               ; preds = %25, %15
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %30, i32 0, i32 0
  store i64 0, ptr %31, align 8, !tbaa !19
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %32, i32 0, i32 1
  store i64 0, ptr %33, align 8, !tbaa !20
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %34, i32 0, i32 2
  store i8 0, ptr %35, align 8, !tbaa !21
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %36, i32 0, i32 3
  store ptr null, ptr %37, align 8, !tbaa !22
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %38, i32 0, i32 4
  store ptr null, ptr %39, align 8, !tbaa !23
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %40, i32 0, i32 5
  store ptr null, ptr %41, align 8, !tbaa !24
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %42, i32 0, i32 6
  store ptr null, ptr %43, align 8, !tbaa !25
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.alglib_impl::ae_obj_array", ptr %44, i32 0, i32 7
  %46 = load ptr, ptr %5, 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_impl20ae_obj_array_destroyEPNS_12ae_obj_arrayE(ptr noundef) #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

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 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 112}
!12 = !{!"_ZTSN11alglib_impl12ae_obj_arrayE", !13, i64 0, !13, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !14, i64 56, !15, i64 104}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl7ae_lockE", !6, i64 0, !15, i64 8, !10, i64 40}
!15 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!12, !6, i64 120}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!12, !13, i64 0}
!20 = !{!12, !13, i64 8}
!21 = !{!12, !10, i64 16}
!22 = !{!12, !6, i64 24}
!23 = !{!12, !6, i64 32}
!24 = !{!12, !6, i64 40}
!25 = !{!12, !6, i64 48}


; 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
define dso_local void @_ZN11alglib_impl17ae_obj_array_initEPNS_12ae_obj_arrayEPNS_8ae_stateEb(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) local_unnamed_addr #2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %4, label %5

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

5:                                                ; preds = %3
  %6 = tail call noundef zeroext i1 @_ZN11alglib_impl14ae_check_zerosEPKvl(ptr noundef %0, i64 noundef 136)
  br i1 %6, label %8, label %7

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

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 112
  store ptr @_ZN11alglib_impl20ae_obj_array_destroyEPNS_12ae_obj_arrayE, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 120
  store volatile ptr %0, ptr %10, align 8, !tbaa !14
  br i1 %2, label %11, label %13

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef nonnull %12, ptr noundef nonnull %1)
  br label %13

13:                                               ; preds = %11, %8
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %0, i8 0, i64 17, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %14, i8 0, i64 32, i1 false)
  tail call void @_ZN11alglib_impl12ae_init_lockEPNS_7ae_lockEPNS_8ae_stateEb(ptr noundef nonnull %15, ptr noundef nonnull %1, i1 noundef zeroext false)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl20ae_obj_array_destroyEPNS_12ae_obj_arrayE(ptr noundef) #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: 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 112}
!6 = !{!"_ZTSN11alglib_impl12ae_obj_arrayE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !12, i64 56, !13, i64 104}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTSN11alglib_impl7ae_lockE", !11, i64 0, !13, i64 8, !10, i64 40}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!14 = !{!6, !11, i64 120}


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