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

; 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_HMAC_CTX = type { %struct.SM3_CTX, [64 x i8] }
%struct.SM3_CTX = type { [8 x i32], i64, [64 x i8], 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 [57 x i8], align 1
@__FUNCTION__.tls_cbc_encrypt = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 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) #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @tls_cbc_encrypt(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7) #3 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca %struct.SM3_HMAC_CTX, align 8
  %19 = alloca [48 x i8], align 16
  %20 = alloca [16 x i8], align 16
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store i64 %5, ptr %15, align 8, !tbaa !9
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 176, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr %19) #6
  call void @llvm.memset.p0.i64(ptr align 16 %19, i8 0, i64 48, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %50

29:                                               ; preds = %8
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %50

32:                                               ; preds = %29
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %50

35:                                               ; preds = %32
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %50

38:                                               ; preds = %35
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %44, label %41

41:                                               ; preds = %38
  %42 = load i64, ptr %15, align 8, !tbaa !9
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %50, label %44

44:                                               ; preds = %41, %38
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %50

47:                                               ; preds = %44
  %48 = load ptr, ptr %17, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %56, label %50

50:                                               ; preds = %47, %44, %41, %35, %32, %29, %8
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 280, ptr noundef @__FUNCTION__.tls_cbc_encrypt) #6
  br label %54

54:                                               ; preds = %51
  br label %55

55:                                               ; preds = %54
  store i32 -1, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %171

56:                                               ; preds = %47
  %57 = load i64, ptr %15, align 8, !tbaa !9
  %58 = icmp ugt i64 %57, 16384
  br i1 %58, label %59, label %66

59:                                               ; preds = %56
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = load i64, ptr %15, align 8, !tbaa !9
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 284, ptr noundef @__FUNCTION__.tls_cbc_encrypt, i64 noundef %62) #6
  br label %64

64:                                               ; preds = %60
  br label %65

65:                                               ; preds = %64
  store i32 -1, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %171

66:                                               ; preds = %56
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 3
  %69 = load i8, ptr %68, align 1, !tbaa !11
  %70 = zext i8 %69 to i64
  %71 = shl i64 %70, 8
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 4
  %74 = load i8, ptr %73, align 1, !tbaa !11
  %75 = zext i8 %74 to i64
  %76 = add i64 %71, %75
  %77 = load i64, ptr %15, align 8, !tbaa !9
  %78 = icmp ne i64 %76, %77
  br i1 %78, label %79, label %85

79:                                               ; preds = %66
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 288, ptr noundef @__FUNCTION__.tls_cbc_encrypt) #6
  br label %83

83:                                               ; preds = %80
  br label %84

84:                                               ; preds = %83
  store i32 -1, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %171

85:                                               ; preds = %66
  %86 = load i64, ptr %15, align 8, !tbaa !9
  %87 = add i64 %86, 32
  %88 = urem i64 %87, 16
  %89 = trunc i64 %88 to i32
  store i32 %89, ptr %23, align 4, !tbaa !12
  %90 = getelementptr inbounds [48 x i8], ptr %19, i64 0, i64 0
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = load i64, ptr %15, align 8, !tbaa !9
  %93 = getelementptr inbounds i8, ptr %91, i64 %92
  %94 = load i32, ptr %23, align 4, !tbaa !12
  %95 = sext i32 %94 to i64
  %96 = sub i64 0, %95
  %97 = getelementptr inbounds i8, ptr %93, i64 %96
  %98 = load i32, ptr %23, align 4, !tbaa !12
  %99 = sext i32 %98 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %90, ptr align 1 %97, i64 %99, i1 false)
  %100 = getelementptr inbounds [48 x i8], ptr %19, i64 0, i64 0
  %101 = load i32, ptr %23, align 4, !tbaa !12
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i8, ptr %100, i64 %102
  store ptr %103, ptr %21, align 8, !tbaa !5
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %104, i64 176, i1 false)
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  call void @sm3_hmac_update(ptr noundef %18, ptr noundef %105, i64 noundef 8)
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  call void @sm3_hmac_update(ptr noundef %18, ptr noundef %106, i64 noundef 5)
  %107 = load ptr, ptr %14, align 8, !tbaa !5
  %108 = load i64, ptr %15, align 8, !tbaa !9
  call void @sm3_hmac_update(ptr noundef %18, ptr noundef %107, i64 noundef %108)
  %109 = load ptr, ptr %21, align 8, !tbaa !5
  call void @sm3_hmac_finish(ptr noundef %18, ptr noundef %109)
  %110 = load ptr, ptr %21, align 8, !tbaa !5
  %111 = getelementptr inbounds i8, ptr %110, i64 32
  store ptr %111, ptr %22, align 8, !tbaa !5
  %112 = load i32, ptr %23, align 4, !tbaa !12
  %113 = sub nsw i32 16, %112
  %114 = sub nsw i32 %113, 1
  store i32 %114, ptr %24, align 4, !tbaa !12
  store i32 0, ptr %25, align 4, !tbaa !12
  br label %115

115:                                              ; preds = %126, %85
  %116 = load i32, ptr %25, align 4, !tbaa !12
  %117 = load i32, ptr %24, align 4, !tbaa !12
  %118 = icmp sle i32 %116, %117
  br i1 %118, label %119, label %129

119:                                              ; preds = %115
  %120 = load i32, ptr %24, align 4, !tbaa !12
  %121 = trunc i32 %120 to i8
  %122 = load ptr, ptr %22, align 8, !tbaa !5
  %123 = load i32, ptr %25, align 4, !tbaa !12
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds i8, ptr %122, i64 %124
  store i8 %121, ptr %125, align 1, !tbaa !11
  br label %126

126:                                              ; preds = %119
  %127 = load i32, ptr %25, align 4, !tbaa !12
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %25, align 4, !tbaa !12
  br label %115, !llvm.loop !14

129:                                              ; preds = %115
  %130 = getelementptr inbounds [16 x i8], ptr %20, i64 0, i64 0
  %131 = call i32 @rand_bytes(ptr noundef %130, i64 noundef 16)
  %132 = icmp ne i32 %131, 1
  br i1 %132, label %133, label %139

133:                                              ; preds = %129
  br label %134

134:                                              ; preds = %133
  %135 = load ptr, ptr @stderr, align 8, !tbaa !5
  %136 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %135, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 309, ptr noundef @__FUNCTION__.tls_cbc_encrypt) #6
  br label %137

137:                                              ; preds = %134
  br label %138

138:                                              ; preds = %137
  store i32 -1, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %171

139:                                              ; preds = %129
  %140 = load ptr, ptr %16, align 8, !tbaa !5
  %141 = getelementptr inbounds [16 x i8], ptr %20, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %140, ptr align 16 %141, i64 16, i1 false)
  %142 = load ptr, ptr %16, align 8, !tbaa !5
  %143 = getelementptr inbounds i8, ptr %142, i64 16
  store ptr %143, ptr %16, align 8, !tbaa !5
  %144 = load i64, ptr %15, align 8, !tbaa !9
  %145 = icmp uge i64 %144, 16
  br i1 %145, label %146, label %159

146:                                              ; preds = %139
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  %148 = getelementptr inbounds [16 x i8], ptr %20, i64 0, i64 0
  %149 = load ptr, ptr %14, align 8, !tbaa !5
  %150 = load i64, ptr %15, align 8, !tbaa !9
  %151 = udiv i64 %150, 16
  %152 = load ptr, ptr %16, align 8, !tbaa !5
  call void @sm4_cbc_encrypt_blocks(ptr noundef %147, ptr noundef %148, ptr noundef %149, i64 noundef %151, ptr noundef %152)
  %153 = load i64, ptr %15, align 8, !tbaa !9
  %154 = load i32, ptr %23, align 4, !tbaa !12
  %155 = sext i32 %154 to i64
  %156 = sub i64 %153, %155
  %157 = load ptr, ptr %16, align 8, !tbaa !5
  %158 = getelementptr inbounds i8, ptr %157, i64 %156
  store ptr %158, ptr %16, align 8, !tbaa !5
  br label %159

159:                                              ; preds = %146, %139
  %160 = load ptr, ptr %11, align 8, !tbaa !5
  %161 = getelementptr inbounds [16 x i8], ptr %20, i64 0, i64 0
  %162 = getelementptr inbounds [48 x i8], ptr %19, i64 0, i64 0
  %163 = load ptr, ptr %16, align 8, !tbaa !5
  call void @sm4_cbc_encrypt_blocks(ptr noundef %160, ptr noundef %161, ptr noundef %162, i64 noundef 3, ptr noundef %163)
  %164 = load i64, ptr %15, align 8, !tbaa !9
  %165 = add i64 16, %164
  %166 = load i32, ptr %23, align 4, !tbaa !12
  %167 = sext i32 %166 to i64
  %168 = sub i64 %165, %167
  %169 = add i64 %168, 48
  %170 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 %169, ptr %170, align 8, !tbaa !9
  store i32 1, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %171

171:                                              ; preds = %159, %138, %84, %65, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 176, ptr %18) #6
  %172 = load i32, ptr %9, align 4
  ret i32 %172
}

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

declare void @sm3_hmac_update(ptr noundef, ptr noundef, i64 noundef) #5

declare void @sm3_hmac_finish(ptr noundef, ptr noundef) #5

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

declare void @sm4_cbc_encrypt_blocks(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) #5

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { "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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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_HMAC_CTX = type { %struct.SM3_CTX, [64 x i8] }
%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 [57 x i8], align 1
@__FUNCTION__.tls_cbc_encrypt = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [48 x i8], align 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) #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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @tls_cbc_encrypt(ptr noundef readonly %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef writeonly %7) local_unnamed_addr #3 {
  %9 = alloca %struct.SM3_HMAC_CTX, align 8
  %10 = alloca [48 x i8], align 16
  %11 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 176, ptr nonnull %9) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %10) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(48) %10, i8 0, i64 48, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %11) #6
  %12 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %13 = insertelement <4 x ptr> %12, ptr %1, i64 1
  %14 = insertelement <4 x ptr> %13, ptr %2, i64 2
  %15 = insertelement <4 x ptr> %14, ptr %3, i64 3
  %16 = icmp eq <4 x ptr> %15, zeroinitializer
  %17 = bitcast <4 x i1> %16 to i4
  %18 = icmp eq i4 %17, 0
  br i1 %18, label %19, label %24

19:                                               ; preds = %8
  %20 = icmp ne ptr %4, null
  %21 = icmp eq i64 %5, 0
  %or.cond7.not70 = or i1 %20, %21
  %22 = icmp ne ptr %6, null
  %or.cond9 = and i1 %or.cond7.not70, %22
  %23 = icmp ne ptr %7, null
  %or.cond11 = and i1 %or.cond9, %23
  br i1 %or.cond11, label %27, label %24

24:                                               ; preds = %8, %19
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 280, ptr noundef nonnull @__FUNCTION__.tls_cbc_encrypt) #7
  br label %71

27:                                               ; preds = %19
  %28 = icmp ugt i64 %5, 16384
  br i1 %28, label %29, label %32

29:                                               ; preds = %27
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 284, ptr noundef nonnull @__FUNCTION__.tls_cbc_encrypt, i64 noundef %5) #7
  br label %71

32:                                               ; preds = %27
  %33 = getelementptr inbounds i8, ptr %3, i64 3
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = zext i8 %34 to i64
  %36 = shl nuw nsw i64 %35, 8
  %37 = getelementptr inbounds i8, ptr %3, i64 4
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = zext i8 %38 to i64
  %40 = or disjoint i64 %36, %39
  %.not = icmp eq i64 %40, %5
  br i1 %.not, label %44, label %41

41:                                               ; preds = %32
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 288, ptr noundef nonnull @__FUNCTION__.tls_cbc_encrypt) #7
  br label %71

44:                                               ; preds = %32
  %45 = trunc i64 %5 to i8
  %46 = and i8 %45, 15
  %47 = getelementptr inbounds i8, ptr %4, i64 %5
  %48 = and i64 %5, 15
  %49 = sub nsw i64 0, %48
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %10, ptr align 1 %50, i64 %48, i1 false)
  %51 = getelementptr inbounds i8, ptr %10, i64 %48
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(176) %9, ptr noundef nonnull align 8 dereferenceable(176) %0, i64 176, i1 false)
  call void @sm3_hmac_update(ptr noundef nonnull %9, ptr noundef nonnull %2, i64 noundef 8) #6
  call void @sm3_hmac_update(ptr noundef nonnull %9, ptr noundef nonnull %3, i64 noundef 5) #6
  call void @sm3_hmac_update(ptr noundef nonnull %9, ptr noundef %4, i64 noundef %5) #6
  call void @sm3_hmac_finish(ptr noundef nonnull %9, ptr noundef nonnull %51) #6
  %52 = getelementptr inbounds i8, ptr %51, i64 32
  %53 = xor i8 %46, 15
  %54 = and i64 %5, 15
  %55 = sub nuw nsw i64 16, %54
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %52, i8 %53, i64 %55, i1 false), !tbaa !9
  %56 = call i32 @rand_bytes(ptr noundef nonnull %11, i64 noundef 16) #6
  %.not72 = icmp eq i32 %56, 1
  br i1 %.not72, label %60, label %57

57:                                               ; preds = %44
  %58 = load ptr, ptr @stderr, align 8, !tbaa !5
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 309, ptr noundef nonnull @__FUNCTION__.tls_cbc_encrypt) #7
  br label %71

60:                                               ; preds = %44
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(16) %6, ptr noundef nonnull align 16 dereferenceable(16) %11, i64 16, i1 false)
  %61 = getelementptr inbounds i8, ptr %6, i64 16
  %62 = icmp ugt i64 %5, 15
  br i1 %62, label %63, label %67

63:                                               ; preds = %60
  %64 = lshr i64 %5, 4
  call void @sm4_cbc_encrypt_blocks(ptr noundef nonnull %1, ptr noundef nonnull %11, ptr noundef %4, i64 noundef %64, ptr noundef nonnull %61) #6
  %65 = and i64 %5, 32752
  %66 = getelementptr inbounds i8, ptr %61, i64 %65
  br label %67

67:                                               ; preds = %63, %60
  %.060 = phi ptr [ %66, %63 ], [ %61, %60 ]
  call void @sm4_cbc_encrypt_blocks(ptr noundef nonnull %1, ptr noundef nonnull %11, ptr noundef nonnull %10, i64 noundef 3, ptr noundef nonnull %.060) #6
  %68 = add nuw nsw i64 %5, 16
  %69 = and i64 %68, 65520
  %70 = add nuw nsw i64 %69, 48
  store i64 %70, ptr %7, align 8, !tbaa !10
  br label %71

71:                                               ; preds = %67, %57, %41, %29, %24
  %.059 = phi i32 [ -1, %29 ], [ -1, %41 ], [ -1, %57 ], [ 1, %67 ], [ -1, %24 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 176, ptr nonnull %9) #6
  ret i32 %.059
}

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

declare void @sm3_hmac_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #5

declare void @sm3_hmac_finish(ptr noundef, ptr noundef) local_unnamed_addr #5

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

declare void @sm4_cbc_encrypt_blocks(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { "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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,PostOrderFunctionAttrsPass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass