; LLVM IR from guanzhi/GmSSL :: src (x509_cer)

; 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.SM2_SIGN_CTX = type { %struct.SM3_CTX, %struct.SM3_CTX, %struct.SM2_KEY, [4 x i64], [32 x %struct.SM2_SIGN_PRE_COMP], i32, [16 x %struct.SM2_Z256_POINT] }
%struct.SM3_CTX = type { [8 x i32], i64, [64 x i8], i64 }
%struct.SM2_KEY = type { %struct.SM2_Z256_POINT, [4 x i64] }
%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }
%struct.SM2_SIGN_PRE_COMP = type { [4 x i64], [4 x i64] }

@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [62 x i8], align 1
@__FUNCTION__.x509_cert_sign_to_der = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_tbs_cert_to_der(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #3

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @x509_cert_sign_to_der(i32 noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, ptr noundef %11, i64 noundef %12, ptr noundef %13, i64 noundef %14, ptr noundef %15, i64 noundef %16, ptr noundef %17, ptr noundef %18, i64 noundef %19, ptr noundef %20, ptr noundef %21) #3 {
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca ptr, align 8
  %26 = alloca i64, align 8
  %27 = alloca i32, align 4
  %28 = alloca ptr, align 8
  %29 = alloca i64, align 8
  %30 = alloca i64, align 8
  %31 = alloca i64, align 8
  %32 = alloca ptr, align 8
  %33 = alloca i64, align 8
  %34 = alloca ptr, align 8
  %35 = alloca ptr, align 8
  %36 = alloca i64, align 8
  %37 = alloca ptr, align 8
  %38 = alloca i64, align 8
  %39 = alloca ptr, align 8
  %40 = alloca i64, align 8
  %41 = alloca ptr, align 8
  %42 = alloca ptr, align 8
  %43 = alloca i64, align 8
  %44 = alloca ptr, align 8
  %45 = alloca ptr, align 8
  %46 = alloca i64, align 8
  %47 = alloca ptr, align 8
  %48 = alloca i32, align 4
  %49 = alloca [72 x i8], align 16
  %50 = alloca i64, align 8
  %51 = alloca i32, align 4
  %52 = alloca %struct.SM2_SIGN_CTX, align 8
  store i32 %0, ptr %24, align 4, !tbaa !5
  store ptr %1, ptr %25, align 8, !tbaa !9
  store i64 %2, ptr %26, align 8, !tbaa !11
  store i32 %3, ptr %27, align 4, !tbaa !5
  store ptr %4, ptr %28, align 8, !tbaa !9
  store i64 %5, ptr %29, align 8, !tbaa !11
  store i64 %6, ptr %30, align 8, !tbaa !11
  store i64 %7, ptr %31, align 8, !tbaa !11
  store ptr %8, ptr %32, align 8, !tbaa !9
  store i64 %9, ptr %33, align 8, !tbaa !11
  store ptr %10, ptr %34, align 8, !tbaa !9
  store ptr %11, ptr %35, align 8, !tbaa !9
  store i64 %12, ptr %36, align 8, !tbaa !11
  store ptr %13, ptr %37, align 8, !tbaa !9
  store i64 %14, ptr %38, align 8, !tbaa !11
  store ptr %15, ptr %39, align 8, !tbaa !9
  store i64 %16, ptr %40, align 8, !tbaa !11
  store ptr %17, ptr %41, align 8, !tbaa !9
  store ptr %18, ptr %42, align 8, !tbaa !9
  store i64 %19, ptr %43, align 8, !tbaa !11
  store ptr %20, ptr %44, align 8, !tbaa !9
  store ptr %21, ptr %45, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %46) #4
  store i64 0, ptr %46, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %47) #4
  store ptr null, ptr %47, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %48) #4
  store i32 16, ptr %48, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 72, ptr %49) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %50) #4
  store i64 71, ptr %50, align 8, !tbaa !11
  %53 = load i32, ptr %24, align 4, !tbaa !5
  %54 = load ptr, ptr %25, align 8, !tbaa !9
  %55 = load i64, ptr %26, align 8, !tbaa !11
  %56 = load i32, ptr %27, align 4, !tbaa !5
  %57 = load ptr, ptr %28, align 8, !tbaa !9
  %58 = load i64, ptr %29, align 8, !tbaa !11
  %59 = load i64, ptr %30, align 8, !tbaa !11
  %60 = load i64, ptr %31, align 8, !tbaa !11
  %61 = load ptr, ptr %32, align 8, !tbaa !9
  %62 = load i64, ptr %33, align 8, !tbaa !11
  %63 = load ptr, ptr %34, align 8, !tbaa !9
  %64 = load ptr, ptr %35, align 8, !tbaa !9
  %65 = load i64, ptr %36, align 8, !tbaa !11
  %66 = load ptr, ptr %37, align 8, !tbaa !9
  %67 = load i64, ptr %38, align 8, !tbaa !11
  %68 = load ptr, ptr %39, align 8, !tbaa !9
  %69 = load i64, ptr %40, align 8, !tbaa !11
  %70 = call i32 @x509_tbs_cert_to_der(i32 noundef %53, ptr noundef %54, i64 noundef %55, i32 noundef %56, ptr noundef %57, i64 noundef %58, i64 noundef %59, i64 noundef %60, ptr noundef %61, i64 noundef %62, ptr noundef %63, ptr noundef %64, i64 noundef %65, ptr noundef %66, i64 noundef %67, ptr noundef %68, i64 noundef %69, ptr noundef null, ptr noundef %46)
  %71 = icmp ne i32 %70, 1
  br i1 %71, label %87, label %72

72:                                               ; preds = %22
  %73 = load i32, ptr %48, align 4, !tbaa !5
  %74 = call i32 @x509_signature_algor_to_der(i32 noundef %73, ptr noundef null, ptr noundef %46)
  %75 = icmp ne i32 %74, 1
  br i1 %75, label %87, label %76

76:                                               ; preds = %72
  %77 = getelementptr inbounds [72 x i8], ptr %49, i64 0, i64 0
  %78 = load i64, ptr %50, align 8, !tbaa !11
  %79 = call i32 @asn1_bit_octets_to_der_ex(i32 noundef 3, ptr noundef %77, i64 noundef %78, ptr noundef null, ptr noundef %46)
  %80 = icmp ne i32 %79, 1
  br i1 %80, label %87, label %81

81:                                               ; preds = %76
  %82 = load i64, ptr %46, align 8, !tbaa !11
  %83 = load ptr, ptr %44, align 8, !tbaa !9
  %84 = load ptr, ptr %45, align 8, !tbaa !9
  %85 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %82, ptr noundef %83, ptr noundef %84)
  %86 = icmp ne i32 %85, 1
  br i1 %86, label %87, label %93

87:                                               ; preds = %81, %76, %72, %22
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr @stderr, align 8, !tbaa !9
  %90 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %89, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1129, ptr noundef @__FUNCTION__.x509_cert_sign_to_der) #4
  br label %91

91:                                               ; preds = %88
  br label %92

92:                                               ; preds = %91
  store i32 -1, ptr %23, align 4
  store i32 1, ptr %51, align 4
  br label %189

93:                                               ; preds = %81
  %94 = load ptr, ptr %44, align 8, !tbaa !9
  %95 = icmp ne ptr %94, null
  br i1 %95, label %96, label %103

96:                                               ; preds = %93
  %97 = load ptr, ptr %44, align 8, !tbaa !9
  %98 = load ptr, ptr %97, align 8, !tbaa !9
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %103

100:                                              ; preds = %96
  %101 = load ptr, ptr %44, align 8, !tbaa !9
  %102 = load ptr, ptr %101, align 8, !tbaa !9
  store ptr %102, ptr %47, align 8, !tbaa !9
  br label %103

103:                                              ; preds = %100, %96, %93
  %104 = load i32, ptr %24, align 4, !tbaa !5
  %105 = load ptr, ptr %25, align 8, !tbaa !9
  %106 = load i64, ptr %26, align 8, !tbaa !11
  %107 = load i32, ptr %27, align 4, !tbaa !5
  %108 = load ptr, ptr %28, align 8, !tbaa !9
  %109 = load i64, ptr %29, align 8, !tbaa !11
  %110 = load i64, ptr %30, align 8, !tbaa !11
  %111 = load i64, ptr %31, align 8, !tbaa !11
  %112 = load ptr, ptr %32, align 8, !tbaa !9
  %113 = load i64, ptr %33, align 8, !tbaa !11
  %114 = load ptr, ptr %34, align 8, !tbaa !9
  %115 = load ptr, ptr %35, align 8, !tbaa !9
  %116 = load i64, ptr %36, align 8, !tbaa !11
  %117 = load ptr, ptr %37, align 8, !tbaa !9
  %118 = load i64, ptr %38, align 8, !tbaa !11
  %119 = load ptr, ptr %39, align 8, !tbaa !9
  %120 = load i64, ptr %40, align 8, !tbaa !11
  %121 = load ptr, ptr %44, align 8, !tbaa !9
  %122 = load ptr, ptr %45, align 8, !tbaa !9
  %123 = call i32 @x509_tbs_cert_to_der(i32 noundef %104, ptr noundef %105, i64 noundef %106, i32 noundef %107, ptr noundef %108, i64 noundef %109, i64 noundef %110, i64 noundef %111, ptr noundef %112, i64 noundef %113, ptr noundef %114, ptr noundef %115, i64 noundef %116, ptr noundef %117, i64 noundef %118, ptr noundef %119, i64 noundef %120, ptr noundef %121, ptr noundef %122)
  %124 = icmp ne i32 %123, 1
  br i1 %124, label %125, label %131

125:                                              ; preds = %103
  br label %126

126:                                              ; preds = %125
  %127 = load ptr, ptr @stderr, align 8, !tbaa !9
  %128 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %127, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1148, ptr noundef @__FUNCTION__.x509_cert_sign_to_der) #4
  br label %129

129:                                              ; preds = %126
  br label %130

130:                                              ; preds = %129
  store i32 -1, ptr %23, align 4
  store i32 1, ptr %51, align 4
  br label %189

131:                                              ; preds = %103
  %132 = load ptr, ptr %44, align 8, !tbaa !9
  %133 = icmp ne ptr %132, null
  br i1 %133, label %134, label %169

134:                                              ; preds = %131
  %135 = load ptr, ptr %44, align 8, !tbaa !9
  %136 = load ptr, ptr %135, align 8, !tbaa !9
  %137 = icmp ne ptr %136, null
  br i1 %137, label %138, label %169

138:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 3976, ptr %52) #4
  %139 = load ptr, ptr %41, align 8, !tbaa !9
  %140 = load ptr, ptr %42, align 8, !tbaa !9
  %141 = load i64, ptr %43, align 8, !tbaa !11
  %142 = call i32 @sm2_sign_init(ptr noundef %52, ptr noundef %139, ptr noundef %140, i64 noundef %141)
  %143 = icmp ne i32 %142, 1
  br i1 %143, label %159, label %144

144:                                              ; preds = %138
  %145 = load ptr, ptr %47, align 8, !tbaa !9
  %146 = load ptr, ptr %44, align 8, !tbaa !9
  %147 = load ptr, ptr %146, align 8, !tbaa !9
  %148 = load ptr, ptr %47, align 8, !tbaa !9
  %149 = ptrtoint ptr %147 to i64
  %150 = ptrtoint ptr %148 to i64
  %151 = sub i64 %149, %150
  %152 = call i32 @sm2_sign_update(ptr noundef %52, ptr noundef %145, i64 noundef %151)
  %153 = icmp ne i32 %152, 1
  br i1 %153, label %159, label %154

154:                                              ; preds = %144
  %155 = load i64, ptr %50, align 8, !tbaa !11
  %156 = getelementptr inbounds [72 x i8], ptr %49, i64 0, i64 0
  %157 = call i32 @sm2_sign_finish_fixlen(ptr noundef %52, i64 noundef %155, ptr noundef %156)
  %158 = icmp ne i32 %157, 1
  br i1 %158, label %159, label %165

159:                                              ; preds = %154, %144, %138
  call void @gmssl_secure_clear(ptr noundef %52, i64 noundef 3976)
  br label %160

160:                                              ; preds = %159
  %161 = load ptr, ptr @stderr, align 8, !tbaa !9
  %162 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %161, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1158, ptr noundef @__FUNCTION__.x509_cert_sign_to_der) #4
  br label %163

163:                                              ; preds = %160
  br label %164

164:                                              ; preds = %163
  store i32 -1, ptr %23, align 4
  store i32 1, ptr %51, align 4
  br label %166

165:                                              ; preds = %154
  call void @gmssl_secure_clear(ptr noundef %52, i64 noundef 3976)
  store i32 0, ptr %51, align 4
  br label %166

166:                                              ; preds = %165, %164
  call void @llvm.lifetime.end.p0(i64 3976, ptr %52) #4
  %167 = load i32, ptr %51, align 4
  switch i32 %167, label %189 [
    i32 0, label %168
  ]

168:                                              ; preds = %166
  br label %169

169:                                              ; preds = %168, %134, %131
  %170 = load i32, ptr %48, align 4, !tbaa !5
  %171 = load ptr, ptr %44, align 8, !tbaa !9
  %172 = load ptr, ptr %45, align 8, !tbaa !9
  %173 = call i32 @x509_signature_algor_to_der(i32 noundef %170, ptr noundef %171, ptr noundef %172)
  %174 = icmp ne i32 %173, 1
  br i1 %174, label %182, label %175

175:                                              ; preds = %169
  %176 = getelementptr inbounds [72 x i8], ptr %49, i64 0, i64 0
  %177 = load i64, ptr %50, align 8, !tbaa !11
  %178 = load ptr, ptr %44, align 8, !tbaa !9
  %179 = load ptr, ptr %45, align 8, !tbaa !9
  %180 = call i32 @asn1_bit_octets_to_der_ex(i32 noundef 3, ptr noundef %176, i64 noundef %177, ptr noundef %178, ptr noundef %179)
  %181 = icmp ne i32 %180, 1
  br i1 %181, label %182, label %188

182:                                              ; preds = %175, %169
  br label %183

183:                                              ; preds = %182
  %184 = load ptr, ptr @stderr, align 8, !tbaa !9
  %185 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %184, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 1166, ptr noundef @__FUNCTION__.x509_cert_sign_to_der) #4
  br label %186

186:                                              ; preds = %183
  br label %187

187:                                              ; preds = %186
  store i32 -1, ptr %23, align 4
  store i32 1, ptr %51, align 4
  br label %189

188:                                              ; preds = %175
  store i32 1, ptr %23, align 4
  store i32 1, ptr %51, align 4
  br label %189

189:                                              ; preds = %188, %187, %166, %130, %92
  call void @llvm.lifetime.end.p0(i64 8, ptr %50) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %49) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %48) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %47) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %46) #4
  %190 = load i32, ptr %23, align 4
  ret i32 %190
}

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

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

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

declare void @gmssl_secure_clear(ptr noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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"

%struct.SM2_SIGN_CTX = type { %struct.SM3_CTX, %struct.SM3_CTX, %struct.SM2_KEY, [4 x i64], [32 x %struct.SM2_SIGN_PRE_COMP], i32, [16 x %struct.SM2_Z256_POINT] }
%struct.SM3_CTX = type { [8 x i32], i64, [64 x i8], i64 }
%struct.SM2_KEY = type { %struct.SM2_Z256_POINT, [4 x i64] }
%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }
%struct.SM2_SIGN_PRE_COMP = type { [4 x i64], [4 x i64] }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [62 x i8], align 1
@__FUNCTION__.x509_cert_sign_to_der = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare i32 @asn1_header_to_der(i32 noundef, i64 noundef, ptr noundef, 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) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_tbs_cert_to_der(i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @x509_cert_sign_to_der(i32 noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, ptr noundef %11, i64 noundef %12, ptr noundef %13, i64 noundef %14, ptr noundef %15, i64 noundef %16, ptr noundef %17, ptr noundef %18, i64 noundef %19, ptr noundef %20, ptr noundef %21) local_unnamed_addr #3 {
  %23 = alloca i64, align 8
  %24 = alloca [72 x i8], align 16
  %25 = alloca %struct.SM2_SIGN_CTX, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %23) #4
  store i64 0, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %24) #4
  %26 = call i32 @x509_tbs_cert_to_der(i32 noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, ptr noundef %11, i64 noundef %12, ptr noundef %13, i64 noundef %14, ptr noundef %15, i64 noundef %16, ptr noundef null, ptr noundef nonnull %23)
  %.not = icmp eq i32 %26, 1
  br i1 %.not, label %27, label %34

27:                                               ; preds = %22
  %28 = call i32 @x509_signature_algor_to_der(i32 noundef 16, ptr noundef null, ptr noundef nonnull %23) #4
  %.not64 = icmp eq i32 %28, 1
  br i1 %.not64, label %29, label %34

29:                                               ; preds = %27
  %30 = call i32 @asn1_bit_octets_to_der_ex(i32 noundef 3, ptr noundef nonnull %24, i64 noundef 71, ptr noundef null, ptr noundef nonnull %23) #4
  %.not65 = icmp eq i32 %30, 1
  br i1 %.not65, label %31, label %34

31:                                               ; preds = %29
  %32 = load i64, ptr %23, align 8, !tbaa !5
  %33 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %32, ptr noundef %20, ptr noundef %21) #4
  %.not66 = icmp eq i32 %33, 1
  br i1 %.not66, label %37, label %34

34:                                               ; preds = %22, %27, %29, %31
  %35 = load ptr, ptr @stderr, align 8, !tbaa !9
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1129, ptr noundef nonnull @__FUNCTION__.x509_cert_sign_to_der) #5
  br label %67

37:                                               ; preds = %31
  %.not67 = icmp eq ptr %20, null
  br i1 %.not67, label %38, label %.thread

38:                                               ; preds = %37
  %39 = call i32 @x509_tbs_cert_to_der(i32 noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, ptr noundef %11, i64 noundef %12, ptr noundef %13, i64 noundef %14, ptr noundef %15, i64 noundef %16, ptr noundef null, ptr noundef %21)
  %.not69 = icmp eq i32 %39, 1
  br i1 %.not69, label %60, label %42

.thread:                                          ; preds = %37
  %40 = load ptr, ptr %20, align 8, !tbaa !9
  %41 = call i32 @x509_tbs_cert_to_der(i32 noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef %10, ptr noundef %11, i64 noundef %12, ptr noundef %13, i64 noundef %14, ptr noundef %15, i64 noundef %16, ptr noundef nonnull %20, ptr noundef %21)
  %.not6977 = icmp eq i32 %41, 1
  br i1 %.not6977, label %45, label %42

42:                                               ; preds = %.thread, %38
  %43 = load ptr, ptr @stderr, align 8, !tbaa !9
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1148, ptr noundef nonnull @__FUNCTION__.x509_cert_sign_to_der) #5
  br label %67

45:                                               ; preds = %.thread
  %46 = load ptr, ptr %20, align 8, !tbaa !9
  %.not70 = icmp eq ptr %46, null
  br i1 %.not70, label %60, label %47

47:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 3976, ptr nonnull %25) #4
  %48 = call i32 @sm2_sign_init(ptr noundef nonnull %25, ptr noundef %17, ptr noundef %18, i64 noundef %19) #4
  %.not71 = icmp eq i32 %48, 1
  br i1 %.not71, label %49, label %.critedge

49:                                               ; preds = %47
  %50 = load ptr, ptr %20, align 8, !tbaa !9
  %51 = ptrtoint ptr %50 to i64
  %52 = ptrtoint ptr %40 to i64
  %53 = sub i64 %51, %52
  %54 = call i32 @sm2_sign_update(ptr noundef nonnull %25, ptr noundef %40, i64 noundef %53) #4
  %.not72 = icmp eq i32 %54, 1
  br i1 %.not72, label %55, label %.critedge

55:                                               ; preds = %49
  %56 = call i32 @sm2_sign_finish_fixlen(ptr noundef nonnull %25, i64 noundef 71, ptr noundef nonnull %24) #4
  %.not73 = icmp eq i32 %56, 1
  br i1 %.not73, label %59, label %.critedge

.critedge:                                        ; preds = %55, %49, %47
  call void @gmssl_secure_clear(ptr noundef nonnull %25, i64 noundef 3976) #4
  %57 = load ptr, ptr @stderr, align 8, !tbaa !9
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1158, ptr noundef nonnull @__FUNCTION__.x509_cert_sign_to_der) #5
  call void @llvm.lifetime.end.p0(i64 3976, ptr nonnull %25) #4
  br label %67

59:                                               ; preds = %55
  call void @gmssl_secure_clear(ptr noundef nonnull %25, i64 noundef 3976) #4
  call void @llvm.lifetime.end.p0(i64 3976, ptr nonnull %25) #4
  br label %60

60:                                               ; preds = %38, %59, %45
  %61 = call i32 @x509_signature_algor_to_der(i32 noundef 16, ptr noundef %20, ptr noundef %21) #4
  %.not74 = icmp eq i32 %61, 1
  br i1 %.not74, label %62, label %64

62:                                               ; preds = %60
  %63 = call i32 @asn1_bit_octets_to_der_ex(i32 noundef 3, ptr noundef nonnull %24, i64 noundef 71, ptr noundef %20, ptr noundef %21) #4
  %.not75 = icmp eq i32 %63, 1
  br i1 %.not75, label %67, label %64

64:                                               ; preds = %60, %62
  %65 = load ptr, ptr @stderr, align 8, !tbaa !9
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 1166, ptr noundef nonnull @__FUNCTION__.x509_cert_sign_to_der) #5
  br label %67

67:                                               ; preds = %62, %.critedge, %64, %42, %34
  %.1 = phi i32 [ -1, %34 ], [ -1, %42 ], [ -1, %64 ], [ -1, %.critedge ], [ 1, %62 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %23) #4
  ret i32 %.1
}

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

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

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

declare void @gmssl_secure_clear(ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 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 #4 = { nounwind }
attributes #5 = { cold 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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