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

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@__FUNCTION__.sm2_do_encrypt_fixlen = external hidden unnamed_addr constant [22 x i8], align 1

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

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

declare void @sm3_init(ptr noundef) #2

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

declare void @sm3_finish(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) #1

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

declare ptr @sm2_z256_order() #2

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

declare i64 @sm2_z256_is_zero(ptr noundef) #2

declare void @sm2_z256_point_mul_generator(ptr noundef, ptr noundef) #2

declare void @sm2_z256_point_mul(ptr noundef, ptr noundef, ptr noundef) #2

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sm2_do_encrypt_fixlen(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca [4 x i64], align 16
  %14 = alloca %struct.SM2_Z256_POINT, align 8
  %15 = alloca %struct.SM2_Z256_POINT, align 8
  %16 = alloca [64 x i8], align 16
  %17 = alloca %struct.SM3_CTX, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 200, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 112, ptr %17) #4
  %20 = load i64, ptr %9, align 8, !tbaa !9
  %21 = icmp ult i64 %20, 1
  br i1 %21, label %25, label %22

22:                                               ; preds = %5
  %23 = load i64, ptr %9, align 8, !tbaa !9
  %24 = icmp ugt i64 %23, 255
  br i1 %24, label %25, label %31

25:                                               ; preds = %22, %5
  br label %26

26:                                               ; preds = %25
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 247, ptr noundef @__FUNCTION__.sm2_do_encrypt_fixlen) #4
  br label %29

29:                                               ; preds = %26
  br label %30

30:                                               ; preds = %29
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %136

31:                                               ; preds = %22
  %32 = load i32, ptr %10, align 4, !tbaa !11
  switch i32 %32, label %34 [
    i32 68, label %33
    i32 69, label %33
    i32 70, label %33
  ]

33:                                               ; preds = %31, %31, %31
  br label %40

34:                                               ; preds = %31
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 257, ptr noundef @__FUNCTION__.sm2_do_encrypt_fixlen) #4
  br label %38

38:                                               ; preds = %35
  br label %39

39:                                               ; preds = %38
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %136

40:                                               ; preds = %33
  br label %41

41:                                               ; preds = %112, %84, %40
  br label %42

42:                                               ; preds = %54, %41
  %43 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  %44 = call ptr @sm2_z256_order()
  %45 = call i32 @sm2_z256_rand_range(ptr noundef %43, ptr noundef %44)
  %46 = icmp ne i32 %45, 1
  br i1 %46, label %47, label %53

47:                                               ; preds = %42
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 265, ptr noundef @__FUNCTION__.sm2_do_encrypt_fixlen) #4
  br label %51

51:                                               ; preds = %48
  br label %52

52:                                               ; preds = %51
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %136

53:                                               ; preds = %42
  br label %54

54:                                               ; preds = %53
  %55 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  %56 = call i64 @sm2_z256_is_zero(ptr noundef %55)
  %57 = icmp ne i64 %56, 0
  br i1 %57, label %42, label %58, !llvm.loop !13

58:                                               ; preds = %54
  %59 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  call void @sm2_z256_point_mul_generator(ptr noundef %14, ptr noundef %59)
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %60, i32 0, i32 0
  %62 = call i32 @sm2_z256_point_to_bytes(ptr noundef %14, ptr noundef %61)
  %63 = load i32, ptr %12, align 4, !tbaa !11
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %87

65:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  store i64 0, ptr %19, align 8, !tbaa !9
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds %struct.SM2_POINT, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds [32 x i8], ptr %68, i64 0, i64 0
  %70 = call i32 @asn1_integer_to_der_ex(i32 noundef 2, ptr noundef %69, i64 noundef 32, ptr noundef null, ptr noundef %19)
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %71, i32 0, i32 0
  %73 = getelementptr inbounds %struct.SM2_POINT, ptr %72, i32 0, i32 1
  %74 = getelementptr inbounds [32 x i8], ptr %73, i64 0, i64 0
  %75 = call i32 @asn1_integer_to_der_ex(i32 noundef 2, ptr noundef %74, i64 noundef 32, ptr noundef null, ptr noundef %19)
  %76 = load i64, ptr %19, align 8, !tbaa !9
  %77 = load i32, ptr %10, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = icmp ne i64 %76, %78
  br i1 %79, label %80, label %83

80:                                               ; preds = %65
  %81 = load i32, ptr %12, align 4, !tbaa !11
  %82 = add i32 %81, -1
  store i32 %82, ptr %12, align 4, !tbaa !11
  store i32 7, ptr %18, align 4
  br label %84

83:                                               ; preds = %65
  store i32 0, ptr %18, align 4
  br label %84

84:                                               ; preds = %83, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  %85 = load i32, ptr %18, align 4
  switch i32 %85, label %138 [
    i32 0, label %86
    i32 7, label %41
  ]

86:                                               ; preds = %84
  br label %94

87:                                               ; preds = %58
  %88 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %88, i64 noundef 32)
  br label %89

89:                                               ; preds = %87
  %90 = load ptr, ptr @stderr, align 8, !tbaa !5
  %91 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %90, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 285, ptr noundef @__FUNCTION__.sm2_do_encrypt_fixlen) #4
  br label %92

92:                                               ; preds = %89
  br label %93

93:                                               ; preds = %92
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %136

94:                                               ; preds = %86
  %95 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.SM2_KEY, ptr %96, i32 0, i32 0
  call void @sm2_z256_point_mul(ptr noundef %15, ptr noundef %95, ptr noundef %97)
  %98 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %99 = call i32 @sm2_z256_point_to_bytes(ptr noundef %15, ptr noundef %98)
  %100 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %101 = load i64, ptr %9, align 8, !tbaa !9
  %102 = load ptr, ptr %11, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %102, i32 0, i32 3
  %104 = getelementptr inbounds [255 x i8], ptr %103, i64 0, i64 0
  %105 = call i32 @sm2_kdf(ptr noundef %100, i64 noundef 64, i64 noundef %101, ptr noundef %104)
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %106, i32 0, i32 3
  %108 = getelementptr inbounds [255 x i8], ptr %107, i64 0, i64 0
  %109 = load i64, ptr %9, align 8, !tbaa !9
  %110 = call i32 @all_zero(ptr noundef %108, i64 noundef %109)
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %113

112:                                              ; preds = %94
  br label %41

113:                                              ; preds = %94
  %114 = load ptr, ptr %11, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %114, i32 0, i32 3
  %116 = getelementptr inbounds [255 x i8], ptr %115, i64 0, i64 0
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %117, i32 0, i32 3
  %119 = getelementptr inbounds [255 x i8], ptr %118, i64 0, i64 0
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = load i64, ptr %9, align 8, !tbaa !9
  call void @gmssl_memxor(ptr noundef %116, ptr noundef %119, ptr noundef %120, i64 noundef %121)
  %122 = load i64, ptr %9, align 8, !tbaa !9
  %123 = trunc i64 %122 to i8
  %124 = load ptr, ptr %11, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %124, i32 0, i32 2
  store i8 %123, ptr %125, align 1, !tbaa !15
  call void @sm3_init(ptr noundef %17)
  %126 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  call void @sm3_update(ptr noundef %17, ptr noundef %126, i64 noundef 32)
  %127 = load ptr, ptr %8, align 8, !tbaa !5
  %128 = load i64, ptr %9, align 8, !tbaa !9
  call void @sm3_update(ptr noundef %17, ptr noundef %127, i64 noundef %128)
  %129 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %130 = getelementptr inbounds i8, ptr %129, i64 32
  call void @sm3_update(ptr noundef %17, ptr noundef %130, i64 noundef 32)
  %131 = load ptr, ptr %11, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.SM2_CIPHERTEXT, ptr %131, i32 0, i32 1
  %133 = getelementptr inbounds [32 x i8], ptr %132, i64 0, i64 0
  call void @sm3_finish(ptr noundef %17, ptr noundef %133)
  %134 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %134, i64 noundef 32)
  call void @gmssl_secure_clear(ptr noundef %15, i64 noundef 96)
  %135 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %135, i64 noundef 64)
  store i32 1, ptr %6, align 4
  store i32 1, ptr %18, align 4
  br label %136

136:                                              ; preds = %113, %93, %52, %39, %30
  call void @llvm.lifetime.end.p0(i64 112, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %137 = load i32, ptr %6, align 4
  ret i32 %137

138:                                              ; preds = %84
  unreachable
}

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

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 "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 = !{!"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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !7, i64 96}
!16 = !{!"", !17, i64 0, !7, i64 64, !7, i64 96, !7, i64 97}
!17 = !{!"", !7, i64 0, !7, i64 32}


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

%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }
%struct.SM3_CTX = type { [8 x i32], i64, [64 x i8], i64 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@__FUNCTION__.sm2_do_encrypt_fixlen = external hidden unnamed_addr constant [22 x i8], align 1

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

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

declare void @sm3_init(ptr noundef) local_unnamed_addr #2

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

declare void @sm3_finish(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) #1

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

declare ptr @sm2_z256_order() local_unnamed_addr #2

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

declare i64 @sm2_z256_is_zero(ptr noundef) local_unnamed_addr #2

declare void @sm2_z256_point_mul_generator(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @sm2_z256_point_mul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @sm2_do_encrypt_fixlen(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca [4 x i64], align 16
  %7 = alloca %struct.SM2_Z256_POINT, align 8
  %8 = alloca %struct.SM2_Z256_POINT, align 8
  %9 = alloca [64 x i8], align 16
  %10 = alloca %struct.SM3_CTX, align 8
  %11 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %10) #4
  %12 = add i64 %2, -256
  %or.cond = icmp ult i64 %12, -255
  br i1 %or.cond, label %13, label %16

13:                                               ; preds = %5
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 247, ptr noundef nonnull @__FUNCTION__.sm2_do_encrypt_fixlen) #5
  br label %52

16:                                               ; preds = %5
  %.off = add i32 %3, -68
  %switch = icmp ult i32 %.off, 3
  br i1 %switch, label %.preheader, label %20

.preheader:                                       ; preds = %16
  %17 = getelementptr inbounds i8, ptr %4, i64 32
  %18 = zext nneg i32 %3 to i64
  %19 = getelementptr inbounds i8, ptr %4, i64 97
  br label %.outer.split

20:                                               ; preds = %16
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 257, ptr noundef nonnull @__FUNCTION__.sm2_do_encrypt_fixlen) #5
  br label %52

23:                                               ; preds = %.backedge, %.outer.split
  %24 = call ptr @sm2_z256_order() #4
  %25 = call i32 @sm2_z256_rand_range(ptr noundef nonnull %6, ptr noundef %24) #4
  %.not = icmp eq i32 %25, 1
  br i1 %.not, label %28, label %.split

.split:                                           ; preds = %23, %.outer.split.us
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 265, ptr noundef nonnull @__FUNCTION__.sm2_do_encrypt_fixlen) #5
  br label %52

28:                                               ; preds = %23
  %29 = call i64 @sm2_z256_is_zero(ptr noundef nonnull %6) #4
  %.not28 = icmp eq i64 %29, 0
  br i1 %.not28, label %30, label %.backedge

.backedge:                                        ; preds = %28, %43
  br label %23, !llvm.loop !9

30:                                               ; preds = %28
  call void @sm2_z256_point_mul_generator(ptr noundef nonnull %7, ptr noundef nonnull %6) #4
  %31 = call i32 @sm2_z256_point_to_bytes(ptr noundef nonnull %7, ptr noundef %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #4
  store i64 0, ptr %11, align 8, !tbaa !11
  %32 = call i32 @asn1_integer_to_der_ex(i32 noundef 2, ptr noundef %4, i64 noundef 32, ptr noundef null, ptr noundef nonnull %11) #4
  %33 = call i32 @asn1_integer_to_der_ex(i32 noundef 2, ptr noundef nonnull %17, i64 noundef 32, ptr noundef null, ptr noundef nonnull %11) #4
  %34 = load i64, ptr %11, align 8, !tbaa !11
  %.not30 = icmp eq i64 %34, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #4
  br i1 %.not30, label %43, label %.outer.loopexit

.outer.loopexit:                                  ; preds = %30
  %35 = add nsw i32 %.025.ph36, -1
  %.not29 = icmp eq i32 %35, 0
  br i1 %.not29, label %.outer.split.us, label %.outer.split

.outer.split.us:                                  ; preds = %.outer.loopexit, %38
  %36 = call ptr @sm2_z256_order() #4
  %37 = call i32 @sm2_z256_rand_range(ptr noundef nonnull %6, ptr noundef %36) #4
  %.not.us = icmp eq i32 %37, 1
  br i1 %.not.us, label %38, label %.split

38:                                               ; preds = %.outer.split.us
  %39 = call i64 @sm2_z256_is_zero(ptr noundef nonnull %6) #4
  %.not28.us = icmp eq i64 %39, 0
  br i1 %.not28.us, label %.split35.us, label %.outer.split.us, !llvm.loop !9

.split35.us:                                      ; preds = %38
  call void @sm2_z256_point_mul_generator(ptr noundef nonnull %7, ptr noundef nonnull %6) #4
  %40 = call i32 @sm2_z256_point_to_bytes(ptr noundef nonnull %7, ptr noundef %4) #4
  call void @gmssl_secure_clear(ptr noundef nonnull %6, i64 noundef 32) #4
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 285, ptr noundef nonnull @__FUNCTION__.sm2_do_encrypt_fixlen) #5
  br label %52

.outer.split:                                     ; preds = %.preheader, %.outer.loopexit
  %.025.ph36 = phi i32 [ 200, %.preheader ], [ %35, %.outer.loopexit ]
  br label %23

43:                                               ; preds = %30
  call void @sm2_z256_point_mul(ptr noundef nonnull %8, ptr noundef nonnull %6, ptr noundef %0) #4
  %44 = call i32 @sm2_z256_point_to_bytes(ptr noundef nonnull %8, ptr noundef nonnull %9) #4
  %45 = call i32 @sm2_kdf(ptr noundef nonnull %9, i64 noundef 64, i64 noundef %2, ptr noundef nonnull %19)
  %46 = call i32 @all_zero(ptr noundef nonnull %19, i64 noundef %2)
  %.not31 = icmp eq i32 %46, 0
  br i1 %.not31, label %47, label %.backedge

47:                                               ; preds = %43
  call void @gmssl_memxor(ptr noundef nonnull %19, ptr noundef nonnull %19, ptr noundef %1, i64 noundef %2) #4
  %48 = trunc nuw i64 %2 to i8
  %49 = getelementptr inbounds i8, ptr %4, i64 96
  store i8 %48, ptr %49, align 1, !tbaa !13
  call void @sm3_init(ptr noundef nonnull %10) #4
  call void @sm3_update(ptr noundef nonnull %10, ptr noundef nonnull %9, i64 noundef 32) #4
  call void @sm3_update(ptr noundef nonnull %10, ptr noundef %1, i64 noundef %2) #4
  %50 = getelementptr inbounds i8, ptr %9, i64 32
  call void @sm3_update(ptr noundef nonnull %10, ptr noundef nonnull %50, i64 noundef 32) #4
  %51 = getelementptr inbounds i8, ptr %4, i64 64
  call void @sm3_finish(ptr noundef nonnull %10, ptr noundef nonnull %51) #4
  call void @gmssl_secure_clear(ptr noundef nonnull %6, i64 noundef 32) #4
  call void @gmssl_secure_clear(ptr noundef nonnull %8, i64 noundef 96) #4
  call void @gmssl_secure_clear(ptr noundef nonnull %9, i64 noundef 64) #4
  br label %52

52:                                               ; preds = %47, %.split35.us, %.split, %20, %13
  %.026 = phi i32 [ -1, %13 ], [ -1, %20 ], [ -1, %.split ], [ 1, %47 ], [ -1, %.split35.us ]
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  ret i32 %.026
}

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

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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !7, i64 96}
!14 = !{!"", !15, i64 0, !7, i64 64, !7, i64 96, !7, i64 97}
!15 = !{!"", !7, i64 0, !7, i64 32}


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