; LLVM IR from Dimandragon/non-parametric-dsp :: alglib-cpp/src/ap.ll (ZN11alglib_impl19ae_shared_pool_initEPvPNS_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_shared_pool" = type { %"struct.alglib_impl::ae_lock", ptr, ptr, ptr, ptr, i64, ptr, ptr, %"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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef, 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) #3

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

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

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

16:                                               ; preds = %12
  call void @abort() #5
  unreachable

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

27:                                               ; preds = %17
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %28, i32 0, i32 8
  %30 = load ptr, ptr %5, 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 %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %32, i32 0, i32 1
  store volatile ptr null, ptr %33, align 8, !tbaa !19
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %34, i32 0, i32 2
  store volatile ptr null, ptr %35, align 8, !tbaa !20
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %36, i32 0, i32 3
  store volatile ptr null, ptr %37, align 8, !tbaa !21
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %38, i32 0, i32 4
  store volatile ptr null, ptr %39, align 8, !tbaa !22
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %40, i32 0, i32 5
  store i64 0, ptr %41, align 8, !tbaa !23
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %42, i32 0, i32 6
  store ptr null, ptr %43, align 8, !tbaa !24
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %44, i32 0, i32 7
  store ptr null, ptr %45, align 8, !tbaa !25
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_init_lockEPNS_7ae_lockEPNS_8ae_stateEb(ptr noundef %47, ptr noundef %48, i1 noundef zeroext false)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl22ae_shared_pool_destroyEPv(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { 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_impl14ae_shared_poolE", !13, i64 0, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !15, i64 80, !6, i64 88, !6, i64 96, !14, i64 104}
!13 = !{!"_ZTSN11alglib_impl7ae_lockE", !6, i64 0, !14, i64 8, !10, i64 40}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !6, i64 120}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!12, !6, i64 48}
!20 = !{!12, !6, i64 56}
!21 = !{!12, !6, i64 64}
!22 = !{!12, !6, i64 72}
!23 = !{!12, !15, i64 80}
!24 = !{!12, !6, i64 88}
!25 = !{!12, !6, i64 96}


; 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_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_impl19ae_shared_pool_initEPvPNS_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_impl22ae_shared_pool_destroyEPv, 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 48
  store volatile ptr null, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  store volatile ptr null, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %0, i64 64
  store volatile ptr null, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 72
  store volatile ptr null, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %0, i64 80
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %18, i8 0, i64 24, i1 false)
  tail call void @_ZN11alglib_impl12ae_init_lockEPNS_7ae_lockEPNS_8ae_stateEb(ptr noundef nonnull %0, ptr noundef nonnull %1, i1 noundef zeroext false)
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl22ae_shared_pool_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, !8, i64 112}
!6 = !{!"_ZTSN11alglib_impl14ae_shared_poolE", !7, i64 0, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !13, i64 80, !8, i64 88, !8, i64 96, !11, i64 104}
!7 = !{!"_ZTSN11alglib_impl7ae_lockE", !8, i64 0, !11, i64 8, !12, i64 40}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"long", !9, i64 0}
!14 = !{!6, !8, i64 120}
!15 = !{!6, !8, i64 48}
!16 = !{!6, !8, i64 56}
!17 = !{!6, !8, i64 64}
!18 = !{!6, !8, i64 72}


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