; 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 }

; 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 144)
  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 1
  store volatile ptr null, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %20, i32 0, i32 2
  store volatile ptr null, ptr %21, align 8, !tbaa !16
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %22, i32 0, i32 3
  store volatile ptr null, ptr %23, align 8, !tbaa !17
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %24, i32 0, i32 4
  store volatile ptr null, ptr %25, align 8, !tbaa !18
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %26, i32 0, i32 5
  store i64 0, ptr %27, align 8, !tbaa !19
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %28, i32 0, i32 6
  store ptr null, ptr %29, align 8, !tbaa !20
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %30, i32 0, i32 7
  store ptr null, ptr %31, align 8, !tbaa !21
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %32, i32 0, i32 8
  store ptr null, ptr %33, align 8, !tbaa !22
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %34, i32 0, i32 9
  %36 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %35, i32 0, i32 1
  store ptr @_ZN11alglib_impl22ae_shared_pool_destroyEPv, ptr %36, align 8, !tbaa !23
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %38, i32 0, i32 9
  %40 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %39, i32 0, i32 2
  store volatile ptr %37, ptr %40, align 8, !tbaa !24
  %41 = load i8, ptr %6, align 1, !tbaa !9, !range !25, !noundef !26
  %42 = trunc i8 %41 to i1
  br i1 %42, label %43, label %47

43:                                               ; preds = %17
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %44, i32 0, i32 9
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef %45, ptr noundef %46)
  br label %47

47:                                               ; preds = %43, %17
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.alglib_impl::ae_shared_pool", ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_init_lockEPNS_7ae_lockEPNS_8ae_stateEb(ptr noundef %49, ptr noundef %50, 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 48}
!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, !6, i64 104, !14, i64 112}
!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 56}
!17 = !{!12, !6, i64 64}
!18 = !{!12, !6, i64 72}
!19 = !{!12, !15, i64 80}
!20 = !{!12, !6, i64 88}
!21 = !{!12, !6, i64 96}
!22 = !{!12, !6, i64 104}
!23 = !{!12, !6, i64 120}
!24 = !{!12, !6, i64 128}
!25 = !{i8 0, i8 2}
!26 = !{}


; 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 144)
  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 48
  store volatile ptr null, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  store volatile ptr null, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  store volatile ptr null, ptr %11, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  store volatile ptr null, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 80
  %14 = getelementptr inbounds i8, ptr %0, i64 120
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %13, i8 0, i64 32, i1 false)
  store ptr @_ZN11alglib_impl22ae_shared_pool_destroyEPv, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %0, i64 128
  store volatile ptr %0, ptr %15, align 8, !tbaa !18
  br i1 %2, label %16, label %18

16:                                               ; preds = %8
  %17 = getelementptr inbounds i8, ptr %0, i64 112
  tail call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef nonnull %17, ptr noundef nonnull %1)
  br label %18

18:                                               ; preds = %16, %8
  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 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 = !{!6, !8, i64 64}
!16 = !{!6, !8, i64 72}
!17 = !{!6, !8, i64 120}
!18 = !{!6, !8, i64 128}


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