; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (key-wrap)

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

@.str = external hidden unnamed_addr constant [23 x i8], align 1
@OID_DSTU7624_WRAP = external global ptr, align 8
@OID_GOST28147_WRAP = external global ptr, align 8
@OID_AES256_WRAP = external global ptr, align 8

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @hash_from_oid_dhkdf(ptr noundef, ptr noundef) #2

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

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

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

declare i32 @private_key_ecdh(i1 noundef zeroext, ptr noundef, ptr noundef, ptr noundef) #1

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

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

declare void @ba_free(ptr noundef) #1

declare ptr @aes_alloc() #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @dke_to_sbox(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

declare void @aes_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @key_unwrap(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #2 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i8, align 1
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca ptr, align 8
  %28 = alloca i64, align 8
  %29 = alloca i32, align 4
  %30 = alloca i64, align 8
  %31 = alloca i64, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store i64 %3, ptr %13, align 8, !tbaa !9
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store ptr null, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  store ptr null, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  store ptr null, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  store ptr null, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #5
  store ptr null, ptr %25, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #5
  store ptr null, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #5
  store ptr null, ptr %27, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %8
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %37, label %35

35:                                               ; preds = %32
  store i32 2, ptr %18, align 4, !tbaa !11
  %36 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 238, i32 noundef %36, ptr noundef null)
  br label %330

37:                                               ; preds = %32
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %45, label %43

43:                                               ; preds = %40
  store i32 2, ptr %18, align 4, !tbaa !11
  %44 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 239, i32 noundef %44, ptr noundef null)
  br label %330

45:                                               ; preds = %40
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %53, label %51

51:                                               ; preds = %48
  store i32 2, ptr %18, align 4, !tbaa !11
  %52 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 240, i32 noundef %52, ptr noundef null)
  br label %330

53:                                               ; preds = %48
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  %57 = load i64, ptr %13, align 8, !tbaa !9
  %58 = icmp ugt i64 %57, 0
  br i1 %58, label %61, label %59

59:                                               ; preds = %56
  store i32 2, ptr %18, align 4, !tbaa !11
  %60 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 241, i32 noundef %60, ptr noundef null)
  br label %330

61:                                               ; preds = %56
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %69, label %67

67:                                               ; preds = %64
  store i32 2, ptr %18, align 4, !tbaa !11
  %68 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 242, i32 noundef %68, ptr noundef null)
  br label %330

69:                                               ; preds = %64
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr %16, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %77, label %75

75:                                               ; preds = %72
  store i32 2, ptr %18, align 4, !tbaa !11
  %76 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 243, i32 noundef %76, ptr noundef null)
  br label %330

77:                                               ; preds = %72
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr %17, align 8, !tbaa !5
  %82 = icmp ne ptr %81, null
  br i1 %82, label %85, label %83

83:                                               ; preds = %80
  store i32 2, ptr %18, align 4, !tbaa !11
  %84 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 244, i32 noundef %84, ptr noundef null)
  br label %330

85:                                               ; preds = %80
  br label %86

86:                                               ; preds = %85
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = call i32 @hash_from_oid_dhkdf(ptr noundef %88, ptr noundef %20)
  store i32 %89, ptr %19, align 4, !tbaa !11
  %90 = load i32, ptr %19, align 4, !tbaa !11
  %91 = icmp eq i32 %90, 0
  br i1 %91, label %92, label %97

92:                                               ; preds = %87
  br label %93

93:                                               ; preds = %92
  store i32 1051, ptr %18, align 4, !tbaa !11
  %94 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 249, i32 noundef %94, ptr noundef null)
  br label %330

95:                                               ; No predecessors!
  br label %96

96:                                               ; preds = %95
  br label %97

97:                                               ; preds = %96, %87
  %98 = load ptr, ptr @OID_DSTU7624_WRAP, align 8, !tbaa !5
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = call zeroext i1 @oid_is_equal(ptr noundef %98, ptr noundef %99)
  br i1 %100, label %114, label %101

101:                                              ; preds = %97
  %102 = load ptr, ptr @OID_GOST28147_WRAP, align 8, !tbaa !5
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = call zeroext i1 @oid_is_equal(ptr noundef %102, ptr noundef %103)
  br i1 %104, label %114, label %105

105:                                              ; preds = %101
  %106 = load ptr, ptr @OID_AES256_WRAP, align 8, !tbaa !5
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = call zeroext i1 @oid_is_equal(ptr noundef %106, ptr noundef %107)
  br i1 %108, label %114, label %109

109:                                              ; preds = %105
  br label %110

110:                                              ; preds = %109
  store i32 1048, ptr %18, align 4, !tbaa !11
  %111 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 256, i32 noundef %111, ptr noundef null)
  br label %330

112:                                              ; No predecessors!
  br label %113

113:                                              ; preds = %112
  br label %114

114:                                              ; preds = %113, %105, %101, %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #5
  store i64 0, ptr %28, align 8, !tbaa !9
  br label %115

115:                                              ; preds = %143, %114
  %116 = load i64, ptr %28, align 8, !tbaa !9
  %117 = load i64, ptr %13, align 8, !tbaa !9
  %118 = icmp ult i64 %116, %117
  br i1 %118, label %120, label %119

119:                                              ; preds = %115
  store i32 21, ptr %29, align 4
  br label %146

120:                                              ; preds = %115
  br label %121

121:                                              ; preds = %120
  %122 = load ptr, ptr %14, align 8, !tbaa !5
  %123 = load i64, ptr %28, align 8, !tbaa !9
  %124 = getelementptr inbounds ptr, ptr %122, i64 %123
  %125 = load ptr, ptr %124, align 8, !tbaa !5
  %126 = icmp ne ptr %125, null
  br i1 %126, label %129, label %127

127:                                              ; preds = %121
  store i32 2, ptr %18, align 4, !tbaa !11
  %128 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 260, i32 noundef %128, ptr noundef null)
  store i32 4, ptr %29, align 4
  br label %146

129:                                              ; preds = %121
  br label %130

130:                                              ; preds = %129
  br label %131

131:                                              ; preds = %130
  br label %132

132:                                              ; preds = %131
  %133 = load ptr, ptr %16, align 8, !tbaa !5
  %134 = load i64, ptr %28, align 8, !tbaa !9
  %135 = getelementptr inbounds ptr, ptr %133, i64 %134
  %136 = load ptr, ptr %135, align 8, !tbaa !5
  %137 = icmp ne ptr %136, null
  br i1 %137, label %140, label %138

138:                                              ; preds = %132
  store i32 2, ptr %18, align 4, !tbaa !11
  %139 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 261, i32 noundef %139, ptr noundef null)
  store i32 4, ptr %29, align 4
  br label %146

140:                                              ; preds = %132
  br label %141

141:                                              ; preds = %140
  br label %142

142:                                              ; preds = %141
  br label %143

143:                                              ; preds = %142
  %144 = load i64, ptr %28, align 8, !tbaa !9
  %145 = add i64 %144, 1
  store i64 %145, ptr %28, align 8, !tbaa !9
  br label %115, !llvm.loop !13

146:                                              ; preds = %138, %127, %119
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #5
  %147 = load i32, ptr %29, align 4
  switch i32 %147, label %360 [
    i32 21, label %148
    i32 4, label %330
  ]

148:                                              ; preds = %146
  br label %149

149:                                              ; preds = %148
  %150 = load i64, ptr %13, align 8, !tbaa !9
  %151 = mul i64 8, %150
  %152 = call noalias ptr @calloc(i64 noundef 1, i64 noundef %151) #6
  store ptr %152, ptr %21, align 8, !tbaa !5
  %153 = icmp eq ptr null, %152
  br i1 %153, label %154, label %156

154:                                              ; preds = %149
  store i32 1, ptr %18, align 4, !tbaa !11
  %155 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 264, i32 noundef %155, ptr noundef null)
  br label %330

156:                                              ; preds = %149
  br label %157

157:                                              ; preds = %156
  br label %158

158:                                              ; preds = %157
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #5
  store i64 0, ptr %30, align 8, !tbaa !9
  br label %159

159:                                              ; preds = %322, %158
  %160 = load i64, ptr %30, align 8, !tbaa !9
  %161 = load i64, ptr %13, align 8, !tbaa !9
  %162 = icmp ult i64 %160, %161
  br i1 %162, label %164, label %163

163:                                              ; preds = %159
  store i32 30, ptr %29, align 4
  br label %325

164:                                              ; preds = %159
  br label %165

165:                                              ; preds = %164
  %166 = load i8, ptr %20, align 1, !tbaa !15, !range !17, !noundef !18
  %167 = trunc i8 %166 to i1
  %168 = load ptr, ptr %10, align 8, !tbaa !5
  %169 = load ptr, ptr %14, align 8, !tbaa !5
  %170 = load i64, ptr %30, align 8, !tbaa !9
  %171 = getelementptr inbounds ptr, ptr %169, i64 %170
  %172 = load ptr, ptr %171, align 8, !tbaa !5
  %173 = call i32 @private_key_ecdh(i1 noundef zeroext %167, ptr noundef %168, ptr noundef %172, ptr noundef %22)
  store i32 %173, ptr %18, align 4, !tbaa !11
  %174 = load i32, ptr %18, align 4, !tbaa !11
  %175 = icmp ne i32 %174, 0
  br i1 %175, label %176, label %178

176:                                              ; preds = %165
  %177 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 269, i32 noundef %177)
  store i32 4, ptr %29, align 4
  br label %325

178:                                              ; preds = %165
  br label %179

179:                                              ; preds = %178
  br label %180

180:                                              ; preds = %179
  br label %181

181:                                              ; preds = %180
  %182 = load i32, ptr %19, align 4, !tbaa !11
  %183 = load ptr, ptr %12, align 8, !tbaa !5
  %184 = load ptr, ptr %15, align 8, !tbaa !5
  %185 = icmp ne ptr %184, null
  br i1 %185, label %186, label %191

186:                                              ; preds = %181
  %187 = load ptr, ptr %15, align 8, !tbaa !5
  %188 = load i64, ptr %30, align 8, !tbaa !9
  %189 = getelementptr inbounds ptr, ptr %187, i64 %188
  %190 = load ptr, ptr %189, align 8, !tbaa !5
  br label %192

191:                                              ; preds = %181
  br label %192

192:                                              ; preds = %191, %186
  %193 = phi ptr [ %190, %186 ], [ null, %191 ]
  %194 = load ptr, ptr %22, align 8, !tbaa !5
  %195 = call i32 @iso15946_generate_secretc(i32 noundef %182, ptr noundef %183, ptr noundef %193, ptr noundef %194, ptr noundef %23)
  store i32 %195, ptr %18, align 4, !tbaa !11
  %196 = load i32, ptr %18, align 4, !tbaa !11
  %197 = icmp ne i32 %196, 0
  br i1 %197, label %198, label %200

198:                                              ; preds = %192
  %199 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 272, i32 noundef %199)
  store i32 4, ptr %29, align 4
  br label %325

200:                                              ; preds = %192
  br label %201

201:                                              ; preds = %200
  br label %202

202:                                              ; preds = %201
  %203 = load ptr, ptr %22, align 8, !tbaa !5
  call void @ba_free(ptr noundef %203)
  store ptr null, ptr %22, align 8, !tbaa !5
  %204 = load ptr, ptr @OID_DSTU7624_WRAP, align 8, !tbaa !5
  %205 = load ptr, ptr %12, align 8, !tbaa !5
  %206 = call zeroext i1 @oid_is_equal(ptr noundef %204, ptr noundef %205)
  br i1 %206, label %207, label %225

207:                                              ; preds = %202
  br label %208

208:                                              ; preds = %207
  %209 = load ptr, ptr %23, align 8, !tbaa !5
  %210 = load ptr, ptr %16, align 8, !tbaa !5
  %211 = load i64, ptr %30, align 8, !tbaa !9
  %212 = getelementptr inbounds ptr, ptr %210, i64 %211
  %213 = load ptr, ptr %212, align 8, !tbaa !5
  %214 = load ptr, ptr %21, align 8, !tbaa !5
  %215 = load i64, ptr %30, align 8, !tbaa !9
  %216 = getelementptr inbounds ptr, ptr %214, i64 %215
  %217 = call i32 @key_unwrap_dstu7624(ptr noundef %209, ptr noundef %213, ptr noundef %216)
  store i32 %217, ptr %18, align 4, !tbaa !11
  %218 = load i32, ptr %18, align 4, !tbaa !11
  %219 = icmp ne i32 %218, 0
  br i1 %219, label %220, label %222

220:                                              ; preds = %208
  %221 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 278, i32 noundef %221)
  store i32 4, ptr %29, align 4
  br label %325

222:                                              ; preds = %208
  br label %223

223:                                              ; preds = %222
  br label %224

224:                                              ; preds = %223
  br label %320

225:                                              ; preds = %202
  %226 = load ptr, ptr @OID_AES256_WRAP, align 8, !tbaa !5
  %227 = load ptr, ptr %12, align 8, !tbaa !5
  %228 = call zeroext i1 @oid_is_equal(ptr noundef %226, ptr noundef %227)
  br i1 %228, label %229, label %266

229:                                              ; preds = %225
  br label %230

230:                                              ; preds = %229
  %231 = call ptr @aes_alloc()
  store ptr %231, ptr %27, align 8, !tbaa !5
  %232 = icmp eq ptr null, %231
  br i1 %232, label %233, label %235

233:                                              ; preds = %230
  store i32 2, ptr %18, align 4, !tbaa !11
  %234 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 281, i32 noundef %234)
  store i32 4, ptr %29, align 4
  br label %325

235:                                              ; preds = %230
  br label %236

236:                                              ; preds = %235
  br label %237

237:                                              ; preds = %236
  br label %238

238:                                              ; preds = %237
  %239 = load ptr, ptr %27, align 8, !tbaa !5
  %240 = load ptr, ptr %23, align 8, !tbaa !5
  %241 = call i32 @aes_init_wrap(ptr noundef %239, ptr noundef %240, ptr noundef null)
  store i32 %241, ptr %18, align 4, !tbaa !11
  %242 = load i32, ptr %18, align 4, !tbaa !11
  %243 = icmp ne i32 %242, 0
  br i1 %243, label %244, label %246

244:                                              ; preds = %238
  %245 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 282, i32 noundef %245)
  store i32 4, ptr %29, align 4
  br label %325

246:                                              ; preds = %238
  br label %247

247:                                              ; preds = %246
  br label %248

248:                                              ; preds = %247
  br label %249

249:                                              ; preds = %248
  %250 = load ptr, ptr %27, align 8, !tbaa !5
  %251 = load ptr, ptr %16, align 8, !tbaa !5
  %252 = load i64, ptr %30, align 8, !tbaa !9
  %253 = getelementptr inbounds ptr, ptr %251, i64 %252
  %254 = load ptr, ptr %253, align 8, !tbaa !5
  %255 = load ptr, ptr %21, align 8, !tbaa !5
  %256 = load i64, ptr %30, align 8, !tbaa !9
  %257 = getelementptr inbounds ptr, ptr %255, i64 %256
  %258 = call i32 @aes_decrypt(ptr noundef %250, ptr noundef %254, ptr noundef %257)
  store i32 %258, ptr %18, align 4, !tbaa !11
  %259 = load i32, ptr %18, align 4, !tbaa !11
  %260 = icmp ne i32 %259, 0
  br i1 %260, label %261, label %263

261:                                              ; preds = %249
  %262 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 283, i32 noundef %262)
  store i32 4, ptr %29, align 4
  br label %325

263:                                              ; preds = %249
  br label %264

264:                                              ; preds = %263
  br label %265

265:                                              ; preds = %264
  br label %319

266:                                              ; preds = %225
  br label %267

267:                                              ; preds = %266
  %268 = load ptr, ptr %10, align 8, !tbaa !5
  %269 = call i32 @private_key_get_spki(ptr noundef %268, ptr noundef %24)
  store i32 %269, ptr %18, align 4, !tbaa !11
  %270 = load i32, ptr %18, align 4, !tbaa !11
  %271 = icmp ne i32 %270, 0
  br i1 %271, label %272, label %274

272:                                              ; preds = %267
  %273 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 286, i32 noundef %273)
  store i32 4, ptr %29, align 4
  br label %325

274:                                              ; preds = %267
  br label %275

275:                                              ; preds = %274
  br label %276

276:                                              ; preds = %275
  br label %277

277:                                              ; preds = %276
  %278 = load ptr, ptr %24, align 8, !tbaa !5
  %279 = call i32 @spki_get_dstu_dke(ptr noundef %278, ptr noundef %25)
  store i32 %279, ptr %18, align 4, !tbaa !11
  %280 = load i32, ptr %18, align 4, !tbaa !11
  %281 = icmp ne i32 %280, 0
  br i1 %281, label %282, label %284

282:                                              ; preds = %277
  %283 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 287, i32 noundef %283)
  store i32 4, ptr %29, align 4
  br label %325

284:                                              ; preds = %277
  br label %285

285:                                              ; preds = %284
  br label %286

286:                                              ; preds = %285
  %287 = load ptr, ptr %25, align 8, !tbaa !5
  %288 = icmp ne ptr %287, null
  br i1 %288, label %289, label %300

289:                                              ; preds = %286
  br label %290

290:                                              ; preds = %289
  %291 = load ptr, ptr %25, align 8, !tbaa !5
  %292 = call i32 @dke_to_sbox(ptr noundef %291, ptr noundef %26)
  store i32 %292, ptr %18, align 4, !tbaa !11
  %293 = load i32, ptr %18, align 4, !tbaa !11
  %294 = icmp ne i32 %293, 0
  br i1 %294, label %295, label %297

295:                                              ; preds = %290
  %296 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 290, i32 noundef %296)
  store i32 4, ptr %29, align 4
  br label %325

297:                                              ; preds = %290
  br label %298

298:                                              ; preds = %297
  br label %299

299:                                              ; preds = %298
  br label %300

300:                                              ; preds = %299, %286
  br label %301

301:                                              ; preds = %300
  %302 = load ptr, ptr %26, align 8, !tbaa !5
  %303 = load ptr, ptr %23, align 8, !tbaa !5
  %304 = load ptr, ptr %16, align 8, !tbaa !5
  %305 = load i64, ptr %30, align 8, !tbaa !9
  %306 = getelementptr inbounds ptr, ptr %304, i64 %305
  %307 = load ptr, ptr %306, align 8, !tbaa !5
  %308 = load ptr, ptr %21, align 8, !tbaa !5
  %309 = load i64, ptr %30, align 8, !tbaa !9
  %310 = getelementptr inbounds ptr, ptr %308, i64 %309
  %311 = call i32 @key_unwrap_gost28147(ptr noundef %302, ptr noundef %303, ptr noundef %307, ptr noundef %310)
  store i32 %311, ptr %18, align 4, !tbaa !11
  %312 = load i32, ptr %18, align 4, !tbaa !11
  %313 = icmp ne i32 %312, 0
  br i1 %313, label %314, label %316

314:                                              ; preds = %301
  %315 = load i32, ptr %18, align 4, !tbaa !11
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 294, i32 noundef %315)
  store i32 4, ptr %29, align 4
  br label %325

316:                                              ; preds = %301
  br label %317

317:                                              ; preds = %316
  br label %318

318:                                              ; preds = %317
  br label %319

319:                                              ; preds = %318, %265
  br label %320

320:                                              ; preds = %319, %224
  %321 = load ptr, ptr %23, align 8, !tbaa !5
  call void @ba_free(ptr noundef %321)
  store ptr null, ptr %23, align 8, !tbaa !5
  br label %322

322:                                              ; preds = %320
  %323 = load i64, ptr %30, align 8, !tbaa !9
  %324 = add i64 %323, 1
  store i64 %324, ptr %30, align 8, !tbaa !9
  br label %159, !llvm.loop !19

325:                                              ; preds = %314, %295, %282, %272, %261, %244, %233, %220, %198, %176, %163
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #5
  %326 = load i32, ptr %29, align 4
  switch i32 %326, label %360 [
    i32 30, label %327
    i32 4, label %330
  ]

327:                                              ; preds = %325
  %328 = load ptr, ptr %21, align 8, !tbaa !5
  %329 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %328, ptr %329, align 8, !tbaa !5
  store ptr null, ptr %21, align 8, !tbaa !5
  br label %330

330:                                              ; preds = %327, %325, %154, %146, %110, %93, %83, %75, %67, %59, %51, %43, %35
  %331 = load i32, ptr %18, align 4, !tbaa !11
  %332 = icmp ne i32 %331, 0
  br i1 %332, label %333, label %351

333:                                              ; preds = %330
  %334 = load ptr, ptr %21, align 8, !tbaa !5
  %335 = icmp ne ptr %334, null
  br i1 %335, label %336, label %351

336:                                              ; preds = %333
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #5
  store i64 0, ptr %31, align 8, !tbaa !9
  br label %337

337:                                              ; preds = %347, %336
  %338 = load i64, ptr %31, align 8, !tbaa !9
  %339 = load i64, ptr %13, align 8, !tbaa !9
  %340 = icmp ult i64 %338, %339
  br i1 %340, label %342, label %341

341:                                              ; preds = %337
  store i32 53, ptr %29, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #5
  br label %350

342:                                              ; preds = %337
  %343 = load ptr, ptr %21, align 8, !tbaa !5
  %344 = load i64, ptr %31, align 8, !tbaa !9
  %345 = getelementptr inbounds ptr, ptr %343, i64 %344
  %346 = load ptr, ptr %345, align 8, !tbaa !5
  call void @ba_free(ptr noundef %346)
  br label %347

347:                                              ; preds = %342
  %348 = load i64, ptr %31, align 8, !tbaa !9
  %349 = add i64 %348, 1
  store i64 %349, ptr %31, align 8, !tbaa !9
  br label %337, !llvm.loop !20

350:                                              ; preds = %341
  br label %351

351:                                              ; preds = %350, %333, %330
  %352 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %352) #5
  %353 = load ptr, ptr %22, align 8, !tbaa !5
  call void @ba_free(ptr noundef %353)
  %354 = load ptr, ptr %23, align 8, !tbaa !5
  call void @ba_free(ptr noundef %354)
  %355 = load ptr, ptr %24, align 8, !tbaa !5
  call void @ba_free(ptr noundef %355)
  %356 = load ptr, ptr %25, align 8, !tbaa !5
  call void @ba_free(ptr noundef %356)
  %357 = load ptr, ptr %26, align 8, !tbaa !5
  call void @ba_free(ptr noundef %357)
  %358 = load ptr, ptr %27, align 8, !tbaa !5
  call void @aes_free(ptr noundef %358)
  %359 = load i32, ptr %18, align 4, !tbaa !11
  store i32 %359, ptr %9, align 4
  store i32 1, ptr %29, align 4
  br label %360

360:                                              ; preds = %351, %325, %146
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  %361 = load i32, ptr %9, align 4
  ret i32 %361
}

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

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

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

declare i32 @key_unwrap_gost28147(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #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 = { 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 = { nounwind allocsize(0,1) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [23 x i8], align 1
@OID_DSTU7624_WRAP = external local_unnamed_addr global ptr, align 8
@OID_GOST28147_WRAP = external local_unnamed_addr global ptr, align 8
@OID_AES256_WRAP = external local_unnamed_addr global ptr, align 8

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @hash_from_oid_dhkdf(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

declare i32 @private_key_ecdh(i1 noundef zeroext, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

declare void @ba_free(ptr noundef) local_unnamed_addr #1

declare ptr @aes_alloc() local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @dke_to_sbox(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

declare void @aes_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @key_unwrap(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef readonly %4, ptr noundef readonly %5, ptr noundef readonly %6, ptr noundef writeonly %7) local_unnamed_addr #2 {
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #5
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #5
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #5
  store ptr null, ptr %14, align 8, !tbaa !5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %15, label %16

15:                                               ; preds = %8
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 238, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

16:                                               ; preds = %8
  %.not131 = icmp eq ptr %1, null
  br i1 %.not131, label %17, label %18

17:                                               ; preds = %16
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 239, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

18:                                               ; preds = %16
  %.not132 = icmp eq ptr %2, null
  br i1 %.not132, label %19, label %20

19:                                               ; preds = %18
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 240, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

20:                                               ; preds = %18
  %.not133 = icmp eq i64 %3, 0
  br i1 %.not133, label %21, label %22

21:                                               ; preds = %20
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 241, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

22:                                               ; preds = %20
  %.not134 = icmp eq ptr %4, null
  br i1 %.not134, label %23, label %24

23:                                               ; preds = %22
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 242, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

24:                                               ; preds = %22
  %.not135 = icmp eq ptr %6, null
  br i1 %.not135, label %25, label %26

25:                                               ; preds = %24
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 243, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

26:                                               ; preds = %24
  %.not136 = icmp eq ptr %7, null
  br i1 %.not136, label %27, label %28

27:                                               ; preds = %26
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 244, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

28:                                               ; preds = %26
  %29 = call i32 @hash_from_oid_dhkdf(ptr noundef nonnull %1, ptr noundef nonnull %9)
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 249, i32 noundef 1051, ptr noundef null) #5
  br label %.thread158

32:                                               ; preds = %28
  %33 = load ptr, ptr @OID_DSTU7624_WRAP, align 8, !tbaa !5
  %34 = call zeroext i1 @oid_is_equal(ptr noundef %33, ptr noundef nonnull %2) #5
  br i1 %34, label %.preheader400, label %35

.preheader400:                                    ; preds = %38, %35, %32
  br label %44

35:                                               ; preds = %32
  %36 = load ptr, ptr @OID_GOST28147_WRAP, align 8, !tbaa !5
  %37 = call zeroext i1 @oid_is_equal(ptr noundef %36, ptr noundef nonnull %2) #5
  br i1 %37, label %.preheader400, label %38

38:                                               ; preds = %35
  %39 = load ptr, ptr @OID_AES256_WRAP, align 8, !tbaa !5
  %40 = call zeroext i1 @oid_is_equal(ptr noundef %39, ptr noundef nonnull %2) #5
  br i1 %40, label %.preheader400, label %41

41:                                               ; preds = %38
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 256, i32 noundef 1048, ptr noundef null) #5
  br label %.thread158

42:                                               ; preds = %48
  %43 = add nuw i64 %.096210, 1
  %exitcond.not = icmp eq i64 %43, %3
  br i1 %exitcond.not, label %52, label %44, !llvm.loop !9

44:                                               ; preds = %.preheader400, %42
  %.096210 = phi i64 [ %43, %42 ], [ 0, %.preheader400 ]
  %45 = getelementptr inbounds ptr, ptr %4, i64 %.096210
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %.not137 = icmp eq ptr %46, null
  br i1 %.not137, label %47, label %48

47:                                               ; preds = %44
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 260, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

48:                                               ; preds = %44
  %49 = getelementptr inbounds ptr, ptr %6, i64 %.096210
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %.not138 = icmp eq ptr %50, null
  br i1 %.not138, label %51, label %42

51:                                               ; preds = %48
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 261, i32 noundef 2, ptr noundef null) #5
  br label %.thread158

52:                                               ; preds = %42
  %53 = shl i64 %3, 3
  %54 = call noalias ptr @calloc(i64 noundef 1, i64 noundef %53) #6
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %.preheader

.preheader:                                       ; preds = %52
  %.not140 = icmp eq ptr %5, null
  br label %57

56:                                               ; preds = %52
  call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 264, i32 noundef 1, ptr noundef null) #5
  br label %.thread158

57:                                               ; preds = %.preheader, %121
  %.094212 = phi i64 [ 0, %.preheader ], [ %123, %121 ]
  %.097211 = phi ptr [ null, %.preheader ], [ %.198, %121 ]
  %58 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %59 = trunc nuw i8 %58 to i1
  %60 = getelementptr inbounds ptr, ptr %4, i64 %.094212
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = call i32 @private_key_ecdh(i1 noundef zeroext %59, ptr noundef nonnull %0, ptr noundef %61, ptr noundef nonnull %10) #5
  %.not139 = icmp eq i32 %62, 0
  br i1 %.not139, label %64, label %63

63:                                               ; preds = %57
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 269, i32 noundef %62) #5
  br label %125

64:                                               ; preds = %57
  br i1 %.not140, label %68, label %65

65:                                               ; preds = %64
  %66 = getelementptr inbounds ptr, ptr %5, i64 %.094212
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %64, %65
  %69 = phi ptr [ %67, %65 ], [ null, %64 ]
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = call i32 @iso15946_generate_secretc(i32 noundef %29, ptr noundef nonnull %2, ptr noundef %69, ptr noundef %70, ptr noundef nonnull %11) #5
  %.not141 = icmp eq i32 %71, 0
  br i1 %.not141, label %73, label %72

72:                                               ; preds = %68
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 272, i32 noundef %71) #5
  br label %125

73:                                               ; preds = %68
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ba_free(ptr noundef %74) #5
  store ptr null, ptr %10, align 8, !tbaa !5
  %75 = load ptr, ptr @OID_DSTU7624_WRAP, align 8, !tbaa !5
  %76 = call zeroext i1 @oid_is_equal(ptr noundef %75, ptr noundef nonnull %2) #5
  br i1 %76, label %77, label %84

77:                                               ; preds = %73
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds ptr, ptr %6, i64 %.094212
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = getelementptr inbounds ptr, ptr %54, i64 %.094212
  %82 = call i32 @key_unwrap_dstu7624(ptr noundef %78, ptr noundef %80, ptr noundef nonnull %81) #5
  %.not149 = icmp eq i32 %82, 0
  br i1 %.not149, label %121, label %83

83:                                               ; preds = %77
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 278, i32 noundef %82) #5
  br label %125

84:                                               ; preds = %73
  %85 = load ptr, ptr @OID_AES256_WRAP, align 8, !tbaa !5
  %86 = call zeroext i1 @oid_is_equal(ptr noundef %85, ptr noundef nonnull %2) #5
  br i1 %86, label %87, label %101

87:                                               ; preds = %84
  %88 = call ptr @aes_alloc() #5
  %89 = icmp eq ptr %88, null
  br i1 %89, label %90, label %91

90:                                               ; preds = %87
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 281, i32 noundef 2) #5
  br label %125

91:                                               ; preds = %87
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = call i32 @aes_init_wrap(ptr noundef nonnull %88, ptr noundef %92, ptr noundef null) #5
  %.not147 = icmp eq i32 %93, 0
  br i1 %.not147, label %95, label %94

94:                                               ; preds = %91
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 282, i32 noundef %93) #5
  br label %125

95:                                               ; preds = %91
  %96 = getelementptr inbounds ptr, ptr %6, i64 %.094212
  %97 = load ptr, ptr %96, align 8, !tbaa !5
  %98 = getelementptr inbounds ptr, ptr %54, i64 %.094212
  %99 = call i32 @aes_decrypt(ptr noundef nonnull %88, ptr noundef %97, ptr noundef nonnull %98) #5
  %.not148 = icmp eq i32 %99, 0
  br i1 %.not148, label %121, label %100

100:                                              ; preds = %95
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 283, i32 noundef %99) #5
  br label %125

101:                                              ; preds = %84
  %102 = call i32 @private_key_get_spki(ptr noundef nonnull %0, ptr noundef nonnull %12) #5
  %.not142 = icmp eq i32 %102, 0
  br i1 %.not142, label %104, label %103

103:                                              ; preds = %101
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 286, i32 noundef %102) #5
  br label %125

104:                                              ; preds = %101
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  %106 = call i32 @spki_get_dstu_dke(ptr noundef %105, ptr noundef nonnull %13) #5
  %.not143 = icmp eq i32 %106, 0
  br i1 %.not143, label %108, label %107

107:                                              ; preds = %104
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 287, i32 noundef %106) #5
  br label %125

108:                                              ; preds = %104
  %109 = load ptr, ptr %13, align 8, !tbaa !5
  %.not144 = icmp eq ptr %109, null
  br i1 %.not144, label %113, label %110

110:                                              ; preds = %108
  %111 = call i32 @dke_to_sbox(ptr noundef nonnull %109, ptr noundef nonnull %14)
  %.not145 = icmp eq i32 %111, 0
  br i1 %.not145, label %113, label %112

112:                                              ; preds = %110
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 290, i32 noundef %111) #5
  br label %125

113:                                              ; preds = %108, %110
  %114 = load ptr, ptr %14, align 8, !tbaa !5
  %115 = load ptr, ptr %11, align 8, !tbaa !5
  %116 = getelementptr inbounds ptr, ptr %6, i64 %.094212
  %117 = load ptr, ptr %116, align 8, !tbaa !5
  %118 = getelementptr inbounds ptr, ptr %54, i64 %.094212
  %119 = call i32 @key_unwrap_gost28147(ptr noundef %114, ptr noundef %115, ptr noundef %117, ptr noundef nonnull %118) #5
  %.not146 = icmp eq i32 %119, 0
  br i1 %.not146, label %121, label %120

120:                                              ; preds = %113
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 294, i32 noundef %119) #5
  br label %125

121:                                              ; preds = %95, %113, %77
  %.198 = phi ptr [ %.097211, %77 ], [ %88, %95 ], [ %.097211, %113 ]
  %122 = load ptr, ptr %11, align 8, !tbaa !5
  call void @ba_free(ptr noundef %122) #5
  store ptr null, ptr %11, align 8, !tbaa !5
  %123 = add nuw i64 %.094212, 1
  %exitcond260.not = icmp eq i64 %123, %3
  br i1 %exitcond260.not, label %124, label %57, !llvm.loop !15

124:                                              ; preds = %121
  store ptr %54, ptr %7, align 8, !tbaa !5
  br label %.thread158

125:                                              ; preds = %63, %72, %83, %90, %94, %100, %103, %107, %112, %120
  %.3104.ph = phi i32 [ %119, %120 ], [ %111, %112 ], [ %106, %107 ], [ %102, %103 ], [ %99, %100 ], [ %93, %94 ], [ 2, %90 ], [ %82, %83 ], [ %71, %72 ], [ %62, %63 ]
  %.2.ph = phi ptr [ %.097211, %120 ], [ %.097211, %112 ], [ %.097211, %107 ], [ %.097211, %103 ], [ %88, %100 ], [ %88, %94 ], [ null, %90 ], [ %.097211, %83 ], [ %.097211, %72 ], [ %.097211, %63 ]
  br label %126

126:                                              ; preds = %125, %126
  %.0213 = phi i64 [ 0, %125 ], [ %129, %126 ]
  %127 = getelementptr inbounds ptr, ptr %54, i64 %.0213
  %128 = load ptr, ptr %127, align 8, !tbaa !5
  call void @ba_free(ptr noundef %128) #5
  %129 = add nuw i64 %.0213, 1
  %exitcond261.not = icmp eq i64 %129, %3
  br i1 %exitcond261.not, label %.thread158, label %126, !llvm.loop !16

.thread158:                                       ; preds = %126, %47, %51, %15, %17, %19, %21, %23, %25, %27, %41, %56, %31, %124
  %.3165 = phi ptr [ null, %15 ], [ null, %17 ], [ null, %19 ], [ null, %21 ], [ null, %23 ], [ null, %25 ], [ null, %27 ], [ null, %41 ], [ %.198, %124 ], [ null, %56 ], [ null, %31 ], [ null, %51 ], [ null, %47 ], [ %.2.ph, %126 ]
  %.099164 = phi ptr [ null, %15 ], [ null, %17 ], [ null, %19 ], [ null, %21 ], [ null, %23 ], [ null, %25 ], [ null, %27 ], [ null, %41 ], [ null, %124 ], [ null, %56 ], [ null, %31 ], [ null, %51 ], [ null, %47 ], [ %54, %126 ]
  %.4163 = phi i32 [ 2, %15 ], [ 2, %17 ], [ 2, %19 ], [ 2, %21 ], [ 2, %23 ], [ 2, %25 ], [ 2, %27 ], [ 1048, %41 ], [ 0, %124 ], [ 1, %56 ], [ 1051, %31 ], [ 2, %51 ], [ 2, %47 ], [ %.3104.ph, %126 ]
  call void @free(ptr noundef %.099164) #5
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ba_free(ptr noundef %130) #5
  %131 = load ptr, ptr %11, align 8, !tbaa !5
  call void @ba_free(ptr noundef %131) #5
  %132 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ba_free(ptr noundef %132) #5
  %133 = load ptr, ptr %13, align 8, !tbaa !5
  call void @ba_free(ptr noundef %133) #5
  %134 = load ptr, ptr %14, align 8, !tbaa !5
  call void @ba_free(ptr noundef %134) #5
  call void @aes_free(ptr noundef %.3165) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #5
  ret i32 %.4163
}

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


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