; LLVM IR from intel/cryptography-primitives :: sources/ippcp (pcpaes_cmacinit)

; 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._cpAES_CMAC = type { i32, i32, [16 x i8], [16 x i8], [16 x i8], [16 x i8], %struct._cpRijndael128 }
%struct._cpRijndael128 = type { i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, [124 x i32] }

@RijEncSbox = external constant [256 x i8], align 64

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsAES_CMACInit(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = icmp eq ptr null, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %4
  store i32 -8, ptr %5, align 4
  br label %107

17:                                               ; preds = %4
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = call i32 @cpSizeofCtx_AESCMAC()
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %17
  store i32 -9, ptr %5, align 4
  br label %107

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = call i64 @IPP_UINT_PTR(ptr noundef %23)
  %25 = trunc i64 %24 to i32
  %26 = xor i32 1129136451, %25
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._cpAES_CMAC, ptr %27, i32 0, i32 0
  store i32 %26, ptr %28, align 8, !tbaa !11
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  call void @init(ptr noundef %29)
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._cpAES_CMAC, ptr %32, i32 0, i32 6
  %34 = call i32 @cpSizeofCtx_AES()
  %35 = call i32 @ippsAESInit(ptr noundef %30, i32 noundef %31, ptr noundef %33, i32 noundef %34)
  store i32 %35, ptr %10, align 4, !tbaa !9
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = icmp eq i32 0, %36
  br i1 %37, label %38, label %105

38:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._cpAES_CMAC, ptr %39, i32 0, i32 6
  store ptr %40, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._cpRijndael128, ptr %41, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !14
  store ptr %43, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._cpAES_CMAC, ptr %45, i32 0, i32 5
  %47 = getelementptr inbounds [16 x i8], ptr %46, i64 0, i64 0
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._cpAES_CMAC, ptr %48, i32 0, i32 2
  %50 = getelementptr inbounds [16 x i8], ptr %49, i64 0, i64 0
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._cpRijndael128, ptr %51, i32 0, i32 3
  %53 = load i32, ptr %52, align 4, !tbaa !15
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._cpRijndael128, ptr %54, i32 0, i32 8
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  call void %44(ptr noundef %47, ptr noundef %50, i32 noundef %53, ptr noundef %56, ptr noundef @RijEncSbox)
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._cpAES_CMAC, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds [16 x i8], ptr %58, i64 0, i64 0
  %60 = load i8, ptr %59, align 8, !tbaa !17
  %61 = zext i8 %60 to i32
  store i32 %61, ptr %13, align 4, !tbaa !9
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._cpAES_CMAC, ptr %62, i32 0, i32 2
  %64 = getelementptr inbounds [16 x i8], ptr %63, i64 0, i64 0
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._cpAES_CMAC, ptr %65, i32 0, i32 2
  %67 = getelementptr inbounds [16 x i8], ptr %66, i64 0, i64 0
  call void @LogicalLeftSift16(ptr noundef %64, ptr noundef %67)
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = ashr i32 %68, 7
  %70 = sub nsw i32 0, %69
  %71 = and i32 %70, 135
  %72 = trunc i32 %71 to i8
  %73 = zext i8 %72 to i32
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._cpAES_CMAC, ptr %74, i32 0, i32 2
  %76 = getelementptr inbounds [16 x i8], ptr %75, i64 0, i64 15
  %77 = load i8, ptr %76, align 1, !tbaa !17
  %78 = zext i8 %77 to i32
  %79 = xor i32 %78, %73
  %80 = trunc i32 %79 to i8
  store i8 %80, ptr %76, align 1, !tbaa !17
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._cpAES_CMAC, ptr %81, i32 0, i32 2
  %83 = getelementptr inbounds [16 x i8], ptr %82, i64 0, i64 0
  %84 = load i8, ptr %83, align 8, !tbaa !17
  %85 = zext i8 %84 to i32
  store i32 %85, ptr %13, align 4, !tbaa !9
  %86 = load ptr, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._cpAES_CMAC, ptr %86, i32 0, i32 2
  %88 = getelementptr inbounds [16 x i8], ptr %87, i64 0, i64 0
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._cpAES_CMAC, ptr %89, i32 0, i32 3
  %91 = getelementptr inbounds [16 x i8], ptr %90, i64 0, i64 0
  call void @LogicalLeftSift16(ptr noundef %88, ptr noundef %91)
  %92 = load i32, ptr %13, align 4, !tbaa !9
  %93 = ashr i32 %92, 7
  %94 = sub nsw i32 0, %93
  %95 = and i32 %94, 135
  %96 = trunc i32 %95 to i8
  %97 = zext i8 %96 to i32
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._cpAES_CMAC, ptr %98, i32 0, i32 3
  %100 = getelementptr inbounds [16 x i8], ptr %99, i64 0, i64 15
  %101 = load i8, ptr %100, align 1, !tbaa !17
  %102 = zext i8 %101 to i32
  %103 = xor i32 %102, %97
  %104 = trunc i32 %103 to i8
  store i8 %104, ptr %100, align 1, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %105

105:                                              ; preds = %38, %22
  %106 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %106, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %107

107:                                              ; preds = %105, %21, %16
  %108 = load i32, ptr %5, align 4
  ret i32 %108
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpSizeofCtx_AESCMAC() #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr noundef) #1

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

declare i32 @ippsAESInit(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpSizeofCtx_AES() #1

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

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

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 = { inlinehint 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 #2 = { nocallback nofree nosync 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 = { 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 = !{!"_cpAES_CMAC", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 24, !7, i64 40, !7, i64 56, !13, i64 72}
!13 = !{!"_cpRijndael128", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !7, i64 72}
!14 = !{!13, !6, i64 16}
!15 = !{!13, !10, i64 12}
!16 = !{!13, !6, i64 48}
!17 = !{!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"

@RijEncSbox = external constant [256 x i8], align 64

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsAES_CMACInit(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %2, null
  br i1 %5, label %37, label %6

6:                                                ; preds = %4
  %7 = tail call i32 @cpSizeofCtx_AESCMAC()
  %8 = icmp sgt i32 %7, %3
  br i1 %8, label %37, label %9

9:                                                ; preds = %6
  %10 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %2)
  %11 = trunc i64 %10 to i32
  %12 = xor i32 %11, 1129136451
  store i32 %12, ptr %2, align 8, !tbaa !5
  tail call void @init(ptr noundef nonnull %2)
  %13 = getelementptr inbounds i8, ptr %2, i64 72
  %14 = tail call i32 @cpSizeofCtx_AES()
  %15 = tail call i32 @ippsAESInit(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %13, i32 noundef %14) #3
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %37

17:                                               ; preds = %9
  %18 = getelementptr inbounds i8, ptr %2, i64 88
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %2, i64 56
  %21 = getelementptr inbounds i8, ptr %2, i64 8
  %22 = getelementptr inbounds i8, ptr %2, i64 84
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %2, i64 120
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  tail call void %19(ptr noundef nonnull %20, ptr noundef nonnull %21, i32 noundef %23, ptr noundef %25, ptr noundef nonnull @RijEncSbox) #3
  %26 = load i8, ptr %21, align 8, !tbaa !15
  tail call void @LogicalLeftSift16(ptr noundef nonnull %21, ptr noundef nonnull %21)
  %isneg = icmp slt i8 %26, 0
  %27 = select i1 %isneg, i8 -121, i8 0
  %28 = getelementptr inbounds i8, ptr %2, i64 23
  %29 = load i8, ptr %28, align 1, !tbaa !15
  %30 = xor i8 %27, %29
  store i8 %30, ptr %28, align 1, !tbaa !15
  %31 = load i8, ptr %21, align 8, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %2, i64 24
  tail call void @LogicalLeftSift16(ptr noundef nonnull %21, ptr noundef nonnull %32)
  %isneg28 = icmp slt i8 %31, 0
  %33 = select i1 %isneg28, i8 -121, i8 0
  %34 = getelementptr inbounds i8, ptr %2, i64 39
  %35 = load i8, ptr %34, align 1, !tbaa !15
  %36 = xor i8 %33, %35
  store i8 %36, ptr %34, align 1, !tbaa !15
  br label %37

37:                                               ; preds = %9, %17, %6, %4
  %.0 = phi i32 [ -8, %4 ], [ -9, %6 ], [ 0, %17 ], [ %15, %9 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpSizeofCtx_AESCMAC() local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpSizeofCtx_AES() local_unnamed_addr #1

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

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 = { inlinehint 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!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, !7, i64 0}
!6 = !{!"_cpAES_CMAC", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 24, !8, i64 40, !8, i64 56, !10, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_cpRijndael128", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !7, i64 64, !7, i64 68, !8, i64 72}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!10, !7, i64 12}
!14 = !{!10, !11, i64 48}
!15 = !{!8, !8, i64 0}


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