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

; 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.SaltInfo = type { ptr, i32 }
%struct._cpRSA_public_key = type { i32, i32, i32, i32, i32, ptr, ptr }

@pksc15_salt = external hidden global [10 x %struct.SaltInfo], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsRSAVerify_PKCS1v15(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, ptr 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 ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca [64 x i8], align 16
  %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 ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i32 %5, ptr %14, align 4, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !5
  %18 = load ptr, ptr %13, align 8, !tbaa !5
  %19 = icmp eq ptr null, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %7
  store i32 -8, ptr %8, align 4
  br label %103

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

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

25:                                               ; preds = %21
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._cpRSA_public_key, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = call i64 @IPP_UINT_PTR(ptr noundef %29)
  %31 = trunc i64 %30 to i32
  %32 = xor i32 %28, %31
  %33 = icmp eq i32 %32, 1381187888
  br i1 %33, label %35, label %34

34:                                               ; preds = %25
  store i32 -13, ptr %8, align 4
  br label %103

35:                                               ; preds = %25
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._cpRSA_public_key, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %37, align 4, !tbaa !13
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  store i32 -1013, ptr %8, align 4
  br label %103

41:                                               ; preds = %35
  %42 = load i32, ptr %14, align 4, !tbaa !9
  %43 = call i32 @cpValidHashAlg(i32 noundef %42)
  store i32 %43, ptr %14, align 4, !tbaa !9
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = icmp eq i32 0, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %41
  store i32 -14, ptr %8, align 4
  br label %103

47:                                               ; preds = %41
  %48 = load i32, ptr %14, align 4, !tbaa !9
  %49 = icmp eq i32 7, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  store i32 -14, ptr %8, align 4
  br label %103

51:                                               ; preds = %47
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = icmp eq ptr null, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %51
  store i32 -8, ptr %8, align 4
  br label %103

55:                                               ; preds = %51
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = icmp eq ptr null, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %55
  store i32 -8, ptr %8, align 4
  br label %103

59:                                               ; preds = %55
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = icmp eq ptr null, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i32 -8, ptr %8, align 4
  br label %103

63:                                               ; preds = %59
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = icmp slt i32 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %63
  store i32 -15, ptr %8, align 4
  br label %103

67:                                               ; preds = %63
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 0, ptr %68, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 64, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = call i32 @cpHashSize(i32 noundef %69)
  store i32 %70, ptr %17, align 4, !tbaa !9
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %74 = load i32, ptr %14, align 4, !tbaa !9
  %75 = call i32 @ippsHashMessage(ptr noundef %71, i32 noundef %72, ptr noundef %73, i32 noundef %74)
  %76 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %77 = load i32, ptr %17, align 4, !tbaa !9
  %78 = load i32, ptr %14, align 4, !tbaa !9
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds [10 x %struct.SaltInfo], ptr @pksc15_salt, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.SaltInfo, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 16, !tbaa !14
  %83 = load i32, ptr %14, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds [10 x %struct.SaltInfo], ptr @pksc15_salt, i64 0, i64 %84
  %86 = getelementptr inbounds %struct.SaltInfo, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %86, align 8, !tbaa !16
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load ptr, ptr %13, align 8, !tbaa !5
  %91 = load ptr, ptr %15, align 8, !tbaa !5
  %92 = load ptr, ptr %15, align 8, !tbaa !5
  %93 = call i64 @IPP_INT_PTR(ptr noundef %92)
  %94 = and i64 %93, 7
  %95 = xor i64 %94, -1
  %96 = add nsw i64 %95, 1
  %97 = and i64 %96, 7
  %98 = getelementptr inbounds i8, ptr %91, i64 %97
  %99 = call i32 @VerifySign(ptr noundef %76, i32 noundef %77, ptr noundef %82, i32 noundef %87, ptr noundef %88, ptr noundef %89, ptr noundef %90, ptr noundef %98)
  %100 = icmp ne i32 %99, 0
  %101 = zext i1 %100 to i64
  %102 = select i1 %100, i32 0, i32 -6
  store i32 %102, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %16) #4
  br label %103

103:                                              ; preds = %67, %66, %62, %58, %54, %50, %46, %40, %34, %24, %20
  %104 = load i32, ptr %8, align 4
  ret i32 %104
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @VerifySign(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

; 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.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 = !{!"_cpRSA_public_key", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!12, !10, i64 12}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !10, i64 8}
!16 = !{!15, !10, i64 8}


; 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.SaltInfo = type { ptr, i32 }

@pksc15_salt = external hidden local_unnamed_addr global [10 x %struct.SaltInfo], align 16

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

11:                                               ; preds = %7
  %12 = load i32, ptr %4, align 8, !tbaa !5
  %13 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %4)
  %14 = trunc i64 %13 to i32
  %15 = xor i32 %12, %14
  %16 = icmp eq i32 %15, 1381187888
  br i1 %16, label %17, label %43

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %4, i64 12
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %43

21:                                               ; preds = %17
  %22 = tail call i32 @cpValidHashAlg(i32 noundef %5)
  switch i32 %22, label %23 [
    i32 0, label %43
    i32 7, label %43
  ]

23:                                               ; preds = %21
  %24 = icmp eq ptr %0, null
  %25 = icmp eq ptr %2, null
  %or.cond32 = or i1 %24, %25
  %26 = icmp eq ptr %3, null
  %or.cond33 = or i1 %or.cond32, %26
  br i1 %or.cond33, label %43, label %27

27:                                               ; preds = %23
  %28 = icmp slt i32 %1, 0
  br i1 %28, label %43, label %29

29:                                               ; preds = %27
  store i32 0, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #4
  %30 = tail call i32 @cpHashSize(i32 noundef %22)
  %31 = call i32 @ippsHashMessage(ptr noundef nonnull %0, i32 noundef %1, ptr noundef nonnull %8, i32 noundef %22) #4
  %32 = zext i32 %22 to i64
  %33 = getelementptr inbounds [10 x %struct.SaltInfo], ptr @pksc15_salt, i64 0, i64 %32
  %34 = load ptr, ptr %33, align 16, !tbaa !13
  %35 = getelementptr inbounds i8, ptr %33, i64 8
  %36 = load i32, ptr %35, align 8, !tbaa !15
  %37 = call i64 @IPP_INT_PTR(ptr noundef nonnull %6)
  %38 = sub i64 0, %37
  %39 = and i64 %38, 7
  %40 = getelementptr inbounds i8, ptr %6, i64 %39
  %41 = call i32 @VerifySign(ptr noundef nonnull %8, i32 noundef %30, ptr noundef %34, i32 noundef %36, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %40)
  %.not = icmp eq i32 %41, 0
  %42 = select i1 %.not, i32 -6, i32 0
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #4
  br label %43

43:                                               ; preds = %27, %23, %21, %21, %17, %11, %7, %29
  %.0 = phi i32 [ %42, %29 ], [ -8, %7 ], [ -13, %11 ], [ -1013, %17 ], [ -14, %21 ], [ -14, %21 ], [ -8, %23 ], [ -15, %27 ]
  ret i32 %.0
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @VerifySign(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; 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.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 = !{!"_cpRSA_public_key", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !7, i64 8}
!15 = !{!14, !7, i64 8}


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