; 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_dyn_block" = type { ptr, ptr, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [28 x i8], align 1

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl10ae_db_initEPNS_12ae_dyn_blockElPNS_8ae_stateEb(ptr noundef %0, i64 noundef %1, ptr noundef %2, i1 noundef zeroext %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %9 = zext i1 %3 to i8
  store i8 %9, ptr %8, align 1, !tbaa !11
  %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 32)
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %13
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = icmp sge i64 %18, 0
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %19, ptr noundef @.str.2, ptr noundef %20)
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %21, i32 0, i32 2
  store volatile ptr null, ptr %22, align 8, !tbaa !13
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %23, i32 0, i32 3
  store ptr null, ptr %24, align 8, !tbaa !15
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %25, i32 0, i32 2
  %27 = load volatile ptr, ptr %26, align 8, !tbaa !13
  call void @_ZN11alglib_impl12ae_touch_ptrEPv(ptr noundef %27)
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  call void @_ZN11alglib_impl12ae_touch_ptrEPv(ptr noundef %30)
  %31 = load i8, ptr %8, align 1, !tbaa !11, !range !16, !noundef !17
  %32 = trunc i8 %31 to i1
  br i1 %32, label %33, label %36

33:                                               ; preds = %17
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef %34, ptr noundef %35)
  br label %39

36:                                               ; preds = %17
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %37, i32 0, i32 0
  store volatile ptr null, ptr %38, align 8, !tbaa !18
  br label %39

39:                                               ; preds = %36, %33
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = icmp ne i64 %40, 0
  br i1 %41, label %42, label %54

42:                                               ; preds = %39
  %43 = load i64, ptr %6, align 8, !tbaa !9
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call noundef ptr @_ZN11alglib_impl9ae_mallocEmPNS_8ae_stateE(i64 noundef %43, ptr noundef %44)
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %46, i32 0, i32 2
  store volatile ptr %45, ptr %47, align 8, !tbaa !13
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %48, i32 0, i32 2
  %50 = load volatile ptr, ptr %49, align 8, !tbaa !13
  %51 = call noundef ptr @_ZN11alglib_impl19aligned_extract_ptrEPv(ptr noundef %50)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %52, i32 0, i32 3
  store ptr %51, ptr %53, align 8, !tbaa !15
  br label %54

54:                                               ; preds = %42, %39
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.alglib_impl::ae_dyn_block", ptr %55, i32 0, i32 1
  store ptr @_ZN11alglib_impl7ae_freeEPv, ptr %56, align 8, !tbaa !19
  ret void
}

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

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 = { 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 #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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!14, !6, i64 24}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!14, !6, i64 0}
!19 = !{!14, !6, i64 8}


; 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.2 = external hidden unnamed_addr constant [28 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN11alglib_impl19aligned_extract_ptrEPv(ptr noundef) 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 #2

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

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

; 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 #0

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

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

6:                                                ; preds = %4
  %7 = tail call noundef zeroext i1 @_ZN11alglib_impl14ae_check_zerosEPKvl(ptr noundef %0, i64 noundef 32)
  br i1 %7, label %9, label %8

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

9:                                                ; preds = %6
  %10 = icmp sgt i64 %1, -1
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %10, ptr noundef nonnull @.str.2, ptr noundef nonnull %2)
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  store volatile ptr null, ptr %11, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr null, ptr %12, align 8, !tbaa !10
  %13 = load volatile ptr, ptr %11, align 8, !tbaa !5
  tail call void @_ZN11alglib_impl12ae_touch_ptrEPv(ptr noundef %13)
  %14 = load ptr, ptr %12, align 8, !tbaa !10
  tail call void @_ZN11alglib_impl12ae_touch_ptrEPv(ptr noundef %14)
  br i1 %3, label %15, label %16

15:                                               ; preds = %9
  tail call void @_ZN11alglib_impl12ae_db_attachEPNS_12ae_dyn_blockEPNS_8ae_stateE(ptr noundef nonnull %0, ptr noundef nonnull %2)
  br label %17

16:                                               ; preds = %9
  store volatile ptr null, ptr %0, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %16, %15
  %.not19 = icmp eq i64 %1, 0
  br i1 %.not19, label %22, label %18

18:                                               ; preds = %17
  %19 = tail call noundef ptr @_ZN11alglib_impl9ae_mallocEmPNS_8ae_stateE(i64 noundef %1, ptr noundef nonnull %2)
  store volatile ptr %19, ptr %11, align 8, !tbaa !5
  %20 = load volatile ptr, ptr %11, align 8, !tbaa !5
  %21 = tail call noundef ptr @_ZN11alglib_impl19aligned_extract_ptrEPv(ptr noundef %20)
  store ptr %21, ptr %12, align 8, !tbaa !10
  br label %22

22:                                               ; preds = %18, %17
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr @_ZN11alglib_impl7ae_freeEPv, ptr %23, align 8, !tbaa !12
  ret void
}

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

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 = { 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 #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, !7, i64 16}
!6 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 24}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 8}


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