; LLVM IR from venumb/ZSPACE :: cpp/depends/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, 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 }

@.str.22 = external hidden unnamed_addr constant [57 x i8], align 1

; 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 uwtable
declare dso_local noundef ptr @_ZN11alglib_impl9ae_mallocEmPNS_8ae_stateE(i64 noundef, ptr noundef) #2

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

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

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

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

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

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

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

13:                                               ; preds = %3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %14, i32 0, i32 1
  %16 = load volatile ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %17, ptr noundef @.str.22, ptr noundef %18)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %19, i32 0, i32 0
  call void @_ZN11alglib_impl15ae_acquire_lockEPNS_7ae_lockE(ptr noundef %20)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %21, i32 0, i32 2
  %23 = load volatile ptr, ptr %22, align 8, !tbaa !15
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %56

25:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %26, i32 0, i32 2
  %28 = load volatile ptr, ptr %27, align 8, !tbaa !15
  store ptr %28, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %29, i32 0, i32 2
  %31 = load volatile ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool_entry", ptr %31, i32 0, i32 1
  %33 = load volatile ptr, ptr %32, align 8, !tbaa !16
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %34, i32 0, i32 2
  store volatile ptr %33, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool_entry", ptr %36, i32 0, i32 0
  %38 = load volatile ptr, ptr %37, align 8, !tbaa !18
  store ptr %38, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool_entry", ptr %39, i32 0, i32 0
  store volatile ptr null, ptr %40, align 8, !tbaa !18
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %41, i32 0, i32 3
  %43 = load volatile ptr, ptr %42, align 8, !tbaa !19
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool_entry", ptr %44, i32 0, i32 1
  store volatile ptr %43, ptr %45, align 8, !tbaa !16
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %47, i32 0, i32 3
  store volatile ptr %46, ptr %48, align 8, !tbaa !19
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %49, i32 0, i32 0
  call void @_ZN11alglib_impl15ae_release_lockEPNS_7ae_lockE(ptr noundef %50)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %53, i32 0, i32 8
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  call void @_ZN11alglib_impl19ae_smart_ptr_assignEPNS_12ae_smart_ptrEPvbbPFvS2_E(ptr noundef %51, ptr noundef %52, i1 noundef zeroext true, i1 noundef zeroext true, ptr noundef %55)
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %81

56:                                               ; preds = %13
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %57, i32 0, i32 0
  call void @_ZN11alglib_impl15ae_release_lockEPNS_7ae_lockE(ptr noundef %58)
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %59, i32 0, i32 5
  %61 = load i64, ptr %60, align 8, !tbaa !21
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = call noundef ptr @_ZN11alglib_impl9ae_mallocEmPNS_8ae_stateE(i64 noundef %61, ptr noundef %62)
  store ptr %63, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %65, i32 0, i32 5
  %67 = load i64, ptr %66, align 8, !tbaa !21
  call void @llvm.memset.p0.i64(ptr align 1 %64, i8 0, i64 %67, i1 false)
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %70, i32 0, i32 8
  %72 = load ptr, ptr %71, align 8, !tbaa !20
  call void @_ZN11alglib_impl19ae_smart_ptr_assignEPNS_12ae_smart_ptrEPvbbPFvS2_E(ptr noundef %68, ptr noundef %69, i1 noundef zeroext true, i1 noundef zeroext true, ptr noundef %72)
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %73, i32 0, i32 7
  %75 = load ptr, ptr %74, align 8, !tbaa !22
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %77, i32 0, i32 1
  %79 = load volatile ptr, ptr %78, align 8, !tbaa !9
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  call void %75(ptr noundef %76, ptr noundef %79, ptr noundef %80, i1 noundef zeroext false)
  store i32 0, ptr %9, align 4
  br label %81

81:                                               ; preds = %56, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  %82 = load i32, ptr %9, align 4
  switch i32 %82, label %84 [
    i32 0, label %83
    i32 1, label %83
  ]

83:                                               ; preds = %81, %81
  ret void

84:                                               ; preds = %81
  unreachable
}

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 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 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { 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, !6, i64 48}
!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, !6, i64 104, !12, i64 112}
!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 = !{!10, !6, i64 56}
!16 = !{!17, !6, i64 8}
!17 = !{!"_ZTSN11alglib_impl20ae_shared_pool_entryE", !6, i64 0, !6, i64 8}
!18 = !{!17, !6, i64 0}
!19 = !{!10, !6, i64 64}
!20 = !{!10, !6, i64 104}
!21 = !{!10, !14, i64 80}
!22 = !{!10, !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"

@.str.22 = external hidden unnamed_addr constant [57 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN11alglib_impl9ae_mallocEmPNS_8ae_stateE(i64 noundef, ptr noundef) local_unnamed_addr #1

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

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

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

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

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

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

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

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load volatile ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %8, ptr noundef nonnull @.str.22, ptr noundef nonnull %2)
  tail call void @_ZN11alglib_impl15ae_acquire_lockEPNS_7ae_lockE(ptr noundef %0)
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = load volatile ptr, ptr %9, align 8, !tbaa !14
  %.not30 = icmp eq ptr %10, null
  br i1 %.not30, label %22, label %11

11:                                               ; preds = %5
  %12 = load volatile ptr, ptr %9, align 8, !tbaa !14
  %13 = load volatile ptr, ptr %9, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = load volatile ptr, ptr %14, align 8, !tbaa !15
  store volatile ptr %15, ptr %9, align 8, !tbaa !14
  %16 = load volatile ptr, ptr %12, align 8, !tbaa !17
  store volatile ptr null, ptr %12, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 64
  %18 = load volatile ptr, ptr %17, align 8, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %12, i64 8
  store volatile ptr %18, ptr %19, align 8, !tbaa !15
  store volatile ptr %12, ptr %17, align 8, !tbaa !18
  tail call void @_ZN11alglib_impl15ae_release_lockEPNS_7ae_lockE(ptr noundef nonnull %0)
  %20 = getelementptr inbounds i8, ptr %0, i64 104
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  tail call void @_ZN11alglib_impl19ae_smart_ptr_assignEPNS_12ae_smart_ptrEPvbbPFvS2_E(ptr noundef %1, ptr noundef %16, i1 noundef zeroext true, i1 noundef zeroext true, ptr noundef %21)
  br label %32

22:                                               ; preds = %5
  tail call void @_ZN11alglib_impl15ae_release_lockEPNS_7ae_lockE(ptr noundef nonnull %0)
  %23 = getelementptr inbounds i8, ptr %0, i64 80
  %24 = load i64, ptr %23, align 8, !tbaa !20
  %25 = tail call noundef ptr @_ZN11alglib_impl9ae_mallocEmPNS_8ae_stateE(i64 noundef %24, ptr noundef nonnull %2)
  %26 = load i64, ptr %23, align 8, !tbaa !20
  tail call void @llvm.memset.p0.i64(ptr align 1 %25, i8 0, i64 %26, i1 false)
  %27 = getelementptr inbounds i8, ptr %0, i64 104
  %28 = load ptr, ptr %27, align 8, !tbaa !19
  tail call void @_ZN11alglib_impl19ae_smart_ptr_assignEPNS_12ae_smart_ptrEPvbbPFvS2_E(ptr noundef %1, ptr noundef %25, i1 noundef zeroext true, i1 noundef zeroext true, ptr noundef %28)
  %29 = getelementptr inbounds i8, ptr %0, i64 96
  %30 = load ptr, ptr %29, align 8, !tbaa !21
  %31 = load volatile ptr, ptr %6, align 8, !tbaa !5
  tail call void %30(ptr noundef %25, ptr noundef %31, ptr noundef nonnull %2, i1 noundef zeroext false)
  br label %32

32:                                               ; preds = %22, %11
  ret void
}

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 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 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 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 48}
!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, !8, i64 104, !11, i64 112}
!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 56}
!15 = !{!16, !8, i64 8}
!16 = !{!"_ZTSN11alglib_impl20ae_shared_pool_entryE", !8, i64 0, !8, i64 8}
!17 = !{!16, !8, i64 0}
!18 = !{!6, !8, i64 64}
!19 = !{!6, !8, i64 104}
!20 = !{!6, !13, i64 80}
!21 = !{!6, !8, i64 96}


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