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

; 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_Final(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 i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [64 x i8], align 16
  %13 = alloca i32, align 4
  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
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp eq ptr null, %14
  br i1 %15, label %16, label %17

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

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

26:                                               ; preds = %17
  store i32 -13, ptr %4, align 4
  br label %90

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

30:                                               ; preds = %27
  store i32 -8, ptr %4, align 4
  br label %90

31:                                               ; preds = %27
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp sle i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  store i32 -15, ptr %4, align 4
  br label %90

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._cpHMAC, ptr %36, i32 0, i32 3
  store ptr %37, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._cpHashCtx, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !15
  %41 = call i32 @cpHashMBS(i32 noundef %40)
  store i32 %41, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._cpHashCtx, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !15
  %45 = call i32 @cpHashSize(i32 noundef %44)
  store i32 %45, ptr %10, align 4, !tbaa !9
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = icmp sgt i32 %46, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %35
  store i32 -15, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %89

50:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 64, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %51 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = call i32 @ippsHashFinal(ptr noundef %51, ptr noundef %52)
  store i32 %53, ptr %13, align 4, !tbaa !9
  %54 = load i32, ptr %13, align 4, !tbaa !9
  %55 = icmp eq i32 0, %54
  br i1 %55, label %56, label %87

56:                                               ; preds = %50
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._cpHMAC, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds [128 x i8], ptr %58, i64 0, i64 0
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = call i32 @ippsHashUpdate(ptr noundef %59, i32 noundef %60, ptr noundef %61)
  %63 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = call i32 @ippsHashUpdate(ptr noundef %63, i32 noundef %64, ptr noundef %65)
  %67 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = call i32 @ippsHashFinal(ptr noundef %67, ptr noundef %68)
  %70 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = load i32, ptr %6, align 4, !tbaa !9
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %75, label %77

75:                                               ; preds = %56
  %76 = load i32, ptr %10, align 4, !tbaa !9
  br label %79

77:                                               ; preds = %56
  %78 = load i32, ptr %6, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %77, %75
  %80 = phi i32 [ %76, %75 ], [ %78, %77 ]
  call void @CopyBlock(ptr noundef %70, ptr noundef %71, i32 noundef %80)
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._cpHMAC, ptr %81, i32 0, i32 1
  %83 = getelementptr inbounds [128 x i8], ptr %82, i64 0, i64 0
  %84 = load i32, ptr %9, align 4, !tbaa !9
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = call i32 @ippsHashUpdate(ptr noundef %83, i32 noundef %84, ptr noundef %85)
  br label %87

87:                                               ; preds = %79, %50
  %88 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %88, ptr %4, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %12) #4
  br label %89

89:                                               ; preds = %87, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %90

90:                                               ; preds = %89, %34, %30, %26, %16
  %91 = load i32, ptr %4, align 4
  ret i32 %91
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_INT_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 i32 @cpHashMBS(i32 noundef) #1

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

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

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

; 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 = { "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 = !{!"_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}
!15 = !{!13, !10, i64 4}


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

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

12:                                               ; preds = %6
  %13 = icmp eq ptr %0, null
  br i1 %13, label %35, label %14

14:                                               ; preds = %12
  %15 = icmp slt i32 %1, 1
  br i1 %15, label %35, label %16

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %2, i64 264
  %18 = getelementptr inbounds i8, ptr %2, i64 268
  %19 = load i32, ptr %18, align 4, !tbaa !13
  %20 = tail call i32 @cpHashMBS(i32 noundef %19)
  %21 = load i32, ptr %18, align 4, !tbaa !13
  %22 = tail call i32 @cpHashSize(i32 noundef %21)
  %23 = icmp slt i32 %22, %1
  br i1 %23, label %35, label %24

24:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #4
  %25 = call i32 @ippsHashFinal(ptr noundef nonnull %4, ptr noundef nonnull %17) #4
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %34

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %2, i64 132
  %29 = call i32 @ippsHashUpdate(ptr noundef nonnull %28, i32 noundef %20, ptr noundef nonnull %17) #4
  %30 = call i32 @ippsHashUpdate(ptr noundef nonnull %4, i32 noundef %22, ptr noundef nonnull %17) #4
  %31 = call i32 @ippsHashFinal(ptr noundef nonnull %4, ptr noundef nonnull %17) #4
  call void @CopyBlock(ptr noundef nonnull %4, ptr noundef nonnull %0, i32 noundef %1)
  %32 = getelementptr inbounds i8, ptr %2, i64 4
  %33 = call i32 @ippsHashUpdate(ptr noundef nonnull %32, i32 noundef %20, ptr noundef nonnull %17) #4
  br label %34

34:                                               ; preds = %27, %24
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #4
  br label %35

35:                                               ; preds = %34, %16, %14, %12, %6, %3
  %.1 = phi i32 [ -8, %3 ], [ -13, %6 ], [ -8, %12 ], [ -15, %14 ], [ %25, %34 ], [ -15, %16 ]
  ret i32 %.1
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_INT_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 i32 @cpHashMBS(i32 noundef) local_unnamed_addr #1

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

declare i32 @ippsHashFinal(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @ippsHashUpdate(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; 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 = { "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, !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}
!13 = !{!10, !7, i64 4}


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