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

; 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] }

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsAES_CCMTagLen(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp eq ptr null, %6
  br i1 %7, label %8, label %9

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

9:                                                ; preds = %2
  %10 = load ptr, ptr %5, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct._cpAES_CCM, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = call i64 @IPP_UINT_PTR(ptr noundef %13)
  %15 = trunc i64 %14 to i32
  %16 = xor i32 %12, %15
  %17 = icmp eq i32 %16, 1129136453
  br i1 %17, label %19, label %18

18:                                               ; preds = %9
  store i32 -13, ptr %3, align 4
  br label %34

19:                                               ; preds = %9
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = icmp sgt i32 %20, 16
  br i1 %21, label %29, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 4
  br i1 %24, label %29, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = and i32 %26, 1
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %25, %22, %19
  store i32 -15, ptr %3, align 4
  br label %34

30:                                               ; preds = %25
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct._cpAES_CCM, ptr %32, i32 0, i32 3
  store i32 %31, ptr %33, align 8, !tbaa !14
  store i32 0, ptr %3, align 4
  br label %34

34:                                               ; preds = %30, %29, %18, %8
  %35 = load i32, ptr %3, align 4
  ret i32 %35
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_cpAES_CCM", !6, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, 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, !6, i64 24}


; 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"

; Function Attrs: nounwind uwtable
define dso_local range(i32 -15, 1) i32 @ippsAES_CCMTagLen(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %1, null
  br i1 %3, label %15, label %4

4:                                                ; preds = %2
  %5 = load i32, ptr %1, align 8, !tbaa !5
  %6 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %1)
  %7 = trunc i64 %6 to i32
  %8 = xor i32 %5, %7
  %9 = icmp eq i32 %8, 1129136453
  br i1 %9, label %10, label %15

10:                                               ; preds = %4
  %11 = add i32 %0, -4
  %or.cond = icmp ult i32 %11, 13
  %12 = and i32 %0, 1
  %.not = icmp eq i32 %12, 0
  %or.cond11 = and i1 %or.cond, %.not
  br i1 %or.cond11, label %13, label %15

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %1, i64 24
  store i32 %0, ptr %14, align 8, !tbaa !11
  br label %15

15:                                               ; preds = %10, %4, %2, %13
  %.0 = phi i32 [ 0, %13 ], [ -8, %2 ], [ -13, %4 ], [ -15, %10 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr 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" }

!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}


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