; LLVM IR from guanzhi/GmSSL :: src (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"

%struct.SM2_Z256_POINT = type { [4 x i64], [4 x i64], [4 x i64] }
%struct.SM2_KEY = type { %struct.SM2_Z256_POINT, [4 x i64] }
%struct.SM2_SIGNATURE = type { [32 x i8], [32 x i8] }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [62 x i8], align 1
@__FUNCTION__.sm2_do_sign = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @sm2_do_sign(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.SM2_Z256_POINT, align 8
  %9 = alloca [4 x i64], align 16
  %10 = alloca [4 x i64], align 16
  %11 = alloca [4 x i64], align 16
  %12 = alloca [4 x i64], align 16
  %13 = alloca [4 x i64], align 16
  %14 = alloca [4 x i64], align 16
  %15 = alloca [4 x i64], align 16
  %16 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 96, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #4
  %17 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.SM2_KEY, ptr %18, i32 0, i32 1
  %20 = getelementptr inbounds [4 x i64], ptr %19, i64 0, i64 0
  %21 = call ptr @sm2_z256_one()
  call void @sm2_z256_modn_add(ptr noundef %17, ptr noundef %20, ptr noundef %21)
  %22 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  %23 = call i64 @sm2_z256_is_zero(ptr noundef %22)
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %3
  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 36, ptr noundef @__FUNCTION__.sm2_do_sign) #4
  br label %29

29:                                               ; preds = %26
  br label %30

30:                                               ; preds = %29
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %16, align 4
  br label %125

31:                                               ; preds = %3
  %32 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  %33 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  call void @sm2_z256_modn_to_mont(ptr noundef %32, ptr noundef %33)
  %34 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  %35 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  call void @sm2_z256_modn_mont_inv(ptr noundef %34, ptr noundef %35)
  %36 = getelementptr inbounds [4 x i64], ptr %10, i64 0, i64 0
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  call void @sm2_z256_from_bytes(ptr noundef %36, ptr noundef %37)
  br label %38

38:                                               ; preds = %112, %94, %31
  br label %39

39:                                               ; preds = %51, %38
  %40 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  %41 = call ptr @sm2_z256_order()
  %42 = call i32 @sm2_z256_rand_range(ptr noundef %40, ptr noundef %41)
  %43 = icmp ne i32 %42, 1
  br i1 %43, label %44, label %50

44:                                               ; preds = %39
  br label %45

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

48:                                               ; preds = %45
  br label %49

49:                                               ; preds = %48
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %16, align 4
  br label %125

50:                                               ; preds = %39
  br label %51

51:                                               ; preds = %50
  %52 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  %53 = call i64 @sm2_z256_is_zero(ptr noundef %52)
  %54 = icmp ne i64 %53, 0
  br i1 %54, label %39, label %55, !llvm.loop !9

55:                                               ; preds = %51
  %56 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  call void @sm2_z256_point_mul_generator(ptr noundef %8, ptr noundef %56)
  %57 = getelementptr inbounds [4 x i64], ptr %12, i64 0, i64 0
  %58 = call i32 @sm2_z256_point_get_xy(ptr noundef %8, ptr noundef %57, ptr noundef null)
  %59 = getelementptr inbounds [4 x i64], ptr %10, i64 0, i64 0
  %60 = call ptr @sm2_z256_order()
  %61 = call i32 @sm2_z256_cmp(ptr noundef %59, ptr noundef %60)
  %62 = icmp sge i32 %61, 0
  br i1 %62, label %63, label %68

63:                                               ; preds = %55
  %64 = getelementptr inbounds [4 x i64], ptr %10, i64 0, i64 0
  %65 = getelementptr inbounds [4 x i64], ptr %10, i64 0, i64 0
  %66 = call ptr @sm2_z256_order()
  %67 = call i64 @sm2_z256_sub(ptr noundef %64, ptr noundef %65, ptr noundef %66)
  br label %68

68:                                               ; preds = %63, %55
  %69 = getelementptr inbounds [4 x i64], ptr %12, i64 0, i64 0
  %70 = call ptr @sm2_z256_order()
  %71 = call i32 @sm2_z256_cmp(ptr noundef %69, ptr noundef %70)
  %72 = icmp sge i32 %71, 0
  br i1 %72, label %73, label %78

73:                                               ; preds = %68
  %74 = getelementptr inbounds [4 x i64], ptr %12, i64 0, i64 0
  %75 = getelementptr inbounds [4 x i64], ptr %12, i64 0, i64 0
  %76 = call ptr @sm2_z256_order()
  %77 = call i64 @sm2_z256_sub(ptr noundef %74, ptr noundef %75, ptr noundef %76)
  br label %78

78:                                               ; preds = %73, %68
  %79 = getelementptr inbounds [4 x i64], ptr %14, i64 0, i64 0
  %80 = getelementptr inbounds [4 x i64], ptr %10, i64 0, i64 0
  %81 = getelementptr inbounds [4 x i64], ptr %12, i64 0, i64 0
  call void @sm2_z256_modn_add(ptr noundef %79, ptr noundef %80, ptr noundef %81)
  %82 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  %83 = getelementptr inbounds [4 x i64], ptr %14, i64 0, i64 0
  %84 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  %85 = call i64 @sm2_z256_add(ptr noundef %82, ptr noundef %83, ptr noundef %84)
  %86 = getelementptr inbounds [4 x i64], ptr %14, i64 0, i64 0
  %87 = call i64 @sm2_z256_is_zero(ptr noundef %86)
  %88 = icmp ne i64 %87, 0
  br i1 %88, label %94, label %89

89:                                               ; preds = %78
  %90 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  %91 = call ptr @sm2_z256_order()
  %92 = call i32 @sm2_z256_cmp(ptr noundef %90, ptr noundef %91)
  %93 = icmp eq i32 %92, 0
  br i1 %93, label %94, label %95

94:                                               ; preds = %89, %78
  br label %38

95:                                               ; preds = %89
  %96 = getelementptr inbounds [4 x i64], ptr %14, i64 0, i64 0
  %97 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  call void @sm2_z256_modn_to_mont(ptr noundef %96, ptr noundef %97)
  %98 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  %99 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.SM2_KEY, ptr %100, i32 0, i32 1
  %102 = getelementptr inbounds [4 x i64], ptr %101, i64 0, i64 0
  call void @sm2_z256_modn_mont_mul(ptr noundef %98, ptr noundef %99, ptr noundef %102)
  %103 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  %104 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  %105 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  call void @sm2_z256_modn_sub(ptr noundef %103, ptr noundef %104, ptr noundef %105)
  %106 = getelementptr inbounds [4 x i64], ptr %15, i64 0, i64 0
  %107 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  %108 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  call void @sm2_z256_modn_mont_mul(ptr noundef %106, ptr noundef %107, ptr noundef %108)
  %109 = getelementptr inbounds [4 x i64], ptr %15, i64 0, i64 0
  %110 = call i64 @sm2_z256_is_zero(ptr noundef %109)
  %111 = icmp ne i64 %110, 0
  br i1 %111, label %112, label %113

112:                                              ; preds = %95
  br label %38

113:                                              ; preds = %95
  %114 = getelementptr inbounds [4 x i64], ptr %14, i64 0, i64 0
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.SM2_SIGNATURE, ptr %115, i32 0, i32 0
  %117 = getelementptr inbounds [32 x i8], ptr %116, i64 0, i64 0
  call void @sm2_z256_to_bytes(ptr noundef %114, ptr noundef %117)
  %118 = getelementptr inbounds [4 x i64], ptr %15, i64 0, i64 0
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.SM2_SIGNATURE, ptr %119, i32 0, i32 1
  %121 = getelementptr inbounds [32 x i8], ptr %120, i64 0, i64 0
  call void @sm2_z256_to_bytes(ptr noundef %118, ptr noundef %121)
  %122 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %122, i64 noundef 32)
  %123 = getelementptr inbounds [4 x i64], ptr %11, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %123, i64 noundef 32)
  %124 = getelementptr inbounds [4 x i64], ptr %13, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %124, i64 noundef 32)
  store i32 1, ptr %4, align 4
  store i32 1, ptr %16, align 4
  br label %125

125:                                              ; preds = %113, %49, %30
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr %8) #4
  %126 = load i32, ptr %4, align 4
  ret i32 %126
}

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

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

declare ptr @sm2_z256_one() #2

declare i64 @sm2_z256_is_zero(ptr noundef) #2

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

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

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

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

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

declare ptr @sm2_z256_order() #2

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

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

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

declare i64 @sm2_z256_sub(ptr noundef, ptr noundef, ptr noundef) #2

declare i64 @sm2_z256_add(ptr noundef, ptr noundef, ptr noundef) #2

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

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

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

declare void @gmssl_secure_clear(ptr noundef, i64 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 "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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] }

@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 [62 x i8], align 1
@__FUNCTION__.sm2_do_sign = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @sm2_do_sign(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.SM2_Z256_POINT, align 8
  %5 = alloca [4 x i64], align 16
  %6 = alloca [4 x i64], align 16
  %7 = alloca [4 x i64], align 16
  %8 = alloca [4 x i64], align 16
  %9 = alloca [4 x i64], align 16
  %10 = alloca [4 x i64], align 16
  %11 = alloca [4 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %11) #4
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  %13 = tail call ptr @sm2_z256_one() #4
  call void @sm2_z256_modn_add(ptr noundef nonnull %5, ptr noundef nonnull %12, ptr noundef %13) #4
  %14 = call i64 @sm2_z256_is_zero(ptr noundef nonnull %5) #4
  %.not = icmp eq i64 %14, 0
  br i1 %.not, label %18, label %15

15:                                               ; preds = %3
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 36, ptr noundef nonnull @__FUNCTION__.sm2_do_sign) #5
  br label %52

18:                                               ; preds = %3
  call void @sm2_z256_modn_to_mont(ptr noundef nonnull %5, ptr noundef nonnull %5) #4
  call void @sm2_z256_modn_mont_inv(ptr noundef nonnull %5, ptr noundef nonnull %5) #4
  call void @sm2_z256_from_bytes(ptr noundef nonnull %6, ptr noundef %1) #4
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %18
  %19 = call ptr @sm2_z256_order() #4
  %20 = call i32 @sm2_z256_rand_range(ptr noundef nonnull %7, ptr noundef %19) #4
  %.not5 = icmp eq i32 %20, 1
  br i1 %.not5, label %24, label %21

21:                                               ; preds = %.backedge
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 50, ptr noundef nonnull @__FUNCTION__.sm2_do_sign) #5
  br label %52

24:                                               ; preds = %.backedge
  %25 = call i64 @sm2_z256_is_zero(ptr noundef nonnull %7) #4
  %.not6 = icmp eq i64 %25, 0
  br i1 %.not6, label %26, label %.backedge.backedge

.backedge.backedge:                               ; preds = %24, %41, %44, %48
  br label %.backedge, !llvm.loop !9

26:                                               ; preds = %24
  call void @sm2_z256_point_mul_generator(ptr noundef nonnull %4, ptr noundef nonnull %7) #4
  %27 = call i32 @sm2_z256_point_get_xy(ptr noundef nonnull %4, ptr noundef nonnull %8, ptr noundef null) #4
  %28 = call ptr @sm2_z256_order() #4
  %29 = call i32 @sm2_z256_cmp(ptr noundef nonnull %6, ptr noundef %28) #4
  %30 = icmp sgt i32 %29, -1
  br i1 %30, label %31, label %34

31:                                               ; preds = %26
  %32 = call ptr @sm2_z256_order() #4
  %33 = call i64 @sm2_z256_sub(ptr noundef nonnull %6, ptr noundef nonnull %6, ptr noundef %32) #4
  br label %34

34:                                               ; preds = %31, %26
  %35 = call ptr @sm2_z256_order() #4
  %36 = call i32 @sm2_z256_cmp(ptr noundef nonnull %8, ptr noundef %35) #4
  %37 = icmp sgt i32 %36, -1
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = call ptr @sm2_z256_order() #4
  %40 = call i64 @sm2_z256_sub(ptr noundef nonnull %8, ptr noundef nonnull %8, ptr noundef %39) #4
  br label %41

41:                                               ; preds = %38, %34
  call void @sm2_z256_modn_add(ptr noundef nonnull %10, ptr noundef nonnull %6, ptr noundef nonnull %8) #4
  %42 = call i64 @sm2_z256_add(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %7) #4
  %43 = call i64 @sm2_z256_is_zero(ptr noundef nonnull %10) #4
  %.not7 = icmp eq i64 %43, 0
  br i1 %.not7, label %44, label %.backedge.backedge

44:                                               ; preds = %41
  %45 = call ptr @sm2_z256_order() #4
  %46 = call i32 @sm2_z256_cmp(ptr noundef nonnull %9, ptr noundef %45) #4
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %.backedge.backedge, label %48

48:                                               ; preds = %44
  call void @sm2_z256_modn_to_mont(ptr noundef nonnull %10, ptr noundef nonnull %9) #4
  call void @sm2_z256_modn_mont_mul(ptr noundef nonnull %9, ptr noundef nonnull %9, ptr noundef nonnull %12) #4
  call void @sm2_z256_modn_sub(ptr noundef nonnull %7, ptr noundef nonnull %7, ptr noundef nonnull %9) #4
  call void @sm2_z256_modn_mont_mul(ptr noundef nonnull %11, ptr noundef nonnull %5, ptr noundef nonnull %7) #4
  %49 = call i64 @sm2_z256_is_zero(ptr noundef nonnull %11) #4
  %.not8 = icmp eq i64 %49, 0
  br i1 %.not8, label %50, label %.backedge.backedge

50:                                               ; preds = %48
  call void @sm2_z256_to_bytes(ptr noundef nonnull %10, ptr noundef %2) #4
  %51 = getelementptr inbounds i8, ptr %2, i64 32
  call void @sm2_z256_to_bytes(ptr noundef nonnull %11, ptr noundef nonnull %51) #4
  call void @gmssl_secure_clear(ptr noundef nonnull %5, i64 noundef 32) #4
  call void @gmssl_secure_clear(ptr noundef nonnull %7, i64 noundef 32) #4
  call void @gmssl_secure_clear(ptr noundef nonnull %9, i64 noundef 32) #4
  br label %52

52:                                               ; preds = %50, %21, %15
  %.0 = phi i32 [ -1, %15 ], [ -1, %21 ], [ 1, %50 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %4) #4
  ret i32 %.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 @sm2_z256_modn_add(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @sm2_z256_one() local_unnamed_addr #2

declare i64 @sm2_z256_is_zero(ptr noundef) local_unnamed_addr #2

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

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

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

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

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

declare ptr @sm2_z256_order() local_unnamed_addr #2

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

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

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

declare i64 @sm2_z256_sub(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i64 @sm2_z256_add(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

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

declare void @gmssl_secure_clear(ptr noundef, i64 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 = { 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"}


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