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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.UapkiNS::SmartBA" = type { ptr }
%struct.GOST28147ParamsOptionalDke = type { %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 }

@.str = external hidden unnamed_addr constant [30 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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

declare ptr @asn_decode_ba_with_alloc(ptr noundef, ptr noundef) #2

declare ptr @get_GOST28147ParamsOptionalDke_desc() #2

declare i32 @asn_OCTSTRING2ba(ptr noundef, ptr noundef) #2

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

declare ptr @ba_alloc_by_len(i64 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS6Cipher9Gost2814712decodeParamsEPK12ByteArray_stPPS2_S6_b(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %"class.UapkiNS::SmartBA", align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i8, align 1
  %20 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  %21 = zext i1 %3 to i8
  store i8 %21, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @_ZN7UapkiNS7SmartBAC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12)
  br label %22

22:                                               ; preds = %4
  %23 = invoke ptr @get_GOST28147ParamsOptionalDke_desc()
          to label %24 unwind label %32

24:                                               ; preds = %22
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = invoke ptr @asn_decode_ba_with_alloc(ptr noundef %23, ptr noundef %25)
          to label %27 unwind label %32

27:                                               ; preds = %24
  store ptr %26, ptr %11, align 8, !tbaa !5
  %28 = icmp eq ptr null, %26
  br i1 %28, label %29, label %36

29:                                               ; preds = %27
  store i32 2, ptr %10, align 4, !tbaa !11
  %30 = load i32, ptr %10, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 194, i32 noundef %30)
          to label %31 unwind label %32

31:                                               ; preds = %29
  br label %154

32:                                               ; preds = %156, %154, %70, %61, %47, %39, %29, %24, %22
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %13, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %14, align 4
  br label %162

36:                                               ; preds = %27
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.GOST28147ParamsOptionalDke, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = invoke i32 @asn_OCTSTRING2ba(ptr noundef %41, ptr noundef %42)
          to label %44 unwind label %32

44:                                               ; preds = %39
  store i32 %43, ptr %10, align 4, !tbaa !11
  %45 = load i32, ptr %10, align 4, !tbaa !11
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %50

47:                                               ; preds = %44
  %48 = load i32, ptr %10, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 195, i32 noundef %48)
          to label %49 unwind label %32

49:                                               ; preds = %47
  br label %154

50:                                               ; preds = %44
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.GOST28147ParamsOptionalDke, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %153

57:                                               ; preds = %52
  %58 = load i8, ptr %9, align 1, !tbaa !9, !range !19, !noundef !20
  %59 = trunc i8 %58 to i1
  br i1 %59, label %60, label %76

60:                                               ; preds = %57
  br label %61

61:                                               ; preds = %60
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.GOST28147ParamsOptionalDke, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !13
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = invoke i32 @asn_OCTSTRING2ba(ptr noundef %64, ptr noundef %65)
          to label %67 unwind label %32

67:                                               ; preds = %61
  store i32 %66, ptr %10, align 4, !tbaa !11
  %68 = load i32, ptr %10, align 4, !tbaa !11
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %73

70:                                               ; preds = %67
  %71 = load i32, ptr %10, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 198, i32 noundef %71)
          to label %72 unwind label %32

72:                                               ; preds = %70
  br label %154

73:                                               ; preds = %67
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  br label %152

76:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.GOST28147ParamsOptionalDke, ptr %77, i32 0, i32 1
  %79 = load ptr, ptr %78, align 8, !tbaa !13
  %80 = getelementptr inbounds %struct.OCTET_STRING, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  store ptr %81, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %82 = load ptr, ptr %11, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.GOST28147ParamsOptionalDke, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = getelementptr inbounds %struct.OCTET_STRING, ptr %84, i32 0, i32 1
  %86 = load i32, ptr %85, align 8, !tbaa !22
  %87 = sext i32 %86 to i64
  store i64 %87, ptr %16, align 8, !tbaa !23
  %88 = load i64, ptr %16, align 8, !tbaa !23
  %89 = mul i64 2, %88
  %90 = invoke ptr @ba_alloc_by_len(i64 noundef %89)
          to label %91 unwind label %98

91:                                               ; preds = %76
  %92 = invoke noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef %90)
          to label %93 unwind label %98

93:                                               ; preds = %91
  br i1 %92, label %104, label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94
  store i32 4097, ptr %10, align 4, !tbaa !11
  %96 = load i32, ptr %10, align 4, !tbaa !11
  invoke void @stacktrace_create(ptr noundef @.str, i64 noundef 204, i32 noundef %96, ptr noundef null)
          to label %97 unwind label %98

97:                                               ; preds = %95
  store i32 4, ptr %20, align 4
  br label %148

98:                                               ; preds = %144, %142, %95, %91, %76
  %99 = landingpad { ptr, i32 }
          cleanup
  %100 = extractvalue { ptr, i32 } %99, 0
  store ptr %100, ptr %13, align 8
  %101 = extractvalue { ptr, i32 } %99, 1
  store i32 %101, ptr %14, align 4
  br label %151

102:                                              ; No predecessors!
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103, %93
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store i64 0, ptr %17, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  store i64 0, ptr %18, align 8, !tbaa !23
  br label %105

105:                                              ; preds = %135, %104
  %106 = load i64, ptr %17, align 8, !tbaa !23
  %107 = load i64, ptr %16, align 8, !tbaa !23
  %108 = icmp ult i64 %106, %107
  br i1 %108, label %110, label %109

109:                                              ; preds = %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %142

110:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #4
  %111 = load ptr, ptr %15, align 8, !tbaa !5
  %112 = load i64, ptr %17, align 8, !tbaa !23
  %113 = getelementptr inbounds i8, ptr %111, i64 %112
  %114 = load i8, ptr %113, align 1, !tbaa !24
  store i8 %114, ptr %19, align 1, !tbaa !24
  %115 = invoke noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %116 unwind label %138

116:                                              ; preds = %110
  %117 = load i64, ptr %18, align 8, !tbaa !23
  %118 = add i64 %117, 1
  store i64 %118, ptr %18, align 8, !tbaa !23
  %119 = load i8, ptr %19, align 1, !tbaa !24
  %120 = zext i8 %119 to i32
  %121 = ashr i32 %120, 4
  %122 = trunc i32 %121 to i8
  %123 = invoke i32 @ba_set_byte(ptr noundef %115, i64 noundef %117, i8 noundef zeroext %122)
          to label %124 unwind label %138

124:                                              ; preds = %116
  %125 = invoke noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %126 unwind label %138

126:                                              ; preds = %124
  %127 = load i64, ptr %18, align 8, !tbaa !23
  %128 = add i64 %127, 1
  store i64 %128, ptr %18, align 8, !tbaa !23
  %129 = load i8, ptr %19, align 1, !tbaa !24
  %130 = zext i8 %129 to i32
  %131 = and i32 %130, 15
  %132 = trunc i32 %131 to i8
  %133 = invoke i32 @ba_set_byte(ptr noundef %125, i64 noundef %127, i8 noundef zeroext %132)
          to label %134 unwind label %138

134:                                              ; preds = %126
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #4
  br label %135

135:                                              ; preds = %134
  %136 = load i64, ptr %17, align 8, !tbaa !23
  %137 = add i64 %136, 1
  store i64 %137, ptr %17, align 8, !tbaa !23
  br label %105, !llvm.loop !25

138:                                              ; preds = %126, %124, %116, %110
  %139 = landingpad { ptr, i32 }
          cleanup
  %140 = extractvalue { ptr, i32 } %139, 0
  store ptr %140, ptr %13, align 8
  %141 = extractvalue { ptr, i32 } %139, 1
  store i32 %141, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %151

142:                                              ; preds = %109
  %143 = invoke noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %144 unwind label %98

144:                                              ; preds = %142
  %145 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %143, ptr %145, align 8, !tbaa !5
  %146 = invoke noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef null)
          to label %147 unwind label %98

147:                                              ; preds = %144
  store i32 0, ptr %20, align 4
  br label %148

148:                                              ; preds = %147, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  %149 = load i32, ptr %20, align 4
  switch i32 %149, label %160 [
    i32 0, label %150
    i32 4, label %154
  ]

150:                                              ; preds = %148
  br label %152

151:                                              ; preds = %138, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %162

152:                                              ; preds = %150, %75
  br label %153

153:                                              ; preds = %152, %52
  br label %154

154:                                              ; preds = %153, %148, %72, %49, %31
  %155 = invoke ptr @get_GOST28147ParamsOptionalDke_desc()
          to label %156 unwind label %32

156:                                              ; preds = %154
  %157 = load ptr, ptr %11, align 8, !tbaa !5
  invoke void @asn_free(ptr noundef %155, ptr noundef %157)
          to label %158 unwind label %32

158:                                              ; preds = %156
  %159 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %159, ptr %5, align 4
  store i32 1, ptr %20, align 4
  br label %160

160:                                              ; preds = %158, %148
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #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 %10) #4
  %161 = load i32, ptr %5, align 4
  ret i32 %161

162:                                              ; preds = %151, %32
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #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 %10) #4
  br label %163

163:                                              ; preds = %162
  %164 = load ptr, ptr %13, align 8
  %165 = load i32, ptr %14, align 4
  %166 = insertvalue { ptr, i32 } poison, ptr %164, 0
  %167 = insertvalue { ptr, i32 } %166, i32 %165, 1
  resume { ptr, i32 } %167
}

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

declare i32 @ba_set_byte(ptr noundef, i64 noundef, i8 noundef zeroext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 40}
!14 = !{!"_ZTS26GOST28147ParamsOptionalDke", !15, i64 0, !6, i64 40, !16, i64 48}
!15 = !{!"_ZTS12OCTET_STRING", !6, i64 0, !12, i64 8, !16, i64 16}
!16 = !{!"_ZTS16asn_struct_ctx_s", !17, i64 0, !17, i64 2, !12, i64 4, !6, i64 8, !18, i64 16}
!17 = !{!"short", !7, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!15, !6, i64 0}
!22 = !{!15, !12, i64 8}
!23 = !{!18, !18, i64 0}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"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.UapkiNS::SmartBA" = type { ptr }

@.str = external hidden unnamed_addr constant [30 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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

declare ptr @get_GOST28147ParamsOptionalDke_desc() local_unnamed_addr #2

declare i32 @asn_OCTSTRING2ba(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare ptr @ba_alloc_by_len(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS6Cipher9Gost2814712decodeParamsEPK12ByteArray_stPPS2_S6_b(ptr noundef %0, ptr noundef %1, ptr noundef %2, i1 noundef zeroext %3) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.UapkiNS::SmartBA", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  call void @_ZN7UapkiNS7SmartBAC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5)
  %6 = invoke ptr @get_GOST28147ParamsOptionalDke_desc()
          to label %7 unwind label %12

7:                                                ; preds = %4
  %8 = invoke ptr @asn_decode_ba_with_alloc(ptr noundef %6, ptr noundef %0)
          to label %9 unwind label %12

9:                                                ; preds = %7
  %10 = icmp eq ptr %8, null
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 194, i32 noundef 2)
          to label %55 unwind label %12

12:                                               ; preds = %57, %55, %25, %22, %17, %14, %11, %7, %4
  %13 = landingpad { ptr, i32 }
          cleanup
  br label %59

14:                                               ; preds = %9
  %15 = invoke i32 @asn_OCTSTRING2ba(ptr noundef nonnull %8, ptr noundef %1)
          to label %16 unwind label %12

16:                                               ; preds = %14
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %18, label %17

17:                                               ; preds = %16
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 195, i32 noundef %15)
          to label %55 unwind label %12

18:                                               ; preds = %16
  %19 = getelementptr inbounds i8, ptr %8, i64 40
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %.not45 = icmp eq ptr %20, null
  br i1 %.not45, label %55, label %21

21:                                               ; preds = %18
  br i1 %3, label %22, label %26

22:                                               ; preds = %21
  %23 = invoke i32 @asn_OCTSTRING2ba(ptr noundef nonnull %20, ptr noundef %2)
          to label %24 unwind label %12

24:                                               ; preds = %22
  %.not47 = icmp eq i32 %23, 0
  br i1 %.not47, label %55, label %25

25:                                               ; preds = %24
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 198, i32 noundef %23)
          to label %55 unwind label %12

26:                                               ; preds = %21
  %27 = load ptr, ptr %20, align 8, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %20, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = sext i32 %29 to i64
  %31 = shl nsw i64 %30, 1
  %32 = invoke ptr @ba_alloc_by_len(i64 noundef %31)
          to label %33 unwind label %36

33:                                               ; preds = %26
  %34 = call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef %32)
  br i1 %34, label %.preheader, label %35

.preheader:                                       ; preds = %33
  %.not52 = icmp eq i32 %29, 0
  br i1 %.not52, label %._crit_edge, label %.lr.ph

35:                                               ; preds = %33
  invoke void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 204, i32 noundef 4097, ptr noundef null)
          to label %55 unwind label %36

36:                                               ; preds = %35, %26
  %37 = landingpad { ptr, i32 }
          cleanup
  br label %59

._crit_edge:                                      ; preds = %50, %.preheader
  %38 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %5)
  store ptr %38, ptr %2, align 8, !tbaa !17
  %39 = call noundef zeroext i1 @_ZN7UapkiNS7SmartBA3setEP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef null)
  br label %55

.lr.ph:                                           ; preds = %.preheader, %50
  %.03251 = phi i64 [ %51, %50 ], [ 0, %.preheader ]
  %.03350 = phi i64 [ %52, %50 ], [ 0, %.preheader ]
  %40 = getelementptr inbounds i8, ptr %27, i64 %.03350
  %41 = load i8, ptr %40, align 1, !tbaa !18
  %42 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %5)
  %43 = lshr i8 %41, 4
  %44 = invoke i32 @ba_set_byte(ptr noundef %42, i64 noundef %.03251, i8 noundef zeroext %43)
          to label %45 unwind label %53

45:                                               ; preds = %.lr.ph
  %46 = or disjoint i64 %.03251, 1
  %47 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %5)
  %48 = and i8 %41, 15
  %49 = invoke i32 @ba_set_byte(ptr noundef %47, i64 noundef %46, i8 noundef zeroext %48)
          to label %50 unwind label %53

50:                                               ; preds = %45
  %51 = add i64 %.03251, 2
  %52 = add nuw i64 %.03350, 1
  %exitcond.not = icmp eq i64 %52, %30
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

53:                                               ; preds = %45, %.lr.ph
  %54 = landingpad { ptr, i32 }
          cleanup
  br label %59

55:                                               ; preds = %._crit_edge, %35, %18, %24, %25, %17, %11
  %.1 = phi i32 [ 2, %11 ], [ %15, %17 ], [ %23, %25 ], [ 0, %24 ], [ 0, %18 ], [ 0, %._crit_edge ], [ 4097, %35 ]
  %56 = invoke ptr @get_GOST28147ParamsOptionalDke_desc()
          to label %57 unwind label %12

57:                                               ; preds = %55
  invoke void @asn_free(ptr noundef %56, ptr noundef %8)
          to label %58 unwind label %12

58:                                               ; preds = %57
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret i32 %.1

59:                                               ; preds = %36, %53, %12
  %.pn48 = phi { ptr, i32 } [ %13, %12 ], [ %54, %53 ], [ %37, %36 ]
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  resume { ptr, i32 } %.pn48
}

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

declare i32 @ba_set_byte(ptr noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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, !8, i64 40}
!6 = !{!"_ZTS26GOST28147ParamsOptionalDke", !7, i64 0, !8, i64 40, !12, i64 48}
!7 = !{!"_ZTS12OCTET_STRING", !8, i64 0, !11, i64 8, !12, 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 = !{!7, !8, i64 0}
!16 = !{!7, !11, i64 8}
!17 = !{!8, !8, i64 0}
!18 = !{!9, !9, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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