; LLVM IR from intel/cryptography-primitives :: sources/ippcp (pcpmgf1ca_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._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 @ippsMGF1_rmf(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %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 i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %struct._cpHashCtx_rmf, align 8
  %16 = alloca [4 x i8], align 1
  %17 = alloca [64 x i8], align 16
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = icmp eq ptr null, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %5
  store i32 -8, ptr %6, align 4
  br label %102

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

24:                                               ; preds = %21
  store i32 -8, ptr %6, align 4
  br label %102

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

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

31:                                               ; preds = %28, %25
  store i32 -15, ptr %6, align 4
  br label %102

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._cpHashMethod_rmf, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !11
  store i32 %35, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 232, ptr %15) #4
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = call i32 @ippsHashInit_rmf(ptr noundef %15, ptr noundef %36)
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %41, label %40

40:                                               ; preds = %32
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %40, %32
  store i32 0, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %98, %41
  %43 = load i32, ptr %14, align 4, !tbaa !9
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %46, label %101

46:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = ashr i32 %47, 24
  %49 = and i32 %48, 255
  %50 = trunc i32 %49 to i8
  %51 = getelementptr inbounds [4 x i8], ptr %16, i64 0, i64 0
  store i8 %50, ptr %51, align 1, !tbaa !13
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = ashr i32 %52, 16
  %54 = and i32 %53, 255
  %55 = trunc i32 %54 to i8
  %56 = getelementptr inbounds [4 x i8], ptr %16, i64 0, i64 1
  store i8 %55, ptr %56, align 1, !tbaa !13
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = ashr i32 %57, 8
  %59 = and i32 %58, 255
  %60 = trunc i32 %59 to i8
  %61 = getelementptr inbounds [4 x i8], ptr %16, i64 0, i64 2
  store i8 %60, ptr %61, align 1, !tbaa !13
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = and i32 %62, 255
  %64 = trunc i32 %63 to i8
  %65 = getelementptr inbounds [4 x i8], ptr %16, i64 0, i64 3
  store i8 %64, ptr %65, align 1, !tbaa !13
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = call i32 @ippsHashUpdate_rmf(ptr noundef %66, i32 noundef %67, ptr noundef %15)
  %69 = getelementptr inbounds [4 x i8], ptr %16, i64 0, i64 0
  %70 = call i32 @ippsHashUpdate_rmf(ptr noundef %69, i32 noundef 4, ptr noundef %15)
  %71 = load i32, ptr %14, align 4, !tbaa !9
  %72 = load i32, ptr %12, align 4, !tbaa !9
  %73 = add nsw i32 %71, %72
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = icmp sle i32 %73, %74
  br i1 %75, label %76, label %85

76:                                               ; preds = %46
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = load i32, ptr %14, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i8, ptr %77, i64 %79
  %81 = call i32 @ippsHashFinal_rmf(ptr noundef %80, ptr noundef %15)
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = load i32, ptr %14, align 4, !tbaa !9
  %84 = add nsw i32 %83, %82
  store i32 %84, ptr %14, align 4, !tbaa !9
  br label %97

85:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 64, ptr %17) #4
  %86 = getelementptr inbounds [64 x i8], ptr %17, i64 0, i64 0
  %87 = call i32 @ippsHashFinal_rmf(ptr noundef %86, ptr noundef %15)
  %88 = getelementptr inbounds [64 x i8], ptr %17, i64 0, i64 0
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = load i32, ptr %14, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  %93 = load i32, ptr %10, align 4, !tbaa !9
  %94 = load i32, ptr %14, align 4, !tbaa !9
  %95 = sub nsw i32 %93, %94
  call void @CopyBlock(ptr noundef %88, ptr noundef %92, i32 noundef %95)
  %96 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %96, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 64, ptr %17) #4
  br label %97

97:                                               ; preds = %85, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %98

98:                                               ; preds = %97
  %99 = load i32, ptr %13, align 4, !tbaa !9
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %13, align 4, !tbaa !9
  br label %42, !llvm.loop !14

101:                                              ; preds = %42
  store i32 0, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 232, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %102

102:                                              ; preds = %101, %31, %24, %20
  %103 = load i32, ptr %6, align 4
  ret i32 %103
}

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

declare i32 @ippsHashInit_rmf(ptr noundef, ptr noundef) #2

declare i32 @ippsHashUpdate_rmf(ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @CopyBlock(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 4}
!12 = !{!"_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}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -15, 1) i32 @ippsMGF1_rmf(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct._cpHashCtx_rmf, align 8
  %7 = alloca [4 x i8], align 1
  %8 = alloca [64 x i8], align 16
  %9 = icmp eq ptr %2, null
  %10 = icmp eq ptr %4, null
  %or.cond = or i1 %9, %10
  br i1 %or.cond, label %42, label %11

11:                                               ; preds = %5
  %12 = or i32 %3, %1
  %or.cond.not = icmp sgt i32 %12, -1
  br i1 %or.cond.not, label %13, label %42

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %4, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 232, ptr nonnull %6) #4
  %16 = call i32 @ippsHashInit_rmf(ptr noundef nonnull %6, ptr noundef nonnull %4) #4
  %.not = icmp eq ptr %0, null
  %spec.select = select i1 %.not, i32 0, i32 %1
  %17 = icmp sgt i32 %3, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %13
  %18 = getelementptr inbounds i8, ptr %7, i64 1
  %19 = getelementptr inbounds i8, ptr %7, i64 2
  %20 = getelementptr inbounds i8, ptr %7, i64 3
  br label %21

21:                                               ; preds = %.lr.ph, %36
  %.039 = phi i32 [ 0, %.lr.ph ], [ %31, %36 ]
  %.02938 = phi i32 [ 0, %.lr.ph ], [ %40, %36 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %22 = lshr i32 %.02938, 24
  %23 = trunc nuw nsw i32 %22 to i8
  store i8 %23, ptr %7, align 1, !tbaa !11
  %24 = lshr i32 %.02938, 16
  %25 = trunc i32 %24 to i8
  store i8 %25, ptr %18, align 1, !tbaa !11
  %26 = lshr i32 %.02938, 8
  %27 = trunc i32 %26 to i8
  store i8 %27, ptr %19, align 1, !tbaa !11
  %28 = trunc i32 %.02938 to i8
  store i8 %28, ptr %20, align 1, !tbaa !11
  %29 = call i32 @ippsHashUpdate_rmf(ptr noundef %0, i32 noundef %spec.select, ptr noundef nonnull %6) #4
  %30 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %7, i32 noundef 4, ptr noundef nonnull %6) #4
  %31 = add nsw i32 %.039, %15
  %.not37 = icmp sgt i32 %31, %3
  br i1 %.not37, label %.thread, label %36

.thread:                                          ; preds = %21
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #4
  %32 = call i32 @ippsHashFinal_rmf(ptr noundef nonnull %8, ptr noundef nonnull %6) #4
  %33 = sext i32 %.039 to i64
  %34 = getelementptr inbounds i8, ptr %2, i64 %33
  %35 = sub nsw i32 %3, %.039
  call void @CopyBlock(ptr noundef nonnull %8, ptr noundef nonnull %34, i32 noundef %35)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  br label %._crit_edge

36:                                               ; preds = %21
  %37 = sext i32 %.039 to i64
  %38 = getelementptr inbounds i8, ptr %2, i64 %37
  %39 = call i32 @ippsHashFinal_rmf(ptr noundef nonnull %38, ptr noundef nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  %40 = add nuw nsw i32 %.02938, 1
  %41 = icmp slt i32 %31, %3
  br i1 %41, label %21, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %36, %.thread, %13
  call void @llvm.lifetime.end.p0(i64 232, ptr nonnull %6) #4
  br label %42

42:                                               ; preds = %11, %5, %._crit_edge
  %.030 = phi i32 [ 0, %._crit_edge ], [ -8, %5 ], [ -15, %11 ]
  ret i32 %.030
}

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

declare i32 @ippsHashInit_rmf(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @ippsHashUpdate_rmf(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @CopyBlock(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 4}
!6 = !{!"_cpHashMethod_rmf", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!8, !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass