; LLVM IR from specinfo-ua/UAPKI :: library/cm-pkcs12/src/storage/store-bag.ll (ZN8StoreBag9encodeBagEPKcm)

; 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.StoreBag = type { i32, %"class.std::__cxx11::basic_string", ptr, %"class.std::vector", ptr, ptr, ptr, ptr, %struct.anon }
%"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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<StoreAttr *, std::allocator<StoreAttr *>>::_Vector_impl" }
%"struct.std::_Vector_base<StoreAttr *, std::allocator<StoreAttr *>>::_Vector_impl" = type { %"struct.std::_Vector_base<StoreAttr *, std::allocator<StoreAttr *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<StoreAttr *, std::allocator<StoreAttr *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.anon = type { ptr, ptr }
%struct.SafeBag = type { %struct.ASN__PRIMITIVE_TYPE_s, %struct.ANY, ptr, %struct.asn_struct_ctx_s }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.ANY = type { ptr, i32, %struct.asn_struct_ctx_s }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }

@.str = external hidden unnamed_addr constant [32 x i8], align 1
@OID_PKCS12_P8_SHROUDED_KEY_BAG = external global ptr, align 8
@OID_PKCS12_CERT_BAG = external global ptr, align 8

declare void @ba_free(ptr noundef) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8StoreBag9encodeBagEPKcm(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef %1, i64 noundef %2) #2 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8
  %13 = getelementptr inbounds %class.StoreBag, ptr %12, i32 0, i32 4
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  call void @ba_free(ptr noundef %14)
  %15 = getelementptr inbounds %class.StoreBag, ptr %12, i32 0, i32 4
  store ptr null, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %16 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 88) #6
  store ptr %16, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %3
  store i32 1025, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %144

20:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %20
  %22 = call noundef ptr @_ZNK8StoreBag5bagIdEv(ptr noundef nonnull align 8 dereferenceable(120) %12)
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.SafeBag, ptr %23, i32 0, i32 0
  %25 = call i32 @asn_set_oid_from_text(ptr noundef %22, ptr noundef %24)
  store i32 %25, ptr %10, align 4, !tbaa !21
  %26 = load i32, ptr %10, align 4, !tbaa !21
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %21
  %29 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 134, i32 noundef %29)
  br label %139

30:                                               ; preds = %21
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr @OID_PKCS12_P8_SHROUDED_KEY_BAG, align 8, !tbaa !5
  %34 = call noundef ptr @_ZNK8StoreBag5bagIdEv(ptr noundef nonnull align 8 dereferenceable(120) %12)
  %35 = call zeroext i1 @oid_is_equal(ptr noundef %33, ptr noundef %34)
  br i1 %35, label %36, label %69

36:                                               ; preds = %32
  br label %37

37:                                               ; preds = %36
  %38 = call noundef ptr @_ZNK8StoreBag8bagValueEv(ptr noundef nonnull align 8 dereferenceable(120) %12)
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = getelementptr inbounds %class.StoreBag, ptr %12, i32 0, i32 8
  %42 = getelementptr inbounds %struct.anon, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !23
  %44 = getelementptr inbounds %class.StoreBag, ptr %12, i32 0, i32 8
  %45 = getelementptr inbounds %struct.anon, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !24
  %47 = call i32 @pkcs8_pbes2_encrypt(ptr noundef %38, ptr noundef %39, i64 noundef %40, ptr noundef %43, ptr noundef %46, ptr noundef %11)
  store i32 %47, ptr %10, align 4, !tbaa !21
  %48 = load i32, ptr %10, align 4, !tbaa !21
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %52

50:                                               ; preds = %37
  %51 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 138, i32 noundef %51)
  br label %139

52:                                               ; preds = %37
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  %56 = call ptr @get_ANY_desc()
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.SafeBag, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = call i32 @asn_decode_ba(ptr noundef %56, ptr noundef %58, ptr noundef %59)
  store i32 %60, ptr %10, align 4, !tbaa !21
  %61 = load i32, ptr %10, align 4, !tbaa !21
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %65

63:                                               ; preds = %55
  %64 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 140, i32 noundef %64)
  br label %139

65:                                               ; preds = %55
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  call void @ba_free(ptr noundef %68)
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %113

69:                                               ; preds = %32
  %70 = load ptr, ptr @OID_PKCS12_CERT_BAG, align 8, !tbaa !5
  %71 = call noundef ptr @_ZNK8StoreBag5bagIdEv(ptr noundef nonnull align 8 dereferenceable(120) %12)
  %72 = call zeroext i1 @oid_is_equal(ptr noundef %70, ptr noundef %71)
  br i1 %72, label %73, label %98

73:                                               ; preds = %69
  br label %74

74:                                               ; preds = %73
  %75 = call noundef ptr @_ZNK8StoreBag8bagValueEv(ptr noundef nonnull align 8 dereferenceable(120) %12)
  %76 = call i32 @pkcs12_write_cert_bag(ptr noundef %75, ptr noundef %11)
  store i32 %76, ptr %10, align 4, !tbaa !21
  %77 = load i32, ptr %10, align 4, !tbaa !21
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %74
  %80 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 145, i32 noundef %80)
  br label %139

81:                                               ; preds = %74
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  %85 = call ptr @get_ANY_desc()
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.SafeBag, ptr %86, i32 0, i32 1
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = call i32 @asn_decode_ba(ptr noundef %85, ptr noundef %87, ptr noundef %88)
  store i32 %89, ptr %10, align 4, !tbaa !21
  %90 = load i32, ptr %10, align 4, !tbaa !21
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %94

92:                                               ; preds = %84
  %93 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 147, i32 noundef %93)
  br label %139

94:                                               ; preds = %84
  br label %95

95:                                               ; preds = %94
  br label %96

96:                                               ; preds = %95
  %97 = load ptr, ptr %11, align 8, !tbaa !5
  call void @ba_free(ptr noundef %97)
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %112

98:                                               ; preds = %69
  br label %99

99:                                               ; preds = %98
  %100 = call ptr @get_ANY_desc()
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.SafeBag, ptr %101, i32 0, i32 1
  %103 = call noundef ptr @_ZNK8StoreBag8bagValueEv(ptr noundef nonnull align 8 dereferenceable(120) %12)
  %104 = call i32 @asn_decode_ba(ptr noundef %100, ptr noundef %102, ptr noundef %103)
  store i32 %104, ptr %10, align 4, !tbaa !21
  %105 = load i32, ptr %10, align 4, !tbaa !21
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %109

107:                                              ; preds = %99
  %108 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 152, i32 noundef %108)
  br label %139

109:                                              ; preds = %99
  br label %110

110:                                              ; preds = %109
  br label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111, %96
  br label %113

113:                                              ; preds = %112, %67
  br label %114

114:                                              ; preds = %113
  %115 = getelementptr inbounds %class.StoreBag, ptr %12, i32 0, i32 3
  %116 = load ptr, ptr %8, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.SafeBag, ptr %116, i32 0, i32 2
  %118 = call noundef i32 @_ZL18set_bag_attributesRKSt6vectorIP9StoreAttrSaIS1_EEPP10Attributes(ptr noundef nonnull align 8 dereferenceable(24) %115, ptr noundef %117)
  store i32 %118, ptr %10, align 4, !tbaa !21
  %119 = load i32, ptr %10, align 4, !tbaa !21
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %123

121:                                              ; preds = %114
  %122 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 155, i32 noundef %122)
  br label %139

123:                                              ; preds = %114
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %125
  %127 = call ptr @get_SafeBag_desc()
  %128 = load ptr, ptr %8, align 8, !tbaa !5
  %129 = call i32 @asn_encode_ba(ptr noundef %127, ptr noundef %128, ptr noundef %11)
  store i32 %129, ptr %10, align 4, !tbaa !21
  %130 = load i32, ptr %10, align 4, !tbaa !21
  %131 = icmp ne i32 %130, 0
  br i1 %131, label %132, label %134

132:                                              ; preds = %126
  %133 = load i32, ptr %10, align 4, !tbaa !21
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 157, i32 noundef %133)
  br label %139

134:                                              ; preds = %126
  br label %135

135:                                              ; preds = %134
  br label %136

136:                                              ; preds = %135
  %137 = load ptr, ptr %11, align 8, !tbaa !5
  %138 = getelementptr inbounds %class.StoreBag, ptr %12, i32 0, i32 4
  store ptr %137, ptr %138, align 8, !tbaa !11
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %139

139:                                              ; preds = %136, %132, %121, %107, %92, %79, %63, %50, %28
  %140 = load ptr, ptr %11, align 8, !tbaa !5
  call void @ba_free(ptr noundef %140)
  %141 = call ptr @get_SafeBag_desc()
  %142 = load ptr, ptr %8, align 8, !tbaa !5
  call void @asn_free(ptr noundef %141, ptr noundef %142)
  %143 = load i32, ptr %10, align 4, !tbaa !21
  store i32 %143, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %144

144:                                              ; preds = %139, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %145 = load i32, ptr %4, align 4
  ret i32 %145
}

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

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

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

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

declare zeroext i1 @oid_is_equal(ptr noundef, ptr noundef) #0

declare i32 @pkcs8_pbes2_encrypt(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) #0

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

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

declare ptr @get_ANY_desc() #0

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL18set_bag_attributesRKSt6vectorIP9StoreAttrSaIS1_EEPP10Attributes(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #2

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

declare ptr @get_SafeBag_desc() #0

declare void @asn_free(ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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) "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 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 72}
!12 = !{!"_ZTS8StoreBag", !13, i64 0, !14, i64 8, !6, i64 40, !16, i64 48, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !20, i64 104}
!13 = !{!"_ZTSN8StoreBag8BAG_TYPEE", !7, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !10, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"_ZTSSt6vectorIP9StoreAttrSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIP9StoreAttrSaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIP9StoreAttrSaIS1_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIP9StoreAttrSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTSN8StoreBagUt_E", !6, i64 0, !6, i64 8}
!21 = !{!22, !22, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!12, !6, i64 104}
!24 = !{!12, !6, i64 112}


; 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 [32 x i8], align 1
@OID_PKCS12_P8_SHROUDED_KEY_BAG = external local_unnamed_addr global ptr, align 8
@OID_PKCS12_CERT_BAG = external local_unnamed_addr global ptr, align 8

declare void @ba_free(ptr noundef) local_unnamed_addr #0

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

; 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 uwtable
define dso_local noundef i32 @_ZN8StoreBag9encodeBagEPKcm(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  tail call void @ba_free(ptr noundef %6)
  store ptr null, ptr %5, align 8, !tbaa !5
  %7 = tail call noalias dereferenceable_or_null(88) ptr @calloc(i64 noundef 1, i64 noundef 88) #5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %68, label %8

8:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store ptr null, ptr %4, align 8, !tbaa !19
  %9 = tail call noundef ptr @_ZNK8StoreBag5bagIdEv(ptr noundef nonnull align 8 dereferenceable(120) %0)
  %10 = tail call i32 @asn_set_oid_from_text(ptr noundef %9, ptr noundef nonnull %7)
  %.not38 = icmp eq i32 %10, 0
  br i1 %.not38, label %12, label %11

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

12:                                               ; preds = %8
  %13 = load ptr, ptr @OID_PKCS12_P8_SHROUDED_KEY_BAG, align 8, !tbaa !19
  %14 = tail call noundef ptr @_ZNK8StoreBag5bagIdEv(ptr noundef nonnull align 8 dereferenceable(120) %0)
  %15 = tail call zeroext i1 @oid_is_equal(ptr noundef %13, ptr noundef %14)
  br i1 %15, label %16, label %32

16:                                               ; preds = %12
  %17 = tail call noundef ptr @_ZNK8StoreBag8bagValueEv(ptr noundef nonnull align 8 dereferenceable(120) %0)
  %18 = getelementptr inbounds i8, ptr %0, i64 104
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %0, i64 112
  %21 = load ptr, ptr %20, align 8, !tbaa !21
  %22 = call i32 @pkcs8_pbes2_encrypt(ptr noundef %17, ptr noundef %1, i64 noundef %2, ptr noundef %19, ptr noundef %21, ptr noundef nonnull %4)
  %.not42 = icmp eq i32 %22, 0
  br i1 %.not42, label %24, label %23

23:                                               ; preds = %16
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 138, i32 noundef %22)
  br label %65

24:                                               ; preds = %16
  %25 = call ptr @get_ANY_desc()
  %26 = getelementptr inbounds i8, ptr %7, i64 16
  %27 = load ptr, ptr %4, align 8, !tbaa !19
  %28 = call i32 @asn_decode_ba(ptr noundef %25, ptr noundef nonnull %26, ptr noundef %27)
  %.not43 = icmp eq i32 %28, 0
  br i1 %.not43, label %30, label %29

29:                                               ; preds = %24
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 140, i32 noundef %28)
  br label %65

30:                                               ; preds = %24
  %31 = load ptr, ptr %4, align 8, !tbaa !19
  call void @ba_free(ptr noundef %31)
  store ptr null, ptr %4, align 8, !tbaa !19
  br label %54

32:                                               ; preds = %12
  %33 = load ptr, ptr @OID_PKCS12_CERT_BAG, align 8, !tbaa !19
  %34 = tail call noundef ptr @_ZNK8StoreBag5bagIdEv(ptr noundef nonnull align 8 dereferenceable(120) %0)
  %35 = tail call zeroext i1 @oid_is_equal(ptr noundef %33, ptr noundef %34)
  br i1 %35, label %36, label %48

36:                                               ; preds = %32
  %37 = tail call noundef ptr @_ZNK8StoreBag8bagValueEv(ptr noundef nonnull align 8 dereferenceable(120) %0)
  %38 = call i32 @pkcs12_write_cert_bag(ptr noundef %37, ptr noundef nonnull %4)
  %.not40 = icmp eq i32 %38, 0
  br i1 %.not40, label %40, label %39

39:                                               ; preds = %36
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 145, i32 noundef %38)
  br label %65

40:                                               ; preds = %36
  %41 = call ptr @get_ANY_desc()
  %42 = getelementptr inbounds i8, ptr %7, i64 16
  %43 = load ptr, ptr %4, align 8, !tbaa !19
  %44 = call i32 @asn_decode_ba(ptr noundef %41, ptr noundef nonnull %42, ptr noundef %43)
  %.not41 = icmp eq i32 %44, 0
  br i1 %.not41, label %46, label %45

45:                                               ; preds = %40
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 147, i32 noundef %44)
  br label %65

46:                                               ; preds = %40
  %47 = load ptr, ptr %4, align 8, !tbaa !19
  call void @ba_free(ptr noundef %47)
  store ptr null, ptr %4, align 8, !tbaa !19
  br label %54

48:                                               ; preds = %32
  %49 = tail call ptr @get_ANY_desc()
  %50 = getelementptr inbounds i8, ptr %7, i64 16
  %51 = tail call noundef ptr @_ZNK8StoreBag8bagValueEv(ptr noundef nonnull align 8 dereferenceable(120) %0)
  %52 = tail call i32 @asn_decode_ba(ptr noundef %49, ptr noundef nonnull %50, ptr noundef %51)
  %.not39 = icmp eq i32 %52, 0
  br i1 %.not39, label %54, label %53

53:                                               ; preds = %48
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 152, i32 noundef %52)
  br label %65

54:                                               ; preds = %30, %48, %46
  %55 = getelementptr inbounds i8, ptr %0, i64 48
  %56 = getelementptr inbounds i8, ptr %7, i64 56
  %57 = call noundef i32 @_ZL18set_bag_attributesRKSt6vectorIP9StoreAttrSaIS1_EEPP10Attributes(ptr noundef nonnull align 8 dereferenceable(24) %55, ptr noundef nonnull %56)
  %.not44 = icmp eq i32 %57, 0
  br i1 %.not44, label %59, label %58

58:                                               ; preds = %54
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 155, i32 noundef %57)
  br label %65

59:                                               ; preds = %54
  %60 = call ptr @get_SafeBag_desc()
  %61 = call i32 @asn_encode_ba(ptr noundef %60, ptr noundef nonnull %7, ptr noundef nonnull %4)
  %.not45 = icmp eq i32 %61, 0
  br i1 %.not45, label %63, label %62

62:                                               ; preds = %59
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 157, i32 noundef %61)
  br label %65

63:                                               ; preds = %59
  %64 = load ptr, ptr %4, align 8, !tbaa !19
  store ptr %64, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %4, align 8, !tbaa !19
  br label %65

65:                                               ; preds = %63, %62, %58, %53, %45, %39, %29, %23, %11
  %.0 = phi i32 [ %10, %11 ], [ %22, %23 ], [ %28, %29 ], [ %57, %58 ], [ %61, %62 ], [ 0, %63 ], [ %38, %39 ], [ %44, %45 ], [ %52, %53 ]
  %66 = load ptr, ptr %4, align 8, !tbaa !19
  call void @ba_free(ptr noundef %66)
  %67 = call ptr @get_SafeBag_desc()
  call void @asn_free(ptr noundef %67, ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %68

68:                                               ; preds = %3, %65
  %.028 = phi i32 [ %.0, %65 ], [ 1025, %3 ]
  ret i32 %.028
}

; 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 i32 @asn_set_oid_from_text(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

declare zeroext i1 @oid_is_equal(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

declare ptr @get_ANY_desc() local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL18set_bag_attributesRKSt6vectorIP9StoreAttrSaIS1_EEPP10Attributes(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #2

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

declare ptr @get_SafeBag_desc() local_unnamed_addr #0

declare void @asn_free(ptr noundef, ptr noundef) 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 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 #5 = { nounwind allocsize(0,1) }
attributes #6 = { 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, !12, i64 72}
!6 = !{!"_ZTS8StoreBag", !7, i64 0, !10, i64 8, !12, i64 40, !14, i64 48, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !18, i64 104}
!7 = !{!"_ZTSN8StoreBag8BAG_TYPEE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !11, i64 0, !13, i64 8, !8, i64 16}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ZTSSt6vectorIP9StoreAttrSaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIP9StoreAttrSaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIP9StoreAttrSaIS1_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIP9StoreAttrSaIS1_EE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!18 = !{!"_ZTSN8StoreBagUt_E", !12, i64 0, !12, i64 8}
!19 = !{!12, !12, i64 0}
!20 = !{!6, !12, i64 104}
!21 = !{!6, !12, i64 112}


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