; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (archive-timestamp-helper)

; 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.UapkiNS::AlgorithmIdentifier" = type { %"class.std::__cxx11::basic_string", ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.UapkiNS::Pkcs7::ArchiveTs3Helper" = type { ptr, i32, %"struct.UapkiNS::Pkcs7::ArchiveTs3Helper::ATSHashIndex", %struct.anon, %"class.UapkiNS::SmartBA" }
%"struct.UapkiNS::Pkcs7::ArchiveTs3Helper::ATSHashIndex" = type { %"class.UapkiNS::VectorBA", %"class.UapkiNS::VectorBA", %"class.UapkiNS::VectorBA" }
%"class.UapkiNS::VectorBA" = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<ByteArray_st *, std::allocator<ByteArray_st *>>::_Vector_impl" }
%"struct.std::_Vector_base<ByteArray_st *, std::allocator<ByteArray_st *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ByteArray_st *, std::allocator<ByteArray_st *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ByteArray_st *, std::allocator<ByteArray_st *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.anon = type { %"class.UapkiNS::SmartBA", %"class.UapkiNS::SmartBA", %"class.UapkiNS::SmartBA", %"class.UapkiNS::SmartBA" }
%"class.UapkiNS::SmartBA" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS5Pkcs716ArchiveTs3Helper4initEPKNS_19AlgorithmIdentifierE(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %26

9:                                                ; preds = %2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_ZNK7UapkiNS19AlgorithmIdentifier9isPresentEv(ptr noundef nonnull align 8 dereferenceable(40) %10)
  br i1 %11, label %12, label %18

12:                                               ; preds = %9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.UapkiNS::AlgorithmIdentifier", ptr %13, i32 0, i32 0
  %15 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %14) #3
  %16 = call i32 @hash_from_oid(ptr noundef %15)
  %17 = getelementptr inbounds %"class.UapkiNS::Pkcs7::ArchiveTs3Helper", ptr %6, i32 0, i32 1
  store i32 %16, ptr %17, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %12, %9
  %19 = getelementptr inbounds %"class.UapkiNS::Pkcs7::ArchiveTs3Helper", ptr %6, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i32 4101, ptr %3, align 4
  br label %27

23:                                               ; preds = %18
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %"class.UapkiNS::Pkcs7::ArchiveTs3Helper", ptr %6, i32 0, i32 0
  store ptr %24, ptr %25, align 8, !tbaa !20
  br label %26

26:                                               ; preds = %23, %2
  store i32 0, ptr %3, align 4
  br label %27

27:                                               ; preds = %26, %22
  %28 = load i32, ptr %3, align 4
  ret i32 %28
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7UapkiNS19AlgorithmIdentifier9isPresentEv(ptr noundef nonnull align 8 dereferenceable(40)) #1 align 2

declare i32 @hash_from_oid(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

attributes #0 = { 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 #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 = { "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, !11, i64 8}
!10 = !{!"_ZTSN7UapkiNS5Pkcs716ArchiveTs3HelperE", !6, i64 0, !11, i64 8, !12, i64 16, !18, i64 88, !19, i64 120}
!11 = !{!"_ZTS7HashAlg", !7, i64 0}
!12 = !{!"_ZTSN7UapkiNS5Pkcs716ArchiveTs3Helper12ATSHashIndexE", !13, i64 0, !13, i64 24, !13, i64 48}
!13 = !{!"_ZTSN7UapkiNS8VectorBAE", !14, i64 0}
!14 = !{!"_ZTSSt6vectorIP12ByteArray_stSaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIP12ByteArray_stSaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIP12ByteArray_stSaIS1_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIP12ByteArray_stSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"_ZTSN7UapkiNS5Pkcs716ArchiveTs3HelperUt_E", !19, i64 0, !19, i64 8, !19, i64 16, !19, i64 24}
!19 = !{!"_ZTSN7UapkiNS7SmartBAE", !6, i64 0}
!20 = !{!10, !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 uwtable
define dso_local noundef range(i32 0, 4102) i32 @_ZN7UapkiNS5Pkcs716ArchiveTs3Helper4initEPKNS_19AlgorithmIdentifierE(ptr nocapture noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %13, label %3

3:                                                ; preds = %2
  %4 = tail call noundef zeroext i1 @_ZNK7UapkiNS19AlgorithmIdentifier9isPresentEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
  br i1 %4, label %5, label %._crit_edge

._crit_edge:                                      ; preds = %3
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 8
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !5
  br label %9

5:                                                ; preds = %3
  %6 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #3
  %7 = tail call i32 @hash_from_oid(ptr noundef %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %7, ptr %8, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %._crit_edge, %5
  %10 = phi i32 [ %.pre, %._crit_edge ], [ %7, %5 ]
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store ptr %1, ptr %0, align 8, !tbaa !19
  br label %13

13:                                               ; preds = %2, %12, %9
  %.0 = phi i32 [ 4101, %9 ], [ 0, %12 ], [ 0, %2 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7UapkiNS19AlgorithmIdentifier9isPresentEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1 align 2

declare i32 @hash_from_oid(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

attributes #0 = { 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 #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 = { "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, !10, i64 8}
!6 = !{!"_ZTSN7UapkiNS5Pkcs716ArchiveTs3HelperE", !7, i64 0, !10, i64 8, !11, i64 16, !17, i64 88, !18, i64 120}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS7HashAlg", !8, i64 0}
!11 = !{!"_ZTSN7UapkiNS5Pkcs716ArchiveTs3Helper12ATSHashIndexE", !12, i64 0, !12, i64 24, !12, i64 48}
!12 = !{!"_ZTSN7UapkiNS8VectorBAE", !13, i64 0}
!13 = !{!"_ZTSSt6vectorIP12ByteArray_stSaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIP12ByteArray_stSaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIP12ByteArray_stSaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIP12ByteArray_stSaIS1_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!17 = !{!"_ZTSN7UapkiNS5Pkcs716ArchiveTs3HelperUt_E", !18, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}
!18 = !{!"_ZTSN7UapkiNS7SmartBAE", !7, i64 0}
!19 = !{!6, !7, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass