; LLVM IR from intel/QAT_Engine :: kpt/apps (kpt_rsa_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_rsa_key = type { i64, ptr, ptr, i64, ptr, ptr, ptr }
%struct.wrapping_metadata = type { ptr, ptr, ptr }
%struct.e_swk = type { ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.7 = 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.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @kpt_rsa_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 [32 x i8], align 16
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = 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) #5
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  store ptr null, ptr %20, align 8, !tbaa !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 4, ptr %23) #5
  store i32 0, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #5
  store i32 0, ptr %24, align 4, !tbaa !9
  %25 = call ptr @BIO_s_file()
  %26 = call ptr @BIO_new(ptr noundef %25)
  store ptr %26, ptr %8, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %30

28:                                               ; preds = %2
  %29 = call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef @.str.2)
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

30:                                               ; preds = %2
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call i64 @BIO_ctrl(ptr noundef %31, i32 noundef 108, i64 noundef 3, ptr noundef %32)
  %34 = trunc i64 %33 to i32
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %39, label %36

36:                                               ; preds = %30
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef @.str.3, ptr noundef %37)
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

39:                                               ; preds = %30
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = call ptr @PEM_read_bio_PrivateKey(ptr noundef %40, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %41, ptr %6, align 8, !tbaa !5
  %42 = icmp eq ptr %41, null
  br i1 %42, label %43, label %45

43:                                               ; preds = %39
  %44 = call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef @.str.4)
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

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

51:                                               ; preds = %45
  %52 = call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef @.str.5)
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

53:                                               ; preds = %45
  %54 = call ptr @CRYPTO_malloc(i64 noundef 12, ptr noundef @.str.6, i32 noundef 431)
  store ptr %54, ptr %20, align 8, !tbaa !5
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

57:                                               ; preds = %53
  %58 = load ptr, ptr %20, align 8, !tbaa !5
  %59 = call i32 @RAND_bytes(ptr noundef %58, i32 noundef 12)
  %60 = call ptr @KPTRSAKEY_new()
  store ptr %60, ptr %7, align 8, !tbaa !5
  %61 = icmp eq ptr %60, null
  br i1 %61, label %62, label %63

62:                                               ; preds = %57
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

63:                                               ; preds = %57
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.kpt_rsa_key, ptr %64, i32 0, i32 6
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  store ptr %66, ptr %10, align 8, !tbaa !5
  %67 = icmp eq ptr %66, null
  br i1 %67, label %68, label %69

68:                                               ; preds = %63
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

69:                                               ; preds = %63
  %70 = call ptr @OBJ_txt2obj(ptr noundef @.str.7, i32 noundef 0)
  store ptr %70, ptr %12, align 8, !tbaa !5
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.wrapping_metadata, ptr %72, i32 0, i32 1
  store ptr %71, ptr %73, align 8, !tbaa !14
  %74 = getelementptr inbounds [32 x i8], ptr %14, i64 0, i64 0
  %75 = call i32 @RAND_bytes(ptr noundef %74, i32 noundef 32)
  %76 = call i32 @kpt_get_per_part_key()
  store i32 %76, ptr %23, align 4, !tbaa !9
  %77 = load i32, ptr %23, align 4, !tbaa !9
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %80

79:                                               ; preds = %69
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

80:                                               ; preds = %69
  store i32 0, ptr %24, align 4, !tbaa !9
  br label %81

81:                                               ; preds = %171, %80
  %82 = load i32, ptr %24, align 4, !tbaa !9
  %83 = load i32, ptr @cpu_socket_num, align 4, !tbaa !9
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %85, label %174

85:                                               ; preds = %81
  %86 = call ptr @ESWK_new()
  store ptr %86, ptr %13, align 8, !tbaa !5
  %87 = icmp eq ptr %86, null
  br i1 %87, label %88, label %89

88:                                               ; preds = %85
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

89:                                               ; preds = %85
  %90 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef @.str.6, i32 noundef 464)
  store ptr %90, ptr %22, align 8, !tbaa !5
  %91 = icmp eq ptr %90, null
  br i1 %91, label %92, label %93

92:                                               ; preds = %89
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

93:                                               ; preds = %89
  %94 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef @.str.6, i32 noundef 469)
  store ptr %94, ptr %21, align 8, !tbaa !5
  %95 = icmp eq ptr %94, null
  br i1 %95, label %96, label %97

96:                                               ; preds = %93
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

97:                                               ; preds = %93
  %98 = load i32, ptr %24, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %99
  %101 = getelementptr inbounds %struct.kpt_per_part_context, ptr %100, i32 0, i32 0
  %102 = getelementptr inbounds [384 x i8], ptr %101, i64 0, i64 0
  call void @hex_log(ptr noundef %102, i32 noundef 384, ptr noundef @.str.8)
  %103 = load i32, ptr %24, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %104
  %106 = getelementptr inbounds %struct.kpt_per_part_context, ptr %105, i32 0, i32 2
  %107 = getelementptr inbounds [8 x i8], ptr %106, i64 0, i64 0
  call void @hex_log(ptr noundef %107, i32 noundef 8, ptr noundef @.str.9)
  %108 = load i32, ptr %24, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.kpt_per_part_context, ptr %110, i32 0, i32 4
  %112 = getelementptr inbounds [384 x i8], ptr %111, i64 0, i64 0
  call void @hex_log(ptr noundef %112, i32 noundef 384, ptr noundef @.str.10)
  %113 = getelementptr inbounds [32 x i8], ptr %14, i64 0, i64 0
  %114 = load ptr, ptr %22, align 8, !tbaa !5
  %115 = load i32, ptr %24, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %116
  %118 = getelementptr inbounds %struct.kpt_per_part_context, ptr %117, i32 0, i32 0
  %119 = getelementptr inbounds [384 x i8], ptr %118, i64 0, i64 0
  %120 = load i32, ptr %24, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %121
  %123 = getelementptr inbounds %struct.kpt_per_part_context, ptr %122, i32 0, i32 1
  %124 = load i32, ptr %123, align 4, !tbaa !16
  %125 = load i32, ptr %24, align 4, !tbaa !9
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %126
  %128 = getelementptr inbounds %struct.kpt_per_part_context, ptr %127, i32 0, i32 2
  %129 = getelementptr inbounds [8 x i8], ptr %128, i64 0, i64 0
  %130 = load i32, ptr %24, align 4, !tbaa !9
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %131
  %133 = getelementptr inbounds %struct.kpt_per_part_context, ptr %132, i32 0, i32 3
  %134 = load i32, ptr %133, align 4, !tbaa !18
  %135 = call i32 @encrypt_swk_with_per_part_key(ptr noundef %113, ptr noundef %114, ptr noundef %119, i32 noundef %124, ptr noundef %129, i32 noundef %134)
  store i32 %135, ptr %23, align 4, !tbaa !9
  %136 = load i32, ptr %23, align 4, !tbaa !9
  %137 = icmp sle i32 %136, 0
  br i1 %137, label %138, label %139

138:                                              ; preds = %97
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

139:                                              ; preds = %97
  %140 = load ptr, ptr %22, align 8, !tbaa !5
  call void @hex_log(ptr noundef %140, i32 noundef 384, ptr noundef @.str.11)
  %141 = load ptr, ptr %21, align 8, !tbaa !5
  %142 = load i32, ptr %24, align 4, !tbaa !9
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %143
  %145 = getelementptr inbounds %struct.kpt_per_part_context, ptr %144, i32 0, i32 4
  %146 = getelementptr inbounds [384 x i8], ptr %145, i64 0, i64 0
  %147 = load i32, ptr %24, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %148
  %150 = getelementptr inbounds %struct.kpt_per_part_context, ptr %149, i32 0, i32 5
  %151 = load i32, ptr %150, align 4, !tbaa !19
  %152 = sext i32 %151 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %141, ptr align 4 %146, i64 %152, i1 false)
  %153 = load ptr, ptr %13, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.e_swk, ptr %153, i32 0, i32 1
  %155 = load ptr, ptr %154, align 8, !tbaa !20
  %156 = load ptr, ptr %22, align 8, !tbaa !5
  call void @ASN1_STRING_set0(ptr noundef %155, ptr noundef %156, i32 noundef 384)
  %157 = load ptr, ptr %13, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.e_swk, ptr %157, i32 0, i32 0
  %159 = load ptr, ptr %158, align 8, !tbaa !22
  %160 = load ptr, ptr %21, align 8, !tbaa !5
  call void @ASN1_STRING_set0(ptr noundef %159, ptr noundef %160, i32 noundef 384)
  %161 = load ptr, ptr %10, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.wrapping_metadata, ptr %161, i32 0, i32 2
  %163 = load ptr, ptr %162, align 8, !tbaa !23
  %164 = load ptr, ptr %13, align 8, !tbaa !5
  %165 = call i32 @sk_ESWK_push(ptr noundef %163, ptr noundef %164)
  %166 = load ptr, ptr %10, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.wrapping_metadata, ptr %166, i32 0, i32 2
  %168 = load ptr, ptr %167, align 8, !tbaa !23
  %169 = call i32 @sk_ESWK_num(ptr noundef %168)
  %170 = call i32 (i32, ptr, ...) @xlog(i32 noundef 2, ptr noundef @.str.12, i32 noundef %169)
  br label %171

171:                                              ; preds = %139
  %172 = load i32, ptr %24, align 4, !tbaa !9
  %173 = add nsw i32 %172, 1
  store i32 %173, ptr %24, align 4, !tbaa !9
  br label %81, !llvm.loop !24

174:                                              ; preds = %81
  %175 = load ptr, ptr %10, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.wrapping_metadata, ptr %175, i32 0, i32 0
  %177 = load ptr, ptr %176, align 8, !tbaa !26
  %178 = load ptr, ptr %20, align 8, !tbaa !5
  call void @ASN1_STRING_set0(ptr noundef %177, ptr noundef %178, i32 noundef 12)
  %179 = load ptr, ptr %7, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.kpt_rsa_key, ptr %179, i32 0, i32 5
  %181 = load ptr, ptr %180, align 8, !tbaa !27
  store ptr %181, ptr %11, align 8, !tbaa !5
  %182 = load ptr, ptr %11, align 8, !tbaa !5
  %183 = icmp ne ptr %182, null
  br i1 %183, label %185, label %184

184:                                              ; preds = %174
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

185:                                              ; preds = %174
  %186 = load ptr, ptr %5, align 8, !tbaa !5
  %187 = load ptr, ptr %11, align 8, !tbaa !5
  call void @build_rsa_public_key(ptr noundef %186, ptr noundef %187)
  %188 = load ptr, ptr %5, align 8, !tbaa !5
  %189 = getelementptr inbounds [32 x i8], ptr %14, i64 0, i64 0
  %190 = load ptr, ptr %20, align 8, !tbaa !5
  %191 = call i32 @build_kpt_wpk(ptr noundef %188, ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr noundef %18, ptr noundef %19, ptr noundef %189, ptr noundef %190)
  store i32 %191, ptr %23, align 4, !tbaa !9
  %192 = load i32, ptr %23, align 4, !tbaa !9
  %193 = icmp slt i32 %192, 0
  br i1 %193, label %194, label %195

194:                                              ; preds = %185
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

195:                                              ; preds = %185
  %196 = load ptr, ptr %15, align 8, !tbaa !5
  %197 = load i32, ptr %18, align 4, !tbaa !9
  call void @hex_log(ptr noundef %196, i32 noundef %197, ptr noundef @.str.13)
  %198 = load ptr, ptr %16, align 8, !tbaa !5
  %199 = load i32, ptr %19, align 4, !tbaa !9
  call void @hex_log(ptr noundef %198, i32 noundef %199, ptr noundef @.str.14)
  %200 = load ptr, ptr %7, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.kpt_rsa_key, ptr %200, i32 0, i32 0
  store i64 1, ptr %201, align 8, !tbaa !28
  %202 = load ptr, ptr %7, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.kpt_rsa_key, ptr %202, i32 0, i32 1
  %204 = load ptr, ptr %203, align 8, !tbaa !29
  %205 = load ptr, ptr %15, align 8, !tbaa !5
  %206 = load i32, ptr %18, align 4, !tbaa !9
  call void @ASN1_STRING_set0(ptr noundef %204, ptr noundef %205, i32 noundef %206)
  %207 = load ptr, ptr %7, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.kpt_rsa_key, ptr %207, i32 0, i32 2
  %209 = load ptr, ptr %208, align 8, !tbaa !30
  %210 = load ptr, ptr %16, align 8, !tbaa !5
  %211 = load i32, ptr %19, align 4, !tbaa !9
  call void @ASN1_STRING_set0(ptr noundef %209, ptr noundef %210, i32 noundef %211)
  %212 = load i32, ptr %17, align 4, !tbaa !9
  %213 = zext i32 %212 to i64
  %214 = load ptr, ptr %7, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.kpt_rsa_key, ptr %214, i32 0, i32 3
  store i64 %213, ptr %215, align 8, !tbaa !31
  %216 = call ptr @OBJ_nid2obj(i32 noundef 186)
  %217 = load ptr, ptr %7, align 8, !tbaa !5
  %218 = getelementptr inbounds %struct.kpt_rsa_key, ptr %217, i32 0, i32 4
  store ptr %216, ptr %218, align 8, !tbaa !32
  %219 = load ptr, ptr %11, align 8, !tbaa !5
  %220 = load ptr, ptr %7, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.kpt_rsa_key, ptr %220, i32 0, i32 5
  store ptr %219, ptr %221, align 8, !tbaa !27
  %222 = call ptr @BIO_s_file()
  %223 = call ptr @BIO_new(ptr noundef %222)
  store ptr %223, ptr %9, align 8, !tbaa !5
  %224 = icmp eq ptr %223, null
  br i1 %224, label %225, label %226

225:                                              ; preds = %195
  store i32 -1, ptr %23, align 4, !tbaa !9
  br label %239

226:                                              ; preds = %195
  %227 = load ptr, ptr %9, align 8, !tbaa !5
  %228 = load ptr, ptr %4, align 8, !tbaa !5
  %229 = call i64 @BIO_ctrl(ptr noundef %227, i32 noundef 108, i64 noundef 5, ptr noundef %228)
  %230 = trunc i64 %229 to i32
  %231 = load ptr, ptr %9, align 8, !tbaa !5
  %232 = load ptr, ptr %7, align 8, !tbaa !5
  %233 = call i32 @PEM_ASN1_write_bio(ptr noundef @i2d_KPTRSAKEY, ptr noundef @.str.15, ptr noundef %231, ptr noundef %232, ptr noundef null, ptr noundef null, i32 noundef 0, ptr noundef null, ptr noundef null)
  %234 = load ptr, ptr %9, align 8, !tbaa !5
  %235 = call i64 @BIO_ctrl(ptr noundef %234, i32 noundef 11, i64 noundef 0, ptr noundef null)
  %236 = trunc i64 %235 to i32
  %237 = load ptr, ptr %9, align 8, !tbaa !5
  %238 = call i32 @BIO_free(ptr noundef %237)
  br label %239

239:                                              ; preds = %226, %225, %194, %184, %138, %96, %92, %88, %79, %68, %62, %56, %51, %43, %36, %28
  %240 = load ptr, ptr %7, align 8, !tbaa !5
  %241 = icmp ne ptr %240, null
  br i1 %241, label %242, label %244

242:                                              ; preds = %239
  %243 = load ptr, ptr %7, align 8, !tbaa !5
  call void @KPTRSAKEY_free(ptr noundef %243)
  br label %244

244:                                              ; preds = %242, %239
  %245 = load ptr, ptr %5, align 8, !tbaa !5
  %246 = icmp ne ptr %245, null
  br i1 %246, label %247, label %249

247:                                              ; preds = %244
  %248 = load ptr, ptr %5, align 8, !tbaa !5
  call void @RSA_free(ptr noundef %248)
  br label %249

249:                                              ; preds = %247, %244
  %250 = load ptr, ptr %6, align 8, !tbaa !5
  %251 = icmp ne ptr %250, null
  br i1 %251, label %252, label %254

252:                                              ; preds = %249
  %253 = load ptr, ptr %6, align 8, !tbaa !5
  call void @EVP_PKEY_free(ptr noundef %253)
  br label %254

254:                                              ; preds = %252, %249
  %255 = load i32, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 4, 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 8, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 %255
}

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

declare ptr @BIO_new(ptr noundef) #2

declare ptr @BIO_s_file() #2

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

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

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

declare i32 @BIO_free(ptr noundef) #2

declare ptr @EVP_PKEY_get1_RSA(ptr noundef) #2

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

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

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

declare i32 @kpt_get_per_part_key() #2

declare ptr @ESWK_new() #2

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

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

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

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

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

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

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

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

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

declare ptr @OBJ_nid2obj(i32 noundef) #2

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

declare void @RSA_free(ptr noundef) #2

declare void @EVP_PKEY_free(ptr noundef) #2

; 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 48}
!12 = !{!"kpt_rsa_key", !13, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"wrapping_metadata", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!17, !10, i64 384}
!17 = !{!"", !7, i64 0, !10, i64 384, !7, i64 388, !10, i64 396, !7, i64 400, !10, i64 784}
!18 = !{!17, !10, i64 396}
!19 = !{!17, !10, i64 784}
!20 = !{!21, !6, i64 8}
!21 = !{!"e_swk", !6, i64 0, !6, i64 8}
!22 = !{!21, !6, i64 0}
!23 = !{!15, !6, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!15, !6, i64 0}
!27 = !{!12, !6, i64 40}
!28 = !{!12, !13, i64 0}
!29 = !{!12, !6, i64 8}
!30 = !{!12, !6, i64 16}
!31 = !{!12, !13, i64 24}
!32 = !{!12, !6, i64 32}


; 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.2 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.7 = 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.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, -2147483648) i32 @kpt_rsa_wpk_gen(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca [32 x i8], align 16
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  %9 = tail call ptr @BIO_s_file() #5
  %10 = tail call ptr @BIO_new(ptr noundef %9) #5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %14

12:                                               ; preds = %2
  %13 = tail call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef nonnull @.str.2) #5
  br label %.thread.thread.thread

14:                                               ; preds = %2
  %15 = tail call i64 @BIO_ctrl(ptr noundef nonnull %10, i32 noundef 108, i64 noundef 3, ptr noundef %0) #5
  %16 = and i64 %15, 4294967295
  %.not = icmp eq i64 %16, 0
  br i1 %.not, label %17, label %19

17:                                               ; preds = %14
  %18 = tail call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef nonnull @.str.3, ptr noundef %0) #5
  br label %.thread.thread.thread

19:                                               ; preds = %14
  %20 = tail call ptr @PEM_read_bio_PrivateKey(ptr noundef nonnull %10, ptr noundef null, ptr noundef null, ptr noundef null) #5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = tail call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef nonnull @.str.4) #5
  br label %.thread.thread.thread

24:                                               ; preds = %19
  %25 = tail call i32 @BIO_free(ptr noundef nonnull %10) #5
  %26 = tail call ptr @EVP_PKEY_get1_RSA(ptr noundef nonnull %20) #5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %.thread.thread.thread122, label %29

.thread.thread.thread122:                         ; preds = %24
  %28 = tail call i32 (i32, ptr, ...) @xlog(i32 noundef 0, ptr noundef nonnull @.str.5) #5
  br label %114

29:                                               ; preds = %24
  %30 = tail call ptr @CRYPTO_malloc(i64 noundef 12, ptr noundef nonnull @.str.6, i32 noundef 431) #5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %.thread.thread110, label %32

32:                                               ; preds = %29
  %33 = tail call i32 @RAND_bytes(ptr noundef nonnull %30, i32 noundef 12) #5
  %34 = tail call ptr @KPTRSAKEY_new()
  %35 = icmp eq ptr %34, null
  br i1 %35, label %.thread.thread110, label %36

36:                                               ; preds = %32
  %37 = getelementptr inbounds i8, ptr %34, i64 48
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = icmp eq ptr %38, null
  br i1 %39, label %.thread93, label %40

40:                                               ; preds = %36
  %41 = tail call ptr @OBJ_txt2obj(ptr noundef nonnull @.str.7, i32 noundef 0) #5
  %42 = getelementptr inbounds i8, ptr %38, i64 8
  store ptr %41, ptr %42, align 8, !tbaa !14
  %43 = call i32 @RAND_bytes(ptr noundef nonnull %3, i32 noundef 32) #5
  %44 = call i32 @kpt_get_per_part_key() #5
  %.not79 = icmp eq i32 %44, 0
  br i1 %.not79, label %.preheader, label %.thread93

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

.lr.ph:                                           ; preds = %.preheader
  %47 = getelementptr inbounds i8, ptr %38, i64 16
  br label %48

48:                                               ; preds = %.lr.ph, %67
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %67 ]
  %49 = call ptr @ESWK_new() #5
  %50 = icmp eq ptr %49, null
  br i1 %50, label %.thread93, label %51

51:                                               ; preds = %48
  %52 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef nonnull @.str.6, i32 noundef 464) #5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %.thread93, label %54

54:                                               ; preds = %51
  %55 = call ptr @CRYPTO_zalloc(i64 noundef 384, ptr noundef nonnull @.str.6, i32 noundef 469) #5
  %56 = icmp eq ptr %55, null
  br i1 %56, label %.thread93, label %57

57:                                               ; preds = %54
  %58 = getelementptr inbounds [32 x %struct.kpt_per_part_context], ptr @kpt_per_part_context_ptr, i64 0, i64 %indvars.iv
  call void @hex_log(ptr noundef nonnull %58, i32 noundef 384, ptr noundef nonnull @.str.8)
  %59 = getelementptr inbounds i8, ptr %58, i64 388
  call void @hex_log(ptr noundef nonnull %59, i32 noundef 8, ptr noundef nonnull @.str.9)
  %60 = getelementptr inbounds i8, ptr %58, i64 400
  call void @hex_log(ptr noundef nonnull %60, i32 noundef 384, ptr noundef nonnull @.str.10)
  %61 = getelementptr inbounds i8, ptr %58, i64 384
  %62 = load i32, ptr %61, align 4, !tbaa !16
  %63 = getelementptr inbounds i8, ptr %58, i64 396
  %64 = load i32, ptr %63, align 4, !tbaa !18
  %65 = call i32 @encrypt_swk_with_per_part_key(ptr noundef nonnull %3, ptr noundef nonnull %52, ptr noundef nonnull %58, i32 noundef %62, ptr noundef nonnull %59, i32 noundef %64) #5
  %66 = icmp slt i32 %65, 1
  br i1 %66, label %.thread93, label %67

67:                                               ; preds = %57
  call void @hex_log(ptr noundef nonnull %52, i32 noundef 384, ptr noundef nonnull @.str.11)
  %68 = getelementptr inbounds i8, ptr %58, i64 784
  %69 = load i32, ptr %68, align 4, !tbaa !19
  %70 = sext i32 %69 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %55, ptr nonnull align 4 %60, i64 %70, i1 false)
  %71 = getelementptr inbounds i8, ptr %49, i64 8
  %72 = load ptr, ptr %71, align 8, !tbaa !20
  call void @ASN1_STRING_set0(ptr noundef %72, ptr noundef nonnull %52, i32 noundef 384) #5
  %73 = load ptr, ptr %49, align 8, !tbaa !22
  call void @ASN1_STRING_set0(ptr noundef %73, ptr noundef nonnull %55, i32 noundef 384) #5
  %74 = load ptr, ptr %47, align 8, !tbaa !23
  %75 = call i32 @sk_ESWK_push(ptr noundef %74, ptr noundef nonnull %49)
  %76 = load ptr, ptr %47, align 8, !tbaa !23
  %77 = call i32 @sk_ESWK_num(ptr noundef %76)
  %78 = call i32 (i32, ptr, ...) @xlog(i32 noundef 2, ptr noundef nonnull @.str.12, i32 noundef %77) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %79 = load i32, ptr @cpu_socket_num, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv.next, %80
  br i1 %81, label %48, label %._crit_edge, !llvm.loop !24

._crit_edge:                                      ; preds = %67, %.preheader
  %82 = load ptr, ptr %38, align 8, !tbaa !26
  call void @ASN1_STRING_set0(ptr noundef %82, ptr noundef nonnull %30, i32 noundef 12) #5
  %83 = getelementptr inbounds i8, ptr %34, i64 40
  %84 = load ptr, ptr %83, align 8, !tbaa !27
  %.not80 = icmp eq ptr %84, null
  br i1 %.not80, label %.thread93, label %85

85:                                               ; preds = %._crit_edge
  call void @build_rsa_public_key(ptr noundef nonnull %26, ptr noundef nonnull %84)
  %86 = call i32 @build_kpt_wpk(ptr noundef nonnull %26, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %3, ptr noundef nonnull %30)
  %87 = icmp slt i32 %86, 0
  br i1 %87, label %.thread93, label %88

88:                                               ; preds = %85
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = load i32, ptr %7, align 4, !tbaa !9
  call void @hex_log(ptr noundef %89, i32 noundef %90, ptr noundef nonnull @.str.13)
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = load i32, ptr %8, align 4, !tbaa !9
  call void @hex_log(ptr noundef %91, i32 noundef %92, ptr noundef nonnull @.str.14)
  store i64 1, ptr %34, align 8, !tbaa !28
  %93 = getelementptr inbounds i8, ptr %34, i64 8
  %94 = load ptr, ptr %93, align 8, !tbaa !29
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = load i32, ptr %7, align 4, !tbaa !9
  call void @ASN1_STRING_set0(ptr noundef %94, ptr noundef %95, i32 noundef %96) #5
  %97 = getelementptr inbounds i8, ptr %34, i64 16
  %98 = load ptr, ptr %97, align 8, !tbaa !30
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = load i32, ptr %8, align 4, !tbaa !9
  call void @ASN1_STRING_set0(ptr noundef %98, ptr noundef %99, i32 noundef %100) #5
  %101 = load i32, ptr %6, align 4, !tbaa !9
  %102 = zext i32 %101 to i64
  %103 = getelementptr inbounds i8, ptr %34, i64 24
  store i64 %102, ptr %103, align 8, !tbaa !31
  %104 = call ptr @OBJ_nid2obj(i32 noundef 186) #5
  %105 = getelementptr inbounds i8, ptr %34, i64 32
  store ptr %104, ptr %105, align 8, !tbaa !32
  store ptr %84, ptr %83, align 8, !tbaa !27
  %106 = call ptr @BIO_s_file() #5
  %107 = call ptr @BIO_new(ptr noundef %106) #5
  %108 = icmp eq ptr %107, null
  br i1 %108, label %.thread93, label %109

109:                                              ; preds = %88
  %110 = call i64 @BIO_ctrl(ptr noundef nonnull %107, i32 noundef 108, i64 noundef 5, ptr noundef %1) #5
  %111 = call i32 @PEM_ASN1_write_bio(ptr noundef nonnull @i2d_KPTRSAKEY, ptr noundef nonnull @.str.15, ptr noundef nonnull %107, ptr noundef nonnull %34, ptr noundef null, ptr noundef null, i32 noundef 0, ptr noundef null, ptr noundef null) #5
  %112 = call i64 @BIO_ctrl(ptr noundef nonnull %107, i32 noundef 11, i64 noundef 0, ptr noundef null) #5
  %113 = call i32 @BIO_free(ptr noundef nonnull %107) #5
  br label %.thread93

.thread93:                                        ; preds = %48, %51, %54, %57, %88, %85, %._crit_edge, %40, %36, %109
  %.061102 = phi i32 [ -1, %88 ], [ -1, %85 ], [ -1, %._crit_edge ], [ -1, %40 ], [ -1, %36 ], [ %86, %109 ], [ -1, %57 ], [ -1, %54 ], [ -1, %51 ], [ -1, %48 ]
  call void @KPTRSAKEY_free(ptr noundef nonnull %34)
  br label %.thread.thread110

.thread.thread110:                                ; preds = %.thread93, %29, %32
  %.06191115 = phi i32 [ %.061102, %.thread93 ], [ -1, %32 ], [ -1, %29 ]
  call void @RSA_free(ptr noundef nonnull %26) #5
  br label %114

114:                                              ; preds = %.thread.thread110, %.thread.thread.thread122
  %.06191107127 = phi i32 [ -1, %.thread.thread.thread122 ], [ %.06191115, %.thread.thread110 ]
  call void @EVP_PKEY_free(ptr noundef nonnull %20) #5
  br label %.thread.thread.thread

.thread.thread.thread:                            ; preds = %17, %22, %12, %114
  %.06191107121 = phi i32 [ %.06191107127, %114 ], [ -1, %12 ], [ -1, %22 ], [ -1, %17 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  ret i32 %.06191107121
}

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

declare ptr @BIO_new(ptr noundef) local_unnamed_addr #2

declare ptr @BIO_s_file() local_unnamed_addr #2

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

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

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

declare i32 @BIO_free(ptr noundef) local_unnamed_addr #2

declare ptr @EVP_PKEY_get1_RSA(ptr noundef) local_unnamed_addr #2

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

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

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

declare i32 @kpt_get_per_part_key() local_unnamed_addr #2

declare ptr @ESWK_new() local_unnamed_addr #2

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

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

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

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

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

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

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

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

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

declare ptr @OBJ_nid2obj(i32 noundef) local_unnamed_addr #2

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 #2

declare void @RSA_free(ptr noundef) local_unnamed_addr #2

declare void @EVP_PKEY_free(ptr noundef) local_unnamed_addr #2

; 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 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 48}
!12 = !{!"kpt_rsa_key", !13, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"wrapping_metadata", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!17, !10, i64 384}
!17 = !{!"", !7, i64 0, !10, i64 384, !7, i64 388, !10, i64 396, !7, i64 400, !10, i64 784}
!18 = !{!17, !10, i64 396}
!19 = !{!17, !10, i64 784}
!20 = !{!21, !6, i64 8}
!21 = !{!"e_swk", !6, i64 0, !6, i64 8}
!22 = !{!21, !6, i64 0}
!23 = !{!15, !6, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!15, !6, i64 0}
!27 = !{!12, !6, i64 40}
!28 = !{!12, !13, i64 0}
!29 = !{!12, !6, i64 8}
!30 = !{!12, !6, i64 16}
!31 = !{!12, !13, i64 24}
!32 = !{!12, !6, i64 32}


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