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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsHMACFinal_rmf(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 ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [64 x i8], align 16
  %14 = 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
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp eq ptr null, %15
  br i1 %16, label %17, label %18

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

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

27:                                               ; preds = %18
  store i32 -13, ptr %4, align 4
  br label %92

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

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

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

35:                                               ; preds = %32
  store i32 -15, ptr %4, align 4
  br label %92

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._cpHMAC_rmf, ptr %37, i32 0, i32 3
  store ptr %38, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._cpHashCtx_rmf, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  store ptr %41, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._cpHashMethod_rmf, ptr %42, i32 0, i32 2
  %44 = load i32, ptr %43, align 8, !tbaa !16
  store i32 %44, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._cpHashMethod_rmf, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !18
  store i32 %47, ptr %11, align 4, !tbaa !9
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = icmp sgt i32 %48, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %36
  store i32 -15, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %91

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

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

77:                                               ; preds = %58
  %78 = load i32, ptr %11, align 4, !tbaa !9
  br label %81

79:                                               ; preds = %58
  %80 = load i32, ptr %6, align 4, !tbaa !9
  br label %81

81:                                               ; preds = %79, %77
  %82 = phi i32 [ %78, %77 ], [ %80, %79 ]
  call void @CopyBlock(ptr noundef %72, ptr noundef %73, i32 noundef %82)
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._cpHMAC_rmf, ptr %83, i32 0, i32 1
  %85 = getelementptr inbounds [128 x i8], ptr %84, i64 0, i64 0
  %86 = load i32, ptr %10, align 4, !tbaa !9
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = call i32 @ippsHashUpdate_rmf(ptr noundef %85, i32 noundef %86, ptr noundef %87)
  br label %89

89:                                               ; preds = %81, %52
  %90 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %90, ptr %4, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %13) #4
  br label %91

91:                                               ; preds = %89, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %92

92:                                               ; preds = %91, %35, %31, %27, %17
  %93 = load i32, ptr %4, align 4
  ret i32 %93
}

; 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

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

declare i32 @ippsHashUpdate_rmf(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_rmf", !10, i64 0, !7, i64 4, !7, i64 132, !13, i64 264}
!13 = !{!"_cpHashCtx_rmf", !10, i64 0, !6, i64 8, !10, i64 16, !7, i64 20, !14, i64 152, !14, i64 160, !7, i64 168}
!14 = !{!"long long", !7, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!17, !10, i64 8}
!17 = !{!"_cpHashMethod_rmf", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!18 = !{!17, !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 @ippsHMACFinal_rmf(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 %36, 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 %36

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

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

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %2, i64 264
  %18 = getelementptr inbounds i8, ptr %2, i64 272
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %19, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !16
  %24 = icmp slt i32 %23, %1
  br i1 %24, label %36, label %25

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

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %2, i64 132
  %30 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %29, i32 noundef %21, ptr noundef nonnull %17) #4
  %31 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %4, i32 noundef %23, ptr noundef nonnull %17) #4
  %32 = call i32 @ippsHashFinal_rmf(ptr noundef nonnull %4, ptr noundef nonnull %17) #4
  call void @CopyBlock(ptr noundef nonnull %4, ptr noundef nonnull %0, i32 noundef %1)
  %33 = getelementptr inbounds i8, ptr %2, i64 4
  %34 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %33, i32 noundef %21, ptr noundef nonnull %17) #4
  br label %35

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

36:                                               ; preds = %35, %16, %14, %12, %6, %3
  %.1 = phi i32 [ -8, %3 ], [ -13, %6 ], [ -8, %12 ], [ -15, %14 ], [ %26, %35 ], [ -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

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

declare i32 @ippsHashUpdate_rmf(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_rmf", !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_rmf", !7, i64 0, !11, i64 8, !7, i64 16, !8, i64 20, !12, i64 152, !12, i64 160, !8, i64 168}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!15, !7, i64 8}
!15 = !{!"_cpHashMethod_rmf", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!16 = !{!15, !7, i64 4}


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