; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (signeddata-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::SignedDataBuilder" = type { ptr, %"class.std::vector", ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *, std::allocator<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *>>::_Vector_impl" }
%"struct.std::_Vector_base<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *, std::allocator<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *>>::_Vector_impl" = type { %"struct.std::_Vector_base<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *, std::allocator<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *, std::allocator<UapkiNS::Pkcs7::SignedDataBuilder::SignerInfo *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.SignedData = type { %struct.ASN__PRIMITIVE_TYPE_s, %struct.DigestAlgorithmIdentifiers, %struct.EncapsulatedContentInfo, ptr, ptr, %struct.SignerInfos, %struct.asn_struct_ctx_s }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.DigestAlgorithmIdentifiers = type { %struct.anon, %struct.asn_struct_ctx_s }
%struct.anon = type { ptr, i32, i32, ptr }
%struct.EncapsulatedContentInfo = type { %struct.ASN__PRIMITIVE_TYPE_s, ptr, %struct.asn_struct_ctx_s }
%struct.SignerInfos = type { %struct.anon.3, %struct.asn_struct_ctx_s }
%struct.anon.3 = type { ptr, i32, i32, ptr }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }

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

declare void @asn_free(ptr noundef, ptr noundef) #0

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #0

declare i32 @asn_set_add(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS5Pkcs717SignedDataBuilder13addSignerInfoEv(ptr noundef nonnull align 8 dereferenceable(40) %0) #4 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store ptr null, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %"class.UapkiNS::Pkcs7::SignedDataBuilder", ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %1
  store i32 4101, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %42

15:                                               ; preds = %1
  %16 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 264) #7
  store ptr %16, ptr %5, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %15
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  store i32 1, ptr %4, align 4, !tbaa !9
  %21 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 180, i32 noundef %21, ptr noundef null)
  br label %34

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = getelementptr inbounds %"class.UapkiNS::Pkcs7::SignedDataBuilder", ptr %10, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.SignedData, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call i32 @asn_set_add(ptr noundef %27, ptr noundef %28)
  %30 = getelementptr inbounds %"class.UapkiNS::Pkcs7::SignedDataBuilder", ptr %10, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %31 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 80) #8
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoC1EP10SignerInfo(ptr noundef nonnull align 8 dereferenceable(80) %31, ptr noundef %32)
          to label %33 unwind label %38

33:                                               ; preds = %24
  store ptr %31, ptr %7, align 8, !tbaa !5
  call void @_ZNSt6vectorIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE9push_backEOS4_(ptr noundef nonnull align 8 dereferenceable(24) %30, ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %33, %20
  %35 = call ptr @get_SignerInfo_desc()
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  call void @asn_free(ptr noundef %35, ptr noundef %36)
  %37 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %37, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %42

38:                                               ; preds = %24
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %8, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %9, align 4
  call void @_ZdlPvm(ptr noundef %31, i64 noundef 80) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %44

42:                                               ; preds = %34, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %43 = load i32, ptr %2, align 4
  ret i32 %43

44:                                               ; preds = %38
  %45 = load ptr, ptr %8, align 8
  %46 = load i32, ptr %9, align 4
  %47 = insertvalue { ptr, i32 } poison, ptr %45, 0
  %48 = insertvalue { ptr, i32 } %47, i32 %46, 1
  resume { ptr, i32 } %48
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE9push_backEOS4_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #5

declare ptr @get_SignerInfo_desc() #0

declare void @_ZN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoC1EP10SignerInfo(ptr, ptr)

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin 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 #3 = { nounwind allocsize(0,1) "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 = { 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 #5 = { nobuiltin allocsize(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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN7UapkiNS5Pkcs717SignedDataBuilderE", !6, i64 0, !13, i64 8, !6, i64 32}
!13 = !{!"_ZTSSt6vectorIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


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

declare void @asn_free(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare i32 @asn_set_add(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 4102) i32 @_ZN7UapkiNS5Pkcs717SignedDataBuilder13addSignerInfoEv(ptr noundef nonnull align 8 dereferenceable(40) %0) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %18, label %4

4:                                                ; preds = %1
  %5 = tail call noalias dereferenceable_or_null(264) ptr @calloc(i64 noundef 1, i64 noundef 264) #6
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %4
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 180, i32 noundef 1, ptr noundef null)
  br label %14

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %3, i64 128
  %10 = tail call i32 @asn_set_add(ptr noundef nonnull %9, ptr noundef nonnull %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %11 = tail call noalias noundef nonnull dereferenceable(80) ptr @_Znwm(i64 noundef 80) #8
  invoke void @_ZN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoC1EP10SignerInfo(ptr noundef nonnull align 8 dereferenceable(80) %11, ptr noundef nonnull %5)
          to label %12 unwind label %16

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %11, ptr %2, align 8, !tbaa !14
  call void @_ZNSt6vectorIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE9push_backEOS4_(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %14

14:                                               ; preds = %12, %7
  %.09 = phi i32 [ 1, %7 ], [ 0, %12 ]
  %15 = call ptr @get_SignerInfo_desc()
  call void @asn_free(ptr noundef %15, ptr noundef null)
  br label %18

16:                                               ; preds = %8
  %17 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %11, i64 noundef 80) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  resume { ptr, i32 } %17

18:                                               ; preds = %1, %14
  %.0 = phi i32 [ %.09, %14 ], [ 4101, %1 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE9push_backEOS4_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #5

declare ptr @get_SignerInfo_desc() local_unnamed_addr #0

declare void @_ZN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoC1EP10SignerInfo(ptr, ptr) local_unnamed_addr

attributes #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin 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 #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #5 = { nobuiltin allocsize(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 #6 = { nounwind allocsize(0,1) }
attributes #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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 0}
!6 = !{!"_ZTSN7UapkiNS5Pkcs717SignedDataBuilderE", !7, i64 0, !10, i64 8, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS5Pkcs717SignedDataBuilder10SignerInfoESaIS4_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!7, !7, i64 0}


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