; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (extension-helper-json)

; 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.UapkiNS::SmartBA" = type { ptr }
%struct.QCStatements = type { %struct.anon.8, %struct.asn_struct_ctx_s }
%struct.anon.8 = type { ptr, i32, i32, ptr }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }
%struct.QCStatement = type { %struct.ASN__PRIMITIVE_TYPE_s, ptr, %struct.asn_struct_ctx_s }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.ANY = type { ptr, i32, %struct.asn_struct_ctx_s }

@.str = external hidden unnamed_addr constant [38 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [14 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

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

declare ptr @json_value_init_array() #1

declare ptr @json_object_get_array(ptr noundef, ptr noundef) #1

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

declare ptr @json_value_init_object() #1

declare ptr @json_array_get_object(ptr noundef, i64 noundef) #1

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

declare noundef i32 @_ZN7UapkiNS4Util11oidFromAsn1EPK21ASN__PRIMITIVE_TYPE_sRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) #1

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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

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

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

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

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

declare ptr @ba_alloc_from_uint8(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15ExtensionHelper18DecodeToJsonObject12qcStatementsEPK12ByteArray_stP13json_object_t(ptr noundef %0, ptr noundef %1) #3 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %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
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca %"class.std::__cxx11::basic_string", align 8
  %14 = alloca %"class.UapkiNS::SmartBA", align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %2
  %18 = call ptr @get_QCStatements_desc()
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call ptr @asn_decode_ba_with_alloc(ptr noundef %18, ptr noundef %19)
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = icmp eq ptr null, %20
  br i1 %21, label %22, label %24

22:                                               ; preds = %17
  store i32 2, ptr %6, align 4, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 440, i32 noundef %23)
  br label %143

24:                                               ; preds = %17
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call ptr @json_value_init_array()
  %29 = call i32 @json_object_set_value(ptr noundef %27, ptr noundef @.str.20, ptr noundef %28)
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %26
  store i32 4113, ptr %6, align 4, !tbaa !9
  br label %143

32:                                               ; preds = %26
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call ptr @json_object_get_array(ptr noundef %33, ptr noundef @.str.20)
  store ptr %34, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %136, %32
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.QCStatements, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.anon.8, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 8, !tbaa !11
  %41 = icmp slt i32 %36, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %35
  store i32 5, ptr %10, align 4
  br label %140

43:                                               ; preds = %35
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = call ptr @json_value_init_object()
  %46 = call i32 @json_array_append_value(ptr noundef %44, ptr noundef %45)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  store i32 4113, ptr %6, align 4, !tbaa !9
  store i32 4, ptr %10, align 4
  br label %140

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = call ptr @json_array_get_object(ptr noundef %50, i64 noundef %52)
  store ptr %53, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.QCStatements, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.anon.8, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  store ptr %61, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  invoke void @_ZN7UapkiNS7SmartBAC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14)
          to label %62 unwind label %73

62:                                               ; preds = %49
  br label %63

63:                                               ; preds = %62
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.QCStatement, ptr %64, i32 0, i32 0
  %66 = invoke noundef i32 @_ZN7UapkiNS4Util11oidFromAsn1EPK21ASN__PRIMITIVE_TYPE_sRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %65, ptr noundef nonnull align 8 dereferenceable(32) %13)
          to label %67 unwind label %77

67:                                               ; preds = %63
  store i32 %66, ptr %6, align 4, !tbaa !9
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %81

70:                                               ; preds = %67
  %71 = load i32, ptr %6, align 4, !tbaa !9
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 452, i32 noundef %71)
          to label %72 unwind label %77

72:                                               ; preds = %70
  store i32 4, ptr %10, align 4
  br label %133

73:                                               ; preds = %49
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %15, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %16, align 4
  br label %139

77:                                               ; preds = %126, %121, %118, %112, %108, %95, %83, %70, %63
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %15, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %16, align 4
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #4
  br label %139

81:                                               ; preds = %67
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %13) #4
  %86 = invoke i32 @json_object_set_string(ptr noundef %84, ptr noundef @.str.21, ptr noundef %85)
          to label %87 unwind label %77

87:                                               ; preds = %83
  %88 = icmp ne i32 %86, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %87
  store i32 4113, ptr %6, align 4, !tbaa !9
  store i32 4, ptr %10, align 4
  br label %133

90:                                               ; preds = %87
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.QCStatement, ptr %91, i32 0, i32 1
  %93 = load ptr, ptr %92, align 8, !tbaa !18
  %94 = icmp ne ptr %93, null
  br i1 %94, label %95, label %132

95:                                               ; preds = %90
  %96 = load ptr, ptr %12, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.QCStatement, ptr %96, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8, !tbaa !18
  %99 = getelementptr inbounds %struct.ANY, ptr %98, i32 0, i32 0
  %100 = load ptr, ptr %99, align 8, !tbaa !21
  %101 = load ptr, ptr %12, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.QCStatement, ptr %101, i32 0, i32 1
  %103 = load ptr, ptr %102, align 8, !tbaa !18
  %104 = getelementptr inbounds %struct.ANY, ptr %103, i32 0, i32 1
  %105 = load i32, ptr %104, align 8, !tbaa !23
  %106 = sext i32 %105 to i64
  %107 = invoke ptr @ba_alloc_from_uint8(ptr noundef %100, i64 noundef %106)
          to label %108 unwind label %77

108:                                              ; preds = %95
  %109 = invoke noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef %107)
          to label %110 unwind label %77

110:                                              ; preds = %108
  br i1 %109, label %117, label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111
  store i32 4097, ptr %6, align 4, !tbaa !9
  %113 = load i32, ptr %6, align 4, !tbaa !9
  invoke void @stacktrace_create(ptr noundef @.str, i64 noundef 456, i32 noundef %113, ptr noundef null)
          to label %114 unwind label %77

114:                                              ; preds = %112
  store i32 4, ptr %10, align 4
  br label %133

115:                                              ; No predecessors!
  br label %116

116:                                              ; preds = %115
  br label %117

117:                                              ; preds = %116, %110
  br label %118

118:                                              ; preds = %117
  %119 = load ptr, ptr %11, align 8, !tbaa !5
  %120 = invoke noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %14)
          to label %121 unwind label %77

121:                                              ; preds = %118
  %122 = invoke i32 @json_object_set_base64(ptr noundef %119, ptr noundef @.str.22, ptr noundef %120)
          to label %123 unwind label %77

123:                                              ; preds = %121
  store i32 %122, ptr %6, align 4, !tbaa !9
  %124 = load i32, ptr %6, align 4, !tbaa !9
  %125 = icmp ne i32 %124, 0
  br i1 %125, label %126, label %129

126:                                              ; preds = %123
  %127 = load i32, ptr %6, align 4, !tbaa !9
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 458, i32 noundef %127)
          to label %128 unwind label %77

128:                                              ; preds = %126
  store i32 4, ptr %10, align 4
  br label %133

129:                                              ; preds = %123
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  br label %132

132:                                              ; preds = %131, %90
  store i32 0, ptr %10, align 4
  br label %133

133:                                              ; preds = %132, %128, %114, %89, %72
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %134 = load i32, ptr %10, align 4
  switch i32 %134, label %140 [
    i32 0, label %135
  ]

135:                                              ; preds = %133
  br label %136

136:                                              ; preds = %135
  %137 = load i32, ptr %9, align 4, !tbaa !9
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %9, align 4, !tbaa !9
  br label %35, !llvm.loop !24

139:                                              ; preds = %77, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %149

140:                                              ; preds = %133, %48, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %141 = load i32, ptr %10, align 4
  switch i32 %141, label %147 [
    i32 5, label %142
    i32 4, label %143
  ]

142:                                              ; preds = %140
  br label %143

143:                                              ; preds = %142, %140, %31, %22
  %144 = call ptr @get_QCStatements_desc()
  %145 = load ptr, ptr %7, align 8, !tbaa !5
  call void @asn_free(ptr noundef %144, ptr noundef %145)
  %146 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %146, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %147

147:                                              ; preds = %143, %140
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %148 = load i32, ptr %3, align 4
  ret i32 %148

149:                                              ; preds = %139
  %150 = load ptr, ptr %15, align 8
  %151 = load i32, ptr %16, align 4
  %152 = insertvalue { ptr, i32 } poison, ptr %150, 0
  %153 = insertvalue { ptr, i32 } %152, i32 %151, 1
  resume { ptr, i32 } %153
}

declare ptr @get_QCStatements_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 }

!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, !10, i64 8}
!12 = !{!"_ZTS12QCStatements", !13, i64 0, !14, i64 24}
!13 = !{!"_ZTSN12QCStatementsUt_E", !6, i64 0, !10, i64 8, !10, i64 12, !6, 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 = !{!12, !6, i64 0}
!18 = !{!19, !6, i64 16}
!19 = !{!"_ZTS11QCStatement", !20, i64 0, !6, i64 16, !14, i64 24}
!20 = !{!"_ZTS21ASN__PRIMITIVE_TYPE_s", !6, i64 0, !10, i64 8}
!21 = !{!22, !6, i64 0}
!22 = !{!"_ZTS3ANY", !6, i64 0, !10, i64 8, !14, i64 16}
!23 = !{!22, !10, i64 8}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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.UapkiNS::SmartBA" = type { ptr }

@.str = external hidden unnamed_addr constant [38 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [14 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 ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

declare ptr @json_value_init_array() local_unnamed_addr #1

declare ptr @json_object_get_array(ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare ptr @json_value_init_object() local_unnamed_addr #1

declare ptr @json_array_get_object(ptr noundef, i64 noundef) local_unnamed_addr #1

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

declare noundef i32 @_ZN7UapkiNS4Util11oidFromAsn1EPK21ASN__PRIMITIVE_TYPE_sRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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

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

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

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

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

declare ptr @ba_alloc_from_uint8(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS15ExtensionHelper18DecodeToJsonObject12qcStatementsEPK12ByteArray_stP13json_object_t(ptr noundef %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.UapkiNS::SmartBA", align 8
  %5 = tail call ptr @get_QCStatements_desc()
  %6 = tail call ptr @asn_decode_ba_with_alloc(ptr noundef %5, ptr noundef %0)
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 440, i32 noundef 2)
  br label %57

9:                                                ; preds = %2
  %10 = tail call ptr @json_value_init_array()
  %11 = tail call i32 @json_object_set_value(ptr noundef %1, ptr noundef nonnull @.str.20, ptr noundef %10)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %57

12:                                               ; preds = %9
  %13 = tail call ptr @json_object_get_array(ptr noundef %1, ptr noundef nonnull @.str.20)
  %14 = getelementptr inbounds i8, ptr %6, i64 8
  %15 = load i32, ptr %14, align 8, !tbaa !5
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

17:                                               ; preds = %54
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr %14, align 8, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !15

.lr.ph:                                           ; preds = %12, %17
  %indvars.iv = phi i64 [ %indvars.iv.next, %17 ], [ 0, %12 ]
  %21 = call ptr @json_value_init_object()
  %22 = call i32 @json_array_append_value(ptr noundef %13, ptr noundef %21)
  %.not39 = icmp eq i32 %22, 0
  br i1 %.not39, label %23, label %._crit_edge.loopexit

23:                                               ; preds = %.lr.ph
  %24 = call ptr @json_array_get_object(ptr noundef %13, i64 noundef %indvars.iv)
  %25 = load ptr, ptr %6, align 8, !tbaa !17
  %26 = getelementptr inbounds ptr, ptr %25, i64 %indvars.iv
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @_ZN7UapkiNS7SmartBAC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %28 = invoke noundef i32 @_ZN7UapkiNS4Util11oidFromAsn1EPK21ASN__PRIMITIVE_TYPE_sRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %27, ptr noundef nonnull align 8 dereferenceable(32) %3)
          to label %29 unwind label %31

29:                                               ; preds = %23
  %.not40 = icmp eq i32 %28, 0
  br i1 %.not40, label %33, label %30

30:                                               ; preds = %29
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 452, i32 noundef %28)
          to label %54 unwind label %31

31:                                               ; preds = %53, %49, %48, %40, %33, %30, %23
  %32 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  resume { ptr, i32 } %32

33:                                               ; preds = %29
  %34 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  %35 = invoke i32 @json_object_set_string(ptr noundef %24, ptr noundef nonnull @.str.21, ptr noundef %34)
          to label %36 unwind label %31

36:                                               ; preds = %33
  %.not41 = icmp eq i32 %35, 0
  br i1 %.not41, label %37, label %54

37:                                               ; preds = %36
  %38 = getelementptr inbounds i8, ptr %27, i64 16
  %39 = load ptr, ptr %38, align 8, !tbaa !19
  %.not42 = icmp eq ptr %39, null
  br i1 %.not42, label %54, label %40

40:                                               ; preds = %37
  %41 = load ptr, ptr %39, align 8, !tbaa !22
  %42 = getelementptr inbounds i8, ptr %39, i64 8
  %43 = load i32, ptr %42, align 8, !tbaa !24
  %44 = sext i32 %43 to i64
  %45 = invoke ptr @ba_alloc_from_uint8(ptr noundef %41, i64 noundef %44)
          to label %46 unwind label %31

46:                                               ; preds = %40
  %47 = call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef %45)
  br i1 %47, label %49, label %48

48:                                               ; preds = %46
  invoke void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 456, i32 noundef 4097, ptr noundef null)
          to label %54 unwind label %31

49:                                               ; preds = %46
  %50 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %51 = invoke i32 @json_object_set_base64(ptr noundef %24, ptr noundef nonnull @.str.22, ptr noundef %50)
          to label %52 unwind label %31

52:                                               ; preds = %49
  %.not43 = icmp eq i32 %51, 0
  br i1 %.not43, label %54, label %53

53:                                               ; preds = %52
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 458, i32 noundef %51)
          to label %54 unwind label %31

54:                                               ; preds = %37, %52, %53, %48, %36, %30
  %cond = phi i1 [ false, %30 ], [ false, %36 ], [ false, %48 ], [ false, %53 ], [ true, %52 ], [ true, %37 ]
  %.030 = phi i32 [ 4, %30 ], [ 4, %36 ], [ 4, %48 ], [ 4, %53 ], [ 0, %52 ], [ 0, %37 ]
  %.2 = phi i32 [ %28, %30 ], [ 4113, %36 ], [ 4097, %48 ], [ %51, %53 ], [ 0, %52 ], [ 0, %37 ]
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  br i1 %cond, label %17, label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %.lr.ph, %17, %54
  %.131.ph = phi i32 [ %.030, %54 ], [ 5, %17 ], [ 4, %.lr.ph ]
  %.3.ph = phi i32 [ %.2, %54 ], [ %.2, %17 ], [ 4113, %.lr.ph ]
  %55 = and i32 %.131.ph, -2
  %56 = icmp eq i32 %55, 4
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %12
  %.131 = phi i1 [ true, %12 ], [ %56, %._crit_edge.loopexit ]
  %.3 = phi i32 [ 0, %12 ], [ %.3.ph, %._crit_edge.loopexit ]
  call void @llvm.assume(i1 %.131)
  br label %57

57:                                               ; preds = %._crit_edge, %9, %8
  %.4 = phi i32 [ 2, %8 ], [ %.3, %._crit_edge ], [ 4113, %9 ]
  %58 = call ptr @get_QCStatements_desc()
  call void @asn_free(ptr noundef %58, ptr noundef %6)
  ret i32 %.4
}

declare ptr @get_QCStatements_desc() local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #4

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 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
attributes #5 = { 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, !11, i64 8}
!6 = !{!"_ZTS12QCStatements", !7, i64 0, !12, i64 24}
!7 = !{!"_ZTSN12QCStatementsUt_E", !8, i64 0, !11, i64 8, !11, i64 12, !8, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTS16asn_struct_ctx_s", !13, i64 0, !13, i64 2, !11, i64 4, !8, i64 8, !14, i64 16}
!13 = !{!"short", !9, i64 0}
!14 = !{!"long", !9, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !8, i64 0}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !8, i64 16}
!20 = !{!"_ZTS11QCStatement", !21, i64 0, !8, i64 16, !12, i64 24}
!21 = !{!"_ZTS21ASN__PRIMITIVE_TYPE_s", !8, i64 0, !11, i64 8}
!22 = !{!23, !8, i64 0}
!23 = !{!"_ZTS3ANY", !8, i64 0, !11, i64 8, !12, i64 16}
!24 = !{!23, !11, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass