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

; 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_CMACGetTag(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [16 x i8], align 16
  %11 = alloca [16 x i8], align 16
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = icmp eq ptr null, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store i32 -8, ptr %4, align 4
  br label %97

15:                                               ; preds = %3
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._cpAES_CMAC, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = call i64 @IPP_UINT_PTR(ptr noundef %19)
  %21 = trunc i64 %20 to i32
  %22 = xor i32 %18, %21
  %23 = icmp eq i32 %22, 1129136451
  br i1 %23, label %25, label %24

24:                                               ; preds = %15
  store i32 -13, ptr %4, align 4
  br label %97

25:                                               ; preds = %15
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = icmp eq ptr null, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store i32 -8, ptr %4, align 4
  br label %97

29:                                               ; preds = %25
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp slt i32 %30, 1
  br i1 %31, label %35, label %32

32:                                               ; preds = %29
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp slt i32 16, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %32, %29
  store i32 -15, ptr %4, align 4
  br label %97

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._cpAES_CMAC, ptr %37, i32 0, i32 6
  store ptr %38, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._cpRijndael128, ptr %39, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  store ptr %41, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #3
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._cpAES_CMAC, ptr %42, i32 0, i32 4
  %44 = getelementptr inbounds [16 x i8], ptr %43, i64 0, i64 0
  %45 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  call void @CopyBlock16(ptr noundef %44, ptr noundef %45)
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._cpAES_CMAC, ptr %46, i32 0, i32 5
  %48 = getelementptr inbounds [16 x i8], ptr %47, i64 0, i64 0
  %49 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  call void @CopyBlock16(ptr noundef %48, ptr noundef %49)
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._cpAES_CMAC, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !15
  %53 = icmp eq i32 16, %52
  br i1 %53, label %54, label %60

54:                                               ; preds = %36
  %55 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._cpAES_CMAC, ptr %56, i32 0, i32 2
  %58 = getelementptr inbounds [16 x i8], ptr %57, i64 0, i64 0
  %59 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  call void @XorBlock16(ptr noundef %55, ptr noundef %58, ptr noundef %59)
  br label %81

60:                                               ; preds = %36
  %61 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._cpAES_CMAC, ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !15
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %61, i64 %65
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._cpAES_CMAC, ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !15
  %70 = sub nsw i32 16, %69
  call void @PadBlock(i8 noundef zeroext 0, ptr noundef %66, i32 noundef %70)
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._cpAES_CMAC, ptr %71, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !15
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 %74
  store i8 -128, ptr %75, align 1, !tbaa !16
  %76 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._cpAES_CMAC, ptr %77, i32 0, i32 3
  %79 = getelementptr inbounds [16 x i8], ptr %78, i64 0, i64 0
  %80 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  call void @XorBlock16(ptr noundef %76, ptr noundef %79, ptr noundef %80)
  br label %81

81:                                               ; preds = %60, %54
  %82 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %83 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %84 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  call void @XorBlock16(ptr noundef %82, ptr noundef %83, ptr noundef %84)
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %87 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._cpRijndael128, ptr %88, i32 0, i32 3
  %90 = load i32, ptr %89, align 4, !tbaa !17
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._cpRijndael128, ptr %91, i32 0, i32 8
  %93 = load ptr, ptr %92, align 8, !tbaa !18
  call void %85(ptr noundef %86, ptr noundef %87, i32 noundef %90, ptr noundef %93, ptr noundef @RijEncSbox)
  %94 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = load i32, ptr %6, align 4, !tbaa !9
  call void @CopyBlock(ptr noundef %94, ptr noundef %95, i32 noundef %96)
  store i32 0, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %97

97:                                               ; preds = %81, %35, %28, %24, %14
  %98 = load i32, ptr %4, align 4
  ret i32 %98
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(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: inlinehint nounwind uwtable
declare hidden void @CopyBlock16(ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @XorBlock16(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PadBlock(i8 noundef zeroext, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @CopyBlock(ptr noundef, ptr noundef, i32 noundef) #1

; 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 = { 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 = !{!12, !10, i64 4}
!16 = !{!7, !7, i64 0}
!17 = !{!13, !10, i64 12}
!18 = !{!13, !6, i64 48}


; 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 range(i32 -15, 1) i32 @ippsAES_CMACGetTag(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [16 x i8], align 16
  %5 = alloca [16 x i8], align 16
  %6 = icmp eq ptr %2, null
  br i1 %6, label %38, label %7

7:                                                ; preds = %3
  %8 = load i32, ptr %2, align 8, !tbaa !5
  %9 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %2)
  %10 = trunc i64 %9 to i32
  %11 = xor i32 %8, %10
  %12 = icmp eq i32 %11, 1129136451
  br i1 %12, label %13, label %38

13:                                               ; preds = %7
  %14 = icmp eq ptr %0, null
  br i1 %14, label %38, label %15

15:                                               ; preds = %13
  %16 = add i32 %1, -17
  %or.cond = icmp ult i32 %16, -16
  br i1 %or.cond, label %38, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %2, i64 88
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  %20 = getelementptr inbounds i8, ptr %2, i64 40
  call void @CopyBlock16(ptr noundef nonnull %20, ptr noundef nonnull %4)
  %21 = getelementptr inbounds i8, ptr %2, i64 56
  call void @CopyBlock16(ptr noundef nonnull %21, ptr noundef nonnull %5)
  %22 = getelementptr inbounds i8, ptr %2, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = icmp eq i32 %23, 16
  br i1 %24, label %32, label %25

25:                                               ; preds = %17
  %26 = sext i32 %23 to i64
  %27 = getelementptr inbounds i8, ptr %4, i64 %26
  %28 = sub nsw i32 16, %23
  call void @PadBlock(i8 noundef zeroext 0, ptr noundef nonnull %27, i32 noundef %28)
  %29 = load i32, ptr %22, align 4, !tbaa !13
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [16 x i8], ptr %4, i64 0, i64 %30
  store i8 -128, ptr %31, align 1, !tbaa !14
  br label %32

32:                                               ; preds = %17, %25
  %.sink26 = phi i64 [ 24, %25 ], [ 8, %17 ]
  %33 = getelementptr inbounds i8, ptr %2, i64 %.sink26
  call void @XorBlock16(ptr noundef nonnull %4, ptr noundef nonnull %33, ptr noundef nonnull %4)
  call void @XorBlock16(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %5)
  %34 = getelementptr inbounds i8, ptr %2, i64 84
  %35 = load i32, ptr %34, align 4, !tbaa !15
  %36 = getelementptr inbounds i8, ptr %2, i64 120
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  call void %19(ptr noundef nonnull %5, ptr noundef nonnull %5, i32 noundef %35, ptr noundef %37, ptr noundef nonnull @RijEncSbox) #3
  call void @CopyBlock(ptr noundef nonnull %5, ptr noundef nonnull %0, i32 noundef %1)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  br label %38

38:                                               ; preds = %15, %13, %7, %3, %32
  %.0 = phi i32 [ 0, %32 ], [ -8, %3 ], [ -13, %7 ], [ -8, %13 ], [ -15, %15 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr noundef) 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: inlinehint nounwind uwtable
declare hidden void @CopyBlock16(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @XorBlock16(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PadBlock(i8 noundef zeroext, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @CopyBlock(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!6, !7, i64 4}
!14 = !{!8, !8, i64 0}
!15 = !{!10, !7, i64 12}
!16 = !{!10, !11, i64 48}


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