; 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.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.std::allocator.6" = type { i8 }
%"struct.UapkiNS::OtherHash" = type { %"struct.UapkiNS::AlgorithmIdentifier", ptr }
%"struct.UapkiNS::AlgorithmIdentifier" = type { %"class.std::__cxx11::basic_string", ptr }
%struct.ESSCertIDv2 = type { ptr, %struct.OCTET_STRING, ptr, %struct.asn_struct_ctx_s }
%struct.OCTET_STRING = type { ptr, i32, %struct.asn_struct_ctx_s }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }
%"struct.UapkiNS::AttrCertId" = type { %"struct.UapkiNS::OtherHash", %"struct.UapkiNS::AttrCertId::IssuerSerial" }
%"struct.UapkiNS::AttrCertId::IssuerSerial" = type { ptr, ptr }
%struct.IssuerSerial = type { %struct.GeneralNames, %struct.ASN__PRIMITIVE_TYPE_s, ptr, %struct.asn_struct_ctx_s }
%struct.GeneralNames = type { %struct.anon.9, %struct.asn_struct_ctx_s }
%struct.anon.9 = type { ptr, i32, i32, ptr }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.SigningCertificateV2 = type { %"struct.SigningCertificateV2::certs", ptr, %struct.asn_struct_ctx_s }
%"struct.SigningCertificateV2::certs" = type { %struct.anon.10, %struct.asn_struct_ctx_s }
%struct.anon.10 = type { ptr, i32, i32, ptr }

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

; 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

declare i32 @asn_encode_ba(ptr noundef, ptr noundef, ptr 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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

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

declare ptr @get_GeneralNames_desc() #1

declare ptr @get_SigningCertificateV2_desc() #1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #5

declare noundef i32 @_ZN7UapkiNS4Util25algorithmIdentifierToAsn1ER19AlgorithmIdentifierRKNS_19AlgorithmIdentifierE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(40)) #1

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15AttributeHelper24encodeSigningCertificateERKNS_10AttrCertIdEPP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1) #3 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.std::__cxx11::basic_string", align 8
  %9 = alloca i1, align 1
  %10 = alloca %"class.std::allocator.6", align 1
  %11 = alloca i1, align 1
  %12 = alloca i1, align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i1, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store ptr null, ptr %7, align 8, !tbaa !5
  %16 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 80) #7
  store ptr %16, ptr %6, align 8, !tbaa !5
  br label %17

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

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

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 80) #7
  store ptr %25, ptr %7, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %24
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %31

29:                                               ; preds = %26
  store i32 1, ptr %5, align 4, !tbaa !9
  %30 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 376, i32 noundef %30, ptr noundef null)
  br label %192

31:                                               ; preds = %26
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.UapkiNS::OtherHash", ptr %34, i32 0, i32 0
  %36 = call noundef zeroext i1 @_ZNK7UapkiNS19AlgorithmIdentifier9isPresentEv(ptr noundef nonnull align 8 dereferenceable(40) %35)
  store i1 false, ptr %9, align 1
  store i1 false, ptr %11, align 1
  store i1 false, ptr %12, align 1
  store i1 false, ptr %15, align 1
  br i1 %36, label %37, label %44

37:                                               ; preds = %33
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.UapkiNS::OtherHash", ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %"struct.UapkiNS::AlgorithmIdentifier", ptr %39, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 32, ptr %8) #6
  store i1 true, ptr %9, align 1
  %41 = load ptr, ptr @OID_SHA256, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #6
  store i1 true, ptr %11, align 1
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #6
  store i1 true, ptr %12, align 1
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef %41, ptr noundef nonnull align 1 dereferenceable(1) %10)
          to label %42 unwind label %69

42:                                               ; preds = %37
  store i1 true, ptr %15, align 1
  %43 = call noundef zeroext i1 @_ZStneIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_(ptr noundef nonnull align 8 dereferenceable(32) %40, ptr noundef nonnull align 8 dereferenceable(32) %8) #6
  br label %44

44:                                               ; preds = %42, %33
  %45 = phi i1 [ false, %33 ], [ %43, %42 ]
  %46 = load i1, ptr %15, align 1
  br i1 %46, label %47, label %48

47:                                               ; preds = %44
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #6
  br label %48

48:                                               ; preds = %47, %44
  %49 = load i1, ptr %12, align 1
  br i1 %49, label %50, label %51

50:                                               ; preds = %48
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #6
  br label %51

51:                                               ; preds = %50, %48
  %52 = load i1, ptr %11, align 1
  br i1 %52, label %53, label %54

53:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #6
  br label %54

54:                                               ; preds = %53, %51
  %55 = load i1, ptr %9, align 1
  br i1 %55, label %56, label %57

56:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #6
  br label %57

57:                                               ; preds = %56, %54
  br i1 %45, label %58, label %99

58:                                               ; preds = %57
  %59 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 48) #7
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ESSCertIDv2, ptr %60, i32 0, i32 0
  store ptr %59, ptr %61, align 8, !tbaa !11
  br label %62

62:                                               ; preds = %58
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ESSCertIDv2, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !11
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %82

67:                                               ; preds = %62
  store i32 1, ptr %5, align 4, !tbaa !9
  %68 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 380, i32 noundef %68, ptr noundef null)
  br label %192

69:                                               ; preds = %37
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %13, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %14, align 4
  %73 = load i1, ptr %12, align 1
  br i1 %73, label %74, label %75

74:                                               ; preds = %69
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #6
  br label %75

75:                                               ; preds = %74, %69
  %76 = load i1, ptr %11, align 1
  br i1 %76, label %77, label %78

77:                                               ; preds = %75
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #6
  br label %78

78:                                               ; preds = %77, %75
  %79 = load i1, ptr %9, align 1
  br i1 %79, label %80, label %81

80:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #6
  br label %81

81:                                               ; preds = %80, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %198

82:                                               ; preds = %62
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.ESSCertIDv2, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !11
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %"struct.UapkiNS::OtherHash", ptr %89, i32 0, i32 0
  %91 = call noundef i32 @_ZN7UapkiNS4Util25algorithmIdentifierToAsn1ER19AlgorithmIdentifierRKNS_19AlgorithmIdentifierE(ptr noundef nonnull align 8 dereferenceable(48) %88, ptr noundef nonnull align 8 dereferenceable(40) %90)
  store i32 %91, ptr %5, align 4, !tbaa !9
  %92 = load i32, ptr %5, align 4, !tbaa !9
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %96

94:                                               ; preds = %85
  %95 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 381, i32 noundef %95)
  br label %192

96:                                               ; preds = %85
  br label %97

97:                                               ; preds = %96
  br label %98

98:                                               ; preds = %97
  br label %99

99:                                               ; preds = %98, %57
  br label %100

100:                                              ; preds = %99
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %"struct.UapkiNS::OtherHash", ptr %101, i32 0, i32 1
  %103 = load ptr, ptr %102, align 8, !tbaa !17
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.ESSCertIDv2, ptr %104, i32 0, i32 1
  %106 = call i32 @asn_ba2OCTSTRING(ptr noundef %103, ptr noundef %105)
  store i32 %106, ptr %5, align 4, !tbaa !9
  %107 = load i32, ptr %5, align 4, !tbaa !9
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %111

109:                                              ; preds = %100
  %110 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 385, i32 noundef %110)
  br label %192

111:                                              ; preds = %100
  br label %112

112:                                              ; preds = %111
  br label %113

113:                                              ; preds = %112
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.UapkiNS::AttrCertId", ptr %114, i32 0, i32 1
  %116 = call noundef zeroext i1 @_ZNK7UapkiNS10AttrCertId12IssuerSerial9isPresentEv(ptr noundef nonnull align 8 dereferenceable(16) %115)
  br i1 %116, label %117, label %166

117:                                              ; preds = %113
  %118 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 96) #7
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.ESSCertIDv2, ptr %119, i32 0, i32 2
  store ptr %118, ptr %120, align 8, !tbaa !22
  br label %121

121:                                              ; preds = %117
  %122 = load ptr, ptr %7, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.ESSCertIDv2, ptr %122, i32 0, i32 2
  %124 = load ptr, ptr %123, align 8, !tbaa !22
  %125 = icmp eq ptr %124, null
  br i1 %125, label %126, label %128

126:                                              ; preds = %121
  store i32 1, ptr %5, align 4, !tbaa !9
  %127 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 389, i32 noundef %127, ptr noundef null)
  br label %192

128:                                              ; preds = %121
  br label %129

129:                                              ; preds = %128
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  %132 = call ptr @get_GeneralNames_desc()
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.ESSCertIDv2, ptr %133, i32 0, i32 2
  %135 = load ptr, ptr %134, align 8, !tbaa !22
  %136 = getelementptr inbounds %struct.IssuerSerial, ptr %135, i32 0, i32 0
  %137 = load ptr, ptr %3, align 8, !tbaa !5
  %138 = getelementptr inbounds %"struct.UapkiNS::AttrCertId", ptr %137, i32 0, i32 1
  %139 = getelementptr inbounds %"struct.UapkiNS::AttrCertId::IssuerSerial", ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !23
  %141 = call i32 @asn_decode_ba(ptr noundef %132, ptr noundef %136, ptr noundef %140)
  store i32 %141, ptr %5, align 4, !tbaa !9
  %142 = load i32, ptr %5, align 4, !tbaa !9
  %143 = icmp ne i32 %142, 0
  br i1 %143, label %144, label %146

144:                                              ; preds = %131
  %145 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 390, i32 noundef %145)
  br label %192

146:                                              ; preds = %131
  br label %147

147:                                              ; preds = %146
  br label %148

148:                                              ; preds = %147
  br label %149

149:                                              ; preds = %148
  %150 = load ptr, ptr %3, align 8, !tbaa !5
  %151 = getelementptr inbounds %"struct.UapkiNS::AttrCertId", ptr %150, i32 0, i32 1
  %152 = getelementptr inbounds %"struct.UapkiNS::AttrCertId::IssuerSerial", ptr %151, i32 0, i32 1
  %153 = load ptr, ptr %152, align 8, !tbaa !26
  %154 = load ptr, ptr %7, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.ESSCertIDv2, ptr %154, i32 0, i32 2
  %156 = load ptr, ptr %155, align 8, !tbaa !22
  %157 = getelementptr inbounds %struct.IssuerSerial, ptr %156, i32 0, i32 1
  %158 = call i32 @asn_ba2INTEGER(ptr noundef %153, ptr noundef %157)
  store i32 %158, ptr %5, align 4, !tbaa !9
  %159 = load i32, ptr %5, align 4, !tbaa !9
  %160 = icmp ne i32 %159, 0
  br i1 %160, label %161, label %163

161:                                              ; preds = %149
  %162 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 391, i32 noundef %162)
  br label %192

163:                                              ; preds = %149
  br label %164

164:                                              ; preds = %163
  br label %165

165:                                              ; preds = %164
  br label %166

166:                                              ; preds = %165, %113
  br label %167

167:                                              ; preds = %166
  %168 = load ptr, ptr %6, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.SigningCertificateV2, ptr %168, i32 0, i32 0
  %170 = getelementptr inbounds %"struct.SigningCertificateV2::certs", ptr %169, i32 0, i32 0
  %171 = load ptr, ptr %7, align 8, !tbaa !5
  %172 = call i32 @asn_set_add(ptr noundef %170, ptr noundef %171)
  store i32 %172, ptr %5, align 4, !tbaa !9
  %173 = load i32, ptr %5, align 4, !tbaa !9
  %174 = icmp ne i32 %173, 0
  br i1 %174, label %175, label %177

175:                                              ; preds = %167
  %176 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 394, i32 noundef %176)
  br label %192

177:                                              ; preds = %167
  br label %178

178:                                              ; preds = %177
  br label %179

179:                                              ; preds = %178
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %180

180:                                              ; preds = %179
  %181 = call ptr @get_SigningCertificateV2_desc()
  %182 = load ptr, ptr %6, align 8, !tbaa !5
  %183 = load ptr, ptr %4, align 8, !tbaa !5
  %184 = call i32 @asn_encode_ba(ptr noundef %181, ptr noundef %182, ptr noundef %183)
  store i32 %184, ptr %5, align 4, !tbaa !9
  %185 = load i32, ptr %5, align 4, !tbaa !9
  %186 = icmp ne i32 %185, 0
  br i1 %186, label %187, label %189

187:                                              ; preds = %180
  %188 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 397, i32 noundef %188)
  br label %192

189:                                              ; preds = %180
  br label %190

190:                                              ; preds = %189
  br label %191

191:                                              ; preds = %190
  br label %192

192:                                              ; preds = %191, %187, %175, %161, %144, %126, %109, %94, %67, %29, %20
  %193 = call ptr @get_SigningCertificateV2_desc()
  %194 = load ptr, ptr %6, align 8, !tbaa !5
  call void @asn_free(ptr noundef %193, ptr noundef %194)
  %195 = call ptr @get_ESSCertIDv2_desc()
  %196 = load ptr, ptr %7, align 8, !tbaa !5
  call void @asn_free(ptr noundef %195, ptr noundef %196)
  %197 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret i32 %197

198:                                              ; preds = %81
  %199 = load ptr, ptr %13, align 8
  %200 = load i32, ptr %14, align 4
  %201 = insertvalue { ptr, i32 } poison, ptr %199, 0
  %202 = insertvalue { ptr, i32 } %201, i32 %200, 1
  resume { ptr, i32 } %202
}

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

declare ptr @get_ESSCertIDv2_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 = { 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 #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 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 #5 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"_ZTS11ESSCertIDv2", !6, i64 0, !13, i64 8, !6, i64 48, !14, i64 56}
!13 = !{!"_ZTS12OCTET_STRING", !6, i64 0, !10, i64 8, !14, i64 16}
!14 = !{!"_ZTS16asn_struct_ctx_s", !15, i64 0, !15, i64 2, !10, i64 4, !6, i64 8, !16, i64 16}
!15 = !{!"short", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !6, i64 40}
!18 = !{!"_ZTSN7UapkiNS9OtherHashE", !19, i64 0, !6, i64 40}
!19 = !{!"_ZTSN7UapkiNS19AlgorithmIdentifierE", !20, i64 0, !6, i64 32}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !21, i64 0, !16, i64 8, !7, i64 16}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!22 = !{!12, !6, i64 48}
!23 = !{!24, !6, i64 48}
!24 = !{!"_ZTSN7UapkiNS10AttrCertIdE", !18, i64 0, !25, i64 48}
!25 = !{!"_ZTSN7UapkiNS10AttrCertId12IssuerSerialE", !6, i64 0, !6, i64 8}
!26 = !{!24, !6, i64 56}


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

%"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.std::allocator.6" = type { i8 }

@.str = external hidden unnamed_addr constant [33 x i8], align 1
@OID_SHA256 = external local_unnamed_addr global ptr, align 8

; 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

declare i32 @asn_encode_ba(ptr noundef, ptr noundef, ptr 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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

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

declare ptr @get_GeneralNames_desc() local_unnamed_addr #1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #5

declare noundef i32 @_ZN7UapkiNS4Util25algorithmIdentifierToAsn1ER19AlgorithmIdentifierRKNS_19AlgorithmIdentifierE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15AttributeHelper24encodeSigningCertificateERKNS_10AttrCertIdEPP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  %4 = alloca %"class.std::allocator.6", align 1
  %5 = tail call noalias dereferenceable_or_null(80) ptr @calloc(i64 noundef 1, i64 noundef 80) #6
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %8

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

8:                                                ; preds = %2
  %9 = tail call noalias dereferenceable_or_null(80) ptr @calloc(i64 noundef 1, i64 noundef 80) #6
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 376, i32 noundef 1, ptr noundef null)
  br label %59

12:                                               ; preds = %8
  %13 = tail call noundef zeroext i1 @_ZNK7UapkiNS19AlgorithmIdentifier9isPresentEv(ptr noundef nonnull align 8 dereferenceable(40) %0)
  br i1 %13, label %14, label %.critedge69.thread

14:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #7
  %15 = load ptr, ptr @OID_SHA256, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #7
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #7
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef %15, ptr noundef nonnull align 1 dereferenceable(1) %4)
          to label %.critedge69 unwind label %21

.critedge69:                                      ; preds = %14
  %16 = call noundef zeroext i1 @_ZStneIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EESA_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %3) #7
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #7
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #7
  br i1 %16, label %17, label %.critedge69.thread

17:                                               ; preds = %.critedge69
  %18 = call noalias dereferenceable_or_null(48) ptr @calloc(i64 noundef 1, i64 noundef 48) #6
  store ptr %18, ptr %9, align 8, !tbaa !9
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 380, i32 noundef 1, ptr noundef null)
  br label %59

21:                                               ; preds = %14
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #7
  resume { ptr, i32 } %22

23:                                               ; preds = %17
  %24 = call noundef i32 @_ZN7UapkiNS4Util25algorithmIdentifierToAsn1ER19AlgorithmIdentifierRKNS_19AlgorithmIdentifierE(ptr noundef nonnull align 8 dereferenceable(48) %18, ptr noundef nonnull align 8 dereferenceable(40) %0)
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %.critedge69.thread, label %25

25:                                               ; preds = %23
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 381, i32 noundef %24)
  br label %59

.critedge69.thread:                               ; preds = %12, %.critedge69, %23
  %26 = getelementptr inbounds i8, ptr %0, i64 40
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %9, i64 8
  %29 = call i32 @asn_ba2OCTSTRING(ptr noundef %27, ptr noundef nonnull %28)
  %.not63 = icmp eq i32 %29, 0
  br i1 %.not63, label %31, label %30

30:                                               ; preds = %.critedge69.thread
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 385, i32 noundef %29)
  br label %59

31:                                               ; preds = %.critedge69.thread
  %32 = getelementptr inbounds i8, ptr %0, i64 48
  %33 = call noundef zeroext i1 @_ZNK7UapkiNS10AttrCertId12IssuerSerial9isPresentEv(ptr noundef nonnull align 8 dereferenceable(16) %32)
  br i1 %33, label %34, label %52

34:                                               ; preds = %31
  %35 = call noalias dereferenceable_or_null(96) ptr @calloc(i64 noundef 1, i64 noundef 96) #6
  %36 = getelementptr inbounds i8, ptr %9, i64 48
  store ptr %35, ptr %36, align 8, !tbaa !21
  %37 = icmp eq ptr %35, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 389, i32 noundef 1, ptr noundef null)
  br label %59

39:                                               ; preds = %34
  %40 = call ptr @get_GeneralNames_desc()
  %41 = load ptr, ptr %36, align 8, !tbaa !21
  %42 = load ptr, ptr %32, align 8, !tbaa !22
  %43 = call i32 @asn_decode_ba(ptr noundef %40, ptr noundef %41, ptr noundef %42)
  %.not64 = icmp eq i32 %43, 0
  br i1 %.not64, label %45, label %44

44:                                               ; preds = %39
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 390, i32 noundef %43)
  br label %59

45:                                               ; preds = %39
  %46 = getelementptr inbounds i8, ptr %0, i64 56
  %47 = load ptr, ptr %46, align 8, !tbaa !25
  %48 = load ptr, ptr %36, align 8, !tbaa !21
  %49 = getelementptr inbounds i8, ptr %48, i64 48
  %50 = call i32 @asn_ba2INTEGER(ptr noundef %47, ptr noundef nonnull %49)
  %.not65 = icmp eq i32 %50, 0
  br i1 %.not65, label %52, label %51

51:                                               ; preds = %45
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 391, i32 noundef %50)
  br label %59

52:                                               ; preds = %31, %45
  %53 = call i32 @asn_set_add(ptr noundef nonnull %5, ptr noundef nonnull %9)
  %.not66 = icmp eq i32 %53, 0
  br i1 %.not66, label %55, label %54

54:                                               ; preds = %52
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 394, i32 noundef %53)
  br label %59

55:                                               ; preds = %52
  %56 = call ptr @get_SigningCertificateV2_desc()
  %57 = call i32 @asn_encode_ba(ptr noundef %56, ptr noundef nonnull %5, ptr noundef %1)
  %.not67 = icmp eq i32 %57, 0
  br i1 %.not67, label %59, label %58

58:                                               ; preds = %55
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 397, i32 noundef %57)
  br label %59

59:                                               ; preds = %55, %58, %54, %51, %44, %38, %30, %25, %20, %11, %7
  %.052 = phi ptr [ null, %7 ], [ null, %11 ], [ %9, %20 ], [ %9, %25 ], [ %9, %30 ], [ %9, %38 ], [ %9, %44 ], [ %9, %51 ], [ %9, %54 ], [ null, %58 ], [ null, %55 ]
  %.048 = phi i32 [ 1, %7 ], [ 1, %11 ], [ 1, %20 ], [ %24, %25 ], [ %29, %30 ], [ 1, %38 ], [ %43, %44 ], [ %50, %51 ], [ %53, %54 ], [ %57, %58 ], [ 0, %55 ]
  %60 = call ptr @get_SigningCertificateV2_desc()
  call void @asn_free(ptr noundef %60, ptr noundef %5)
  %61 = call ptr @get_ESSCertIDv2_desc()
  call void @asn_free(ptr noundef %61, ptr noundef %.052)
  ret i32 %.048
}

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

declare ptr @get_ESSCertIDv2_desc() local_unnamed_addr #1

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 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 #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 = { 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 #5 = { inlinehint 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 #6 = { nounwind allocsize(0,1) }
attributes #7 = { 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, !6, i64 0}
!10 = !{!"_ZTS11ESSCertIDv2", !6, i64 0, !11, i64 8, !6, i64 48, !13, i64 56}
!11 = !{!"_ZTS12OCTET_STRING", !6, i64 0, !12, i64 8, !13, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS16asn_struct_ctx_s", !14, i64 0, !14, i64 2, !12, i64 4, !6, i64 8, !15, i64 16}
!14 = !{!"short", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !6, i64 40}
!17 = !{!"_ZTSN7UapkiNS9OtherHashE", !18, i64 0, !6, i64 40}
!18 = !{!"_ZTSN7UapkiNS19AlgorithmIdentifierE", !19, i64 0, !6, i64 32}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !15, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!10, !6, i64 48}
!22 = !{!23, !6, i64 48}
!23 = !{!"_ZTSN7UapkiNS10AttrCertIdE", !17, i64 0, !24, i64 48}
!24 = !{!"_ZTSN7UapkiNS10AttrCertId12IssuerSerialE", !6, i64 0, !6, i64 8}
!25 = !{!23, !6, i64 56}


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