; 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 }
%"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" = type { i8 }
%"struct.UapkiNS::AlgorithmIdentifier" = type { %"class.std::__cxx11::basic_string", ptr }

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@OID_GOST28147_CTR = external global ptr, align 8
@OID_GOST28147_CFB = 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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 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 #1 align 2

; 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) #4

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

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

; 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

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

22:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !11
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.UapkiNS::AlgorithmIdentifier", ptr %23, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #5
  %25 = load ptr, ptr @OID_GOST28147_CTR, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %19) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %18, ptr noundef %25, ptr noundef nonnull align 1 dereferenceable(1) %19)
          to label %26 unwind label %33

26:                                               ; preds = %22
  %27 = call noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32) %24, ptr noundef nonnull align 8 dereferenceable(32) %18) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %18) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %19) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  br i1 %27, label %28, label %37

28:                                               ; preds = %26
  store i32 2, ptr %17, align 4, !tbaa !11
  br label %59

29:                                               ; preds = %5
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %14, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %15, align 4
  br label %179

33:                                               ; preds = %22
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %14, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %15, align 4
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %19) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  br label %178

37:                                               ; preds = %26
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.UapkiNS::AlgorithmIdentifier", ptr %38, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #5
  %40 = load ptr, ptr @OID_GOST28147_CFB, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef %40, ptr noundef nonnull align 1 dereferenceable(1) %21)
          to label %41 unwind label %44

41:                                               ; preds = %37
  %42 = call noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32) %39, ptr noundef nonnull align 8 dereferenceable(32) %20) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #5
  br i1 %42, label %43, label %48

43:                                               ; preds = %41
  store i32 3, ptr %17, align 4, !tbaa !11
  br label %58

44:                                               ; preds = %37
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %14, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %15, align 4
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #5
  br label %178

48:                                               ; preds = %41
  br label %49

49:                                               ; preds = %48
  store i32 4110, ptr %11, align 4, !tbaa !11
  %50 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_create(ptr noundef @.str, i64 noundef 154, i32 noundef %50, ptr noundef null)
          to label %51 unwind label %52

51:                                               ; preds = %49
  br label %174

52:                                               ; preds = %174, %167, %159, %152, %144, %133, %128, %124, %117, %112, %108, %99, %95, %88, %84, %82, %77, %72, %67, %65, %60, %49
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %14, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %15, align 4
  br label %178

56:                                               ; No predecessors!
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57, %43
  br label %59

59:                                               ; preds = %58, %28
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.UapkiNS::AlgorithmIdentifier", ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !13
  %64 = invoke noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %65 unwind label %52

65:                                               ; preds = %60
  %66 = invoke noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
          to label %67 unwind label %52

67:                                               ; preds = %65
  %68 = invoke noundef i32 @_ZN7UapkiNS6Cipher9Gost2814712decodeParamsEPK12ByteArray_stPPS2_S6_b(ptr noundef %63, ptr noundef %64, ptr noundef %66, i1 noundef zeroext false)
          to label %69 unwind label %52

69:                                               ; preds = %67
  store i32 %68, ptr %11, align 4, !tbaa !11
  %70 = load i32, ptr %11, align 4, !tbaa !11
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %75

72:                                               ; preds = %69
  %73 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 157, i32 noundef %73)
          to label %74 unwind label %52

74:                                               ; preds = %72
  br label %174

75:                                               ; preds = %69
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  %78 = invoke noundef i64 @_ZNK7UapkiNS7SmartBA4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
          to label %79 unwind label %52

79:                                               ; preds = %77
  %80 = icmp ugt i64 %78, 0
  br i1 %80, label %81, label %94

81:                                               ; preds = %79
  br label %82

82:                                               ; preds = %81
  %83 = invoke noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
          to label %84 unwind label %52

84:                                               ; preds = %82
  %85 = invoke ptr @gost28147_alloc_user_sbox(ptr noundef %83)
          to label %86 unwind label %52

86:                                               ; preds = %84
  store ptr %85, ptr %16, align 8, !tbaa !5
  %87 = icmp eq ptr null, %85
  br i1 %87, label %88, label %91

88:                                               ; preds = %86
  store i32 2, ptr %11, align 4, !tbaa !11
  %89 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 159, i32 noundef %89)
          to label %90 unwind label %52

90:                                               ; preds = %88
  br label %174

91:                                               ; preds = %86
  br label %92

92:                                               ; preds = %91
  br label %93

93:                                               ; preds = %92
  br label %105

94:                                               ; preds = %79
  br label %95

95:                                               ; preds = %94
  %96 = invoke ptr @gost28147_alloc(i32 noundef 0)
          to label %97 unwind label %52

97:                                               ; preds = %95
  store ptr %96, ptr %16, align 8, !tbaa !5
  %98 = icmp eq ptr null, %96
  br i1 %98, label %99, label %102

99:                                               ; preds = %97
  store i32 2, ptr %11, align 4, !tbaa !11
  %100 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 162, i32 noundef %100)
          to label %101 unwind label %52

101:                                              ; preds = %99
  br label %174

102:                                              ; preds = %97
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104, %93
  %106 = load i32, ptr %17, align 4, !tbaa !11
  switch i32 %106, label %139 [
    i32 2, label %107
    i32 3, label %123
  ]

107:                                              ; preds = %105
  br label %108

108:                                              ; preds = %107
  %109 = load ptr, ptr %16, align 8, !tbaa !5
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = invoke noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %112 unwind label %52

112:                                              ; preds = %108
  %113 = invoke i32 @gost28147_init_ctr(ptr noundef %109, ptr noundef %110, ptr noundef %111)
          to label %114 unwind label %52

114:                                              ; preds = %112
  store i32 %113, ptr %11, align 4, !tbaa !11
  %115 = load i32, ptr %11, align 4, !tbaa !11
  %116 = icmp ne i32 %115, 0
  br i1 %116, label %117, label %120

117:                                              ; preds = %114
  %118 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 167, i32 noundef %118)
          to label %119 unwind label %52

119:                                              ; preds = %117
  br label %174

120:                                              ; preds = %114
  br label %121

121:                                              ; preds = %120
  br label %122

122:                                              ; preds = %121
  br label %140

123:                                              ; preds = %105
  br label %124

124:                                              ; preds = %123
  %125 = load ptr, ptr %16, align 8, !tbaa !5
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  %127 = invoke noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %12)
          to label %128 unwind label %52

128:                                              ; preds = %124
  %129 = invoke i32 @gost28147_init_cfb(ptr noundef %125, ptr noundef %126, ptr noundef %127)
          to label %130 unwind label %52

130:                                              ; preds = %128
  store i32 %129, ptr %11, align 4, !tbaa !11
  %131 = load i32, ptr %11, align 4, !tbaa !11
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %136

133:                                              ; preds = %130
  %134 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 170, i32 noundef %134)
          to label %135 unwind label %52

135:                                              ; preds = %133
  br label %174

136:                                              ; preds = %130
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137
  br label %140

139:                                              ; preds = %105
  br label %140

140:                                              ; preds = %139, %138, %122
  %141 = load i32, ptr %8, align 4, !tbaa !9
  %142 = icmp eq i32 %141, 0
  br i1 %142, label %143, label %158

143:                                              ; preds = %140
  br label %144

144:                                              ; preds = %143
  %145 = load ptr, ptr %16, align 8, !tbaa !5
  %146 = load ptr, ptr %9, align 8, !tbaa !5
  %147 = load ptr, ptr %10, align 8, !tbaa !5
  %148 = invoke i32 @gost28147_encrypt(ptr noundef %145, ptr noundef %146, ptr noundef %147)
          to label %149 unwind label %52

149:                                              ; preds = %144
  store i32 %148, ptr %11, align 4, !tbaa !11
  %150 = load i32, ptr %11, align 4, !tbaa !11
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %155

152:                                              ; preds = %149
  %153 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 177, i32 noundef %153)
          to label %154 unwind label %52

154:                                              ; preds = %152
  br label %174

155:                                              ; preds = %149
  br label %156

156:                                              ; preds = %155
  br label %157

157:                                              ; preds = %156
  br label %173

158:                                              ; preds = %140
  br label %159

159:                                              ; preds = %158
  %160 = load ptr, ptr %16, align 8, !tbaa !5
  %161 = load ptr, ptr %9, align 8, !tbaa !5
  %162 = load ptr, ptr %10, align 8, !tbaa !5
  %163 = invoke i32 @gost28147_decrypt(ptr noundef %160, ptr noundef %161, ptr noundef %162)
          to label %164 unwind label %52

164:                                              ; preds = %159
  store i32 %163, ptr %11, align 4, !tbaa !11
  %165 = load i32, ptr %11, align 4, !tbaa !11
  %166 = icmp ne i32 %165, 0
  br i1 %166, label %167, label %170

167:                                              ; preds = %164
  %168 = load i32, ptr %11, align 4, !tbaa !11
  invoke void @stacktrace_add(ptr noundef @.str, i64 noundef 180, i32 noundef %168)
          to label %169 unwind label %52

169:                                              ; preds = %167
  br label %174

170:                                              ; preds = %164
  br label %171

171:                                              ; preds = %170
  br label %172

172:                                              ; preds = %171
  br label %173

173:                                              ; preds = %172, %157
  br label %174

174:                                              ; preds = %173, %169, %154, %135, %119, %101, %90, %74, %51
  %175 = load ptr, ptr %16, align 8, !tbaa !5
  invoke void @gost28147_free(ptr noundef %175)
          to label %176 unwind label %52

176:                                              ; preds = %174
  %177 = load i32, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret i32 %177

178:                                              ; preds = %52, %44, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  br label %179

179:                                              ; preds = %178, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %180

180:                                              ; preds = %179
  %181 = load ptr, ptr %14, align 8
  %182 = load i32, ptr %15, align 4
  %183 = insertvalue { ptr, i32 } poison, ptr %181, 0
  %184 = insertvalue { ptr, i32 } %183, i32 %182, 1
  resume { ptr, i32 } %184
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7UapkiNS6Cipher9Gost2814712decodeParamsEPK12ByteArray_stPPS2_S6_b(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK7UapkiNS7SmartBA4sizeEv(ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

declare ptr @gost28147_alloc_user_sbox(ptr noundef) #4

declare ptr @gost28147_alloc(i32 noundef) #4

declare i32 @gost28147_init_ctr(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @gost28147_init_cfb(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @gost28147_encrypt(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @gost28147_decrypt(ptr noundef, ptr noundef, ptr noundef) #4

declare void @gost28147_free(ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 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 = { 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 #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 = { "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 }

!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 = !{!"_ZTSN7UapkiNS6Cipher9DirectionE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 32}
!14 = !{!"_ZTSN7UapkiNS19AlgorithmIdentifierE", !15, i64 0, !6, i64 32}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"long", !7, i64 0}


; 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 }
%"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" = type { i8 }

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@OID_GOST28147_CTR = external local_unnamed_addr global ptr, align 8
@OID_GOST28147_CFB = 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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 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 #1 align 2

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

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

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

; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7UapkiNS6Cipher9Gost281479cryptDataERKNS_19AlgorithmIdentifierEPK12ByteArray_stNS0_9DirectionES7_PPS5_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.UapkiNS::SmartBA", align 8
  %7 = alloca %"class.UapkiNS::SmartBA", align 8
  %8 = alloca %"class.std::__cxx11::basic_string", align 8
  %9 = alloca %"class.std::allocator", align 1
  %10 = alloca %"class.std::__cxx11::basic_string", align 8
  %11 = alloca %"class.std::allocator", align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  call void @_ZN7UapkiNS7SmartBAC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  call void @_ZN7UapkiNS7SmartBAC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  %12 = load ptr, ptr @OID_GOST28147_CTR, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef %12, ptr noundef nonnull align 1 dereferenceable(1) %9)
          to label %13 unwind label %15

13:                                               ; preds = %5
  %14 = call noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %8) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  br i1 %14, label %26, label %17

15:                                               ; preds = %5
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  br label %69

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %10) #5
  %18 = load ptr, ptr @OID_GOST28147_CFB, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %11) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef %18, ptr noundef nonnull align 1 dereferenceable(1) %11)
          to label %19 unwind label %21

19:                                               ; preds = %17
  %20 = call noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %10) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #5
  br i1 %20, label %26, label %23

21:                                               ; preds = %17
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #5
  br label %69

23:                                               ; preds = %19
  invoke void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 154, i32 noundef 4110, ptr noundef null)
          to label %67 unwind label %24

24:                                               ; preds = %.invoke, %67, %66, %63, %62, %59, %56, %53, %52, %49, %42, %37, %34, %33, %26, %23
  %25 = landingpad { ptr, i32 }
          cleanup
  br label %69

26:                                               ; preds = %19, %13
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = call noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  %30 = call noundef ptr @_ZN7UapkiNS7SmartBAadEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %31 = invoke noundef i32 @_ZN7UapkiNS6Cipher9Gost2814712decodeParamsEPK12ByteArray_stPPS2_S6_b(ptr noundef %28, ptr noundef %29, ptr noundef %30, i1 noundef zeroext false)
          to label %32 unwind label %24

32:                                               ; preds = %26
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %34, label %33

33:                                               ; preds = %32
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 157, i32 noundef %31)
          to label %67 unwind label %24

34:                                               ; preds = %32
  %35 = invoke noundef i64 @_ZNK7UapkiNS7SmartBA4sizeEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %36 unwind label %24

36:                                               ; preds = %34
  %.not46 = icmp eq i64 %35, 0
  br i1 %.not46, label %42, label %37

37:                                               ; preds = %36
  %38 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %39 = invoke ptr @gost28147_alloc_user_sbox(ptr noundef %38)
          to label %40 unwind label %24

40:                                               ; preds = %37
  %41 = icmp eq ptr %39, null
  br i1 %41, label %.invoke, label %47

42:                                               ; preds = %36
  %43 = invoke ptr @gost28147_alloc(i32 noundef 0)
          to label %44 unwind label %24

44:                                               ; preds = %42
  %45 = icmp eq ptr %43, null
  br i1 %45, label %.invoke, label %47

.invoke:                                          ; preds = %44, %40
  %46 = phi i64 [ 159, %40 ], [ 162, %44 ]
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef %46, i32 noundef 2)
          to label %67 unwind label %24

47:                                               ; preds = %44, %40
  %.031 = phi ptr [ %39, %40 ], [ %43, %44 ]
  %48 = call noundef ptr @_ZNK7UapkiNS7SmartBA3getEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
  br i1 %14, label %49, label %53

49:                                               ; preds = %47
  %50 = invoke i32 @gost28147_init_ctr(ptr noundef nonnull %.031, ptr noundef %1, ptr noundef %48)
          to label %51 unwind label %24

51:                                               ; preds = %49
  %.not48 = icmp eq i32 %50, 0
  br i1 %.not48, label %57, label %52

52:                                               ; preds = %51
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 167, i32 noundef %50)
          to label %67 unwind label %24

53:                                               ; preds = %47
  %54 = invoke i32 @gost28147_init_cfb(ptr noundef nonnull %.031, ptr noundef %1, ptr noundef %48)
          to label %55 unwind label %24

55:                                               ; preds = %53
  %.not47 = icmp eq i32 %54, 0
  br i1 %.not47, label %57, label %56

56:                                               ; preds = %55
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 170, i32 noundef %54)
          to label %67 unwind label %24

57:                                               ; preds = %55, %51
  %58 = icmp eq i32 %2, 0
  br i1 %58, label %59, label %63

59:                                               ; preds = %57
  %60 = invoke i32 @gost28147_encrypt(ptr noundef nonnull %.031, ptr noundef %3, ptr noundef %4)
          to label %61 unwind label %24

61:                                               ; preds = %59
  %.not50 = icmp eq i32 %60, 0
  br i1 %.not50, label %67, label %62

62:                                               ; preds = %61
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 177, i32 noundef %60)
          to label %67 unwind label %24

63:                                               ; preds = %57
  %64 = invoke i32 @gost28147_decrypt(ptr noundef nonnull %.031, ptr noundef %3, ptr noundef %4)
          to label %65 unwind label %24

65:                                               ; preds = %63
  %.not49 = icmp eq i32 %64, 0
  br i1 %.not49, label %67, label %66

66:                                               ; preds = %65
  invoke void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 180, i32 noundef %64)
          to label %67 unwind label %24

67:                                               ; preds = %.invoke, %61, %65, %66, %62, %56, %52, %33, %23
  %.034 = phi i32 [ %31, %33 ], [ %60, %62 ], [ 0, %61 ], [ %64, %66 ], [ 0, %65 ], [ %54, %56 ], [ %50, %52 ], [ 4110, %23 ], [ 2, %.invoke ]
  %.1 = phi ptr [ null, %33 ], [ %.031, %62 ], [ %.031, %61 ], [ %.031, %66 ], [ %.031, %65 ], [ %.031, %56 ], [ %.031, %52 ], [ null, %23 ], [ null, %.invoke ]
  invoke void @gost28147_free(ptr noundef %.1)
          to label %68 unwind label %24

68:                                               ; preds = %67
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  ret i32 %.034

69:                                               ; preds = %24, %21, %15
  %.pn = phi { ptr, i32 } [ %25, %24 ], [ %22, %21 ], [ %16, %15 ]
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @_ZN7UapkiNS7SmartBAD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7UapkiNS6Cipher9Gost2814712decodeParamsEPK12ByteArray_stPPS2_S6_b(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #3 align 2

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

declare ptr @gost28147_alloc_user_sbox(ptr noundef) local_unnamed_addr #4

declare ptr @gost28147_alloc(i32 noundef) local_unnamed_addr #4

declare i32 @gost28147_init_ctr(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @gost28147_init_cfb(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @gost28147_encrypt(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @gost28147_decrypt(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @gost28147_free(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 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 = { 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 #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 = { "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 }

!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 32}
!10 = !{!"_ZTSN7UapkiNS19AlgorithmIdentifierE", !11, i64 0, !6, i64 32}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!13 = !{!"long", !7, i64 0}


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