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

; 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._cpHMAC = type { i32, [128 x i8], [128 x i8], %struct._cpHashCtx }
%struct._cpHashCtx = type { i32, i32, i64, i64, ptr, ptr, [8 x i64], i32, [128 x i8] }

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsHMAC_Update(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
  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
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr null, %8
  br i1 %9, label %10, label %11

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

11:                                               ; preds = %3
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._cpHMAC, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = call i64 @IPP_INT_PTR(ptr noundef %15)
  %17 = trunc i64 %16 to i32
  %18 = xor i32 %14, %17
  %19 = icmp eq i32 %18, 1213022531
  br i1 %19, label %21, label %20

20:                                               ; preds = %11
  store i32 -13, ptr %4, align 4
  br label %42

21:                                               ; preds = %11
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %24, label %25

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

25:                                               ; preds = %21
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %28, %25
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._cpHMAC, ptr %38, i32 0, i32 3
  %40 = call i32 @ippsHashUpdate(ptr noundef %36, i32 noundef %37, ptr noundef %39)
  store i32 %40, ptr %4, align 4
  br label %42

41:                                               ; preds = %32
  store i32 0, ptr %4, align 4
  br label %42

42:                                               ; preds = %41, %35, %31, %24, %20, %10
  %43 = load i32, ptr %4, align 4
  ret i32 %43
}

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

declare i32 @ippsHashUpdate(ptr noundef, i32 noundef, ptr noundef) #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 = { "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 = !{!"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 = !{!"_cpHMAC", !10, i64 0, !7, i64 4, !7, i64 132, !13, i64 264}
!13 = !{!"_cpHashCtx", !10, i64 0, !10, i64 4, !14, i64 8, !14, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !10, i64 104, !7, i64 108}
!14 = !{!"long long", !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"

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

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

11:                                               ; preds = %5
  %12 = icmp slt i32 %1, 0
  br i1 %12, label %20, label %13

13:                                               ; preds = %11
  %14 = icmp eq i32 %1, 0
  %15 = icmp ne ptr %0, null
  %or.cond = or i1 %15, %14
  %16 = xor i1 %15, true
  %brmerge = or i1 %14, %16
  %.mux = select i1 %or.cond, i32 0, i32 -8
  br i1 %brmerge, label %20, label %17

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %2, i64 264
  %19 = tail call i32 @ippsHashUpdate(ptr noundef nonnull %0, i32 noundef %1, ptr noundef nonnull %18) #3
  br label %20

20:                                               ; preds = %13, %11, %5, %3, %17
  %.0 = phi i32 [ %19, %17 ], [ -8, %3 ], [ -13, %5 ], [ -15, %11 ], [ %.mux, %13 ]
  ret i32 %.0
}

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

declare i32 @ippsHashUpdate(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 = { "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 = !{!"_cpHMAC", !7, i64 0, !8, i64 4, !8, i64 132, !10, i64 264}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_cpHashCtx", !7, i64 0, !7, i64 4, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 32, !8, i64 40, !7, i64 104, !8, i64 108}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}


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