; LLVM IR from openanolis/openssl :: crypto/sm2 (sm2_sign)

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

@.str = external hidden unnamed_addr constant [74 x i8], align 1
@__func__.ossl_sm2_compute_z_digest = external hidden unnamed_addr constant [26 x i8], align 1

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

31:                                               ; preds = %5
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 47, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null)
  br label %221

32:                                               ; preds = %5
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = call ptr @ossl_ec_key_get_libctx(ptr noundef %33)
  %35 = call ptr @BN_CTX_new_ex(ptr noundef %34)
  store ptr %35, ptr %13, align 8, !tbaa !5
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %32
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 52, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524291, ptr noundef null)
  br label %221

39:                                               ; preds = %32
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = call ptr @BN_CTX_get(ptr noundef %40)
  store ptr %41, ptr %15, align 8, !tbaa !5
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = call ptr @BN_CTX_get(ptr noundef %42)
  store ptr %43, ptr %16, align 8, !tbaa !5
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = call ptr @BN_CTX_get(ptr noundef %44)
  store ptr %45, ptr %17, align 8, !tbaa !5
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  %47 = call ptr @BN_CTX_get(ptr noundef %46)
  store ptr %47, ptr %18, align 8, !tbaa !5
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = call ptr @BN_CTX_get(ptr noundef %48)
  store ptr %49, ptr %19, align 8, !tbaa !5
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = call ptr @BN_CTX_get(ptr noundef %50)
  store ptr %51, ptr %20, align 8, !tbaa !5
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = call ptr @BN_CTX_get(ptr noundef %52)
  store ptr %53, ptr %21, align 8, !tbaa !5
  %54 = load ptr, ptr %21, align 8, !tbaa !5
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %57

56:                                               ; preds = %39
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 65, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524291, ptr noundef null)
  br label %221

57:                                               ; preds = %39
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = call i32 @EVP_DigestInit(ptr noundef %58, ptr noundef %59)
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %63, label %62

62:                                               ; preds = %57
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 70, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null)
  br label %221

63:                                               ; preds = %57
  %64 = load i64, ptr %9, align 8, !tbaa !9
  %65 = icmp uge i64 %64, 8191
  br i1 %65, label %66, label %67

66:                                               ; preds = %63
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 78, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 111, ptr noundef null)
  br label %221

67:                                               ; preds = %63
  %68 = load i64, ptr %9, align 8, !tbaa !9
  %69 = mul i64 8, %68
  %70 = trunc i64 %69 to i16
  store i16 %70, ptr %24, align 2, !tbaa !13
  %71 = load i16, ptr %24, align 2, !tbaa !13
  %72 = zext i16 %71 to i32
  %73 = ashr i32 %72, 8
  %74 = trunc i32 %73 to i8
  store i8 %74, ptr %25, align 1, !tbaa !15
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = call i32 @EVP_DigestUpdate(ptr noundef %75, ptr noundef %25, i64 noundef 1)
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %79, label %78

78:                                               ; preds = %67
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 86, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null)
  br label %221

79:                                               ; preds = %67
  %80 = load i16, ptr %24, align 2, !tbaa !13
  %81 = zext i16 %80 to i32
  %82 = and i32 %81, 255
  %83 = trunc i32 %82 to i8
  store i8 %83, ptr %25, align 1, !tbaa !15
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = call i32 @EVP_DigestUpdate(ptr noundef %84, ptr noundef %25, i64 noundef 1)
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %88, label %87

87:                                               ; preds = %79
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 91, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null)
  br label %221

88:                                               ; preds = %79
  %89 = load i64, ptr %9, align 8, !tbaa !9
  %90 = icmp ugt i64 %89, 0
  br i1 %90, label %91, label %98

91:                                               ; preds = %88
  %92 = load ptr, ptr %14, align 8, !tbaa !5
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = load i64, ptr %9, align 8, !tbaa !9
  %95 = call i32 @EVP_DigestUpdate(ptr noundef %92, ptr noundef %93, i64 noundef %94)
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %98, label %97

97:                                               ; preds = %91
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 96, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null)
  br label %221

98:                                               ; preds = %91, %88
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = load ptr, ptr %15, align 8, !tbaa !5
  %101 = load ptr, ptr %16, align 8, !tbaa !5
  %102 = load ptr, ptr %17, align 8, !tbaa !5
  %103 = load ptr, ptr %13, align 8, !tbaa !5
  %104 = call i32 @EC_GROUP_get_curve(ptr noundef %99, ptr noundef %100, ptr noundef %101, ptr noundef %102, ptr noundef %103)
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %107, label %106

106:                                              ; preds = %98
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 101, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524304, ptr noundef null)
  br label %221

107:                                              ; preds = %98
  %108 = load ptr, ptr %15, align 8, !tbaa !5
  %109 = call i32 @BN_num_bits(ptr noundef %108)
  %110 = add nsw i32 %109, 7
  %111 = sdiv i32 %110, 8
  store i32 %111, ptr %22, align 4, !tbaa !11
  %112 = load i32, ptr %22, align 4, !tbaa !11
  %113 = sext i32 %112 to i64
  %114 = call ptr @CRYPTO_zalloc(i64 noundef %113, ptr noundef @.str, i32 noundef 106)
  store ptr %114, ptr %23, align 8, !tbaa !5
  %115 = load ptr, ptr %23, align 8, !tbaa !5
  %116 = icmp eq ptr %115, null
  br i1 %116, label %117, label %118

117:                                              ; preds = %107
  br label %221

118:                                              ; preds = %107
  %119 = load ptr, ptr %16, align 8, !tbaa !5
  %120 = load ptr, ptr %23, align 8, !tbaa !5
  %121 = load i32, ptr %22, align 4, !tbaa !11
  %122 = call i32 @BN_bn2binpad(ptr noundef %119, ptr noundef %120, i32 noundef %121)
  %123 = icmp slt i32 %122, 0
  br i1 %123, label %219, label %124

124:                                              ; preds = %118
  %125 = load ptr, ptr %14, align 8, !tbaa !5
  %126 = load ptr, ptr %23, align 8, !tbaa !5
  %127 = load i32, ptr %22, align 4, !tbaa !11
  %128 = sext i32 %127 to i64
  %129 = call i32 @EVP_DigestUpdate(ptr noundef %125, ptr noundef %126, i64 noundef %128)
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %131, label %219

131:                                              ; preds = %124
  %132 = load ptr, ptr %17, align 8, !tbaa !5
  %133 = load ptr, ptr %23, align 8, !tbaa !5
  %134 = load i32, ptr %22, align 4, !tbaa !11
  %135 = call i32 @BN_bn2binpad(ptr noundef %132, ptr noundef %133, i32 noundef %134)
  %136 = icmp slt i32 %135, 0
  br i1 %136, label %219, label %137

137:                                              ; preds = %131
  %138 = load ptr, ptr %14, align 8, !tbaa !5
  %139 = load ptr, ptr %23, align 8, !tbaa !5
  %140 = load i32, ptr %22, align 4, !tbaa !11
  %141 = sext i32 %140 to i64
  %142 = call i32 @EVP_DigestUpdate(ptr noundef %138, ptr noundef %139, i64 noundef %141)
  %143 = icmp ne i32 %142, 0
  br i1 %143, label %144, label %219

144:                                              ; preds = %137
  %145 = load ptr, ptr %12, align 8, !tbaa !5
  %146 = load ptr, ptr %12, align 8, !tbaa !5
  %147 = call ptr @EC_GROUP_get0_generator(ptr noundef %146)
  %148 = load ptr, ptr %18, align 8, !tbaa !5
  %149 = load ptr, ptr %19, align 8, !tbaa !5
  %150 = load ptr, ptr %13, align 8, !tbaa !5
  %151 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %145, ptr noundef %147, ptr noundef %148, ptr noundef %149, ptr noundef %150)
  %152 = icmp ne i32 %151, 0
  br i1 %152, label %153, label %219

153:                                              ; preds = %144
  %154 = load ptr, ptr %18, align 8, !tbaa !5
  %155 = load ptr, ptr %23, align 8, !tbaa !5
  %156 = load i32, ptr %22, align 4, !tbaa !11
  %157 = call i32 @BN_bn2binpad(ptr noundef %154, ptr noundef %155, i32 noundef %156)
  %158 = icmp slt i32 %157, 0
  br i1 %158, label %219, label %159

159:                                              ; preds = %153
  %160 = load ptr, ptr %14, align 8, !tbaa !5
  %161 = load ptr, ptr %23, align 8, !tbaa !5
  %162 = load i32, ptr %22, align 4, !tbaa !11
  %163 = sext i32 %162 to i64
  %164 = call i32 @EVP_DigestUpdate(ptr noundef %160, ptr noundef %161, i64 noundef %163)
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %166, label %219

166:                                              ; preds = %159
  %167 = load ptr, ptr %19, align 8, !tbaa !5
  %168 = load ptr, ptr %23, align 8, !tbaa !5
  %169 = load i32, ptr %22, align 4, !tbaa !11
  %170 = call i32 @BN_bn2binpad(ptr noundef %167, ptr noundef %168, i32 noundef %169)
  %171 = icmp slt i32 %170, 0
  br i1 %171, label %219, label %172

172:                                              ; preds = %166
  %173 = load ptr, ptr %14, align 8, !tbaa !5
  %174 = load ptr, ptr %23, align 8, !tbaa !5
  %175 = load i32, ptr %22, align 4, !tbaa !11
  %176 = sext i32 %175 to i64
  %177 = call i32 @EVP_DigestUpdate(ptr noundef %173, ptr noundef %174, i64 noundef %176)
  %178 = icmp ne i32 %177, 0
  br i1 %178, label %179, label %219

179:                                              ; preds = %172
  %180 = load ptr, ptr %12, align 8, !tbaa !5
  %181 = load ptr, ptr %10, align 8, !tbaa !5
  %182 = call ptr @EC_KEY_get0_public_key(ptr noundef %181)
  %183 = load ptr, ptr %20, align 8, !tbaa !5
  %184 = load ptr, ptr %21, align 8, !tbaa !5
  %185 = load ptr, ptr %13, align 8, !tbaa !5
  %186 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %180, ptr noundef %182, ptr noundef %183, ptr noundef %184, ptr noundef %185)
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %188, label %219

188:                                              ; preds = %179
  %189 = load ptr, ptr %20, align 8, !tbaa !5
  %190 = load ptr, ptr %23, align 8, !tbaa !5
  %191 = load i32, ptr %22, align 4, !tbaa !11
  %192 = call i32 @BN_bn2binpad(ptr noundef %189, ptr noundef %190, i32 noundef %191)
  %193 = icmp slt i32 %192, 0
  br i1 %193, label %219, label %194

194:                                              ; preds = %188
  %195 = load ptr, ptr %14, align 8, !tbaa !5
  %196 = load ptr, ptr %23, align 8, !tbaa !5
  %197 = load i32, ptr %22, align 4, !tbaa !11
  %198 = sext i32 %197 to i64
  %199 = call i32 @EVP_DigestUpdate(ptr noundef %195, ptr noundef %196, i64 noundef %198)
  %200 = icmp ne i32 %199, 0
  br i1 %200, label %201, label %219

201:                                              ; preds = %194
  %202 = load ptr, ptr %21, align 8, !tbaa !5
  %203 = load ptr, ptr %23, align 8, !tbaa !5
  %204 = load i32, ptr %22, align 4, !tbaa !11
  %205 = call i32 @BN_bn2binpad(ptr noundef %202, ptr noundef %203, i32 noundef %204)
  %206 = icmp slt i32 %205, 0
  br i1 %206, label %219, label %207

207:                                              ; preds = %201
  %208 = load ptr, ptr %14, align 8, !tbaa !5
  %209 = load ptr, ptr %23, align 8, !tbaa !5
  %210 = load i32, ptr %22, align 4, !tbaa !11
  %211 = sext i32 %210 to i64
  %212 = call i32 @EVP_DigestUpdate(ptr noundef %208, ptr noundef %209, i64 noundef %211)
  %213 = icmp ne i32 %212, 0
  br i1 %213, label %214, label %219

214:                                              ; preds = %207
  %215 = load ptr, ptr %14, align 8, !tbaa !5
  %216 = load ptr, ptr %6, align 8, !tbaa !5
  %217 = call i32 @EVP_DigestFinal(ptr noundef %215, ptr noundef %216, ptr noundef null)
  %218 = icmp ne i32 %217, 0
  br i1 %218, label %220, label %219

219:                                              ; preds = %214, %207, %201, %194, %188, %179, %172, %166, %159, %153, %144, %137, %131, %124, %118
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 129, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 786691, ptr noundef null)
  br label %221

220:                                              ; preds = %214
  store i32 1, ptr %11, align 4, !tbaa !11
  br label %221

221:                                              ; preds = %220, %219, %117, %106, %97, %87, %78, %66, %62, %56, %38, %31
  %222 = load ptr, ptr %23, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %222, ptr noundef @.str, i32 noundef 136)
  %223 = load ptr, ptr %13, align 8, !tbaa !5
  call void @BN_CTX_free(ptr noundef %223)
  %224 = load ptr, ptr %14, align 8, !tbaa !5
  call void @EVP_MD_CTX_free(ptr noundef %224)
  %225 = load i32, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 1, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 %225
}

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

declare ptr @EC_KEY_get0_group(ptr noundef) #2

declare ptr @EVP_MD_CTX_new() #2

declare void @ERR_new() #2

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

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) #2

declare ptr @BN_CTX_new_ex(ptr noundef) #2

declare ptr @ossl_ec_key_get_libctx(ptr noundef) #2

declare ptr @BN_CTX_get(ptr noundef) #2

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

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

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

declare i32 @BN_num_bits(ptr noundef) #2

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

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

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

declare ptr @EC_GROUP_get0_generator(ptr noundef) #2

declare ptr @EC_KEY_get0_public_key(ptr noundef) #2

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

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

declare void @BN_CTX_free(ptr noundef) #2

declare void @EVP_MD_CTX_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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!7, !7, i64 0}


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

@.str = external hidden unnamed_addr constant [74 x i8], align 1
@__func__.ossl_sm2_compute_z_digest = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_sm2_compute_z_digest(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca i8, align 1
  %7 = tail call ptr @EC_KEY_get0_group(ptr noundef %4) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #3
  store i8 0, ptr %6, align 1, !tbaa !5
  %8 = tail call ptr @EVP_MD_CTX_new() #3
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %5
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 47, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null) #3
  br label %94

11:                                               ; preds = %5
  %12 = tail call ptr @ossl_ec_key_get_libctx(ptr noundef %4) #3
  %13 = tail call ptr @BN_CTX_new_ex(ptr noundef %12) #3
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 52, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524291, ptr noundef null) #3
  br label %94

16:                                               ; preds = %11
  %17 = tail call ptr @BN_CTX_get(ptr noundef nonnull %13) #3
  %18 = tail call ptr @BN_CTX_get(ptr noundef nonnull %13) #3
  %19 = tail call ptr @BN_CTX_get(ptr noundef nonnull %13) #3
  %20 = tail call ptr @BN_CTX_get(ptr noundef nonnull %13) #3
  %21 = tail call ptr @BN_CTX_get(ptr noundef nonnull %13) #3
  %22 = tail call ptr @BN_CTX_get(ptr noundef nonnull %13) #3
  %23 = tail call ptr @BN_CTX_get(ptr noundef nonnull %13) #3
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %26

25:                                               ; preds = %16
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 65, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524291, ptr noundef null) #3
  br label %94

26:                                               ; preds = %16
  %27 = tail call i32 @EVP_DigestInit(ptr noundef nonnull %8, ptr noundef %1) #3
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %28, label %29

28:                                               ; preds = %26
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 70, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null) #3
  br label %94

29:                                               ; preds = %26
  %30 = icmp ugt i64 %3, 8190
  br i1 %30, label %31, label %32

31:                                               ; preds = %29
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 78, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 111, ptr noundef null) #3
  br label %94

32:                                               ; preds = %29
  %33 = lshr i64 %3, 5
  %34 = trunc nuw i64 %33 to i8
  store i8 %34, ptr %6, align 1, !tbaa !5
  %35 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %6, i64 noundef 1) #3
  %.not91 = icmp eq i32 %35, 0
  br i1 %.not91, label %36, label %37

36:                                               ; preds = %32
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 86, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null) #3
  br label %94

37:                                               ; preds = %32
  %.tr = trunc i64 %3 to i8
  %38 = shl i8 %.tr, 3
  store i8 %38, ptr %6, align 1, !tbaa !5
  %39 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %6, i64 noundef 1) #3
  %.not92 = icmp eq i32 %39, 0
  br i1 %.not92, label %40, label %41

40:                                               ; preds = %37
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 91, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null) #3
  br label %94

41:                                               ; preds = %37
  %.not93 = icmp eq i64 %3, 0
  br i1 %.not93, label %45, label %42

42:                                               ; preds = %41
  %43 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef %2, i64 noundef %3) #3
  %.not94 = icmp eq i32 %43, 0
  br i1 %.not94, label %44, label %45

44:                                               ; preds = %42
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 96, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524294, ptr noundef null) #3
  br label %94

45:                                               ; preds = %42, %41
  %46 = call i32 @EC_GROUP_get_curve(ptr noundef %7, ptr noundef %17, ptr noundef %18, ptr noundef %19, ptr noundef nonnull %13) #3
  %.not95 = icmp eq i32 %46, 0
  br i1 %.not95, label %47, label %48

47:                                               ; preds = %45
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 101, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 524304, ptr noundef null) #3
  br label %94

48:                                               ; preds = %45
  %49 = call i32 @BN_num_bits(ptr noundef %17) #3
  %50 = add nsw i32 %49, 7
  %51 = sdiv i32 %50, 8
  %52 = sext i32 %51 to i64
  %53 = call ptr @CRYPTO_zalloc(i64 noundef %52, ptr noundef nonnull @.str, i32 noundef 106) #3
  %54 = icmp eq ptr %53, null
  br i1 %54, label %94, label %55

55:                                               ; preds = %48
  %56 = call i32 @BN_bn2binpad(ptr noundef %18, ptr noundef nonnull %53, i32 noundef %51) #3
  %57 = icmp slt i32 %56, 0
  br i1 %57, label %93, label %58

58:                                               ; preds = %55
  %59 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %53, i64 noundef %52) #3
  %.not96 = icmp eq i32 %59, 0
  br i1 %.not96, label %93, label %60

60:                                               ; preds = %58
  %61 = call i32 @BN_bn2binpad(ptr noundef %19, ptr noundef nonnull %53, i32 noundef %51) #3
  %62 = icmp slt i32 %61, 0
  br i1 %62, label %93, label %63

63:                                               ; preds = %60
  %64 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %53, i64 noundef %52) #3
  %.not97 = icmp eq i32 %64, 0
  br i1 %.not97, label %93, label %65

65:                                               ; preds = %63
  %66 = call ptr @EC_GROUP_get0_generator(ptr noundef %7) #3
  %67 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %7, ptr noundef %66, ptr noundef %20, ptr noundef %21, ptr noundef nonnull %13) #3
  %.not98 = icmp eq i32 %67, 0
  br i1 %.not98, label %93, label %68

68:                                               ; preds = %65
  %69 = call i32 @BN_bn2binpad(ptr noundef %20, ptr noundef nonnull %53, i32 noundef %51) #3
  %70 = icmp slt i32 %69, 0
  br i1 %70, label %93, label %71

71:                                               ; preds = %68
  %72 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %53, i64 noundef %52) #3
  %.not99 = icmp eq i32 %72, 0
  br i1 %.not99, label %93, label %73

73:                                               ; preds = %71
  %74 = call i32 @BN_bn2binpad(ptr noundef %21, ptr noundef nonnull %53, i32 noundef %51) #3
  %75 = icmp slt i32 %74, 0
  br i1 %75, label %93, label %76

76:                                               ; preds = %73
  %77 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %53, i64 noundef %52) #3
  %.not100 = icmp eq i32 %77, 0
  br i1 %.not100, label %93, label %78

78:                                               ; preds = %76
  %79 = call ptr @EC_KEY_get0_public_key(ptr noundef %4) #3
  %80 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %7, ptr noundef %79, ptr noundef %22, ptr noundef nonnull %23, ptr noundef nonnull %13) #3
  %.not101 = icmp eq i32 %80, 0
  br i1 %.not101, label %93, label %81

81:                                               ; preds = %78
  %82 = call i32 @BN_bn2binpad(ptr noundef %22, ptr noundef nonnull %53, i32 noundef %51) #3
  %83 = icmp slt i32 %82, 0
  br i1 %83, label %93, label %84

84:                                               ; preds = %81
  %85 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %53, i64 noundef %52) #3
  %.not102 = icmp eq i32 %85, 0
  br i1 %.not102, label %93, label %86

86:                                               ; preds = %84
  %87 = call i32 @BN_bn2binpad(ptr noundef nonnull %23, ptr noundef nonnull %53, i32 noundef %51) #3
  %88 = icmp slt i32 %87, 0
  br i1 %88, label %93, label %89

89:                                               ; preds = %86
  %90 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %8, ptr noundef nonnull %53, i64 noundef %52) #3
  %.not103 = icmp eq i32 %90, 0
  br i1 %.not103, label %93, label %91

91:                                               ; preds = %89
  %92 = call i32 @EVP_DigestFinal(ptr noundef nonnull %8, ptr noundef %0, ptr noundef null) #3
  %.not104 = icmp eq i32 %92, 0
  br i1 %.not104, label %93, label %94

93:                                               ; preds = %91, %89, %86, %84, %81, %78, %76, %73, %71, %68, %65, %63, %60, %58, %55
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 129, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 786691, ptr noundef null) #3
  br label %94

94:                                               ; preds = %91, %48, %93, %47, %44, %40, %36, %31, %28, %25, %15, %10
  %.084 = phi i32 [ 0, %10 ], [ 0, %15 ], [ 0, %25 ], [ 0, %31 ], [ 0, %48 ], [ 0, %93 ], [ 0, %47 ], [ 0, %44 ], [ 0, %40 ], [ 0, %36 ], [ 0, %28 ], [ 1, %91 ]
  %.083 = phi ptr [ null, %10 ], [ null, %15 ], [ %13, %25 ], [ %13, %31 ], [ %13, %48 ], [ %13, %93 ], [ %13, %47 ], [ %13, %44 ], [ %13, %40 ], [ %13, %36 ], [ %13, %28 ], [ %13, %91 ]
  %.0 = phi ptr [ null, %10 ], [ null, %15 ], [ null, %25 ], [ null, %31 ], [ null, %48 ], [ %53, %93 ], [ null, %47 ], [ null, %44 ], [ null, %40 ], [ null, %36 ], [ null, %28 ], [ %53, %91 ]
  call void @CRYPTO_free(ptr noundef %.0, ptr noundef nonnull @.str, i32 noundef 136) #3
  call void @BN_CTX_free(ptr noundef %.083) #3
  call void @EVP_MD_CTX_free(ptr noundef %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  ret i32 %.084
}

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

declare ptr @EC_KEY_get0_group(ptr noundef) local_unnamed_addr #2

declare ptr @EVP_MD_CTX_new() local_unnamed_addr #2

declare void @ERR_new() local_unnamed_addr #2

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

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

declare ptr @BN_CTX_new_ex(ptr noundef) local_unnamed_addr #2

declare ptr @ossl_ec_key_get_libctx(ptr noundef) local_unnamed_addr #2

declare ptr @BN_CTX_get(ptr noundef) local_unnamed_addr #2

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

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

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

declare i32 @BN_num_bits(ptr noundef) local_unnamed_addr #2

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

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

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

declare ptr @EC_GROUP_get0_generator(ptr noundef) local_unnamed_addr #2

declare ptr @EC_KEY_get0_public_key(ptr noundef) local_unnamed_addr #2

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

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

declare void @BN_CTX_free(ptr noundef) local_unnamed_addr #2

declare void @EVP_MD_CTX_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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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