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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl29ae_shared_pool_clear_recycledEPNS_14ae_shared_poolEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %7, i32 0, i32 0
  call void @_ZN11alglib_impl15ae_acquire_lockEPNS_7ae_lockE(ptr noundef %8)
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %9, i32 0, i32 2
  %11 = load volatile ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %12, i32 0, i32 2
  store volatile ptr null, ptr %13, align 8, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %14, i32 0, i32 0
  call void @_ZN11alglib_impl15ae_release_lockEPNS_7ae_lockE(ptr noundef %15)
  br label %16

16:                                               ; preds = %19, %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %34

19:                                               ; preds = %16
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool_entry", ptr %20, i32 0, i32 1
  %22 = load volatile ptr, ptr %21, align 8, !tbaa !15
  store ptr %22, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %23, i32 0, i32 7
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool_entry", ptr %26, i32 0, i32 0
  %28 = load volatile ptr, ptr %27, align 8, !tbaa !18
  call void %25(ptr noundef %28)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool_entry", ptr %29, i32 0, i32 0
  %31 = load volatile ptr, ptr %30, align 8, !tbaa !18
  call void @_ZN11alglib_impl7ae_freeEPv(ptr noundef %31)
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN11alglib_impl7ae_freeEPv(ptr noundef %32)
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %33, ptr %5, align 8, !tbaa !5
  br label %16, !llvm.loop !19

34:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 56}
!10 = !{!"_ZTSN11alglib_impl14ae_shared_poolE", !11, i64 0, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !14, i64 80, !6, i64 88, !6, i64 96, !12, i64 104}
!11 = !{!"_ZTSN11alglib_impl7ae_lockE", !6, i64 0, !12, i64 8, !13, i64 40}
!12 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"_ZTSN11alglib_impl20ae_shared_pool_entryE", !6, i64 0, !6, i64 8}
!17 = !{!10, !6, i64 96}
!18 = !{!16, !6, i64 0}
!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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl7ae_freeEPv(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl15ae_acquire_lockEPNS_7ae_lockE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN11alglib_impl15ae_release_lockEPNS_7ae_lockE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl29ae_shared_pool_clear_recycledEPNS_14ae_shared_poolEPNS_8ae_stateE(ptr noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  tail call void @_ZN11alglib_impl15ae_acquire_lockEPNS_7ae_lockE(ptr noundef %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = load volatile ptr, ptr %3, align 8, !tbaa !5
  store volatile ptr null, ptr %3, align 8, !tbaa !5
  tail call void @_ZN11alglib_impl15ae_release_lockEPNS_7ae_lockE(ptr noundef %0)
  %.not11 = icmp eq ptr %4, null
  br i1 %.not11, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  br label %6

6:                                                ; preds = %.lr.ph, %6
  %.012 = phi ptr [ %4, %.lr.ph ], [ %8, %6 ]
  %7 = getelementptr inbounds i8, ptr %.012, i64 8
  %8 = load volatile ptr, ptr %7, align 8, !tbaa !14
  %9 = load ptr, ptr %5, align 8, !tbaa !16
  %10 = load volatile ptr, ptr %.012, align 8, !tbaa !17
  tail call void %9(ptr noundef %10)
  %11 = load volatile ptr, ptr %.012, align 8, !tbaa !17
  tail call void @_ZN11alglib_impl7ae_freeEPv(ptr noundef %11)
  tail call void @_ZN11alglib_impl7ae_freeEPv(ptr noundef nonnull %.012)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %._crit_edge, label %6, !llvm.loop !18

._crit_edge:                                      ; preds = %6, %2
  ret void
}

attributes #0 = { 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 #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, !8, i64 56}
!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 = !{!15, !8, i64 8}
!15 = !{!"_ZTSN11alglib_impl20ae_shared_pool_entryE", !8, i64 0, !8, i64 8}
!16 = !{!6, !8, i64 96}
!17 = !{!15, !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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