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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl19ae_smart_ptr_assignEPNS_12ae_smart_ptrEPvbbPFvS2_E(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  %11 = zext i1 %2 to i8
  store i8 %11, ptr %8, align 1, !tbaa !9
  %12 = zext i1 %3 to i8
  store i8 %12, ptr %9, align 1, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %13, i32 0, i32 2
  %15 = load i8, ptr %14, align 8, !tbaa !11, !range !14, !noundef !15
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %38

17:                                               ; preds = %5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %38

22:                                               ; preds = %17
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  call void %25(ptr noundef %28)
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %29, i32 0, i32 3
  %31 = load i8, ptr %30, align 1, !tbaa !18, !range !14, !noundef !15
  %32 = trunc i8 %31 to i1
  br i1 %32, label %33, label %37

33:                                               ; preds = %22
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  call void @_ZN11alglib_impl7ae_freeEPv(ptr noundef %36)
  br label %37

37:                                               ; preds = %33, %22
  br label %38

38:                                               ; preds = %37, %17, %5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %58

41:                                               ; preds = %38
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %43, i32 0, i32 1
  store ptr %42, ptr %44, align 8, !tbaa !16
  %45 = load i8, ptr %8, align 1, !tbaa !9, !range !14, !noundef !15
  %46 = trunc i8 %45 to i1
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %47, i32 0, i32 2
  %49 = zext i1 %46 to i8
  store i8 %49, ptr %48, align 8, !tbaa !11
  %50 = load i8, ptr %9, align 1, !tbaa !9, !range !14, !noundef !15
  %51 = trunc i8 %50 to i1
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %52, i32 0, i32 3
  %54 = zext i1 %51 to i8
  store i8 %54, ptr %53, align 1, !tbaa !18
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %56, i32 0, i32 4
  store ptr %55, ptr %57, align 8, !tbaa !17
  br label %67

58:                                               ; preds = %38
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %59, i32 0, i32 1
  store ptr null, ptr %60, align 8, !tbaa !16
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %61, i32 0, i32 2
  store i8 0, ptr %62, align 8, !tbaa !11
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %63, i32 0, i32 3
  store i8 0, ptr %64, align 1, !tbaa !18
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %65, i32 0, i32 4
  store ptr null, ptr %66, align 8, !tbaa !17
  br label %67

67:                                               ; preds = %58, %41
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %79

72:                                               ; preds = %67
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.alglib_impl::ae_smart_ptr", ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  store ptr %75, ptr %78, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %72, %67
  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, !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, !10, i64 16}
!12 = !{!"_ZTSN11alglib_impl12ae_smart_ptrE", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 17, !6, i64 24, !13, i64 32}
!13 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!12, !6, i64 8}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !10, i64 17}
!19 = !{!12, !6, i64 0}


; 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 uwtable
define dso_local void @_ZN11alglib_impl19ae_smart_ptr_assignEPNS_12ae_smart_ptrEPvbbPFvS2_E(ptr nocapture noundef %0, ptr noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i8, ptr %6, align 8, !tbaa !5, !range !12, !noundef !13
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %20

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %20, label %12

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  tail call void %14(ptr noundef nonnull %11)
  %15 = getelementptr inbounds i8, ptr %0, i64 17
  %16 = load i8, ptr %15, align 1, !tbaa !16, !range !12, !noundef !13
  %17 = trunc nuw i8 %16 to i1
  br i1 %17, label %18, label %20

18:                                               ; preds = %12
  %19 = load ptr, ptr %10, align 8, !tbaa !14
  tail call void @_ZN11alglib_impl7ae_freeEPv(ptr noundef %19)
  br label %20

20:                                               ; preds = %12, %18, %9, %5
  %.not23 = icmp ne ptr %1, null
  %narrow = and i1 %.not23, %2
  %.sink26 = zext i1 %narrow to i8
  %narrow28 = and i1 %.not23, %3
  %.sink25 = zext i1 %narrow28 to i8
  %.sink = select i1 %.not23, ptr %4, ptr null
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %21, align 8
  store i8 %.sink26, ptr %6, align 8
  %22 = getelementptr inbounds i8, ptr %0, i64 17
  store i8 %.sink25, ptr %22, align 1
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %.sink, ptr %23, align 8
  %24 = load ptr, ptr %0, align 8, !tbaa !17
  %.not24 = icmp eq ptr %24, null
  br i1 %.not24, label %26, label %25

25:                                               ; preds = %20
  store ptr %1, ptr %24, align 8, !tbaa !18
  br label %26

26:                                               ; preds = %25, %20
  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, !10, i64 16}
!6 = !{!"_ZTSN11alglib_impl12ae_smart_ptrE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 17, !7, i64 24, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !10, i64 17}
!17 = !{!6, !7, i64 0}
!18 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass