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

%"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 nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS5Pkcs716ArchiveTs3Helper14setHashContentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPK12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2) #1 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = call noundef zeroext i1 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(32) %11) #4
  br i1 %12, label %16, label %13

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %13, %3
  store i32 4101, ptr %4, align 4
  br label %37

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %18) #4
  %20 = getelementptr inbounds %"class.UapkiNS::Pkcs7::ArchiveTs3Helper", ptr %10, i32 0, i32 3
  %21 = getelementptr inbounds %struct.anon, ptr %20, i32 0, i32 0
  %22 = call noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8) %21)
  %23 = call noundef i32 @_ZN7UapkiNS4Util9encodeOidEPKcPP12ByteArray_st(ptr noundef %19, ptr noundef %22)
  store i32 %23, ptr %8, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %17
  %27 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %27, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %36

28:                                               ; preds = %17
  %29 = getelementptr inbounds %"class.UapkiNS::Pkcs7::ArchiveTs3Helper", ptr %10, i32 0, i32 3
  %30 = getelementptr inbounds %struct.anon, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call ptr @ba_copy_with_alloc(ptr noundef %31, i64 noundef 0, i64 noundef 0)
  %33 = call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef %32)
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i32 4097, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %36

35:                                               ; preds = %28
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %36

36:                                               ; preds = %35, %34, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %37

37:                                               ; preds = %36, %16
  %38 = load i32, ptr %4, align 4
  ret i32 %38
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef zeroext i1 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare noundef i32 @_ZN7UapkiNS4Util9encodeOidEPKcPP12ByteArray_st(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 align 2

declare ptr @ba_copy_with_alloc(ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 }

!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 = !{!"int", !7, 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 noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS5Pkcs716ArchiveTs3Helper14setHashContentERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPK12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2) local_unnamed_addr #1 align 2 {
  %4 = tail call noundef zeroext i1 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #3
  %5 = icmp eq ptr %2, null
  %or.cond.not = or i1 %5, %4
  br i1 %or.cond.not, label %15, label %6

6:                                                ; preds = %3
  %7 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #3
  %8 = getelementptr inbounds i8, ptr %0, i64 88
  %9 = tail call noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8) %8)
  %10 = tail call noundef i32 @_ZN7UapkiNS4Util9encodeOidEPKcPP12ByteArray_st(ptr noundef %7, ptr noundef %9)
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %15

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  %13 = tail call ptr @ba_copy_with_alloc(ptr noundef nonnull %2, i64 noundef 0, i64 noundef 0)
  %14 = tail call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef %13)
  %. = select i1 %14, i32 0, i32 4097
  br label %15

15:                                               ; preds = %6, %11, %3
  %.1 = phi i32 [ 4101, %3 ], [ %10, %6 ], [ %., %11 ]
  ret i32 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef zeroext i1 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

declare noundef i32 @_ZN7UapkiNS4Util9encodeOidEPKcPP12ByteArray_st(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

declare ptr @ba_copy_with_alloc(ptr noundef, i64 noundef, i64 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 = { 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 = { "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)"}


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