; LLVM IR from intel/cryptography-primitives :: sources/ippcp (pcprsasign_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_private_key = type { i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%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 @ippsRSASign_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
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = 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
  %21 = load ptr, ptr %12, align 8, !tbaa !5
  %22 = icmp eq ptr null, %21
  br i1 %22, label %23, label %24

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

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

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

28:                                               ; preds = %24
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._cpRSA_private_key, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = call i64 @IPP_UINT_PTR(ptr noundef %32)
  %34 = trunc i64 %33 to i32
  %35 = xor i32 %31, %34
  %36 = icmp eq i32 %35, 1381187889
  br i1 %36, label %47, label %37

37:                                               ; preds = %28
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._cpRSA_private_key, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = call i64 @IPP_UINT_PTR(ptr noundef %41)
  %43 = trunc i64 %42 to i32
  %44 = xor i32 %40, %43
  %45 = icmp eq i32 %44, 1381187890
  br i1 %45, label %47, label %46

46:                                               ; preds = %37
  store i32 -13, ptr %8, align 4
  br label %133

47:                                               ; preds = %37, %28
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._cpRSA_private_key, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %53, label %52

52:                                               ; preds = %47
  store i32 -1013, ptr %8, align 4
  br label %133

53:                                               ; preds = %47
  %54 = load i32, ptr %14, align 4, !tbaa !9
  %55 = call i32 @cpValidHashAlg(i32 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 %59

58:                                               ; preds = %53
  store i32 -14, ptr %8, align 4
  br label %133

59:                                               ; preds = %53
  %60 = load i32, ptr %14, align 4, !tbaa !9
  %61 = icmp eq i32 7, %60
  br i1 %61, label %62, label %63

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

63:                                               ; preds = %59
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %83

66:                                               ; preds = %63
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._cpRSA_public_key, ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 8, !tbaa !14
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = call i64 @IPP_UINT_PTR(ptr noundef %70)
  %72 = trunc i64 %71 to i32
  %73 = xor i32 %69, %72
  %74 = icmp eq i32 %73, 1381187888
  br i1 %74, label %76, label %75

75:                                               ; preds = %66
  store i32 -13, ptr %8, align 4
  br label %133

76:                                               ; preds = %66
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._cpRSA_public_key, ptr %77, i32 0, i32 3
  %79 = load i32, ptr %78, align 4, !tbaa !16
  %80 = icmp sgt i32 %79, 0
  br i1 %80, label %82, label %81

81:                                               ; preds = %76
  store i32 -1013, ptr %8, align 4
  br label %133

82:                                               ; preds = %76
  br label %83

83:                                               ; preds = %82, %63
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = icmp eq ptr null, %84
  br i1 %85, label %86, label %87

86:                                               ; preds = %83
  store i32 -8, ptr %8, align 4
  br label %133

87:                                               ; preds = %83
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = icmp eq ptr null, %88
  br i1 %89, label %90, label %91

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

91:                                               ; preds = %87
  %92 = load i32, ptr %10, align 4, !tbaa !9
  %93 = icmp slt i32 %92, 0
  br i1 %93, label %94, label %95

94:                                               ; preds = %91
  store i32 -15, ptr %8, align 4
  br label %133

95:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 64, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %96 = load i32, ptr %14, align 4, !tbaa !9
  %97 = call i32 @cpHashSize(i32 noundef %96)
  store i32 %97, ptr %17, align 4, !tbaa !9
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = load i32, ptr %10, align 4, !tbaa !9
  %100 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %101 = load i32, ptr %14, align 4, !tbaa !9
  %102 = call i32 @ippsHashMessage(ptr noundef %98, i32 noundef %99, ptr noundef %100, i32 noundef %101)
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %103 = load i32, ptr %14, align 4, !tbaa !9
  %104 = zext i32 %103 to i64
  %105 = getelementptr inbounds [10 x %struct.SaltInfo], ptr @pksc15_salt, i64 0, i64 %104
  %106 = getelementptr inbounds %struct.SaltInfo, ptr %105, i32 0, i32 0
  %107 = load ptr, ptr %106, align 16, !tbaa !17
  store ptr %107, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %108 = load i32, ptr %14, align 4, !tbaa !9
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds [10 x %struct.SaltInfo], ptr @pksc15_salt, i64 0, i64 %109
  %111 = getelementptr inbounds %struct.SaltInfo, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 8, !tbaa !19
  store i32 %112, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %113 = getelementptr inbounds [64 x i8], ptr %16, i64 0, i64 0
  %114 = load i32, ptr %17, align 4, !tbaa !9
  %115 = load ptr, ptr %18, align 8, !tbaa !5
  %116 = load i32, ptr %19, align 4, !tbaa !9
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  %118 = load ptr, ptr %12, align 8, !tbaa !5
  %119 = load ptr, ptr %13, align 8, !tbaa !5
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = load ptr, ptr %15, align 8, !tbaa !5
  %122 = call i64 @IPP_INT_PTR(ptr noundef %121)
  %123 = and i64 %122, 7
  %124 = xor i64 %123, -1
  %125 = add nsw i64 %124, 1
  %126 = and i64 %125, 7
  %127 = getelementptr inbounds i8, ptr %120, i64 %126
  %128 = call i32 @GenerateSign(ptr noundef %113, i32 noundef %114, ptr noundef %115, i32 noundef %116, ptr noundef %117, ptr noundef %118, ptr noundef %119, ptr noundef %127)
  store i32 %128, ptr %20, align 4, !tbaa !9
  %129 = load i32, ptr %20, align 4, !tbaa !9
  %130 = icmp eq i32 1, %129
  %131 = zext i1 %130 to i64
  %132 = select i1 %130, i32 0, i32 -6
  store i32 %132, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #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 %133

133:                                              ; preds = %95, %94, %90, %86, %81, %75, %62, %58, %52, %46, %27, %23
  %134 = load i32, ptr %8, align 4
  ret i32 %134
}

; 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 @GenerateSign(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_private_key", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!13 = !{!12, !10, i64 12}
!14 = !{!15, !10, i64 0}
!15 = !{!"_cpRSA_public_key", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32}
!16 = !{!15, !10, i64 12}
!17 = !{!18, !6, i64 0}
!18 = !{!"", !6, i64 0, !10, i64 8}
!19 = !{!18, !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 @ippsRSASign_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 %3, null
  %10 = icmp eq ptr %6, null
  %or.cond = or i1 %9, %10
  br i1 %or.cond, label %60, label %11

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

17:                                               ; preds = %11
  %18 = load i32, ptr %3, align 8, !tbaa !5
  %19 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %3)
  %20 = trunc i64 %19 to i32
  %21 = xor i32 %18, %20
  %22 = icmp eq i32 %21, 1381187890
  br i1 %22, label %23, label %60

23:                                               ; preds = %17, %11
  %24 = getelementptr inbounds i8, ptr %3, i64 12
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %27, label %60

27:                                               ; preds = %23
  %28 = tail call i32 @cpValidHashAlg(i32 noundef %5)
  switch i32 %28, label %29 [
    i32 0, label %60
    i32 7, label %60
  ]

29:                                               ; preds = %27
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %40, label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %4, align 8, !tbaa !12
  %32 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %4)
  %33 = trunc i64 %32 to i32
  %34 = xor i32 %31, %33
  %35 = icmp eq i32 %34, 1381187888
  br i1 %35, label %36, label %60

36:                                               ; preds = %30
  %37 = getelementptr inbounds i8, ptr %4, i64 12
  %38 = load i32, ptr %37, align 4, !tbaa !14
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %40, label %60

40:                                               ; preds = %36, %29
  %41 = icmp eq ptr %0, null
  %42 = icmp eq ptr %2, null
  %or.cond39 = or i1 %41, %42
  br i1 %or.cond39, label %60, label %43

43:                                               ; preds = %40
  %44 = icmp slt i32 %1, 0
  br i1 %44, label %60, label %45

45:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #4
  %46 = tail call i32 @cpHashSize(i32 noundef %28)
  %47 = call i32 @ippsHashMessage(ptr noundef nonnull %0, i32 noundef %1, ptr noundef nonnull %8, i32 noundef %28) #4
  %48 = zext i32 %28 to i64
  %49 = getelementptr inbounds [10 x %struct.SaltInfo], ptr @pksc15_salt, i64 0, i64 %48
  %50 = load ptr, ptr %49, align 16, !tbaa !15
  %51 = getelementptr inbounds i8, ptr %49, i64 8
  %52 = load i32, ptr %51, align 8, !tbaa !17
  %53 = call i64 @IPP_INT_PTR(ptr noundef nonnull %6)
  %54 = sub i64 0, %53
  %55 = and i64 %54, 7
  %56 = getelementptr inbounds i8, ptr %6, i64 %55
  %57 = call i32 @GenerateSign(ptr noundef nonnull %8, i32 noundef %46, ptr noundef %50, i32 noundef %52, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef %4, ptr noundef nonnull %56)
  %58 = icmp eq i32 %57, 1
  %59 = select i1 %58, i32 0, i32 -6
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #4
  br label %60

60:                                               ; preds = %43, %40, %36, %30, %27, %27, %23, %17, %7, %45
  %.0 = phi i32 [ %59, %45 ], [ -8, %7 ], [ -13, %17 ], [ -1013, %23 ], [ -14, %27 ], [ -14, %27 ], [ -13, %30 ], [ -1013, %36 ], [ -8, %40 ], [ -15, %43 ]
  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 @GenerateSign(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_private_key", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80}
!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 = !{!13, !7, i64 0}
!13 = !{!"_cpRSA_public_key", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !10, i64 32}
!14 = !{!13, !7, i64 12}
!15 = !{!16, !10, i64 0}
!16 = !{!"", !10, i64 0, !7, i64 8}
!17 = !{!16, !7, i64 8}


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