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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsRSADecrypt_PKCSv15(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr %10, align 8, !tbaa !5
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %5
  %17 = load ptr, ptr %11, align 8, !tbaa !5
  %18 = icmp eq ptr null, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  store i32 -8, ptr %6, align 4
  br label %81

20:                                               ; preds = %16
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._cpRSA_private_key, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = call i64 @IPP_UINT_PTR(ptr noundef %24)
  %26 = trunc i64 %25 to i32
  %27 = xor i32 %23, %26
  %28 = icmp eq i32 %27, 1381187889
  br i1 %28, label %39, label %29

29:                                               ; preds = %20
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._cpRSA_private_key, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = call i64 @IPP_UINT_PTR(ptr noundef %33)
  %35 = trunc i64 %34 to i32
  %36 = xor i32 %32, %35
  %37 = icmp eq i32 %36, 1381187890
  br i1 %37, label %39, label %38

38:                                               ; preds = %29
  store i32 -13, ptr %6, align 4
  br label %81

39:                                               ; preds = %29, %20
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._cpRSA_private_key, ptr %40, i32 0, i32 3
  %42 = load i32, ptr %41, align 4, !tbaa !12
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %45, label %44

44:                                               ; preds = %39
  store i32 -1013, ptr %6, align 4
  br label %81

45:                                               ; preds = %39
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = icmp eq ptr null, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  store i32 -8, ptr %6, align 4
  br label %81

49:                                               ; preds = %45
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = icmp eq ptr null, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %49
  store i32 -8, ptr %6, align 4
  br label %81

53:                                               ; preds = %49
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = icmp eq ptr null, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  store i32 -8, ptr %6, align 4
  br label %81

57:                                               ; preds = %53
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._cpRSA_private_key, ptr %58, i32 0, i32 3
  %60 = load i32, ptr %59, align 4, !tbaa !12
  %61 = icmp slt i32 %60, 88
  br i1 %61, label %62, label %63

62:                                               ; preds = %57
  store i32 -6, ptr %6, align 4
  br label %81

63:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = call i64 @IPP_INT_PTR(ptr noundef %65)
  %67 = and i64 %66, 7
  %68 = xor i64 %67, -1
  %69 = add nsw i64 %68, 1
  %70 = and i64 %69, 7
  %71 = getelementptr inbounds i8, ptr %64, i64 %70
  store ptr %71, ptr %12, align 8, !tbaa !5
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = call i32 @Decryption(ptr noundef %72, ptr noundef %73, ptr noundef %74, ptr noundef %75, ptr noundef %76)
  %78 = icmp ne i32 %77, 0
  %79 = zext i1 %78 to i64
  %80 = select i1 %78, i32 0, i32 -1004
  store i32 %80, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %81

81:                                               ; preds = %63, %62, %56, %52, %48, %44, %38, %19, %15
  %82 = load i32, ptr %6, align 4
  ret i32 %82
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_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

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

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

; 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 = { 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, !11, i64 0}
!10 = !{!"_cpRSA_private_key", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 12}


; 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 range(i32 -1013, 1) i32 @ippsRSADecrypt_PKCSv15(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq ptr %3, null
  %7 = icmp eq ptr %4, null
  %or.cond = or i1 %6, %7
  br i1 %or.cond, label %37, label %8

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

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

20:                                               ; preds = %14, %8
  %21 = getelementptr inbounds i8, ptr %3, i64 12
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %37

24:                                               ; preds = %20
  %25 = icmp eq ptr %0, null
  %26 = icmp eq ptr %1, null
  %or.cond24 = or i1 %25, %26
  %27 = icmp eq ptr %2, null
  %or.cond25 = or i1 %or.cond24, %27
  br i1 %or.cond25, label %37, label %28

28:                                               ; preds = %24
  %29 = icmp ult i32 %22, 88
  br i1 %29, label %37, label %30

30:                                               ; preds = %28
  %31 = tail call i64 @IPP_INT_PTR(ptr noundef nonnull %4)
  %32 = sub i64 0, %31
  %33 = and i64 %32, 7
  %34 = getelementptr inbounds i8, ptr %4, i64 %33
  %35 = tail call i32 @Decryption(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %34)
  %.not = icmp eq i32 %35, 0
  %36 = select i1 %.not, i32 -1004, i32 0
  br label %37

37:                                               ; preds = %28, %24, %20, %14, %5, %30
  %.0 = phi i32 [ %36, %30 ], [ -8, %5 ], [ -13, %14 ], [ -1013, %20 ], [ -8, %24 ], [ -6, %28 ]
  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 i64 @IPP_INT_PTR(ptr noundef) local_unnamed_addr #1

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

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

!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}


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