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

; 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_public_key = type { i32, i32, i32, i32, i32, ptr, ptr }
%struct._cpBigNum = type { i32, i32, i32, i32, ptr, ptr }
%struct._gsModEngine = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr, i32, i32, ptr }

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

13:                                               ; preds = %4
  store i32 -8, ptr %5, align 4
  br label %113

14:                                               ; preds = %4
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = icmp eq ptr null, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  store i32 -8, ptr %5, align 4
  br label %113

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

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

28:                                               ; preds = %18
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._cpRSA_public_key, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %30, align 4, !tbaa !12
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  store i32 -1013, ptr %5, align 4
  br label %113

34:                                               ; preds = %28
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = icmp eq ptr null, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  store i32 -8, ptr %5, align 4
  br label %113

38:                                               ; preds = %34
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._cpBigNum, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = call i64 @IPP_UINT_PTR(ptr noundef %42)
  %44 = trunc i64 %43 to i32
  %45 = xor i32 %41, %44
  %46 = icmp eq i32 %45, 1112098638
  br i1 %46, label %48, label %47

47:                                               ; preds = %38
  store i32 -13, ptr %5, align 4
  br label %113

48:                                               ; preds = %38
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._cpBigNum, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !15
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  store i32 -11, ptr %5, align 4
  br label %113

54:                                               ; preds = %48
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._cpBigNum, ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._cpBigNum, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %59, align 8, !tbaa !17
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._cpRSA_public_key, ptr %61, i32 0, i32 6
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = getelementptr inbounds %struct._gsModEngine, ptr %63, i32 0, i32 8
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._cpRSA_public_key, ptr %66, i32 0, i32 6
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = getelementptr inbounds %struct._gsModEngine, ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 8, !tbaa !22
  %71 = call i32 @cpCmp_BNU(ptr noundef %57, i32 noundef %60, ptr noundef %65, i32 noundef %70)
  %72 = icmp sle i32 0, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %54
  store i32 -11, ptr %5, align 4
  br label %113

74:                                               ; preds = %54
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = icmp eq ptr null, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %74
  store i32 -8, ptr %5, align 4
  br label %113

78:                                               ; preds = %74
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._cpBigNum, ptr %79, i32 0, i32 0
  %81 = load i32, ptr %80, align 8, !tbaa !13
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = call i64 @IPP_UINT_PTR(ptr noundef %82)
  %84 = trunc i64 %83 to i32
  %85 = xor i32 %81, %84
  %86 = icmp eq i32 %85, 1112098638
  br i1 %86, label %88, label %87

87:                                               ; preds = %78
  store i32 -13, ptr %5, align 4
  br label %113

88:                                               ; preds = %78
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._cpBigNum, ptr %89, i32 0, i32 3
  %91 = load i32, ptr %90, align 4, !tbaa !23
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._cpRSA_public_key, ptr %92, i32 0, i32 3
  %94 = load i32, ptr %93, align 4, !tbaa !12
  %95 = add nsw i32 %94, 64
  %96 = sub nsw i32 %95, 1
  %97 = sdiv i32 %96, 64
  %98 = icmp slt i32 %91, %97
  br i1 %98, label %99, label %100

99:                                               ; preds = %88
  store i32 -6, ptr %5, align 4
  br label %113

100:                                              ; preds = %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  %102 = load ptr, ptr %9, align 8, !tbaa !5
  %103 = call i64 @IPP_INT_PTR(ptr noundef %102)
  %104 = and i64 %103, 7
  %105 = xor i64 %104, -1
  %106 = add nsw i64 %105, 1
  %107 = and i64 %106, 7
  %108 = getelementptr inbounds i8, ptr %101, i64 %107
  store ptr %108, ptr %10, align 8, !tbaa !5
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = load ptr, ptr %8, align 8, !tbaa !5
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  call void @gsRSApub_cipher(ptr noundef %109, ptr noundef %110, ptr noundef %111, ptr noundef %112)
  store i32 0, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %113

113:                                              ; preds = %100, %99, %87, %77, %73, %53, %47, %37, %33, %27, %17, %13
  %114 = load i32, ptr %5, align 4
  ret i32 %114
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpCmp_BNU(ptr noundef, i32 noundef, ptr noundef, 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 i64 @IPP_INT_PTR(ptr noundef) #1

declare void @gsRSApub_cipher(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; 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, !11, i64 0}
!10 = !{!"_cpRSA_public_key", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 12}
!13 = !{!14, !11, i64 0}
!14 = !{!"_cpBigNum", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24}
!15 = !{!14, !11, i64 4}
!16 = !{!14, !6, i64 16}
!17 = !{!14, !11, i64 8}
!18 = !{!10, !6, i64 32}
!19 = !{!20, !6, i64 48}
!20 = !{!"_gsModEngine", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !21, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !6, i64 104}
!21 = !{!"long long", !7, i64 0}
!22 = !{!20, !11, i64 16}
!23 = !{!14, !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 @ippsRSA_Encrypt(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %2, null
  %6 = icmp eq ptr %3, null
  %or.cond = or i1 %5, %6
  br i1 %or.cond, label %62, label %7

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

13:                                               ; preds = %7
  %14 = getelementptr inbounds i8, ptr %2, i64 12
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %62

17:                                               ; preds = %13
  %18 = icmp eq ptr %0, null
  br i1 %18, label %62, label %19

19:                                               ; preds = %17
  %20 = load i32, ptr %0, align 8, !tbaa !12
  %21 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %0)
  %22 = trunc i64 %21 to i32
  %23 = xor i32 %20, %22
  %24 = icmp eq i32 %23, 1112098638
  br i1 %24, label %25, label %62

25:                                               ; preds = %19
  %26 = getelementptr inbounds i8, ptr %0, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %62, label %29

29:                                               ; preds = %25
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load i32, ptr %32, align 8, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %2, i64 32
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %35, i64 48
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = getelementptr inbounds i8, ptr %35, i64 16
  %39 = load i32, ptr %38, align 8, !tbaa !21
  %40 = tail call i32 @cpCmp_BNU(ptr noundef %31, i32 noundef %33, ptr noundef %37, i32 noundef %39)
  %41 = icmp sgt i32 %40, -1
  br i1 %41, label %62, label %42

42:                                               ; preds = %29
  %43 = icmp eq ptr %1, null
  br i1 %43, label %62, label %44

44:                                               ; preds = %42
  %45 = load i32, ptr %1, align 8, !tbaa !12
  %46 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %1)
  %47 = trunc i64 %46 to i32
  %48 = xor i32 %45, %47
  %49 = icmp eq i32 %48, 1112098638
  br i1 %49, label %50, label %62

50:                                               ; preds = %44
  %51 = getelementptr inbounds i8, ptr %1, i64 12
  %52 = load i32, ptr %51, align 4, !tbaa !22
  %53 = load i32, ptr %14, align 4, !tbaa !11
  %54 = add nsw i32 %53, 63
  %55 = sdiv i32 %54, 64
  %56 = icmp slt i32 %52, %55
  br i1 %56, label %62, label %57

57:                                               ; preds = %50
  %58 = tail call i64 @IPP_INT_PTR(ptr noundef nonnull %3)
  %59 = sub i64 0, %58
  %60 = and i64 %59, 7
  %61 = getelementptr inbounds i8, ptr %3, i64 %60
  tail call void @gsRSApub_cipher(ptr noundef nonnull %1, ptr noundef nonnull %0, ptr noundef nonnull %2, ptr noundef nonnull %61) #3
  br label %62

62:                                               ; preds = %50, %44, %42, %29, %25, %19, %17, %13, %7, %4, %57
  %.0 = phi i32 [ 0, %57 ], [ -8, %4 ], [ -13, %7 ], [ -1013, %13 ], [ -8, %17 ], [ -13, %19 ], [ -11, %25 ], [ -11, %29 ], [ -8, %42 ], [ -13, %44 ], [ -6, %50 ]
  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 @cpCmp_BNU(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

declare void @gsRSApub_cipher(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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 = { 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 = !{!13, !7, i64 0}
!13 = !{!"_cpBigNum", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!14 = !{!13, !7, i64 4}
!15 = !{!13, !10, i64 16}
!16 = !{!13, !7, i64 8}
!17 = !{!6, !10, i64 32}
!18 = !{!19, !10, i64 48}
!19 = !{!"_gsModEngine", !10, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !20, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !7, i64 96, !7, i64 100, !10, i64 104}
!20 = !{!"long long", !8, i64 0}
!21 = !{!19, !7, i64 16}
!22 = !{!13, !7, i64 12}


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