; LLVM IR from openssl/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 [71 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 ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca i16, align 2
  %26 = 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
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = call ptr @EC_KEY_get0_group(ptr noundef %27)
  store ptr %28, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = call ptr @EC_KEY_get0_public_key(ptr noundef %29)
  store ptr %30, 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 8, ptr %22) #3
  store ptr null, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  store i32 0, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  store ptr null, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %25) #3
  store i16 0, ptr %25, align 2, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %26) #3
  store i8 0, ptr %26, align 1, !tbaa !15
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %5
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 48, ptr noundef @__func__.ossl_sm2_compute_z_digest)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 786690, ptr noundef null)
  br label %227

34:                                               ; preds = %5
  %35 = call ptr @EVP_MD_CTX_new()
  store ptr %35, ptr %15, align 8, !tbaa !5
  %36 = load ptr, ptr %15, align 8, !tbaa !5
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 54, 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 %227

39:                                               ; preds = %34
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = call ptr @ossl_ec_key_get_libctx(ptr noundef %40)
  %42 = call ptr @BN_CTX_new_ex(ptr noundef %41)
  store ptr %42, ptr %14, align 8, !tbaa !5
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = icmp eq ptr %43, null
  br i1 %44, label %45, label %46

45:                                               ; preds = %39
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 59, 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 %227

46:                                               ; preds = %39
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = call ptr @BN_CTX_get(ptr noundef %47)
  store ptr %48, ptr %16, align 8, !tbaa !5
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = call ptr @BN_CTX_get(ptr noundef %49)
  store ptr %50, ptr %17, align 8, !tbaa !5
  %51 = load ptr, ptr %14, align 8, !tbaa !5
  %52 = call ptr @BN_CTX_get(ptr noundef %51)
  store ptr %52, ptr %18, align 8, !tbaa !5
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = call ptr @BN_CTX_get(ptr noundef %53)
  store ptr %54, ptr %19, align 8, !tbaa !5
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  %56 = call ptr @BN_CTX_get(ptr noundef %55)
  store ptr %56, ptr %20, align 8, !tbaa !5
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = call ptr @BN_CTX_get(ptr noundef %57)
  store ptr %58, ptr %21, align 8, !tbaa !5
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = call ptr @BN_CTX_get(ptr noundef %59)
  store ptr %60, ptr %22, align 8, !tbaa !5
  %61 = load ptr, ptr %22, align 8, !tbaa !5
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %64

63:                                               ; preds = %46
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 72, 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 %227

64:                                               ; preds = %46
  %65 = load ptr, ptr %15, align 8, !tbaa !5
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = call i32 @EVP_DigestInit(ptr noundef %65, ptr noundef %66)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %70, label %69

69:                                               ; preds = %64
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 77, 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 %227

70:                                               ; preds = %64
  %71 = load i64, ptr %9, align 8, !tbaa !9
  %72 = icmp uge i64 %71, 8191
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 85, 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 %227

74:                                               ; preds = %70
  %75 = load i64, ptr %9, align 8, !tbaa !9
  %76 = mul i64 8, %75
  %77 = trunc i64 %76 to i16
  store i16 %77, ptr %25, align 2, !tbaa !13
  %78 = load i16, ptr %25, align 2, !tbaa !13
  %79 = zext i16 %78 to i32
  %80 = ashr i32 %79, 8
  %81 = trunc i32 %80 to i8
  store i8 %81, ptr %26, align 1, !tbaa !15
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  %83 = call i32 @EVP_DigestUpdate(ptr noundef %82, ptr noundef %26, i64 noundef 1)
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %86, label %85

85:                                               ; preds = %74
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 93, 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 %227

86:                                               ; preds = %74
  %87 = load i16, ptr %25, align 2, !tbaa !13
  %88 = zext i16 %87 to i32
  %89 = and i32 %88, 255
  %90 = trunc i32 %89 to i8
  store i8 %90, ptr %26, align 1, !tbaa !15
  %91 = load ptr, ptr %15, align 8, !tbaa !5
  %92 = call i32 @EVP_DigestUpdate(ptr noundef %91, ptr noundef %26, i64 noundef 1)
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %95, label %94

94:                                               ; preds = %86
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 98, 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 %227

95:                                               ; preds = %86
  %96 = load i64, ptr %9, align 8, !tbaa !9
  %97 = icmp ugt i64 %96, 0
  br i1 %97, label %98, label %105

98:                                               ; preds = %95
  %99 = load ptr, ptr %15, align 8, !tbaa !5
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = load i64, ptr %9, align 8, !tbaa !9
  %102 = call i32 @EVP_DigestUpdate(ptr noundef %99, ptr noundef %100, i64 noundef %101)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %105, label %104

104:                                              ; preds = %98
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 103, 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 %227

105:                                              ; preds = %98, %95
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = load ptr, ptr %16, align 8, !tbaa !5
  %108 = load ptr, ptr %17, align 8, !tbaa !5
  %109 = load ptr, ptr %18, align 8, !tbaa !5
  %110 = load ptr, ptr %14, align 8, !tbaa !5
  %111 = call i32 @EC_GROUP_get_curve(ptr noundef %106, ptr noundef %107, ptr noundef %108, ptr noundef %109, ptr noundef %110)
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %114, label %113

113:                                              ; preds = %105
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 108, 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 %227

114:                                              ; preds = %105
  %115 = load ptr, ptr %16, align 8, !tbaa !5
  %116 = call i32 @BN_num_bits(ptr noundef %115)
  %117 = add nsw i32 %116, 7
  %118 = sdiv i32 %117, 8
  store i32 %118, ptr %23, align 4, !tbaa !11
  %119 = load i32, ptr %23, align 4, !tbaa !11
  %120 = sext i32 %119 to i64
  %121 = call ptr @CRYPTO_zalloc(i64 noundef %120, ptr noundef @.str, i32 noundef 113)
  store ptr %121, ptr %24, align 8, !tbaa !5
  %122 = load ptr, ptr %24, align 8, !tbaa !5
  %123 = icmp eq ptr %122, null
  br i1 %123, label %124, label %125

124:                                              ; preds = %114
  br label %227

125:                                              ; preds = %114
  %126 = load ptr, ptr %17, align 8, !tbaa !5
  %127 = load ptr, ptr %24, align 8, !tbaa !5
  %128 = load i32, ptr %23, align 4, !tbaa !11
  %129 = call i32 @BN_bn2binpad(ptr noundef %126, ptr noundef %127, i32 noundef %128)
  %130 = icmp slt i32 %129, 0
  br i1 %130, label %225, label %131

131:                                              ; preds = %125
  %132 = load ptr, ptr %15, align 8, !tbaa !5
  %133 = load ptr, ptr %24, align 8, !tbaa !5
  %134 = load i32, ptr %23, align 4, !tbaa !11
  %135 = sext i32 %134 to i64
  %136 = call i32 @EVP_DigestUpdate(ptr noundef %132, ptr noundef %133, i64 noundef %135)
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %225

138:                                              ; preds = %131
  %139 = load ptr, ptr %18, align 8, !tbaa !5
  %140 = load ptr, ptr %24, align 8, !tbaa !5
  %141 = load i32, ptr %23, align 4, !tbaa !11
  %142 = call i32 @BN_bn2binpad(ptr noundef %139, ptr noundef %140, i32 noundef %141)
  %143 = icmp slt i32 %142, 0
  br i1 %143, label %225, label %144

144:                                              ; preds = %138
  %145 = load ptr, ptr %15, align 8, !tbaa !5
  %146 = load ptr, ptr %24, align 8, !tbaa !5
  %147 = load i32, ptr %23, align 4, !tbaa !11
  %148 = sext i32 %147 to i64
  %149 = call i32 @EVP_DigestUpdate(ptr noundef %145, ptr noundef %146, i64 noundef %148)
  %150 = icmp ne i32 %149, 0
  br i1 %150, label %151, label %225

151:                                              ; preds = %144
  %152 = load ptr, ptr %12, align 8, !tbaa !5
  %153 = load ptr, ptr %12, align 8, !tbaa !5
  %154 = call ptr @EC_GROUP_get0_generator(ptr noundef %153)
  %155 = load ptr, ptr %19, align 8, !tbaa !5
  %156 = load ptr, ptr %20, align 8, !tbaa !5
  %157 = load ptr, ptr %14, align 8, !tbaa !5
  %158 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %152, ptr noundef %154, ptr noundef %155, ptr noundef %156, ptr noundef %157)
  %159 = icmp ne i32 %158, 0
  br i1 %159, label %160, label %225

160:                                              ; preds = %151
  %161 = load ptr, ptr %19, align 8, !tbaa !5
  %162 = load ptr, ptr %24, align 8, !tbaa !5
  %163 = load i32, ptr %23, align 4, !tbaa !11
  %164 = call i32 @BN_bn2binpad(ptr noundef %161, ptr noundef %162, i32 noundef %163)
  %165 = icmp slt i32 %164, 0
  br i1 %165, label %225, label %166

166:                                              ; preds = %160
  %167 = load ptr, ptr %15, align 8, !tbaa !5
  %168 = load ptr, ptr %24, align 8, !tbaa !5
  %169 = load i32, ptr %23, align 4, !tbaa !11
  %170 = sext i32 %169 to i64
  %171 = call i32 @EVP_DigestUpdate(ptr noundef %167, ptr noundef %168, i64 noundef %170)
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %173, label %225

173:                                              ; preds = %166
  %174 = load ptr, ptr %20, align 8, !tbaa !5
  %175 = load ptr, ptr %24, align 8, !tbaa !5
  %176 = load i32, ptr %23, align 4, !tbaa !11
  %177 = call i32 @BN_bn2binpad(ptr noundef %174, ptr noundef %175, i32 noundef %176)
  %178 = icmp slt i32 %177, 0
  br i1 %178, label %225, label %179

179:                                              ; preds = %173
  %180 = load ptr, ptr %15, align 8, !tbaa !5
  %181 = load ptr, ptr %24, align 8, !tbaa !5
  %182 = load i32, ptr %23, align 4, !tbaa !11
  %183 = sext i32 %182 to i64
  %184 = call i32 @EVP_DigestUpdate(ptr noundef %180, ptr noundef %181, i64 noundef %183)
  %185 = icmp ne i32 %184, 0
  br i1 %185, label %186, label %225

186:                                              ; preds = %179
  %187 = load ptr, ptr %12, align 8, !tbaa !5
  %188 = load ptr, ptr %13, align 8, !tbaa !5
  %189 = load ptr, ptr %21, align 8, !tbaa !5
  %190 = load ptr, ptr %22, align 8, !tbaa !5
  %191 = load ptr, ptr %14, align 8, !tbaa !5
  %192 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %187, ptr noundef %188, ptr noundef %189, ptr noundef %190, ptr noundef %191)
  %193 = icmp ne i32 %192, 0
  br i1 %193, label %194, label %225

194:                                              ; preds = %186
  %195 = load ptr, ptr %21, align 8, !tbaa !5
  %196 = load ptr, ptr %24, align 8, !tbaa !5
  %197 = load i32, ptr %23, align 4, !tbaa !11
  %198 = call i32 @BN_bn2binpad(ptr noundef %195, ptr noundef %196, i32 noundef %197)
  %199 = icmp slt i32 %198, 0
  br i1 %199, label %225, label %200

200:                                              ; preds = %194
  %201 = load ptr, ptr %15, align 8, !tbaa !5
  %202 = load ptr, ptr %24, align 8, !tbaa !5
  %203 = load i32, ptr %23, align 4, !tbaa !11
  %204 = sext i32 %203 to i64
  %205 = call i32 @EVP_DigestUpdate(ptr noundef %201, ptr noundef %202, i64 noundef %204)
  %206 = icmp ne i32 %205, 0
  br i1 %206, label %207, label %225

207:                                              ; preds = %200
  %208 = load ptr, ptr %22, align 8, !tbaa !5
  %209 = load ptr, ptr %24, align 8, !tbaa !5
  %210 = load i32, ptr %23, align 4, !tbaa !11
  %211 = call i32 @BN_bn2binpad(ptr noundef %208, ptr noundef %209, i32 noundef %210)
  %212 = icmp slt i32 %211, 0
  br i1 %212, label %225, label %213

213:                                              ; preds = %207
  %214 = load ptr, ptr %15, align 8, !tbaa !5
  %215 = load ptr, ptr %24, align 8, !tbaa !5
  %216 = load i32, ptr %23, align 4, !tbaa !11
  %217 = sext i32 %216 to i64
  %218 = call i32 @EVP_DigestUpdate(ptr noundef %214, ptr noundef %215, i64 noundef %217)
  %219 = icmp ne i32 %218, 0
  br i1 %219, label %220, label %225

220:                                              ; preds = %213
  %221 = load ptr, ptr %15, align 8, !tbaa !5
  %222 = load ptr, ptr %6, align 8, !tbaa !5
  %223 = call i32 @EVP_DigestFinal(ptr noundef %221, ptr noundef %222, ptr noundef null)
  %224 = icmp ne i32 %223, 0
  br i1 %224, label %226, label %225

225:                                              ; preds = %220, %213, %207, %200, %194, %186, %179, %173, %166, %160, %151, %144, %138, %131, %125
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 136, 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 %227

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

227:                                              ; preds = %226, %225, %124, %113, %104, %94, %85, %73, %69, %63, %45, %38, %33
  %228 = load ptr, ptr %24, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %228, ptr noundef @.str, i32 noundef 143)
  %229 = load ptr, ptr %14, align 8, !tbaa !5
  call void @BN_CTX_free(ptr noundef %229)
  %230 = load ptr, ptr %15, align 8, !tbaa !5
  call void @EVP_MD_CTX_free(ptr noundef %230)
  %231 = load i32, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 1, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, 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 %231
}

; 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 @EC_KEY_get0_public_key(ptr noundef) #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 @EVP_MD_CTX_new() #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 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 [71 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
  %8 = tail call ptr @EC_KEY_get0_public_key(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
  %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 48, ptr noundef nonnull @__func__.ossl_sm2_compute_z_digest) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 53, i32 noundef 786690, ptr noundef null) #3
  br label %97

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

14:                                               ; preds = %11
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 54, 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 %97

15:                                               ; preds = %11
  %16 = tail call ptr @ossl_ec_key_get_libctx(ptr noundef %4) #3
  %17 = tail call ptr @BN_CTX_new_ex(ptr noundef %16) #3
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 59, 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 %97

20:                                               ; preds = %15
  %21 = tail call ptr @BN_CTX_get(ptr noundef nonnull %17) #3
  %22 = tail call ptr @BN_CTX_get(ptr noundef nonnull %17) #3
  %23 = tail call ptr @BN_CTX_get(ptr noundef nonnull %17) #3
  %24 = tail call ptr @BN_CTX_get(ptr noundef nonnull %17) #3
  %25 = tail call ptr @BN_CTX_get(ptr noundef nonnull %17) #3
  %26 = tail call ptr @BN_CTX_get(ptr noundef nonnull %17) #3
  %27 = tail call ptr @BN_CTX_get(ptr noundef nonnull %17) #3
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %20
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 72, 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 %97

30:                                               ; preds = %20
  %31 = tail call i32 @EVP_DigestInit(ptr noundef nonnull %12, ptr noundef %1) #3
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %32, label %33

32:                                               ; preds = %30
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 77, 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 %97

33:                                               ; preds = %30
  %34 = icmp ugt i64 %3, 8190
  br i1 %34, label %35, label %36

35:                                               ; preds = %33
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 85, 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 %97

36:                                               ; preds = %33
  %37 = lshr i64 %3, 5
  %38 = trunc nuw i64 %37 to i8
  store i8 %38, ptr %6, align 1, !tbaa !5
  %39 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %6, i64 noundef 1) #3
  %.not96 = icmp eq i32 %39, 0
  br i1 %.not96, label %40, label %41

40:                                               ; preds = %36
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 93, 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 %97

41:                                               ; preds = %36
  %.tr = trunc i64 %3 to i8
  %42 = shl i8 %.tr, 3
  store i8 %42, ptr %6, align 1, !tbaa !5
  %43 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %6, i64 noundef 1) #3
  %.not97 = icmp eq i32 %43, 0
  br i1 %.not97, label %44, label %45

44:                                               ; preds = %41
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 98, 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 %97

45:                                               ; preds = %41
  %.not98 = icmp eq i64 %3, 0
  br i1 %.not98, label %49, label %46

46:                                               ; preds = %45
  %47 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef %2, i64 noundef %3) #3
  %.not99 = icmp eq i32 %47, 0
  br i1 %.not99, label %48, label %49

48:                                               ; preds = %46
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 103, 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 %97

49:                                               ; preds = %46, %45
  %50 = call i32 @EC_GROUP_get_curve(ptr noundef %7, ptr noundef %21, ptr noundef %22, ptr noundef %23, ptr noundef nonnull %17) #3
  %.not100 = icmp eq i32 %50, 0
  br i1 %.not100, label %51, label %52

51:                                               ; preds = %49
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 108, 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 %97

52:                                               ; preds = %49
  %53 = call i32 @BN_num_bits(ptr noundef %21) #3
  %54 = add nsw i32 %53, 7
  %55 = sdiv i32 %54, 8
  %56 = sext i32 %55 to i64
  %57 = call ptr @CRYPTO_zalloc(i64 noundef %56, ptr noundef nonnull @.str, i32 noundef 113) #3
  %58 = icmp eq ptr %57, null
  br i1 %58, label %97, label %59

59:                                               ; preds = %52
  %60 = call i32 @BN_bn2binpad(ptr noundef %22, ptr noundef nonnull %57, i32 noundef %55) #3
  %61 = icmp slt i32 %60, 0
  br i1 %61, label %96, label %62

62:                                               ; preds = %59
  %63 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %57, i64 noundef %56) #3
  %.not101 = icmp eq i32 %63, 0
  br i1 %.not101, label %96, label %64

64:                                               ; preds = %62
  %65 = call i32 @BN_bn2binpad(ptr noundef %23, ptr noundef nonnull %57, i32 noundef %55) #3
  %66 = icmp slt i32 %65, 0
  br i1 %66, label %96, label %67

67:                                               ; preds = %64
  %68 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %57, i64 noundef %56) #3
  %.not102 = icmp eq i32 %68, 0
  br i1 %.not102, label %96, label %69

69:                                               ; preds = %67
  %70 = call ptr @EC_GROUP_get0_generator(ptr noundef %7) #3
  %71 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %7, ptr noundef %70, ptr noundef %24, ptr noundef %25, ptr noundef nonnull %17) #3
  %.not103 = icmp eq i32 %71, 0
  br i1 %.not103, label %96, label %72

72:                                               ; preds = %69
  %73 = call i32 @BN_bn2binpad(ptr noundef %24, ptr noundef nonnull %57, i32 noundef %55) #3
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %96, label %75

75:                                               ; preds = %72
  %76 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %57, i64 noundef %56) #3
  %.not104 = icmp eq i32 %76, 0
  br i1 %.not104, label %96, label %77

77:                                               ; preds = %75
  %78 = call i32 @BN_bn2binpad(ptr noundef %25, ptr noundef nonnull %57, i32 noundef %55) #3
  %79 = icmp slt i32 %78, 0
  br i1 %79, label %96, label %80

80:                                               ; preds = %77
  %81 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %57, i64 noundef %56) #3
  %.not105 = icmp eq i32 %81, 0
  br i1 %.not105, label %96, label %82

82:                                               ; preds = %80
  %83 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %7, ptr noundef nonnull %8, ptr noundef %26, ptr noundef nonnull %27, ptr noundef nonnull %17) #3
  %.not106 = icmp eq i32 %83, 0
  br i1 %.not106, label %96, label %84

84:                                               ; preds = %82
  %85 = call i32 @BN_bn2binpad(ptr noundef %26, ptr noundef nonnull %57, i32 noundef %55) #3
  %86 = icmp slt i32 %85, 0
  br i1 %86, label %96, label %87

87:                                               ; preds = %84
  %88 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %57, i64 noundef %56) #3
  %.not107 = icmp eq i32 %88, 0
  br i1 %.not107, label %96, label %89

89:                                               ; preds = %87
  %90 = call i32 @BN_bn2binpad(ptr noundef nonnull %27, ptr noundef nonnull %57, i32 noundef %55) #3
  %91 = icmp slt i32 %90, 0
  br i1 %91, label %96, label %92

92:                                               ; preds = %89
  %93 = call i32 @EVP_DigestUpdate(ptr noundef nonnull %12, ptr noundef nonnull %57, i64 noundef %56) #3
  %.not108 = icmp eq i32 %93, 0
  br i1 %.not108, label %96, label %94

94:                                               ; preds = %92
  %95 = call i32 @EVP_DigestFinal(ptr noundef nonnull %12, ptr noundef %0, ptr noundef null) #3
  %.not109 = icmp eq i32 %95, 0
  br i1 %.not109, label %96, label %97

96:                                               ; preds = %94, %92, %89, %87, %84, %82, %80, %77, %75, %72, %69, %67, %64, %62, %59
  call void @ERR_new() #3
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 136, 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 %97

97:                                               ; preds = %94, %52, %96, %51, %48, %44, %40, %35, %32, %29, %19, %14, %10
  %.087 = phi i32 [ 0, %10 ], [ 0, %14 ], [ 0, %19 ], [ 0, %29 ], [ 0, %35 ], [ 0, %52 ], [ 0, %96 ], [ 0, %51 ], [ 0, %48 ], [ 0, %44 ], [ 0, %40 ], [ 0, %32 ], [ 1, %94 ]
  %.086 = phi ptr [ null, %10 ], [ null, %14 ], [ null, %19 ], [ %17, %29 ], [ %17, %35 ], [ %17, %52 ], [ %17, %96 ], [ %17, %51 ], [ %17, %48 ], [ %17, %44 ], [ %17, %40 ], [ %17, %32 ], [ %17, %94 ]
  %.085 = phi ptr [ null, %10 ], [ null, %14 ], [ %12, %19 ], [ %12, %29 ], [ %12, %35 ], [ %12, %52 ], [ %12, %96 ], [ %12, %51 ], [ %12, %48 ], [ %12, %44 ], [ %12, %40 ], [ %12, %32 ], [ %12, %94 ]
  %.0 = phi ptr [ null, %10 ], [ null, %14 ], [ null, %19 ], [ null, %29 ], [ null, %35 ], [ null, %52 ], [ %57, %96 ], [ null, %51 ], [ null, %48 ], [ null, %44 ], [ null, %40 ], [ null, %32 ], [ %57, %94 ]
  call void @CRYPTO_free(ptr noundef %.0, ptr noundef nonnull @.str, i32 noundef 143) #3
  call void @BN_CTX_free(ptr noundef %.086) #3
  call void @EVP_MD_CTX_free(ptr noundef %.085) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  ret i32 %.087
}

; 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 @EC_KEY_get0_public_key(ptr noundef) 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 @EVP_MD_CTX_new() 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 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