; 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_smart_ptr" = type { ptr, ptr, i8, i8, i64, ptr, ptr, %"struct.alglib_impl::ae_dyn_block" }
%"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 nounwind uwtable
define dso_local void @_ZN11alglib_impl17ae_smart_ptr_initEPNS_12ae_smart_ptrEPPvPNS_8ae_stateEb(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %9 = zext i1 %3 to i8
  store i8 %9, ptr %8, align 1, !tbaa !9
  %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 80)
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %13
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %19, i32 0, i32 0
  store ptr %18, ptr %20, align 8, !tbaa !11
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %21, i32 0, i32 1
  store ptr null, ptr %22, align 8, !tbaa !15
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %34

27:                                               ; preds = %17
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  store ptr %30, ptr %33, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %27, %17
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %35, i32 0, i32 2
  store i8 0, ptr %36, align 8, !tbaa !16
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %37, i32 0, i32 3
  store i8 0, ptr %38, align 1, !tbaa !17
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %39, i32 0, i32 4
  store i64 0, ptr %40, align 8, !tbaa !18
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %41, i32 0, i32 5
  store ptr null, ptr %42, align 8, !tbaa !19
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %43, i32 0, i32 6
  store ptr null, ptr %44, align 8, !tbaa !20
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %45, i32 0, i32 7
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %46, i32 0, i32 1
  store ptr @_ZN11alglib_impl20ae_smart_ptr_destroyEPv, ptr %47, align 8, !tbaa !21
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %49, i32 0, i32 7
  %51 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %50, i32 0, i32 2
  store volatile ptr %48, ptr %51, align 8, !tbaa !22
  %52 = load i8, ptr %8, align 1, !tbaa !9, !range !23, !noundef !24
  %53 = trunc i8 %52 to i1
  br i1 %53, label %54, label %58

54:                                               ; preds = %34
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %55, i32 0, i32 7
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef %56, ptr noundef %57)
  br label %58

58:                                               ; preds = %54, %34
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl20ae_smart_ptr_destroyEPv(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 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN11alglib_impl12ae_smart_ptrE", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 17, !13, i64 24, !6, i64 32, !6, i64 40, !14, i64 48}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !10, i64 17}
!18 = !{!12, !13, i64 24}
!19 = !{!12, !6, i64 32}
!20 = !{!12, !6, i64 40}
!21 = !{!12, !6, i64 56}
!22 = !{!12, !6, i64 64}
!23 = !{i8 0, i8 2}
!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 nounwind uwtable
define dso_local void @_ZN11alglib_impl17ae_smart_ptr_initEPNS_12ae_smart_ptrEPPvPNS_8ae_stateEb(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) local_unnamed_addr #1 {
  %.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 80)
  br i1 %7, label %9, label %8

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

9:                                                ; preds = %6
  store ptr %1, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %10, align 8, !tbaa !13
  %.not19 = icmp eq ptr %1, null
  br i1 %.not19, label %12, label %11

11:                                               ; preds = %9
  store ptr null, ptr %1, align 8, !tbaa !14
  br label %12

12:                                               ; preds = %11, %9
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 0, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 17
  store i8 0, ptr %14, align 1, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %16 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %15, i8 0, i64 24, i1 false)
  store ptr @_ZN11alglib_impl20ae_smart_ptr_destroyEPv, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 64
  store volatile ptr %0, ptr %17, align 8, !tbaa !18
  br i1 %3, label %18, label %20

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef nonnull %19, ptr noundef nonnull %2)
  br label %20

20:                                               ; preds = %18, %12
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl20ae_smart_ptr_destroyEPv(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, !7, i64 0}
!6 = !{!"_ZTSN11alglib_impl12ae_smart_ptrE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 17, !11, i64 24, !7, i64 32, !7, i64 40, !12, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!13 = !{!6, !7, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !10, i64 17}
!17 = !{!6, !7, i64 56}
!18 = !{!6, !7, i64 64}


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