; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (attribute-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::AttributeHelper::RevocationRefsBuilder" = type { ptr, %"class.std::vector.22", ptr }
%"class.std::vector.22" = type { %"struct.std::_Vector_base.23" }
%"struct.std::_Vector_base.23" = type { %"struct.std::_Vector_base<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *, std::allocator<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *>>::_Vector_impl" }
%"struct.std::_Vector_base<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *, std::allocator<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *>>::_Vector_impl" = type { %"struct.std::_Vector_base<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *, std::allocator<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *, std::allocator<UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.CompleteRevocationRefs = type { %struct.anon.28, %struct.asn_struct_ctx_s }
%struct.anon.28 = type { ptr, i32, i32, ptr }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }

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

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

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #1

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder13addCrlOcspRefEv(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::AttributeHelper::RevocationRefsBuilder", 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 %50

15:                                               ; preds = %1
  %16 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 48) #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 663, i32 noundef %21, ptr noundef null)
  br label %42

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = getelementptr inbounds %"class.UapkiNS::AttributeHelper::RevocationRefsBuilder", ptr %10, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.CompleteRevocationRefs, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call i32 @asn_set_add(ptr noundef %28, ptr noundef %29)
  store i32 %30, ptr %4, align 4, !tbaa !9
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %25
  %34 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 665, i32 noundef %34)
  br label %42

35:                                               ; preds = %25
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = getelementptr inbounds %"class.UapkiNS::AttributeHelper::RevocationRefsBuilder", ptr %10, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %39 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 8) #8
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefC1EP10CrlOcspRef(ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef %40)
          to label %41 unwind label %46

41:                                               ; preds = %37
  store ptr %39, ptr %7, align 8, !tbaa !5
  call void @_ZNSt6vectorIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_EE9push_backEOS4_(ptr noundef nonnull align 8 dereferenceable(24) %38, 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 %42

42:                                               ; preds = %41, %33, %20
  %43 = call ptr @get_CrlOcspRef_desc()
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  call void @asn_free(ptr noundef %43, ptr noundef %44)
  %45 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %45, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %50

46:                                               ; preds = %37
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %8, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %9, align 4
  call void @_ZdlPvm(ptr noundef %39, i64 noundef 8) #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 %52

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

52:                                               ; preds = %46
  %53 = load ptr, ptr %8, align 8
  %54 = load i32, ptr %9, align 4
  %55 = insertvalue { ptr, i32 } poison, ptr %53, 0
  %56 = insertvalue { ptr, i32 } %55, i32 %54, 1
  resume { ptr, i32 } %56
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_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_CrlOcspRef_desc() #1

declare void @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefC1EP10CrlOcspRef(ptr, ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 #3 = { 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 #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 = !{!"_ZTSN7UapkiNS15AttributeHelper21RevocationRefsBuilderE", !6, i64 0, !13, i64 8, !6, i64 32}
!13 = !{!"_ZTSSt6vectorIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_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 [33 x i8], align 1

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

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

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

declare i32 @__gxx_personality_v0(...)

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 #2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder13addCrlOcspRefEv(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 %19, label %4

4:                                                ; preds = %1
  %5 = tail call noalias dereferenceable_or_null(48) ptr @calloc(i64 noundef 1, i64 noundef 48) #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 663, i32 noundef 1, ptr noundef null)
  br label %15

8:                                                ; preds = %4
  %9 = tail call i32 @asn_set_add(ptr noundef nonnull %3, ptr noundef nonnull %5)
  %.not16 = icmp eq i32 %9, 0
  br i1 %.not16, label %11, label %10

10:                                               ; preds = %8
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 665, i32 noundef %9)
  br label %15

11:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %12 = tail call noalias noundef nonnull dereferenceable(8) ptr @_Znwm(i64 noundef 8) #8
  invoke void @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefC1EP10CrlOcspRef(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull %5)
          to label %13 unwind label %17

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

15:                                               ; preds = %13, %10, %7
  %.012 = phi ptr [ null, %7 ], [ %5, %10 ], [ null, %13 ]
  %.011 = phi i32 [ 1, %7 ], [ %9, %10 ], [ 0, %13 ]
  %16 = call ptr @get_CrlOcspRef_desc()
  call void @asn_free(ptr noundef %16, ptr noundef %.012)
  br label %19

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

19:                                               ; preds = %1, %15
  %.0 = phi i32 [ %.011, %15 ], [ 4101, %1 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_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_CrlOcspRef_desc() local_unnamed_addr #1

declare void @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefC1EP10CrlOcspRef(ptr, ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 #3 = { 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 #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 = !{!"_ZTSN7UapkiNS15AttributeHelper21RevocationRefsBuilderE", !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 = !{!"_ZTSSt6vectorIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIPN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefESaIS4_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