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

; 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_CCM = type { i32, i64, i64, i32, i32, [16 x i8], [16 x i8], [16 x i8], [16 x i8], [16 x i8], [568 x i8] }
%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_CCMGetTag(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 i32, align 4
  %9 = alloca [4 x i32], align 16
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = 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
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %16

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

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

25:                                               ; preds = %16
  store i32 -13, ptr %4, align 4
  br label %83

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

29:                                               ; preds = %26
  store i32 -8, ptr %4, align 4
  br label %83

30:                                               ; preds = %26
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._cpAES_CCM, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 8, !tbaa !14
  %35 = icmp ugt i32 %31, %34
  br i1 %35, label %39, label %36

36:                                               ; preds = %30
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = icmp slt i32 %37, 1
  br i1 %38, label %39, label %40

39:                                               ; preds = %36, %30
  store i32 -15, ptr %4, align 4
  br label %83

40:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._cpAES_CCM, ptr %41, i32 0, i32 2
  %43 = load i64, ptr %42, align 8, !tbaa !15
  %44 = and i64 %43, 15
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._cpAES_CCM, ptr %46, i32 0, i32 9
  %48 = getelementptr inbounds [16 x i8], ptr %47, i64 0, i64 0
  %49 = getelementptr inbounds [4 x i32], ptr %9, i64 0, i64 0
  call void @CopyBlock16(ptr noundef %48, ptr noundef %49)
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %76

52:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._cpAES_CCM, ptr %53, i32 0, i32 10
  store ptr %54, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._cpRijndael128, ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  store ptr %57, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %58 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  call void @FillBlock16(i8 noundef zeroext 0, ptr noundef null, ptr noundef %58, i32 noundef 0)
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._cpAES_CCM, ptr %59, i32 0, i32 8
  %61 = getelementptr inbounds [16 x i8], ptr %60, i64 0, i64 0
  %62 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %63 = load i32, ptr %8, align 4, !tbaa !9
  call void @CopyBlock(ptr noundef %61, ptr noundef %62, i32 noundef %63)
  %64 = getelementptr inbounds [4 x i32], ptr %9, i64 0, i64 0
  %65 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %66 = getelementptr inbounds [4 x i32], ptr %9, i64 0, i64 0
  call void @XorBlock16(ptr noundef %64, ptr noundef %65, ptr noundef %66)
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds [4 x i32], ptr %9, i64 0, i64 0
  %69 = getelementptr inbounds [4 x i32], ptr %9, i64 0, i64 0
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._cpRijndael128, ptr %70, i32 0, i32 3
  %72 = load i32, ptr %71, align 4, !tbaa !18
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._cpRijndael128, ptr %73, i32 0, i32 8
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  call void %67(ptr noundef %68, ptr noundef %69, i32 noundef %72, ptr noundef %75, ptr noundef @RijEncSbox)
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %76

76:                                               ; preds = %52, %40
  %77 = getelementptr inbounds [4 x i32], ptr %9, i64 0, i64 0
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._cpAES_CCM, ptr %78, i32 0, i32 6
  %80 = getelementptr inbounds [16 x i8], ptr %79, i64 0, i64 0
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load i32, ptr %6, align 4, !tbaa !9
  call void @XorBlock(ptr noundef %77, ptr noundef %80, ptr noundef %81, i32 noundef %82)
  store i32 0, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %83

83:                                               ; preds = %76, %39, %29, %25, %15
  %84 = load i32, ptr %4, align 4
  ret i32 %84
}

; 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 @FillBlock16(i8 noundef zeroext, ptr noundef, ptr noundef, i32 noundef) #1

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

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

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

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

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_CCM", !10, i64 0, !13, i64 8, !13, i64 16, !10, i64 24, !10, i64 28, !7, i64 32, !7, i64 48, !7, i64 64, !7, i64 80, !7, i64 96, !7, i64 112}
!13 = !{!"long long", !7, i64 0}
!14 = !{!12, !10, i64 24}
!15 = !{!12, !13, i64 16}
!16 = !{!17, !6, i64 16}
!17 = !{!"_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}
!18 = !{!17, !10, i64 12}
!19 = !{!17, !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_CCMGetTag(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [4 x i32], align 16
  %5 = alloca [16 x i8], align 16
  %6 = icmp eq ptr %2, null
  br i1 %6, label %36, 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, 1129136453
  br i1 %12, label %13, label %36

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

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %2, i64 24
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp ult i32 %17, %1
  %19 = icmp slt i32 %1, 1
  %or.cond = or i1 %19, %18
  br i1 %or.cond, label %36, label %20

20:                                               ; preds = %15
  %21 = getelementptr inbounds i8, ptr %2, i64 16
  %22 = load i64, ptr %21, align 8, !tbaa !12
  %23 = trunc i64 %22 to i32
  %24 = and i32 %23, 15
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  %25 = getelementptr inbounds i8, ptr %2, i64 96
  call void @CopyBlock16(ptr noundef nonnull %25, ptr noundef nonnull %4)
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %34, label %26

26:                                               ; preds = %20
  %27 = getelementptr inbounds i8, ptr %2, i64 128
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  call void @FillBlock16(i8 noundef zeroext 0, ptr noundef null, ptr noundef nonnull %5, i32 noundef 0)
  %29 = getelementptr inbounds i8, ptr %2, i64 80
  call void @CopyBlock(ptr noundef nonnull %29, ptr noundef nonnull %5, i32 noundef %24)
  call void @XorBlock16(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %4)
  %30 = getelementptr inbounds i8, ptr %2, i64 124
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %2, i64 160
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  call void %28(ptr noundef nonnull %4, ptr noundef nonnull %4, i32 noundef %31, ptr noundef %33, ptr noundef nonnull @RijEncSbox) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  br label %34

34:                                               ; preds = %26, %20
  %35 = getelementptr inbounds i8, ptr %2, i64 48
  call void @XorBlock(ptr noundef nonnull %4, ptr noundef nonnull %35, ptr noundef nonnull %0, i32 noundef %1)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  br label %36

36:                                               ; preds = %15, %13, %7, %3, %34
  %.0 = phi i32 [ 0, %34 ], [ -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 @FillBlock16(i8 noundef zeroext, ptr noundef, 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: inlinehint nounwind uwtable
declare hidden void @XorBlock16(ptr noundef, ptr noundef, ptr 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

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

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


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