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

; 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.SM3_HSS_KEY = type { %struct.SM3_HSS_PUBLIC_KEY, [5 x %struct.SM3_LMS_KEY], [4 x %struct.SM3_LMS_SIGNATURE] }
%struct.SM3_HSS_PUBLIC_KEY = type { i32, %struct.SM3_LMS_PUBLIC_KEY }
%struct.SM3_LMS_PUBLIC_KEY = type { [4 x i8], [4 x i8], [16 x i8], [32 x i8] }
%struct.SM3_LMS_KEY = type { %struct.SM3_LMS_PUBLIC_KEY, ptr, [32 x i8], i32 }
%struct.SM3_LMS_SIGNATURE = type { [4 x i8], [4 x i8], %struct.anon, [25 x [32 x i8]] }
%struct.anon = type { [4 x i8], [34 x [32 x i8]], [32 x i8] }

@stderr = external global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [61 x i8], align 1
@__FUNCTION__.sm3_hss_key_generate = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @sm3_lms_key_generate_ex(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) #5

declare i32 @rand_bytes(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @sm3_lms_do_sign(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @sm3_lms_digest(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @sm3_hss_key_cleanup(ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local i32 @sm3_hss_key_generate(ptr noundef %0, i32 noundef %1, ptr noundef %2) #5 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca [32 x i8], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca [32 x i8], align 16
  %15 = alloca [32 x i8], align 16
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 -1, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp sle i32 %16, 0
  br i1 %17, label %21, label %18

18:                                               ; preds = %3
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp sgt i32 %19, 5
  br i1 %20, label %21, label %27

21:                                               ; preds = %18, %3
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 971, ptr noundef @__FUNCTION__.sm3_hss_key_generate) #6
  br label %25

25:                                               ; preds = %22
  br label %26

26:                                               ; preds = %25
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %156

27:                                               ; preds = %18
  %28 = getelementptr inbounds [32 x i8], ptr %9, i64 0, i64 0
  %29 = call i32 @rand_bytes(ptr noundef %28, i64 noundef 32)
  %30 = icmp ne i32 %29, 1
  br i1 %30, label %31, label %37

31:                                               ; preds = %27
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 975, ptr noundef @__FUNCTION__.sm3_hss_key_generate) #6
  br label %35

35:                                               ; preds = %32
  br label %36

36:                                               ; preds = %35
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %156

37:                                               ; preds = %27
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %38, i8 0, i64 8312, i1 false)
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %39, i32 0, i32 1
  %41 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %40, i64 0, i64 0
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds i32, ptr %42, i64 0
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = getelementptr inbounds [32 x i8], ptr %9, i64 0, i64 0
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = call i32 @sm3_lms_key_generate_ex(ptr noundef %41, i32 noundef %44, ptr noundef %45, ptr noundef null, i32 noundef %46)
  %48 = icmp ne i32 %47, 1
  br i1 %48, label %49, label %55

49:                                               ; preds = %37
  br label %50

50:                                               ; preds = %49
  %51 = load ptr, ptr @stderr, align 8, !tbaa !5
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %51, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 981, ptr noundef @__FUNCTION__.sm3_hss_key_generate) #6
  br label %53

53:                                               ; preds = %50
  br label %54

54:                                               ; preds = %53
  br label %148

55:                                               ; preds = %37
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds %struct.SM3_HSS_PUBLIC_KEY, ptr %58, i32 0, i32 0
  store i32 %56, ptr %59, align 8, !tbaa !11
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds %struct.SM3_HSS_PUBLIC_KEY, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %64, i64 0, i64 0
  %66 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %65, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %62, ptr align 8 %66, i64 56, i1 false), !tbaa.struct !15
  store i32 1, ptr %12, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %144, %55
  %68 = load i32, ptr %12, align 4, !tbaa !9
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %71, label %147

71:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #6
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %12, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %73, i64 0, i64 %75
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i32, ptr %77, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = getelementptr inbounds [32 x i8], ptr %9, i64 0, i64 0
  %83 = load i32, ptr %10, align 4, !tbaa !9
  %84 = call i32 @sm3_lms_key_generate_ex(ptr noundef %76, i32 noundef %81, ptr noundef %82, ptr noundef null, i32 noundef %83)
  %85 = icmp ne i32 %84, 1
  br i1 %85, label %86, label %92

86:                                               ; preds = %71
  br label %87

87:                                               ; preds = %86
  %88 = load ptr, ptr @stderr, align 8, !tbaa !5
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 993, ptr noundef @__FUNCTION__.sm3_hss_key_generate) #6
  br label %90

90:                                               ; preds = %87
  br label %91

91:                                               ; preds = %90
  store i32 8, ptr %13, align 4
  br label %141

92:                                               ; preds = %71
  %93 = getelementptr inbounds [32 x i8], ptr %14, i64 0, i64 0
  %94 = call i32 @rand_bytes(ptr noundef %93, i64 noundef 32)
  %95 = icmp ne i32 %94, 1
  br i1 %95, label %96, label %102

96:                                               ; preds = %92
  br label %97

97:                                               ; preds = %96
  %98 = load ptr, ptr @stderr, align 8, !tbaa !5
  %99 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %98, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 997, ptr noundef @__FUNCTION__.sm3_hss_key_generate) #6
  br label %100

100:                                              ; preds = %97
  br label %101

101:                                              ; preds = %100
  store i32 8, ptr %13, align 4
  br label %141

102:                                              ; preds = %92
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %103, i32 0, i32 1
  %105 = load i32, ptr %12, align 4, !tbaa !9
  %106 = sub nsw i32 %105, 1
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %104, i64 0, i64 %107
  %109 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %108, i32 0, i32 0
  %110 = getelementptr inbounds [32 x i8], ptr %14, i64 0, i64 0
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %111, i32 0, i32 1
  %113 = load i32, ptr %12, align 4, !tbaa !9
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %112, i64 0, i64 %114
  %116 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %115, i32 0, i32 0
  %117 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  call void @sm3_lms_digest(ptr noundef %109, i32 noundef 0, ptr noundef %110, ptr noundef %116, i64 noundef 56, ptr noundef %117)
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %118, i32 0, i32 1
  %120 = load i32, ptr %12, align 4, !tbaa !9
  %121 = sub nsw i32 %120, 1
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %119, i64 0, i64 %122
  %124 = getelementptr inbounds [32 x i8], ptr %14, i64 0, i64 0
  %125 = getelementptr inbounds [32 x i8], ptr %15, i64 0, i64 0
  %126 = load ptr, ptr %5, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.SM3_HSS_KEY, ptr %126, i32 0, i32 2
  %128 = load i32, ptr %12, align 4, !tbaa !9
  %129 = sub nsw i32 %128, 1
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [4 x %struct.SM3_LMS_SIGNATURE], ptr %127, i64 0, i64 %130
  %132 = call i32 @sm3_lms_do_sign(ptr noundef %123, ptr noundef %124, ptr noundef %125, ptr noundef %131)
  %133 = icmp ne i32 %132, 1
  br i1 %133, label %134, label %140

134:                                              ; preds = %102
  br label %135

135:                                              ; preds = %134
  %136 = load ptr, ptr @stderr, align 8, !tbaa !5
  %137 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %136, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 1005, ptr noundef @__FUNCTION__.sm3_hss_key_generate) #6
  br label %138

138:                                              ; preds = %135
  br label %139

139:                                              ; preds = %138
  store i32 8, ptr %13, align 4
  br label %141

140:                                              ; preds = %102
  store i32 0, ptr %13, align 4
  br label %141

141:                                              ; preds = %140, %139, %101, %91
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #6
  %142 = load i32, ptr %13, align 4
  switch i32 %142, label %156 [
    i32 0, label %143
    i32 8, label %148
  ]

143:                                              ; preds = %141
  br label %144

144:                                              ; preds = %143
  %145 = load i32, ptr %12, align 4, !tbaa !9
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %12, align 4, !tbaa !9
  br label %67, !llvm.loop !17

147:                                              ; preds = %67
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %148

148:                                              ; preds = %147, %141, %54
  %149 = getelementptr inbounds [32 x i8], ptr %9, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %149, i64 noundef 32)
  %150 = load i32, ptr %8, align 4, !tbaa !9
  %151 = icmp ne i32 %150, 1
  br i1 %151, label %152, label %154

152:                                              ; preds = %148
  %153 = load ptr, ptr %5, align 8, !tbaa !5
  call void @sm3_hss_key_cleanup(ptr noundef %153)
  br label %154

154:                                              ; preds = %152, %148
  %155 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %155, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %156

156:                                              ; preds = %154, %141, %36, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %157 = load i32, ptr %4, align 4
  ret i32 %157
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !13, i64 0, !7, i64 64, !7, i64 584}
!13 = !{!"", !10, i64 0, !14, i64 4}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 24}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 16, !16, i64 24, i64 32, !16}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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.SM3_LMS_KEY = type { %struct.SM3_LMS_PUBLIC_KEY, ptr, [32 x i8], i32 }
%struct.SM3_LMS_PUBLIC_KEY = type { [4 x i8], [4 x i8], [16 x i8], [32 x i8] }
%struct.SM3_LMS_SIGNATURE = type { [4 x i8], [4 x i8], %struct.anon, [25 x [32 x i8]] }
%struct.anon = type { [4 x i8], [34 x [32 x i8]], [32 x i8] }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [61 x i8], align 1
@__FUNCTION__.sm3_hss_key_generate = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) 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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @sm3_lms_key_generate_ex(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

declare i32 @rand_bytes(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @sm3_lms_do_sign(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local void @sm3_lms_digest(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local void @sm3_hss_key_cleanup(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @sm3_hss_key_generate(ptr noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #5 {
  %4 = alloca [32 x i8], align 16
  %5 = alloca [32 x i8], align 16
  %6 = alloca [32 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #6
  %7 = add i32 %1, -6
  %or.cond = icmp ult i32 %7, -5
  br i1 %or.cond, label %8, label %11

8:                                                ; preds = %3
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.15, i32 noundef 971, ptr noundef nonnull @__FUNCTION__.sm3_hss_key_generate) #7
  br label %43

11:                                               ; preds = %3
  %12 = call i32 @rand_bytes(ptr noundef nonnull %4, i64 noundef 32) #6
  %.not = icmp eq i32 %12, 1
  br i1 %.not, label %16, label %13

13:                                               ; preds = %11
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.15, i32 noundef 975, ptr noundef nonnull @__FUNCTION__.sm3_hss_key_generate) #7
  br label %43

16:                                               ; preds = %11
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(8312) %0, i8 0, i64 8312, i1 false)
  %17 = getelementptr inbounds i8, ptr %0, i64 64
  %18 = load i32, ptr %2, align 4, !tbaa !9
  %19 = call i32 @sm3_lms_key_generate_ex(ptr noundef nonnull %17, i32 noundef %18, ptr noundef nonnull %4, ptr noundef null, i32 noundef 1)
  %.not35 = icmp eq i32 %19, 1
  br i1 %.not35, label %23, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.15, i32 noundef 981, ptr noundef nonnull @__FUNCTION__.sm3_hss_key_generate) #7
  br label %42

23:                                               ; preds = %16
  store i32 %1, ptr %0, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %0, i64 4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(56) %24, ptr noundef nonnull align 8 dereferenceable(56) %17, i64 56, i1 false), !tbaa.struct !15
  %25 = icmp ugt i32 %1, 1
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %23
  %26 = getelementptr inbounds i8, ptr %0, i64 584
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %27

27:                                               ; preds = %.lr.ph, %41
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %41 ]
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #6
  %28 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %17, i64 0, i64 %indvars.iv
  %29 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = call i32 @sm3_lms_key_generate_ex(ptr noundef nonnull %28, i32 noundef %30, ptr noundef nonnull %4, ptr noundef null, i32 noundef 1)
  %.not36 = icmp eq i32 %31, 1
  br i1 %.not36, label %32, label %.thread

32:                                               ; preds = %27
  %33 = call i32 @rand_bytes(ptr noundef nonnull %5, i64 noundef 32) #6
  %.not37 = icmp eq i32 %33, 1
  br i1 %.not37, label %34, label %.thread

34:                                               ; preds = %32
  %35 = add nsw i64 %indvars.iv, -1
  %36 = getelementptr inbounds [5 x %struct.SM3_LMS_KEY], ptr %17, i64 0, i64 %35
  call void @sm3_lms_digest(ptr noundef nonnull %36, i32 noundef 0, ptr noundef nonnull %5, ptr noundef nonnull %28, i64 noundef 56, ptr noundef nonnull %6)
  %37 = getelementptr inbounds [4 x %struct.SM3_LMS_SIGNATURE], ptr %26, i64 0, i64 %35
  %38 = call i32 @sm3_lms_do_sign(ptr noundef nonnull %36, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %37)
  %.not38 = icmp eq i32 %38, 1
  br i1 %.not38, label %41, label %.thread

.thread:                                          ; preds = %34, %32, %27
  %.sink50 = phi i32 [ 993, %27 ], [ 997, %32 ], [ 1005, %34 ]
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.15, i32 noundef %.sink50, ptr noundef nonnull @__FUNCTION__.sm3_hss_key_generate) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  br label %42

41:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %27, !llvm.loop !17

._crit_edge:                                      ; preds = %41, %23
  call void @gmssl_secure_clear(ptr noundef nonnull %4, i64 noundef 32) #6
  br label %43

42:                                               ; preds = %20, %.thread
  call void @gmssl_secure_clear(ptr noundef nonnull %4, i64 noundef 32) #6
  call void @sm3_hss_key_cleanup(ptr noundef %0)
  br label %43

43:                                               ; preds = %._crit_edge, %42, %13, %8
  %.032 = phi i32 [ -1, %8 ], [ -1, %13 ], [ -1, %42 ], [ 1, %._crit_edge ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #6
  ret i32 %.032
}

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !13, i64 0, !7, i64 64, !7, i64 584}
!13 = !{!"", !10, i64 0, !14, i64 4}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 24}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 16, !16, i64 24, i64 32, !16}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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