; LLVM IR from intel/QAT_Engine :: kpt/apps (kpt_ecc_key)

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

%struct.kpt_per_part_context = type { [384 x i8], i32, [8 x i8], i32, [384 x i8], i32 }
%struct.kpt_ecc_key_st = type { i64, ptr, ptr, ptr, ptr }
%struct.wrapping_metadata = type { ptr, ptr, ptr }
%struct.e_swk = type { ptr, ptr }
%struct.asn1_string_st = type { i32, i32, ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@cpu_socket_num = external global i32, align 4
@kpt_per_part_context_ptr = external global [32 x %struct.kpt_per_part_context], align 16
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @i2d_KPTECCKEY(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @KPTECCKEY_new() #0

; Function Attrs: nounwind uwtable
declare dso_local void @KPTECCKEY_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @kpt_ecc_wpk_gen(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca [1024 x i8], align 16
  %18 = alloca [1024 x i8], align 16
  %19 = alloca [32 x i8], align 16
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %17) #6
  call void @llvm.lifetime.start.p0(i64 1024, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %19) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  store ptr null, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  store ptr null, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  store ptr null, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  store ptr null, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  store i32 0, ptr %25, align 4, !tbaa !9
  %31 = getelementptr inbounds [1024 x i8], ptr %17, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %31, i8 0, i64 1024, i1 false)
  %32 = getelementptr inbounds [1024 x i8], ptr %18, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %32, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  store i32 0, ptr %26, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #6
  store i32 0, ptr %27, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #6
  store i32 0, ptr %28, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #6
  store i32 0, ptr %29, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #6
  store i32 0, ptr %30, align 4, !tbaa !9
  %33 = call ptr @CRYPTO_malloc(i64 noundef 12, ptr noundef @.str.1, i32 noundef 264)
  store ptr %33, ptr %20, align 8, !tbaa !5
  %34 = load ptr, ptr %20, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %2
  br label %293

37:                                               ; preds = %2
  %38 = call ptr @BIO_s_file()
  %39 = call ptr @BIO_new(ptr noundef %38)
  store ptr %39, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call i64 @BIO_ctrl(ptr noundef %40, i32 noundef 108, i64 noundef 3, ptr noundef %41)
  %43 = trunc i64 %42 to i32
  %44 = icmp sle i32 %43, 0
  br i1 %44, label %45, label %46

45:                                               ; preds = %37
  br label %293

46:                                               ; preds = %37
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = call ptr @PEM_read_bio_ECPrivateKey(ptr noundef %47, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %48, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = call i32 @BIO_free(ptr noundef %49)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = icmp eq ptr null, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %46
  br label %293

54:                                               ; preds = %46
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call ptr @EC_KEY_get0_group(ptr noundef %55)
  store ptr %56, ptr %6, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = icmp eq ptr null, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %54
  br label %293

60:                                               ; preds = %54
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds [1024 x i8], ptr %17, i64 0, i64 0
  %63 = call i32 @eckey_get_private_key(ptr noundef %61, ptr noundef %62, ptr noundef %26)
  %64 = getelementptr inbounds [1024 x i8], ptr %17, i64 0, i64 0
  %65 = load i32, ptr %26, align 4, !tbaa !9
  call void @hex_log(ptr noundef %64, i32 noundef %65, ptr noundef @.str.2)
  %66 = load ptr, ptr %20, align 8, !tbaa !5
  %67 = call i32 @RAND_bytes(ptr noundef %66, i32 noundef 12)
  %68 = getelementptr inbounds [32 x i8], ptr %19, i64 0, i64 0
  %69 = call i32 @RAND_bytes(ptr noundef %68, i32 noundef 32)
  %70 = getelementptr inbounds [32 x i8], ptr %19, i64 0, i64 0
  call void @hex_log(ptr noundef %70, i32 noundef 32, ptr noundef @.str.3)
  %71 = load ptr, ptr %20, align 8, !tbaa !5
  call void @hex_log(ptr noundef %71, i32 noundef 12, ptr noundef @.str.4)
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call i32 @EC_GROUP_get_curve_name(ptr noundef %72)
  store i32 %73, ptr %28, align 4, !tbaa !9
  %74 = load i32, ptr %28, align 4, !tbaa !9
  %75 = call ptr @ecc_get_aad(i32 noundef %74, ptr noundef %25)
  store ptr %75, ptr %24, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %78, label %77

77:                                               ; preds = %60
  br label %293

78:                                               ; preds = %60
  %79 = load ptr, ptr %24, align 8, !tbaa !5
  %80 = load i32, ptr %25, align 4, !tbaa !9
  call void @hex_log(ptr noundef %79, i32 noundef %80, ptr noundef @.str.5)
  %81 = getelementptr inbounds [1024 x i8], ptr %17, i64 0, i64 0
  %82 = load i32, ptr %26, align 4, !tbaa !9
  %83 = getelementptr inbounds [1024 x i8], ptr %18, i64 0, i64 0
  %84 = getelementptr inbounds [32 x i8], ptr %19, i64 0, i64 0
  %85 = load ptr, ptr %20, align 8, !tbaa !5
  %86 = load ptr, ptr %24, align 8, !tbaa !5
  %87 = load i32, ptr %25, align 4, !tbaa !9
  %88 = call i32 @wrap_key_with_gcm256(ptr noundef %81, i32 noundef %82, ptr noundef %83, ptr noundef %27, ptr noundef %84, ptr noundef %85, i32 noundef 12, ptr noundef %86, i32 noundef %87)
  store i32 %88, ptr %29, align 4, !tbaa !9
  %89 = load i32, ptr %29, align 4, !tbaa !9
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %92

91:                                               ; preds = %78
  br label %293

92:                                               ; preds = %78
  %93 = getelementptr inbounds [1024 x i8], ptr %18, i64 0, i64 0
  %94 = load i32, ptr %27, align 4, !tbaa !9
  call void @hex_log(ptr noundef %93, i32 noundef %94, ptr noundef @.str.6)
  %95 = load i32, ptr %27, align 4, !tbaa !9
  %96 = call i32 (i32, ptr, ...) @xlog(i32 noundef 2, ptr noundef @.str.7, i32 noundef %95)
  %97 = call ptr @KPTECCKEY_new()
  store ptr %97, ptr %10, align 8, !tbaa !5
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  %99 = icmp ne ptr %98, null
  br i1 %99, label %101, label %100

100:                                              ; preds = %92
  br label %293

101:                                              ; preds = %92
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %102, i32 0, i32 4
  %104 = load ptr, ptr %103, align 8, !tbaa !11
  store ptr %104, ptr %16, align 8, !tbaa !5
  %105 = load ptr, ptr %16, align 8, !tbaa !5
  %106 = icmp eq ptr null, %105
  br i1 %106, label %107, label %108

107:                                              ; preds = %101
  br label %293

108:                                              ; preds = %101
  %109 = call ptr @OBJ_txt2obj(ptr noundef @.str.8, i32 noundef 0)
  store ptr %109, ptr %12, align 8, !tbaa !5
  %110 = load ptr, ptr %12, align 8, !tbaa !5
  %111 = load ptr, ptr %16, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.wrapping_metadata, ptr %111, i32 0, i32 1
  store ptr %110, ptr %112, align 8, !tbaa !14
  %113 = load ptr, ptr %16, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.wrapping_metadata, ptr %113, i32 0, i32 0
  %115 = load ptr, ptr %114, align 8, !tbaa !16
  %116 = load ptr, ptr %20, align 8, !tbaa !5
  call void @ASN1_STRING_set0(ptr noundef %115, ptr noundef %116, i32 noundef 12)
  %117 = call i32 @kpt_get_per_part_key()
  store i32 %117, ptr %29, align 4, !tbaa !9
  %118 = load i32, ptr %29, align 4, !tbaa !9
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %121

120:                                              ; preds = %108
  br label %293

121:                                              ; preds = %108
  store i32 0, ptr %30, align 4, !tbaa !9
  br label %122

122:                                              ; preds = %211, %121
  %123 = load i32, ptr %30, align 4, !tbaa !9
  %124 = load i32, ptr @cpu_socket_num, align 4, !tbaa !9
  %125 = icmp slt i32 %123, %124
  br i1 %125, label %126, label %214

126:                                              ; preds = %122
  %127 = call ptr @ESWK_new()
  store ptr %127, ptr %13, align 8, !tbaa !5
  %128 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef @.str.1, i32 noundef 335)
  store ptr %128, ptr %23, align 8, !tbaa !5
  %129 = load ptr, ptr %23, align 8, !tbaa !5
  %130 = icmp ne ptr %129, null
  br i1 %130, label %132, label %131

131:                                              ; preds = %126
  br label %293

132:                                              ; preds = %126
  %133 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef @.str.1, i32 noundef 340)
  store ptr %133, ptr %22, align 8, !tbaa !5
  %134 = load ptr, ptr %22, align 8, !tbaa !5
  %135 = icmp ne ptr %134, null
  br i1 %135, label %137, label %136

136:                                              ; preds = %132
  br label %293

137:                                              ; preds = %132
  %138 = load i32, ptr %30, align 4, !tbaa !9
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %139
  %141 = getelementptr inbounds %struct.kpt_per_part_context, ptr %140, i32 0, i32 0
  %142 = getelementptr inbounds [384 x i8], ptr %141, i64 0, i64 0
  call void @hex_log(ptr noundef %142, i32 noundef 384, ptr noundef @.str.9)
  %143 = load i32, ptr %30, align 4, !tbaa !9
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %144
  %146 = getelementptr inbounds %struct.kpt_per_part_context, ptr %145, i32 0, i32 2
  %147 = getelementptr inbounds [8 x i8], ptr %146, i64 0, i64 0
  call void @hex_log(ptr noundef %147, i32 noundef 8, ptr noundef @.str.10)
  %148 = load i32, ptr %30, align 4, !tbaa !9
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %149
  %151 = getelementptr inbounds %struct.kpt_per_part_context, ptr %150, i32 0, i32 4
  %152 = getelementptr inbounds [384 x i8], ptr %151, i64 0, i64 0
  call void @hex_log(ptr noundef %152, i32 noundef 384, ptr noundef @.str.11)
  %153 = getelementptr inbounds [32 x i8], ptr %19, i64 0, i64 0
  %154 = load ptr, ptr %23, align 8, !tbaa !5
  %155 = load i32, ptr %30, align 4, !tbaa !9
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %156
  %158 = getelementptr inbounds %struct.kpt_per_part_context, ptr %157, i32 0, i32 0
  %159 = getelementptr inbounds [384 x i8], ptr %158, i64 0, i64 0
  %160 = load i32, ptr %30, align 4, !tbaa !9
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %161
  %163 = getelementptr inbounds %struct.kpt_per_part_context, ptr %162, i32 0, i32 1
  %164 = load i32, ptr %163, align 4, !tbaa !17
  %165 = load i32, ptr %30, align 4, !tbaa !9
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %166
  %168 = getelementptr inbounds %struct.kpt_per_part_context, ptr %167, i32 0, i32 2
  %169 = getelementptr inbounds [8 x i8], ptr %168, i64 0, i64 0
  %170 = load i32, ptr %30, align 4, !tbaa !9
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %171
  %173 = getelementptr inbounds %struct.kpt_per_part_context, ptr %172, i32 0, i32 3
  %174 = load i32, ptr %173, align 4, !tbaa !19
  %175 = call i32 @encrypt_swk_with_per_part_key(ptr noundef %153, ptr noundef %154, ptr noundef %159, i32 noundef %164, ptr noundef %169, i32 noundef %174)
  store i32 %175, ptr %29, align 4, !tbaa !9
  %176 = load i32, ptr %29, align 4, !tbaa !9
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %179, label %178

178:                                              ; preds = %137
  br label %293

179:                                              ; preds = %137
  %180 = load ptr, ptr %23, align 8, !tbaa !5
  call void @hex_log(ptr noundef %180, i32 noundef 384, ptr noundef @.str.12)
  %181 = load ptr, ptr %22, align 8, !tbaa !5
  %182 = load i32, ptr %30, align 4, !tbaa !9
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %183
  %185 = getelementptr inbounds %struct.kpt_per_part_context, ptr %184, i32 0, i32 4
  %186 = getelementptr inbounds [384 x i8], ptr %185, i64 0, i64 0
  %187 = load i32, ptr %30, align 4, !tbaa !9
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %188
  %190 = getelementptr inbounds %struct.kpt_per_part_context, ptr %189, i32 0, i32 5
  %191 = load i32, ptr %190, align 4, !tbaa !20
  %192 = sext i32 %191 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %181, ptr align 4 %186, i64 %192, i1 false)
  %193 = load ptr, ptr %13, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.e_swk, ptr %193, i32 0, i32 1
  %195 = load ptr, ptr %194, align 8, !tbaa !21
  %196 = load ptr, ptr %23, align 8, !tbaa !5
  call void @ASN1_STRING_set0(ptr noundef %195, ptr noundef %196, i32 noundef 384)
  %197 = load ptr, ptr %13, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.e_swk, ptr %197, i32 0, i32 0
  %199 = load ptr, ptr %198, align 8, !tbaa !23
  %200 = load ptr, ptr %22, align 8, !tbaa !5
  call void @ASN1_STRING_set0(ptr noundef %199, ptr noundef %200, i32 noundef 384)
  %201 = load ptr, ptr %16, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.wrapping_metadata, ptr %201, i32 0, i32 2
  %203 = load ptr, ptr %202, align 8, !tbaa !24
  %204 = load ptr, ptr %13, align 8, !tbaa !5
  %205 = call i32 @sk_ESWK_push(ptr noundef %203, ptr noundef %204)
  %206 = load ptr, ptr %16, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.wrapping_metadata, ptr %206, i32 0, i32 2
  %208 = load ptr, ptr %207, align 8, !tbaa !24
  %209 = call i32 @sk_ESWK_num(ptr noundef %208)
  %210 = call i32 (i32, ptr, ...) @xlog(i32 noundef 2, ptr noundef @.str.13, i32 noundef %209)
  br label %211

211:                                              ; preds = %179
  %212 = load i32, ptr %30, align 4, !tbaa !9
  %213 = add nsw i32 %212, 1
  store i32 %213, ptr %30, align 4, !tbaa !9
  br label %122, !llvm.loop !25

214:                                              ; preds = %122
  %215 = load ptr, ptr %10, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %215, i32 0, i32 0
  store i64 1, ptr %216, align 8, !tbaa !27
  %217 = load i32, ptr %27, align 4, !tbaa !9
  %218 = sext i32 %217 to i64
  %219 = call ptr @CRYPTO_malloc(i64 noundef %218, ptr noundef @.str.1, i32 noundef 376)
  store ptr %219, ptr %21, align 8, !tbaa !5
  %220 = load ptr, ptr %21, align 8, !tbaa !5
  %221 = icmp ne ptr %220, null
  br i1 %221, label %223, label %222

222:                                              ; preds = %214
  br label %293

223:                                              ; preds = %214
  %224 = load ptr, ptr %21, align 8, !tbaa !5
  %225 = getelementptr inbounds [1024 x i8], ptr %18, i64 0, i64 0
  %226 = load i32, ptr %27, align 4, !tbaa !9
  %227 = sext i32 %226 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %224, ptr align 16 %225, i64 %227, i1 false)
  %228 = load ptr, ptr %10, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %228, i32 0, i32 1
  %230 = load ptr, ptr %229, align 8, !tbaa !28
  %231 = load ptr, ptr %21, align 8, !tbaa !5
  %232 = load i32, ptr %27, align 4, !tbaa !9
  call void @ASN1_STRING_set0(ptr noundef %230, ptr noundef %231, i32 noundef %232)
  %233 = load ptr, ptr %6, align 8, !tbaa !5
  %234 = call i32 @EC_GROUP_get_curve_name(ptr noundef %233)
  %235 = call ptr @OBJ_nid2obj(i32 noundef %234)
  %236 = load ptr, ptr %10, align 8, !tbaa !5
  %237 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %236, i32 0, i32 2
  store ptr %235, ptr %237, align 8, !tbaa !29
  %238 = load ptr, ptr %5, align 8, !tbaa !5
  %239 = call ptr @EC_KEY_get0_public_key(ptr noundef %238)
  store ptr %239, ptr %11, align 8, !tbaa !5
  %240 = load ptr, ptr %11, align 8, !tbaa !5
  %241 = icmp ne ptr %240, null
  br i1 %241, label %242, label %274

242:                                              ; preds = %223
  %243 = call ptr @ASN1_BIT_STRING_new()
  %244 = load ptr, ptr %10, align 8, !tbaa !5
  %245 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %244, i32 0, i32 3
  store ptr %243, ptr %245, align 8, !tbaa !30
  %246 = load ptr, ptr %10, align 8, !tbaa !5
  %247 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %246, i32 0, i32 3
  %248 = load ptr, ptr %247, align 8, !tbaa !30
  %249 = icmp ne ptr %248, null
  br i1 %249, label %251, label %250

250:                                              ; preds = %242
  br label %293

251:                                              ; preds = %242
  %252 = load ptr, ptr %10, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %252, i32 0, i32 3
  %254 = load ptr, ptr %253, align 8, !tbaa !30
  %255 = getelementptr inbounds %struct.asn1_string_st, ptr %254, i32 0, i32 3
  %256 = load i64, ptr %255, align 8, !tbaa !31
  %257 = and i64 %256, -16
  store i64 %257, ptr %255, align 8, !tbaa !31
  %258 = load ptr, ptr %10, align 8, !tbaa !5
  %259 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %258, i32 0, i32 3
  %260 = load ptr, ptr %259, align 8, !tbaa !30
  %261 = getelementptr inbounds %struct.asn1_string_st, ptr %260, i32 0, i32 3
  %262 = load i64, ptr %261, align 8, !tbaa !31
  %263 = or i64 %262, 8
  store i64 %263, ptr %261, align 8, !tbaa !31
  %264 = load ptr, ptr %5, align 8, !tbaa !5
  %265 = load ptr, ptr %5, align 8, !tbaa !5
  %266 = call i32 @EC_KEY_get_conv_form(ptr noundef %265)
  %267 = call i64 @EC_KEY_key2buf(ptr noundef %264, i32 noundef %266, ptr noundef %15, ptr noundef null)
  %268 = trunc i64 %267 to i32
  store i32 %268, ptr %14, align 4, !tbaa !9
  %269 = load ptr, ptr %10, align 8, !tbaa !5
  %270 = getelementptr inbounds %struct.kpt_ecc_key_st, ptr %269, i32 0, i32 3
  %271 = load ptr, ptr %270, align 8, !tbaa !30
  %272 = load ptr, ptr %15, align 8, !tbaa !5
  %273 = load i32, ptr %14, align 4, !tbaa !9
  call void @ASN1_STRING_set0(ptr noundef %271, ptr noundef %272, i32 noundef %273)
  br label %274

274:                                              ; preds = %251, %223
  %275 = call ptr @BIO_s_file()
  %276 = call ptr @BIO_new(ptr noundef %275)
  store ptr %276, ptr %9, align 8, !tbaa !5
  %277 = load ptr, ptr %9, align 8, !tbaa !5
  %278 = icmp eq ptr null, %277
  br i1 %278, label %279, label %280

279:                                              ; preds = %274
  br label %293

280:                                              ; preds = %274
  %281 = load ptr, ptr %9, align 8, !tbaa !5
  %282 = load ptr, ptr %4, align 8, !tbaa !5
  %283 = call i64 @BIO_ctrl(ptr noundef %281, i32 noundef 108, i64 noundef 5, ptr noundef %282)
  %284 = trunc i64 %283 to i32
  %285 = load ptr, ptr %9, align 8, !tbaa !5
  %286 = load ptr, ptr %10, align 8, !tbaa !5
  %287 = call i32 @PEM_ASN1_write_bio(ptr noundef @i2d_KPTECCKEY, ptr noundef @.str.14, ptr noundef %285, ptr noundef %286, ptr noundef null, ptr noundef null, i32 noundef 0, ptr noundef null, ptr noundef null)
  %288 = load ptr, ptr %9, align 8, !tbaa !5
  %289 = call i64 @BIO_ctrl(ptr noundef %288, i32 noundef 11, i64 noundef 0, ptr noundef null)
  %290 = trunc i64 %289 to i32
  %291 = load ptr, ptr %9, align 8, !tbaa !5
  %292 = call i32 @BIO_free(ptr noundef %291)
  br label %293

293:                                              ; preds = %280, %279, %250, %222, %178, %136, %131, %120, %107, %100, %91, %77, %59, %53, %45, %36
  %294 = load ptr, ptr %5, align 8, !tbaa !5
  %295 = icmp ne ptr %294, null
  br i1 %295, label %296, label %298

296:                                              ; preds = %293
  %297 = load ptr, ptr %5, align 8, !tbaa !5
  call void @EC_KEY_free(ptr noundef %297)
  br label %298

298:                                              ; preds = %296, %293
  %299 = load ptr, ptr %10, align 8, !tbaa !5
  %300 = icmp ne ptr %299, null
  br i1 %300, label %301, label %303

301:                                              ; preds = %298
  %302 = load ptr, ptr %10, align 8, !tbaa !5
  call void @KPTECCKEY_free(ptr noundef %302)
  br label %303

303:                                              ; preds = %301, %298
  %304 = load ptr, ptr %20, align 8, !tbaa !5
  %305 = icmp ne ptr %304, null
  br i1 %305, label %306, label %308

306:                                              ; preds = %303
  %307 = load ptr, ptr %20, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %307, ptr noundef @.str.1, i32 noundef 415)
  br label %308

308:                                              ; preds = %306, %303
  %309 = load i32, ptr %29, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret i32 %309
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) #3

declare ptr @BIO_new(ptr noundef) #3

declare ptr @BIO_s_file() #3

declare i64 @BIO_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) #3

declare ptr @PEM_read_bio_ECPrivateKey(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @BIO_free(ptr noundef) #3

declare ptr @EC_KEY_get0_group(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden void @hex_log(ptr noundef, i32 noundef, ptr noundef) #0

declare i32 @RAND_bytes(ptr noundef, i32 noundef) #3

declare i32 @EC_GROUP_get_curve_name(ptr noundef) #3

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

declare i32 @wrap_key_with_gcm256(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

declare i32 @xlog(i32 noundef, ptr noundef, ...) #3

declare ptr @OBJ_txt2obj(ptr noundef, i32 noundef) #3

declare void @ASN1_STRING_set0(ptr noundef, ptr noundef, i32 noundef) #3

declare i32 @kpt_get_per_part_key() #3

declare ptr @ESWK_new() #3

declare ptr @CRYPTO_zalloc(i64 noundef, ptr noundef, i32 noundef) #3

declare i32 @encrypt_swk_with_per_part_key(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @sk_ESWK_push(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @sk_ESWK_num(ptr noundef) #5

declare ptr @OBJ_nid2obj(i32 noundef) #3

declare ptr @EC_KEY_get0_public_key(ptr noundef) #3

declare ptr @ASN1_BIT_STRING_new() #3

declare i64 @EC_KEY_key2buf(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #3

declare i32 @EC_KEY_get_conv_form(ptr noundef) #3

declare i32 @PEM_ASN1_write_bio(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #3

declare void @EC_KEY_free(ptr noundef) #3

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #3

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"kpt_ecc_key_st", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"wrapping_metadata", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!15, !6, i64 0}
!17 = !{!18, !10, i64 384}
!18 = !{!"", !7, i64 0, !10, i64 384, !7, i64 388, !10, i64 396, !7, i64 400, !10, i64 784}
!19 = !{!18, !10, i64 396}
!20 = !{!18, !10, i64 784}
!21 = !{!22, !6, i64 8}
!22 = !{!"e_swk", !6, i64 0, !6, i64 8}
!23 = !{!22, !6, i64 0}
!24 = !{!15, !6, i64 16}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!12, !13, i64 0}
!28 = !{!12, !6, i64 8}
!29 = !{!12, !6, i64 16}
!30 = !{!12, !6, i64 24}
!31 = !{!32, !13, i64 16}
!32 = !{!"asn1_string_st", !10, i64 0, !10, i64 4, !6, i64 8, !13, i64 16}


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

%struct.kpt_per_part_context = type { [384 x i8], i32, [8 x i8], i32, [384 x i8], i32 }

@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@cpu_socket_num = external local_unnamed_addr global i32, align 4
@kpt_per_part_context_ptr = external global [32 x %struct.kpt_per_part_context], align 16
@.str.9 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @i2d_KPTECCKEY(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @KPTECCKEY_new() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @KPTECCKEY_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @kpt_ecc_wpk_gen(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca [1024 x i8], align 16
  %5 = alloca [1024 x i8], align 16
  %6 = alloca [32 x i8], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) %4, i8 0, i64 1024, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) %5, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  %10 = tail call ptr @CRYPTO_malloc(i64 noundef 12, ptr noundef nonnull @.str.1, i32 noundef 264) #6
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %.thread129.thread137, label %11

11:                                               ; preds = %2
  %12 = tail call ptr @BIO_s_file() #6
  %13 = tail call ptr @BIO_new(ptr noundef %12) #6
  %14 = tail call i64 @BIO_ctrl(ptr noundef %13, i32 noundef 108, i64 noundef 3, ptr noundef %0) #6
  %15 = trunc i64 %14 to i32
  %16 = icmp slt i32 %15, 1
  br i1 %16, label %.thread129.thread, label %17

17:                                               ; preds = %11
  %18 = tail call ptr @PEM_read_bio_ECPrivateKey(ptr noundef %13, ptr noundef null, ptr noundef null, ptr noundef null) #6
  %19 = tail call i32 @BIO_free(ptr noundef %13) #6
  %20 = icmp eq ptr %18, null
  br i1 %20, label %.thread129.thread, label %21

21:                                               ; preds = %17
  %22 = tail call ptr @EC_KEY_get0_group(ptr noundef nonnull %18) #6
  %23 = icmp eq ptr %22, null
  br i1 %23, label %.thread.thread150, label %24

24:                                               ; preds = %21
  %25 = call i32 @eckey_get_private_key(ptr noundef nonnull %18, ptr noundef nonnull %4, ptr noundef nonnull %8)
  %26 = load i32, ptr %8, align 4, !tbaa !9
  call void @hex_log(ptr noundef nonnull %4, i32 noundef %26, ptr noundef nonnull @.str.2)
  %27 = call i32 @RAND_bytes(ptr noundef nonnull %10, i32 noundef 12) #6
  %28 = call i32 @RAND_bytes(ptr noundef nonnull %6, i32 noundef 32) #6
  call void @hex_log(ptr noundef nonnull %6, i32 noundef 32, ptr noundef nonnull @.str.3)
  call void @hex_log(ptr noundef nonnull %10, i32 noundef 12, ptr noundef nonnull @.str.4)
  %29 = call i32 @EC_GROUP_get_curve_name(ptr noundef nonnull %22) #6
  %30 = call ptr @ecc_get_aad(i32 noundef %29, ptr noundef nonnull %7)
  %.not102 = icmp eq ptr %30, null
  br i1 %.not102, label %.thread.thread150, label %31

31:                                               ; preds = %24
  %32 = load i32, ptr %7, align 4, !tbaa !9
  call void @hex_log(ptr noundef nonnull %30, i32 noundef %32, ptr noundef nonnull @.str.5)
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = call i32 @wrap_key_with_gcm256(ptr noundef nonnull %4, i32 noundef %33, ptr noundef nonnull %5, ptr noundef nonnull %9, ptr noundef nonnull %6, ptr noundef nonnull %10, i32 noundef 12, ptr noundef nonnull %30, i32 noundef %34) #6
  %.not103 = icmp eq i32 %35, 0
  br i1 %.not103, label %36, label %.thread.thread150

36:                                               ; preds = %31
  %37 = load i32, ptr %9, align 4, !tbaa !9
  call void @hex_log(ptr noundef nonnull %5, i32 noundef %37, ptr noundef nonnull @.str.6)
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = call i32 (i32, ptr, ...) @xlog(i32 noundef 2, ptr noundef nonnull @.str.7, i32 noundef %38) #6
  %40 = call ptr @KPTECCKEY_new()
  %.not104 = icmp eq ptr %40, null
  br i1 %.not104, label %.thread.thread150, label %41

41:                                               ; preds = %36
  %42 = getelementptr inbounds i8, ptr %40, i64 32
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = icmp eq ptr %43, null
  br i1 %44, label %.thread.thread, label %45

45:                                               ; preds = %41
  %46 = call ptr @OBJ_txt2obj(ptr noundef nonnull @.str.8, i32 noundef 0) #6
  %47 = getelementptr inbounds i8, ptr %43, i64 8
  store ptr %46, ptr %47, align 8, !tbaa !14
  %48 = load ptr, ptr %43, align 8, !tbaa !16
  call void @ASN1_STRING_set0(ptr noundef %48, ptr noundef nonnull %10, i32 noundef 12) #6
  %49 = call i32 @kpt_get_per_part_key() #6
  %.not105 = icmp eq i32 %49, 0
  br i1 %.not105, label %.preheader, label %.thread.thread

.preheader:                                       ; preds = %45
  %50 = load i32, ptr @cpu_socket_num, align 4, !tbaa !9
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %52 = getelementptr inbounds i8, ptr %43, i64 16
  %53 = call ptr @ESWK_new() #6
  %54 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef nonnull @.str.1, i32 noundef 335) #6
  %.not109154 = icmp eq ptr %54, null
  br i1 %.not109154, label %.thread.thread, label %.lr.ph157

55:                                               ; preds = %70
  %56 = call ptr @ESWK_new() #6
  %57 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef nonnull @.str.1, i32 noundef 335) #6
  %.not109 = icmp eq ptr %57, null
  br i1 %.not109, label %.thread.thread, label %.lr.ph157, !llvm.loop !17

.lr.ph157:                                        ; preds = %.lr.ph, %55
  %58 = phi ptr [ %57, %55 ], [ %54, %.lr.ph ]
  %59 = phi ptr [ %56, %55 ], [ %53, %.lr.ph ]
  %.079140156 = phi i32 [ %69, %55 ], [ 0, %.lr.ph ]
  %indvars.iv155 = phi i64 [ %indvars.iv.next, %55 ], [ 0, %.lr.ph ]
  %60 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef nonnull @.str.1, i32 noundef 340) #6
  %.not110 = icmp eq ptr %60, null
  br i1 %.not110, label %.thread.thread, label %61

61:                                               ; preds = %.lr.ph157
  %62 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %indvars.iv155
  call void @hex_log(ptr noundef nonnull %62, i32 noundef 384, ptr noundef nonnull @.str.9)
  %63 = getelementptr inbounds i8, ptr %62, i64 388
  call void @hex_log(ptr noundef nonnull %63, i32 noundef 8, ptr noundef nonnull @.str.10)
  %64 = getelementptr inbounds i8, ptr %62, i64 400
  call void @hex_log(ptr noundef nonnull %64, i32 noundef 384, ptr noundef nonnull @.str.11)
  %65 = getelementptr inbounds i8, ptr %62, i64 384
  %66 = load i32, ptr %65, align 4, !tbaa !19
  %67 = getelementptr inbounds i8, ptr %62, i64 396
  %68 = load i32, ptr %67, align 4, !tbaa !21
  %69 = call i32 @encrypt_swk_with_per_part_key(ptr noundef nonnull %6, ptr noundef nonnull %58, ptr noundef nonnull %62, i32 noundef %66, ptr noundef nonnull %63, i32 noundef %68) #6
  %.not111 = icmp eq i32 %69, 0
  br i1 %.not111, label %.thread.thread, label %70

70:                                               ; preds = %61
  call void @hex_log(ptr noundef nonnull %58, i32 noundef 384, ptr noundef nonnull @.str.12)
  %71 = getelementptr inbounds i8, ptr %62, i64 784
  %72 = load i32, ptr %71, align 4, !tbaa !22
  %73 = sext i32 %72 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %60, ptr nonnull align 4 %64, i64 %73, i1 false)
  %74 = getelementptr inbounds i8, ptr %59, i64 8
  %75 = load ptr, ptr %74, align 8, !tbaa !23
  call void @ASN1_STRING_set0(ptr noundef %75, ptr noundef nonnull %58, i32 noundef 384) #6
  %76 = load ptr, ptr %59, align 8, !tbaa !25
  call void @ASN1_STRING_set0(ptr noundef %76, ptr noundef nonnull %60, i32 noundef 384) #6
  %77 = load ptr, ptr %52, align 8, !tbaa !26
  %78 = call i32 @sk_ESWK_push(ptr noundef %77, ptr noundef nonnull %59)
  %79 = load ptr, ptr %52, align 8, !tbaa !26
  %80 = call i32 @sk_ESWK_num(ptr noundef %79)
  %81 = call i32 (i32, ptr, ...) @xlog(i32 noundef 2, ptr noundef nonnull @.str.13, i32 noundef %80) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv155, 1
  %82 = load i32, ptr @cpu_socket_num, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = icmp slt i64 %indvars.iv.next, %83
  br i1 %84, label %55, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %70, %.preheader
  %.079.lcssa = phi i32 [ 0, %.preheader ], [ %69, %70 ]
  store i64 1, ptr %40, align 8, !tbaa !27
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = call ptr @CRYPTO_malloc(i64 noundef %86, ptr noundef nonnull @.str.1, i32 noundef 376) #6
  %.not106 = icmp eq ptr %87, null
  br i1 %.not106, label %.thread.thread, label %88

88:                                               ; preds = %._crit_edge
  %89 = load i32, ptr %9, align 4, !tbaa !9
  %90 = sext i32 %89 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %87, ptr nonnull align 16 %5, i64 %90, i1 false)
  %91 = getelementptr inbounds i8, ptr %40, i64 8
  %92 = load ptr, ptr %91, align 8, !tbaa !28
  %93 = load i32, ptr %9, align 4, !tbaa !9
  call void @ASN1_STRING_set0(ptr noundef %92, ptr noundef nonnull %87, i32 noundef %93) #6
  %94 = call i32 @EC_GROUP_get_curve_name(ptr noundef nonnull %22) #6
  %95 = call ptr @OBJ_nid2obj(i32 noundef %94) #6
  %96 = getelementptr inbounds i8, ptr %40, i64 16
  store ptr %95, ptr %96, align 8, !tbaa !29
  %97 = call ptr @EC_KEY_get0_public_key(ptr noundef nonnull %18) #6
  %.not107 = icmp eq ptr %97, null
  br i1 %.not107, label %111, label %98

98:                                               ; preds = %88
  %99 = call ptr @ASN1_BIT_STRING_new() #6
  %100 = getelementptr inbounds i8, ptr %40, i64 24
  store ptr %99, ptr %100, align 8, !tbaa !30
  %.not108 = icmp eq ptr %99, null
  br i1 %.not108, label %.thread.thread, label %101

101:                                              ; preds = %98
  %102 = getelementptr inbounds i8, ptr %99, i64 16
  %103 = load i64, ptr %102, align 8, !tbaa !31
  %104 = and i64 %103, -16
  %105 = or disjoint i64 %104, 8
  store i64 %105, ptr %102, align 8, !tbaa !31
  %106 = call i32 @EC_KEY_get_conv_form(ptr noundef nonnull %18) #6
  %107 = call i64 @EC_KEY_key2buf(ptr noundef nonnull %18, i32 noundef %106, ptr noundef nonnull %3, ptr noundef null) #6
  %108 = trunc i64 %107 to i32
  %109 = load ptr, ptr %100, align 8, !tbaa !30
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  call void @ASN1_STRING_set0(ptr noundef %109, ptr noundef %110, i32 noundef %108) #6
  br label %111

111:                                              ; preds = %101, %88
  %112 = call ptr @BIO_s_file() #6
  %113 = call ptr @BIO_new(ptr noundef %112) #6
  %114 = icmp eq ptr %113, null
  br i1 %114, label %.thread.thread, label %115

115:                                              ; preds = %111
  %116 = call i64 @BIO_ctrl(ptr noundef nonnull %113, i32 noundef 108, i64 noundef 5, ptr noundef %1) #6
  %117 = call i32 @PEM_ASN1_write_bio(ptr noundef nonnull @i2d_KPTECCKEY, ptr noundef nonnull @.str.14, ptr noundef nonnull %113, ptr noundef nonnull %40, ptr noundef null, ptr noundef null, i32 noundef 0, ptr noundef null, ptr noundef null) #6
  %118 = call i64 @BIO_ctrl(ptr noundef nonnull %113, i32 noundef 11, i64 noundef 0, ptr noundef null) #6
  %119 = call i32 @BIO_free(ptr noundef nonnull %113) #6
  br label %.thread.thread

.thread.thread150:                                ; preds = %24, %36, %31, %21
  %.1121.ph149 = phi i32 [ 0, %21 ], [ %35, %31 ], [ 0, %36 ], [ 0, %24 ]
  call void @EC_KEY_free(ptr noundef nonnull %18) #6
  br label %.thread129.thread

.thread.thread:                                   ; preds = %55, %.lr.ph157, %61, %.lr.ph, %._crit_edge, %98, %115, %111, %41, %45
  %.1121146 = phi i32 [ %.079.lcssa, %._crit_edge ], [ %.079.lcssa, %98 ], [ %.079.lcssa, %115 ], [ %.079.lcssa, %111 ], [ 0, %41 ], [ %49, %45 ], [ 0, %.lr.ph ], [ 0, %61 ], [ %.079140156, %.lr.ph157 ], [ %69, %55 ]
  call void @EC_KEY_free(ptr noundef nonnull %18) #6
  call void @KPTECCKEY_free(ptr noundef nonnull %40)
  br label %.thread129.thread

.thread129.thread:                                ; preds = %.thread.thread150, %.thread.thread, %17, %11
  %.1122133135 = phi i32 [ 0, %11 ], [ 0, %17 ], [ %.1121146, %.thread.thread ], [ %.1121.ph149, %.thread.thread150 ]
  call void @CRYPTO_free(ptr noundef nonnull %10, ptr noundef nonnull @.str.1, i32 noundef 415) #6
  br label %.thread129.thread137

.thread129.thread137:                             ; preds = %2, %.thread129.thread
  %.1122133136 = phi i32 [ %.1122133135, %.thread129.thread ], [ 0, %2 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  ret i32 %.1122133136
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare ptr @BIO_new(ptr noundef) local_unnamed_addr #3

declare ptr @BIO_s_file() local_unnamed_addr #3

declare i64 @BIO_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

declare ptr @PEM_read_bio_ECPrivateKey(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @BIO_free(ptr noundef) local_unnamed_addr #3

declare ptr @EC_KEY_get0_group(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden void @hex_log(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare i32 @RAND_bytes(ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @EC_GROUP_get_curve_name(ptr noundef) local_unnamed_addr #3

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

declare i32 @wrap_key_with_gcm256(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @xlog(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

declare ptr @OBJ_txt2obj(ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @ASN1_STRING_set0(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @kpt_get_per_part_key() local_unnamed_addr #3

declare ptr @ESWK_new() local_unnamed_addr #3

declare ptr @CRYPTO_zalloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @encrypt_swk_with_per_part_key(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @sk_ESWK_push(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @sk_ESWK_num(ptr noundef) local_unnamed_addr #5

declare ptr @OBJ_nid2obj(i32 noundef) local_unnamed_addr #3

declare ptr @EC_KEY_get0_public_key(ptr noundef) local_unnamed_addr #3

declare ptr @ASN1_BIT_STRING_new() local_unnamed_addr #3

declare i64 @EC_KEY_key2buf(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @EC_KEY_get_conv_form(ptr noundef) local_unnamed_addr #3

declare i32 @PEM_ASN1_write_bio(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @EC_KEY_free(ptr noundef) local_unnamed_addr #3

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint 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 #6 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"kpt_ecc_key_st", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"wrapping_metadata", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!15, !6, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !10, i64 384}
!20 = !{!"", !7, i64 0, !10, i64 384, !7, i64 388, !10, i64 396, !7, i64 400, !10, i64 784}
!21 = !{!20, !10, i64 396}
!22 = !{!20, !10, i64 784}
!23 = !{!24, !6, i64 8}
!24 = !{!"e_swk", !6, i64 0, !6, i64 8}
!25 = !{!24, !6, i64 0}
!26 = !{!15, !6, i64 16}
!27 = !{!12, !13, i64 0}
!28 = !{!12, !6, i64 8}
!29 = !{!12, !6, i64 16}
!30 = !{!12, !6, i64 24}
!31 = !{!32, !13, i64 16}
!32 = !{!"asn1_string_st", !10, i64 0, !10, i64 4, !6, i64 8, !13, i64 16}


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