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

; 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.SM4_CBC_MAC_CTX = type { %struct.SM4_KEY, [16 x i8], i64 }
%struct.SM4_KEY = type { [32 x i32] }

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

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

32:                                               ; preds = %10
  %33 = load i64, ptr %14, align 8, !tbaa !9
  %34 = icmp ugt i64 %33, 13
  br i1 %34, label %35, label %41

35:                                               ; preds = %32, %10
  br label %36

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

39:                                               ; preds = %36
  br label %40

40:                                               ; preds = %39
  store i32 -1, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %220

41:                                               ; preds = %32
  %42 = load ptr, ptr %15, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %53, label %44

44:                                               ; preds = %41
  %45 = load i64, ptr %16, align 8, !tbaa !9
  %46 = icmp ne i64 %45, 0
  br i1 %46, label %47, label %53

47:                                               ; preds = %44
  br label %48

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

51:                                               ; preds = %48
  br label %52

52:                                               ; preds = %51
  store i32 -1, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %220

53:                                               ; preds = %44, %41
  %54 = load i64, ptr %20, align 8, !tbaa !9
  %55 = icmp ult i64 %54, 4
  br i1 %55, label %63, label %56

56:                                               ; preds = %53
  %57 = load i64, ptr %20, align 8, !tbaa !9
  %58 = icmp ugt i64 %57, 16
  br i1 %58, label %63, label %59

59:                                               ; preds = %56
  %60 = load i64, ptr %20, align 8, !tbaa !9
  %61 = and i64 %60, 1
  %62 = icmp ne i64 %61, 0
  br i1 %62, label %63, label %69

63:                                               ; preds = %59, %56, %53
  br label %64

64:                                               ; preds = %63
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 72, ptr noundef @__FUNCTION__.sm4_ccm_encrypt) #6
  br label %67

67:                                               ; preds = %64
  br label %68

68:                                               ; preds = %67
  store i32 -1, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %220

69:                                               ; preds = %59
  %70 = load i64, ptr %14, align 8, !tbaa !9
  %71 = sub i64 15, %70
  store i64 %71, ptr %27, align 8, !tbaa !9
  %72 = load i64, ptr %27, align 8, !tbaa !9
  %73 = icmp ult i64 %72, 8
  br i1 %73, label %74, label %86

74:                                               ; preds = %69
  %75 = load i64, ptr %18, align 8, !tbaa !9
  %76 = load i64, ptr %27, align 8, !tbaa !9
  %77 = mul i64 %76, 8
  %78 = shl i64 1, %77
  %79 = icmp uge i64 %75, %78
  br i1 %79, label %80, label %86

80:                                               ; preds = %74
  br label %81

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

84:                                               ; preds = %81
  br label %85

85:                                               ; preds = %84
  store i32 -1, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %220

86:                                               ; preds = %74, %69
  call void @llvm.memset.p0.i64(ptr align 8 %22, i8 0, i64 152, i1 false)
  %87 = getelementptr inbounds %struct.SM4_CBC_MAC_CTX, ptr %22, i32 0, i32 0
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %87, ptr align 4 %88, i64 128, i1 false), !tbaa.struct !11
  %89 = load i64, ptr %16, align 8, !tbaa !9
  %90 = icmp ugt i64 %89, 0
  %91 = zext i1 %90 to i32
  %92 = and i32 %91, 1
  %93 = shl i32 %92, 6
  %94 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %95 = load i8, ptr %94, align 16, !tbaa !12
  %96 = zext i8 %95 to i32
  %97 = or i32 %96, %93
  %98 = trunc i32 %97 to i8
  store i8 %98, ptr %94, align 16, !tbaa !12
  %99 = load i64, ptr %20, align 8, !tbaa !9
  %100 = sub i64 %99, 2
  %101 = udiv i64 %100, 2
  %102 = and i64 %101, 7
  %103 = shl i64 %102, 3
  %104 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %105 = load i8, ptr %104, align 16, !tbaa !12
  %106 = zext i8 %105 to i64
  %107 = or i64 %106, %103
  %108 = trunc i64 %107 to i8
  store i8 %108, ptr %104, align 16, !tbaa !12
  %109 = load i64, ptr %27, align 8, !tbaa !9
  %110 = sub i64 %109, 1
  %111 = and i64 %110, 7
  %112 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %113 = load i8, ptr %112, align 16, !tbaa !12
  %114 = zext i8 %113 to i64
  %115 = or i64 %114, %111
  %116 = trunc i64 %115 to i8
  store i8 %116, ptr %112, align 16, !tbaa !12
  %117 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %118 = getelementptr inbounds i8, ptr %117, i64 1
  %119 = load ptr, ptr %13, align 8, !tbaa !5
  %120 = load i64, ptr %14, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %118, ptr align 1 %119, i64 %120, i1 false)
  %121 = load i64, ptr %18, align 8, !tbaa !9
  %122 = load i64, ptr %27, align 8, !tbaa !9
  %123 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %124 = getelementptr inbounds i8, ptr %123, i64 1
  %125 = load i64, ptr %14, align 8, !tbaa !9
  %126 = getelementptr inbounds i8, ptr %124, i64 %125
  call void @length_to_bytes(i64 noundef %121, i64 noundef %122, ptr noundef %126)
  %127 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  call void @sm4_cbc_mac_update(ptr noundef %22, ptr noundef %127, i64 noundef 16)
  %128 = load ptr, ptr %15, align 8, !tbaa !5
  %129 = icmp ne ptr %128, null
  br i1 %129, label %130, label %173

130:                                              ; preds = %86
  %131 = load i64, ptr %16, align 8, !tbaa !9
  %132 = icmp ne i64 %131, 0
  br i1 %132, label %133, label %173

133:                                              ; preds = %130
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #6
  %134 = load i64, ptr %16, align 8, !tbaa !9
  %135 = icmp ult i64 %134, 65280
  br i1 %135, label %136, label %139

136:                                              ; preds = %133
  %137 = load i64, ptr %16, align 8, !tbaa !9
  %138 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  call void @length_to_bytes(i64 noundef %137, i64 noundef 2, ptr noundef %138)
  store i64 2, ptr %29, align 8, !tbaa !9
  br label %155

139:                                              ; preds = %133
  %140 = load i64, ptr %16, align 8, !tbaa !9
  %141 = icmp ult i64 %140, 4294967296
  br i1 %141, label %142, label %148

142:                                              ; preds = %139
  %143 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  store i8 -1, ptr %143, align 16, !tbaa !12
  %144 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 1
  store i8 -2, ptr %144, align 1, !tbaa !12
  %145 = load i64, ptr %16, align 8, !tbaa !9
  %146 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %147 = getelementptr inbounds i8, ptr %146, i64 2
  call void @length_to_bytes(i64 noundef %145, i64 noundef 4, ptr noundef %147)
  store i64 6, ptr %29, align 8, !tbaa !9
  br label %154

148:                                              ; preds = %139
  %149 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  store i8 -1, ptr %149, align 16, !tbaa !12
  %150 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 1
  store i8 -1, ptr %150, align 1, !tbaa !12
  %151 = load i64, ptr %16, align 8, !tbaa !9
  %152 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %153 = getelementptr inbounds i8, ptr %152, i64 2
  call void @length_to_bytes(i64 noundef %151, i64 noundef 8, ptr noundef %153)
  store i64 10, ptr %29, align 8, !tbaa !9
  br label %154

154:                                              ; preds = %148, %142
  br label %155

155:                                              ; preds = %154, %136
  %156 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %157 = load i64, ptr %29, align 8, !tbaa !9
  call void @sm4_cbc_mac_update(ptr noundef %22, ptr noundef %156, i64 noundef %157)
  %158 = load ptr, ptr %15, align 8, !tbaa !5
  %159 = load i64, ptr %16, align 8, !tbaa !9
  call void @sm4_cbc_mac_update(ptr noundef %22, ptr noundef %158, i64 noundef %159)
  %160 = load i64, ptr %29, align 8, !tbaa !9
  %161 = load i64, ptr %16, align 8, !tbaa !9
  %162 = urem i64 %161, 16
  %163 = add i64 %160, %162
  %164 = icmp ne i64 %163, 0
  br i1 %164, label %165, label %172

165:                                              ; preds = %155
  %166 = getelementptr inbounds [16 x i8], ptr %23, i64 0, i64 0
  %167 = load i64, ptr %29, align 8, !tbaa !9
  %168 = load i64, ptr %16, align 8, !tbaa !9
  %169 = add i64 %167, %168
  %170 = urem i64 %169, 16
  %171 = sub i64 16, %170
  call void @sm4_cbc_mac_update(ptr noundef %22, ptr noundef %166, i64 noundef %171)
  br label %172

172:                                              ; preds = %165, %155
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #6
  br label %173

173:                                              ; preds = %172, %130, %86
  %174 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 0
  store i8 0, ptr %174, align 16, !tbaa !12
  %175 = load i64, ptr %27, align 8, !tbaa !9
  %176 = sub i64 %175, 1
  %177 = and i64 %176, 7
  %178 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 0
  %179 = load i8, ptr %178, align 16, !tbaa !12
  %180 = zext i8 %179 to i64
  %181 = or i64 %180, %177
  %182 = trunc i64 %181 to i8
  store i8 %182, ptr %178, align 16, !tbaa !12
  %183 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 0
  %184 = getelementptr inbounds i8, ptr %183, i64 1
  %185 = load ptr, ptr %13, align 8, !tbaa !5
  %186 = load i64, ptr %14, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %184, ptr align 1 %185, i64 %186, i1 false)
  %187 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 0
  %188 = getelementptr inbounds i8, ptr %187, i64 1
  %189 = load i64, ptr %14, align 8, !tbaa !9
  %190 = getelementptr inbounds i8, ptr %188, i64 %189
  %191 = load i64, ptr %14, align 8, !tbaa !9
  %192 = sub i64 15, %191
  call void @llvm.memset.p0.i64(ptr align 1 %190, i8 0, i64 %192, i1 false)
  %193 = load ptr, ptr %12, align 8, !tbaa !5
  %194 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 0
  %195 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  call void @sm4_encrypt(ptr noundef %193, ptr noundef %194, ptr noundef %195)
  %196 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 15
  store i8 1, ptr %196, align 1, !tbaa !12
  %197 = load ptr, ptr %12, align 8, !tbaa !5
  %198 = getelementptr inbounds [16 x i8], ptr %25, i64 0, i64 0
  %199 = load i64, ptr %14, align 8, !tbaa !9
  %200 = sub i64 15, %199
  %201 = load ptr, ptr %17, align 8, !tbaa !5
  %202 = load i64, ptr %18, align 8, !tbaa !9
  %203 = load ptr, ptr %19, align 8, !tbaa !5
  call void @sm4_ctr_n_encrypt(ptr noundef %197, ptr noundef %198, i64 noundef %200, ptr noundef %201, i64 noundef %202, ptr noundef %203)
  %204 = load ptr, ptr %17, align 8, !tbaa !5
  %205 = load i64, ptr %18, align 8, !tbaa !9
  call void @sm4_cbc_mac_update(ptr noundef %22, ptr noundef %204, i64 noundef %205)
  %206 = load i64, ptr %18, align 8, !tbaa !9
  %207 = urem i64 %206, 16
  %208 = icmp ne i64 %207, 0
  br i1 %208, label %209, label %214

209:                                              ; preds = %173
  %210 = getelementptr inbounds [16 x i8], ptr %23, i64 0, i64 0
  %211 = load i64, ptr %18, align 8, !tbaa !9
  %212 = urem i64 %211, 16
  %213 = sub i64 16, %212
  call void @sm4_cbc_mac_update(ptr noundef %22, ptr noundef %210, i64 noundef %213)
  br label %214

214:                                              ; preds = %209, %173
  %215 = getelementptr inbounds [16 x i8], ptr %26, i64 0, i64 0
  call void @sm4_cbc_mac_finish(ptr noundef %22, ptr noundef %215)
  %216 = load ptr, ptr %21, align 8, !tbaa !5
  %217 = getelementptr inbounds [16 x i8], ptr %26, i64 0, i64 0
  %218 = getelementptr inbounds [16 x i8], ptr %24, i64 0, i64 0
  %219 = load i64, ptr %20, align 8, !tbaa !9
  call void @gmssl_memxor(ptr noundef %216, ptr noundef %217, ptr noundef %218, i64 noundef %219)
  call void @gmssl_secure_clear(ptr noundef %22, i64 noundef 152)
  store i32 1, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %220

220:                                              ; preds = %214, %85, %68, %52, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 152, ptr %22) #6
  %221 = load i32, ptr %11, align 4
  ret i32 %221
}

; 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

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

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

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

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

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

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

declare void @gmssl_secure_clear(ptr noundef, 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 128, !12}
!12 = !{!7, !7, i64 0}


; 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.SM4_CBC_MAC_CTX = type { %struct.SM4_KEY, [16 x i8], i64 }
%struct.SM4_KEY = type { [32 x i32] }

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @sm4_ccm_encrypt(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8, ptr noundef %9) local_unnamed_addr #0 {
  %11 = alloca %struct.SM4_CBC_MAC_CTX, align 8
  %12 = alloca [16 x i8], align 16
  %13 = alloca [16 x i8], align 16
  %14 = alloca [16 x i8], align 16
  %15 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 152, ptr nonnull %11) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %12) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %12, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %13) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %13, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %14) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %14, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %15) #6
  %16 = add i64 %2, -14
  %or.cond = icmp ult i64 %16, -7
  br i1 %or.cond, label %17, label %20

17:                                               ; preds = %10
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 64, ptr noundef nonnull @__FUNCTION__.sm4_ccm_encrypt) #7
  br label %74

20:                                               ; preds = %10
  %21 = icmp eq ptr %3, null
  %22 = icmp ne i64 %4, 0
  %or.cond3 = and i1 %21, %22
  br i1 %or.cond3, label %23, label %26

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 68, ptr noundef nonnull @__FUNCTION__.sm4_ccm_encrypt) #7
  br label %74

26:                                               ; preds = %20
  %27 = add i64 %8, -4
  %or.cond5 = icmp ult i64 %27, 13
  %28 = and i64 %8, 1
  %.not = icmp eq i64 %28, 0
  %or.cond68 = and i1 %or.cond5, %.not
  br i1 %or.cond68, label %32, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 72, ptr noundef nonnull @__FUNCTION__.sm4_ccm_encrypt) #7
  br label %74

32:                                               ; preds = %26
  %33 = sub nuw nsw i64 15, %2
  %34 = icmp ugt i64 %2, 7
  br i1 %34, label %35, label %40

35:                                               ; preds = %32
  %36 = shl nuw nsw i64 %33, 3
  %.highbits = lshr i64 %6, %36
  %.not65 = icmp eq i64 %.highbits, 0
  br i1 %.not65, label %40, label %37

37:                                               ; preds = %35
  %38 = load ptr, ptr @stderr, align 8, !tbaa !5
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 78, ptr noundef nonnull @__FUNCTION__.sm4_ccm_encrypt) #7
  br label %74

40:                                               ; preds = %35, %32
  %41 = getelementptr inbounds i8, ptr %11, i64 128
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %41, i8 0, i64 24, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %11, ptr noundef nonnull align 4 dereferenceable(128) %0, i64 128, i1 false), !tbaa.struct !9
  %.not66 = icmp eq i64 %4, 0
  %42 = select i1 %.not66, i8 0, i8 64
  %.tr = trunc nuw i64 %8 to i8
  %43 = shl nuw nsw i8 %.tr, 2
  %44 = add nuw nsw i8 %43, 56
  %45 = and i8 %44, 56
  %46 = trunc nuw i64 %2 to i8
  %47 = sub nsw i8 6, %46
  %48 = and i8 %47, 7
  %49 = or disjoint i8 %42, %45
  %50 = or disjoint i8 %49, %48
  store i8 %50, ptr %13, align 16, !tbaa !10
  %51 = getelementptr inbounds i8, ptr %13, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %51, ptr align 1 %1, i64 %2, i1 false)
  %52 = getelementptr inbounds i8, ptr %51, i64 %2
  call void @length_to_bytes(i64 noundef %6, i64 noundef %33, ptr noundef nonnull %52)
  call void @sm4_cbc_mac_update(ptr noundef nonnull %11, ptr noundef nonnull %13, i64 noundef 16) #6
  %53 = icmp ne ptr %3, null
  %or.cond7 = and i1 %53, %22
  br i1 %or.cond7, label %54, label %66

54:                                               ; preds = %40
  %55 = icmp ult i64 %4, 65280
  br i1 %55, label %56, label %57

56:                                               ; preds = %54
  call void @length_to_bytes(i64 noundef %4, i64 noundef 2, ptr noundef nonnull %13)
  br label %62

57:                                               ; preds = %54
  %58 = icmp ult i64 %4, 4294967296
  store i8 -1, ptr %13, align 16, !tbaa !10
  %59 = getelementptr inbounds i8, ptr %13, i64 2
  br i1 %58, label %60, label %61

60:                                               ; preds = %57
  store i8 -2, ptr %51, align 1, !tbaa !10
  call void @length_to_bytes(i64 noundef %4, i64 noundef 4, ptr noundef nonnull %59)
  br label %62

61:                                               ; preds = %57
  store i8 -1, ptr %51, align 1, !tbaa !10
  call void @length_to_bytes(i64 noundef %4, i64 noundef 8, ptr noundef nonnull %59)
  br label %62

62:                                               ; preds = %60, %61, %56
  %.0 = phi i64 [ 2, %56 ], [ 6, %60 ], [ 10, %61 ]
  call void @sm4_cbc_mac_update(ptr noundef nonnull %11, ptr noundef nonnull %13, i64 noundef %.0) #6
  call void @sm4_cbc_mac_update(ptr noundef nonnull %11, ptr noundef nonnull %3, i64 noundef %4) #6
  %63 = add i64 %.0, %4
  %64 = and i64 %63, 15
  %65 = sub nuw nsw i64 16, %64
  call void @sm4_cbc_mac_update(ptr noundef nonnull %11, ptr noundef nonnull %12, i64 noundef %65) #6
  br label %66

66:                                               ; preds = %62, %40
  store i8 %48, ptr %14, align 16, !tbaa !10
  %67 = getelementptr inbounds i8, ptr %14, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %67, ptr align 1 %1, i64 %2, i1 false)
  %68 = getelementptr inbounds i8, ptr %67, i64 %2
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %68, i8 0, i64 %33, i1 false)
  call void @sm4_encrypt(ptr noundef nonnull %0, ptr noundef nonnull %14, ptr noundef nonnull %13) #6
  %69 = getelementptr inbounds i8, ptr %14, i64 15
  store i8 1, ptr %69, align 1, !tbaa !10
  call void @sm4_ctr_n_encrypt(ptr noundef nonnull %0, ptr noundef nonnull %14, i64 noundef %33, ptr noundef %5, i64 noundef %6, ptr noundef %7)
  call void @sm4_cbc_mac_update(ptr noundef nonnull %11, ptr noundef %5, i64 noundef %6) #6
  %70 = and i64 %6, 15
  %.not67 = icmp eq i64 %70, 0
  br i1 %.not67, label %73, label %71

71:                                               ; preds = %66
  %72 = sub nuw nsw i64 16, %70
  call void @sm4_cbc_mac_update(ptr noundef nonnull %11, ptr noundef nonnull %12, i64 noundef %72) #6
  br label %73

73:                                               ; preds = %71, %66
  call void @sm4_cbc_mac_finish(ptr noundef nonnull %11, ptr noundef nonnull %15) #6
  call void @gmssl_memxor(ptr noundef %9, ptr noundef nonnull %15, ptr noundef nonnull %13, i64 noundef %8) #6
  call void @gmssl_secure_clear(ptr noundef nonnull %11, i64 noundef 152) #6
  br label %74

74:                                               ; preds = %73, %37, %29, %23, %17
  %.058 = phi i32 [ -1, %17 ], [ -1, %23 ], [ -1, %29 ], [ -1, %37 ], [ 1, %73 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %15) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %14) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %13) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %12) #6
  call void @llvm.lifetime.end.p0(i64 152, ptr nonnull %11) #6
  ret i32 %.058
}

; 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

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

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

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

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

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

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

declare void @gmssl_secure_clear(ptr noundef, 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 128, !10}
!10 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass