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

@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_lms_key_generate_ex = external hidden unnamed_addr constant [24 x i8], align 1

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

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

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

; 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) #3

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sm3_lms_key_generate_ex(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = call i32 @sm3_lms_type_to_height(i32 noundef %15, ptr noundef %12)
  %17 = icmp ne i32 %16, 1
  br i1 %17, label %18, label %24

18:                                               ; preds = %5
  br label %19

19:                                               ; preds = %18
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 534, ptr noundef @__FUNCTION__.sm3_lms_key_generate_ex) #6
  br label %22

22:                                               ; preds = %19
  br label %23

23:                                               ; preds = %22
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %171

24:                                               ; preds = %5
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = shl i32 1, %25
  store i32 %26, ptr %13, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = ashr i32 %27, 24
  %29 = trunc i32 %28 to i8
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [4 x i8], ptr %32, i64 0, i64 0
  store i8 %29, ptr %33, align 8, !tbaa !11
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = ashr i32 %34, 16
  %36 = trunc i32 %35 to i8
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 1
  store i8 %36, ptr %40, align 1, !tbaa !11
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = ashr i32 %41, 8
  %43 = trunc i32 %42 to i8
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds [4 x i8], ptr %46, i64 0, i64 2
  store i8 %43, ptr %47, align 2, !tbaa !11
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = trunc i32 %48 to i8
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds [4 x i8], ptr %52, i64 0, i64 3
  store i8 %49, ptr %53, align 1, !tbaa !11
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds [4 x i8], ptr %56, i64 0, i64 0
  store i8 0, ptr %57, align 4, !tbaa !11
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds [4 x i8], ptr %60, i64 0, i64 1
  store i8 0, ptr %61, align 1, !tbaa !11
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %62, i32 0, i32 0
  %64 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds [4 x i8], ptr %64, i64 0, i64 2
  store i8 0, ptr %65, align 2, !tbaa !11
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %67, i32 0, i32 1
  %69 = getelementptr inbounds [4 x i8], ptr %68, i64 0, i64 3
  store i8 4, ptr %69, align 1, !tbaa !11
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %78

72:                                               ; preds = %24
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %74, i32 0, i32 2
  %76 = getelementptr inbounds [16 x i8], ptr %75, i64 0, i64 0
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %76, ptr align 1 %77, i64 16, i1 false)
  br label %92

78:                                               ; preds = %24
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %80, i32 0, i32 2
  %82 = getelementptr inbounds [16 x i8], ptr %81, i64 0, i64 0
  %83 = call i32 @rand_bytes(ptr noundef %82, i64 noundef 16)
  %84 = icmp ne i32 %83, 1
  br i1 %84, label %85, label %91

85:                                               ; preds = %78
  br label %86

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

89:                                               ; preds = %86
  br label %90

90:                                               ; preds = %89
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %171

91:                                               ; preds = %78
  br label %92

92:                                               ; preds = %91, %72
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %95, label %100

95:                                               ; preds = %92
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %96, i32 0, i32 2
  %98 = getelementptr inbounds [32 x i8], ptr %97, i64 0, i64 0
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %98, ptr align 1 %99, i64 32, i1 false)
  br label %113

100:                                              ; preds = %92
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %101, i32 0, i32 2
  %103 = getelementptr inbounds [32 x i8], ptr %102, i64 0, i64 0
  %104 = call i32 @rand_bytes(ptr noundef %103, i64 noundef 32)
  %105 = icmp ne i32 %104, 1
  br i1 %105, label %106, label %112

106:                                              ; preds = %100
  br label %107

107:                                              ; preds = %106
  %108 = load ptr, ptr @stderr, align 8, !tbaa !5
  %109 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %108, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 555, ptr noundef @__FUNCTION__.sm3_lms_key_generate_ex) #6
  br label %110

110:                                              ; preds = %107
  br label %111

111:                                              ; preds = %110
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %171

112:                                              ; preds = %100
  br label %113

113:                                              ; preds = %112, %95
  %114 = load i32, ptr %11, align 4, !tbaa !9
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %153

116:                                              ; preds = %113
  %117 = load i32, ptr %13, align 4, !tbaa !9
  %118 = mul nsw i32 2, %117
  %119 = sub nsw i32 %118, 1
  %120 = sext i32 %119 to i64
  %121 = mul i64 32, %120
  %122 = call noalias ptr @malloc(i64 noundef %121) #7
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %123, i32 0, i32 1
  store ptr %122, ptr %124, align 8, !tbaa !12
  %125 = icmp ne ptr %122, null
  br i1 %125, label %132, label %126

126:                                              ; preds = %116
  br label %127

127:                                              ; preds = %126
  %128 = load ptr, ptr @stderr, align 8, !tbaa !5
  %129 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %128, ptr noundef @.str.14, ptr noundef @.str.15, i32 noundef 562, ptr noundef @__FUNCTION__.sm3_lms_key_generate_ex) #6
  br label %130

130:                                              ; preds = %127
  br label %131

131:                                              ; preds = %130
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %171

132:                                              ; preds = %116
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %133, i32 0, i32 2
  %135 = getelementptr inbounds [32 x i8], ptr %134, i64 0, i64 0
  %136 = load ptr, ptr %7, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %136, i32 0, i32 0
  %138 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %137, i32 0, i32 2
  %139 = getelementptr inbounds [16 x i8], ptr %138, i64 0, i64 0
  %140 = load i32, ptr %12, align 4, !tbaa !9
  %141 = load ptr, ptr %7, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %141, i32 0, i32 1
  %143 = load ptr, ptr %142, align 8, !tbaa !12
  call void @sm3_lms_derive_merkle_tree(ptr noundef %135, ptr noundef %139, i32 noundef %140, ptr noundef %143)
  %144 = load ptr, ptr %7, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %144, i32 0, i32 0
  %146 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %145, i32 0, i32 3
  %147 = getelementptr inbounds [32 x i8], ptr %146, i64 0, i64 0
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %148, i32 0, i32 1
  %150 = load ptr, ptr %149, align 8, !tbaa !12
  %151 = getelementptr inbounds [32 x i8], ptr %150, i64 0
  %152 = getelementptr inbounds [32 x i8], ptr %151, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %147, ptr align 1 %152, i64 32, i1 false)
  br label %168

153:                                              ; preds = %113
  %154 = load ptr, ptr %7, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %154, i32 0, i32 1
  store ptr null, ptr %155, align 8, !tbaa !12
  %156 = load ptr, ptr %7, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %156, i32 0, i32 2
  %158 = getelementptr inbounds [32 x i8], ptr %157, i64 0, i64 0
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %159, i32 0, i32 0
  %161 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %160, i32 0, i32 2
  %162 = getelementptr inbounds [16 x i8], ptr %161, i64 0, i64 0
  %163 = load i32, ptr %12, align 4, !tbaa !9
  %164 = load ptr, ptr %7, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %164, i32 0, i32 0
  %166 = getelementptr inbounds %struct.SM3_LMS_PUBLIC_KEY, ptr %165, i32 0, i32 3
  %167 = getelementptr inbounds [32 x i8], ptr %166, i64 0, i64 0
  call void @sm3_lms_derive_merkle_root(ptr noundef %158, ptr noundef %162, i32 noundef %163, ptr noundef %167)
  br label %168

168:                                              ; preds = %153, %132
  %169 = load ptr, ptr %7, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.SM3_LMS_KEY, ptr %169, i32 0, i32 3
  store i32 0, ptr %170, align 8, !tbaa !15
  store i32 1, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %171

171:                                              ; preds = %168, %131, %111, %90, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %172 = load i32, ptr %6, align 4
  ret i32 %172
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { nounwind allocsize(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 = { nounwind allocsize(0) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 56}
!13 = !{!"", !14, i64 0, !6, i64 56, !7, i64 64, !10, i64 96}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 24}
!15 = !{!13, !10, i64 96}


; 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"

@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_lms_key_generate_ex = external hidden unnamed_addr constant [24 x i8], align 1

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

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

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

; 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) #3

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

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @sm3_lms_key_generate_ex(ptr noundef %0, i32 noundef %1, ptr noundef readonly %2, ptr noundef readonly %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  %7 = call i32 @sm3_lms_type_to_height(i32 noundef %1, ptr noundef nonnull %6)
  %.not = icmp eq i32 %7, 1
  br i1 %.not, label %11, label %8

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

11:                                               ; preds = %5
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = lshr i32 %1, 24
  %14 = trunc nuw i32 %13 to i8
  store i8 %14, ptr %0, align 8, !tbaa !11
  %15 = lshr i32 %1, 16
  %16 = trunc i32 %15 to i8
  %17 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %16, ptr %17, align 1, !tbaa !11
  %18 = lshr i32 %1, 8
  %19 = trunc i32 %18 to i8
  %20 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %19, ptr %20, align 2, !tbaa !11
  %21 = trunc i32 %1 to i8
  %22 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %21, ptr %22, align 1, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  store <4 x i8> <i8 0, i8 0, i8 0, i8 4>, ptr %23, align 4, !tbaa !11
  %.not37 = icmp eq ptr %3, null
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %.not37, label %26, label %25

25:                                               ; preds = %11
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 1 dereferenceable(16) %3, i64 16, i1 false)
  br label %31

26:                                               ; preds = %11
  %27 = call i32 @rand_bytes(ptr noundef nonnull %24, i64 noundef 16) #6
  %.not38 = icmp eq i32 %27, 1
  br i1 %.not38, label %31, label %28

28:                                               ; preds = %26
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.15, i32 noundef 546, ptr noundef nonnull @__FUNCTION__.sm3_lms_key_generate_ex) #7
  br label %64

31:                                               ; preds = %26, %25
  %.not39 = icmp eq ptr %2, null
  %32 = getelementptr inbounds i8, ptr %0, i64 64
  br i1 %.not39, label %34, label %33

33:                                               ; preds = %31
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %32, ptr noundef nonnull align 1 dereferenceable(32) %2, i64 32, i1 false)
  br label %39

34:                                               ; preds = %31
  %35 = call i32 @rand_bytes(ptr noundef nonnull %32, i64 noundef 32) #6
  %.not40 = icmp eq i32 %35, 1
  br i1 %.not40, label %39, label %36

36:                                               ; preds = %34
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.15, i32 noundef 555, ptr noundef nonnull @__FUNCTION__.sm3_lms_key_generate_ex) #7
  br label %64

39:                                               ; preds = %34, %33
  %.not41 = icmp eq i32 %4, 0
  br i1 %.not41, label %56, label %40

40:                                               ; preds = %39
  %41 = shl i32 2, %12
  %42 = add nsw i32 %41, -1
  %43 = sext i32 %42 to i64
  %44 = shl nsw i64 %43, 5
  %45 = call noalias ptr @malloc(i64 noundef %44) #8
  %46 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %45, ptr %46, align 8, !tbaa !12
  %.not42 = icmp eq ptr %45, null
  br i1 %.not42, label %47, label %50

47:                                               ; preds = %40
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.15, i32 noundef 562, ptr noundef nonnull @__FUNCTION__.sm3_lms_key_generate_ex) #7
  br label %64

50:                                               ; preds = %40
  %51 = getelementptr inbounds i8, ptr %0, i64 64
  %52 = getelementptr inbounds i8, ptr %0, i64 8
  %53 = load i32, ptr %6, align 4, !tbaa !9
  call void @sm3_lms_derive_merkle_tree(ptr noundef nonnull %51, ptr noundef nonnull %52, i32 noundef %53, ptr noundef nonnull %45)
  %54 = getelementptr inbounds i8, ptr %0, i64 24
  %55 = load ptr, ptr %46, align 8, !tbaa !12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %54, ptr noundef nonnull align 1 dereferenceable(32) %55, i64 32, i1 false)
  br label %62

56:                                               ; preds = %39
  %57 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr null, ptr %57, align 8, !tbaa !12
  %58 = getelementptr inbounds i8, ptr %0, i64 64
  %59 = getelementptr inbounds i8, ptr %0, i64 8
  %60 = load i32, ptr %6, align 4, !tbaa !9
  %61 = getelementptr inbounds i8, ptr %0, i64 24
  call void @sm3_lms_derive_merkle_root(ptr noundef nonnull %58, ptr noundef nonnull %59, i32 noundef %60, ptr noundef nonnull %61)
  br label %62

62:                                               ; preds = %56, %50
  %63 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 0, ptr %63, align 8, !tbaa !15
  br label %64

64:                                               ; preds = %62, %47, %36, %28, %8
  %.0 = phi i32 [ -1, %8 ], [ 1, %62 ], [ -1, %47 ], [ -1, %36 ], [ -1, %28 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  ret i32 %.0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 56}
!13 = !{!"", !14, i64 0, !6, i64 56, !7, i64 64, !10, i64 96}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 24}
!15 = !{!13, !10, i64 96}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass