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

; 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_Message(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca %struct._cpHMAC, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store ptr %2, ptr %11, align 8, !tbaa !5
  store i32 %3, ptr %12, align 4, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  %18 = load i32, ptr %15, align 4, !tbaa !9
  %19 = call i32 @cpValidHashAlg(i32 noundef %18)
  store i32 %19, ptr %15, align 4, !tbaa !9
  %20 = load i32, ptr %15, align 4, !tbaa !9
  %21 = icmp eq i32 0, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %7
  store i32 -14, ptr %8, align 4
  br label %77

23:                                               ; preds = %7
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = icmp eq ptr null, %24
  br i1 %25, label %26, label %27

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

27:                                               ; preds = %23
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 0
  br i1 %29, label %30, label %31

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

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

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

35:                                               ; preds = %31
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %42

38:                                               ; preds = %35
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  store i32 -8, ptr %8, align 4
  br label %77

42:                                               ; preds = %38, %35
  %43 = load ptr, ptr %13, align 8, !tbaa !5
  %44 = icmp eq ptr null, %43
  br i1 %44, label %45, label %46

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

46:                                               ; preds = %42
  %47 = load i32, ptr %14, align 4, !tbaa !9
  %48 = icmp sge i32 0, %47
  br i1 %48, label %54, label %49

49:                                               ; preds = %46
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = load i32, ptr %15, align 4, !tbaa !9
  %52 = call i32 @cpHashSize(i32 noundef %51)
  %53 = icmp sgt i32 %50, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %49, %46
  store i32 -15, ptr %8, align 4
  br label %77

55:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 504, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = load i32, ptr %12, align 4, !tbaa !9
  %58 = load i32, ptr %15, align 4, !tbaa !9
  %59 = call i32 @ippsHMAC_Init(ptr noundef %56, i32 noundef %57, ptr noundef %16, i32 noundef %58)
  store i32 %59, ptr %17, align 4, !tbaa !9
  %60 = load i32, ptr %17, align 4, !tbaa !9
  %61 = icmp ne i32 0, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %55
  br label %75

63:                                               ; preds = %55
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = getelementptr inbounds %struct._cpHMAC, ptr %16, i32 0, i32 3
  %67 = call i32 @ippsHashUpdate(ptr noundef %64, i32 noundef %65, ptr noundef %66)
  store i32 %67, ptr %17, align 4, !tbaa !9
  %68 = load i32, ptr %17, align 4, !tbaa !9
  %69 = icmp ne i32 0, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %63
  br label %75

71:                                               ; preds = %63
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = load i32, ptr %14, align 4, !tbaa !9
  %74 = call i32 @ippsHMAC_Final(ptr noundef %72, i32 noundef %73, ptr noundef %16)
  store i32 %74, ptr %17, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %71, %70, %62
  call void @PurgeBlock(ptr noundef %16, i32 noundef 504)
  %76 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %76, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 504, ptr %16) #4
  br label %77

77:                                               ; preds = %75, %54, %45, %41, %34, %30, %26, %22
  %78 = load i32, ptr %8, align 4
  ret i32 %78
}

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

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

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PurgeBlock(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}


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

%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_Message(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = alloca %struct._cpHMAC, align 8
  %9 = tail call i32 @cpValidHashAlg(i32 noundef %6)
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %32, label %11

11:                                               ; preds = %7
  %12 = icmp eq ptr %2, null
  br i1 %12, label %32, label %13

13:                                               ; preds = %11
  %14 = or i32 %3, %1
  %or.cond32.not = icmp sgt i32 %14, -1
  br i1 %or.cond32.not, label %15, label %32

15:                                               ; preds = %13
  %16 = icmp ne i32 %1, 0
  %17 = icmp eq ptr %0, null
  %or.cond.not36 = and i1 %17, %16
  %18 = icmp eq ptr %4, null
  %or.cond33 = or i1 %or.cond.not36, %18
  br i1 %or.cond33, label %32, label %19

19:                                               ; preds = %15
  %20 = icmp slt i32 %5, 1
  br i1 %20, label %32, label %21

21:                                               ; preds = %19
  %22 = tail call i32 @cpHashSize(i32 noundef %9)
  %23 = icmp slt i32 %22, %5
  br i1 %23, label %32, label %24

24:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 504, ptr nonnull %8) #4
  %25 = call i32 @ippsHMAC_Init(ptr noundef nonnull %2, i32 noundef %3, ptr noundef nonnull %8, i32 noundef %9) #4
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %26, label %31

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %8, i64 264
  %28 = call i32 @ippsHashUpdate(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %27) #4
  %.not31 = icmp eq i32 %28, 0
  br i1 %.not31, label %29, label %31

29:                                               ; preds = %26
  %30 = call i32 @ippsHMAC_Final(ptr noundef nonnull %4, i32 noundef %5, ptr noundef nonnull %8) #4
  br label %31

31:                                               ; preds = %26, %24, %29
  %.0 = phi i32 [ %25, %24 ], [ %28, %26 ], [ %30, %29 ]
  call void @PurgeBlock(ptr noundef nonnull %8, i32 noundef 504)
  call void @llvm.lifetime.end.p0(i64 504, ptr nonnull %8) #4
  br label %32

32:                                               ; preds = %19, %21, %15, %13, %11, %7, %31
  %.022 = phi i32 [ %.0, %31 ], [ -14, %7 ], [ -8, %11 ], [ -15, %13 ], [ -8, %15 ], [ -15, %21 ], [ -15, %19 ]
  ret i32 %.022
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpHashSize(i32 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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PurgeBlock(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)"}


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