; 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::CrlOcspRef" = type { ptr }
%struct.CrlOcspRef = type { ptr, ptr, ptr, %struct.asn_struct_ctx_s }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }
%struct.OcspResponsesID = type { %struct.OcspIdentifier, ptr, %struct.asn_struct_ctx_s }
%struct.OcspIdentifier = type { %struct.ResponderID, %struct.OCTET_STRING, %struct.asn_struct_ctx_s }
%struct.ResponderID = type { i32, %"union.ResponderID::ResponderID_u", %struct.asn_struct_ctx_s }
%"union.ResponderID::ResponderID_u" = type { %struct.Name }
%struct.Name = type { i32, %"union.Name::Name_u", %struct.asn_struct_ctx_s }
%"union.Name::Name_u" = type { %struct.RDNSequence }
%struct.RDNSequence = type { %struct.anon.30, %struct.asn_struct_ctx_s }
%struct.anon.30 = type { ptr, i32, i32, ptr }
%struct.OCTET_STRING = type { ptr, i32, %struct.asn_struct_ctx_s }
%struct.OcspListID = type { %"struct.OcspListID::ocspResponses", %struct.asn_struct_ctx_s }
%"struct.OcspListID::ocspResponses" = type { %struct.anon.31, %struct.asn_struct_ctx_s }
%struct.anon.31 = type { ptr, i32, i32, ptr }

@.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 ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) #1

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

declare ptr @get_OtherHash_desc() #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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRef17addOcspResponseIdEPK12ByteArray_stS5_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, ptr noundef %2) #3 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 ptr, align 8
  %10 = 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
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store ptr null, ptr %9, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef", ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %15, %3
  store i32 4101, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %100

19:                                               ; preds = %15
  %20 = getelementptr inbounds %"class.UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef", ptr %11, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.CrlOcspRef, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = icmp ne ptr %23, null
  br i1 %24, label %41, label %25

25:                                               ; preds = %19
  %26 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 72) #5
  %27 = getelementptr inbounds %"class.UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef", ptr %11, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds %struct.CrlOcspRef, ptr %28, i32 0, i32 1
  store ptr %26, ptr %29, align 8, !tbaa !13
  br label %30

30:                                               ; preds = %25
  %31 = getelementptr inbounds %"class.UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef", ptr %11, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = getelementptr inbounds %struct.CrlOcspRef, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %38

36:                                               ; preds = %30
  store i32 1, ptr %8, align 4, !tbaa !9
  %37 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 763, i32 noundef %37, ptr noundef null)
  br label %96

38:                                               ; preds = %30
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40, %19
  %42 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 208) #5
  store ptr %42, ptr %9, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %41
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %48

46:                                               ; preds = %43
  store i32 1, ptr %8, align 4, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 766, i32 noundef %47, ptr noundef null)
  br label %96

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  %52 = call ptr @get_OcspIdentifier_desc()
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.OcspResponsesID, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = call i32 @asn_decode_ba(ptr noundef %52, ptr noundef %54, ptr noundef %55)
  store i32 %56, ptr %8, align 4, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %51
  %60 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 767, i32 noundef %60)
  br label %96

61:                                               ; preds = %51
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %79

66:                                               ; preds = %63
  br label %67

67:                                               ; preds = %66
  %68 = call ptr @get_OtherHash_desc()
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = call ptr @asn_decode_ba_with_alloc(ptr noundef %68, ptr noundef %69)
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.OcspResponsesID, ptr %71, i32 0, i32 1
  store ptr %70, ptr %72, align 8, !tbaa !18
  %73 = icmp eq ptr null, %70
  br i1 %73, label %74, label %76

74:                                               ; preds = %67
  store i32 2, ptr %8, align 4, !tbaa !9
  %75 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 769, i32 noundef %75)
  br label %96

76:                                               ; preds = %67
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78, %63
  br label %80

80:                                               ; preds = %79
  %81 = getelementptr inbounds %"class.UapkiNS::AttributeHelper::RevocationRefsBuilder::CrlOcspRef", ptr %11, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = getelementptr inbounds %struct.CrlOcspRef, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = getelementptr inbounds %struct.OcspListID, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds %"struct.OcspListID::ocspResponses", ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = call i32 @asn_set_add(ptr noundef %86, ptr noundef %87)
  store i32 %88, ptr %8, align 4, !tbaa !9
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %93

91:                                               ; preds = %80
  %92 = load i32, ptr %8, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 772, i32 noundef %92)
  br label %96

93:                                               ; preds = %80
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %96

96:                                               ; preds = %95, %91, %74, %59, %46, %36
  %97 = call ptr @get_OcspResponsesID_desc()
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  call void @asn_free(ptr noundef %97, ptr noundef %98)
  %99 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %99, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %100

100:                                              ; preds = %96, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %101 = load i32, ptr %4, align 4
  ret i32 %101
}

declare ptr @get_OcspIdentifier_desc() #1

declare ptr @get_OcspResponsesID_desc() #1

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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0,1) }

!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 = !{!"_ZTSN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefE", !6, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS10CrlOcspRef", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24}
!15 = !{!"_ZTS16asn_struct_ctx_s", !16, i64 0, !16, i64 2, !10, i64 4, !6, i64 8, !17, i64 16}
!16 = !{!"short", !7, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!19, !6, i64 176}
!19 = !{!"_ZTS15OcspResponsesID", !20, i64 0, !6, i64 176, !15, i64 184}
!20 = !{!"_ZTS14OcspIdentifier", !21, i64 0, !23, i64 112, !15, i64 152}
!21 = !{!"_ZTS11ResponderID", !22, i64 0, !7, i64 8, !15, i64 88}
!22 = !{!"_ZTS14ResponderID_PR", !7, i64 0}
!23 = !{!"_ZTS12OCTET_STRING", !6, i64 0, !10, i64 8, !15, 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

declare ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

declare ptr @get_OtherHash_desc() local_unnamed_addr #0

; 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 #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRef17addOcspResponseIdEPK12ByteArray_stS5_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 align 2 {
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = icmp ne ptr %4, null
  %6 = icmp ne ptr %1, null
  %or.cond = and i1 %6, %5
  br i1 %or.cond, label %7, label %37

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !10
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %10, label %14

10:                                               ; preds = %7
  %11 = tail call noalias dereferenceable_or_null(72) ptr @calloc(i64 noundef 1, i64 noundef 72) #3
  store ptr %11, ptr %8, align 8, !tbaa !10
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 763, i32 noundef 1, ptr noundef null)
  br label %35

14:                                               ; preds = %10, %7
  %15 = tail call noalias dereferenceable_or_null(208) ptr @calloc(i64 noundef 1, i64 noundef 208) #3
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

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

18:                                               ; preds = %14
  %19 = tail call ptr @get_OcspIdentifier_desc()
  %20 = tail call i32 @asn_decode_ba(ptr noundef %19, ptr noundef nonnull %15, ptr noundef nonnull %1)
  %.not28 = icmp eq i32 %20, 0
  br i1 %.not28, label %22, label %21

21:                                               ; preds = %18
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 767, i32 noundef %20)
  br label %35

22:                                               ; preds = %18
  %.not29 = icmp eq ptr %2, null
  br i1 %.not29, label %29, label %23

23:                                               ; preds = %22
  %24 = tail call ptr @get_OtherHash_desc()
  %25 = tail call ptr @asn_decode_ba_with_alloc(ptr noundef %24, ptr noundef nonnull %2)
  %26 = getelementptr inbounds i8, ptr %15, i64 176
  store ptr %25, ptr %26, align 8, !tbaa !16
  %27 = icmp eq ptr %25, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 769, i32 noundef 2)
  br label %35

29:                                               ; preds = %22, %23
  %30 = load ptr, ptr %0, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !10
  %33 = tail call i32 @asn_set_add(ptr noundef %32, ptr noundef nonnull %15)
  %.not30 = icmp eq i32 %33, 0
  br i1 %.not30, label %35, label %34

34:                                               ; preds = %29
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 772, i32 noundef %33)
  br label %35

35:                                               ; preds = %29, %34, %28, %21, %17, %13
  %.019 = phi i32 [ 1, %17 ], [ %20, %21 ], [ 2, %28 ], [ %33, %34 ], [ 1, %13 ], [ 0, %29 ]
  %.0 = phi ptr [ null, %17 ], [ %15, %21 ], [ %15, %28 ], [ %15, %34 ], [ null, %13 ], [ null, %29 ]
  %36 = tail call ptr @get_OcspResponsesID_desc()
  tail call void @asn_free(ptr noundef %36, ptr noundef %.0)
  br label %37

37:                                               ; preds = %3, %35
  %.020 = phi i32 [ %.019, %35 ], [ 4101, %3 ]
  ret i32 %.020
}

declare ptr @get_OcspIdentifier_desc() local_unnamed_addr #0

declare ptr @get_OcspResponsesID_desc() local_unnamed_addr #0

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 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 #2 = { 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 #3 = { nounwind allocsize(0,1) }

!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 = !{!"_ZTSN7UapkiNS15AttributeHelper21RevocationRefsBuilder10CrlOcspRefE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 8}
!11 = !{!"_ZTS10CrlOcspRef", !7, i64 0, !7, i64 8, !7, i64 16, !12, i64 24}
!12 = !{!"_ZTS16asn_struct_ctx_s", !13, i64 0, !13, i64 2, !14, i64 4, !7, i64 8, !15, i64 16}
!13 = !{!"short", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!17, !7, i64 176}
!17 = !{!"_ZTS15OcspResponsesID", !18, i64 0, !7, i64 176, !12, i64 184}
!18 = !{!"_ZTS14OcspIdentifier", !19, i64 0, !21, i64 112, !12, i64 152}
!19 = !{!"_ZTS11ResponderID", !20, i64 0, !8, i64 8, !12, i64 88}
!20 = !{!"_ZTS14ResponderID_PR", !8, i64 0}
!21 = !{!"_ZTS12OCTET_STRING", !7, i64 0, !14, i64 8, !12, i64 16}


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