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

; 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 @ippsRSA_InitPrivateKeyType1(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !9
  %16 = icmp eq ptr null, %15
  br i1 %16, label %17, label %18

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

18:                                               ; preds = %4
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = icmp sgt i32 8, %19
  br i1 %20, label %24, label %21

21:                                               ; preds = %18
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = icmp sgt i32 %22, 16384
  br i1 %23, label %24, label %25

24:                                               ; preds = %21, %18
  store i32 -14, ptr %5, align 4
  br label %125

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

28:                                               ; preds = %25
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = icmp sle i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28, %25
  store i32 -5, ptr %5, align 4
  br label %125

33:                                               ; preds = %28
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = call i32 @cpSizeof_RSA_privateKey1(i32 noundef %35, i32 noundef %36)
  %38 = icmp slt i32 %34, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %33
  store i32 -9, ptr %5, align 4
  br label %125

40:                                               ; preds = %33
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = call i64 @IPP_UINT_PTR(ptr noundef %41)
  %43 = trunc i64 %42 to i32
  %44 = xor i32 1381187889, %43
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct._cpRSA_private_key, ptr %45, i32 0, i32 0
  store i32 %44, ptr %46, align 8, !tbaa !11
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct._cpRSA_private_key, ptr %48, i32 0, i32 1
  store i32 %47, ptr %49, align 4, !tbaa !13
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = load ptr, ptr %8, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct._cpRSA_private_key, ptr %51, i32 0, i32 2
  store i32 %50, ptr %52, align 8, !tbaa !14
  %53 = load ptr, ptr %8, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct._cpRSA_private_key, ptr %53, i32 0, i32 3
  store i32 0, ptr %54, align 4, !tbaa !15
  %55 = load ptr, ptr %8, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct._cpRSA_private_key, ptr %55, i32 0, i32 4
  store i32 0, ptr %56, align 8, !tbaa !16
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct._cpRSA_private_key, ptr %57, i32 0, i32 5
  store i32 0, ptr %58, align 4, !tbaa !17
  %59 = load ptr, ptr %8, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct._cpRSA_private_key, ptr %59, i32 0, i32 6
  store i32 0, ptr %60, align 8, !tbaa !18
  %61 = load ptr, ptr %8, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct._cpRSA_private_key, ptr %61, i32 0, i32 8
  store ptr null, ptr %62, align 8, !tbaa !19
  %63 = load ptr, ptr %8, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct._cpRSA_private_key, ptr %63, i32 0, i32 9
  store ptr null, ptr %64, align 8, !tbaa !20
  %65 = load ptr, ptr %8, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct._cpRSA_private_key, ptr %65, i32 0, i32 10
  store ptr null, ptr %66, align 8, !tbaa !21
  %67 = load ptr, ptr %8, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct._cpRSA_private_key, ptr %67, i32 0, i32 11
  store ptr null, ptr %68, align 8, !tbaa !22
  %69 = load ptr, ptr %8, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct._cpRSA_private_key, ptr %69, i32 0, i32 12
  store ptr null, ptr %70, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %71 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %71, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = add nsw i32 %72, 64
  %74 = sub nsw i32 %73, 1
  %75 = sdiv i32 %74, 64
  store i32 %75, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = add nsw i32 %76, 31
  %78 = ashr i32 %77, 5
  store i32 %78, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %79 = load i32, ptr %12, align 4, !tbaa !5
  call void @rsaMontExpGetSize(i32 noundef %79, ptr noundef %13)
  %80 = load ptr, ptr %10, align 8, !tbaa !9
  %81 = getelementptr inbounds i8, ptr %80, i64 88
  store ptr %81, ptr %10, align 8, !tbaa !9
  %82 = load ptr, ptr %10, align 8, !tbaa !9
  %83 = load ptr, ptr %10, align 8, !tbaa !9
  %84 = call i64 @IPP_INT_PTR(ptr noundef %83)
  %85 = and i64 %84, 7
  %86 = xor i64 %85, -1
  %87 = add nsw i64 %86, 1
  %88 = and i64 %87, 7
  %89 = getelementptr inbounds i8, ptr %82, i64 %88
  %90 = load ptr, ptr %8, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct._cpRSA_private_key, ptr %90, i32 0, i32 7
  store ptr %89, ptr %91, align 8, !tbaa !24
  %92 = load i32, ptr %11, align 4, !tbaa !5
  %93 = mul nsw i32 %92, 8
  %94 = load ptr, ptr %10, align 8, !tbaa !9
  %95 = sext i32 %93 to i64
  %96 = getelementptr inbounds i8, ptr %94, i64 %95
  store ptr %96, ptr %10, align 8, !tbaa !9
  %97 = load ptr, ptr %10, align 8, !tbaa !9
  %98 = load ptr, ptr %8, align 8, !tbaa !9
  %99 = getelementptr inbounds %struct._cpRSA_private_key, ptr %98, i32 0, i32 13
  store ptr %97, ptr %99, align 8, !tbaa !25
  %100 = load i32, ptr %13, align 4, !tbaa !5
  %101 = load ptr, ptr %10, align 8, !tbaa !9
  %102 = sext i32 %100 to i64
  %103 = getelementptr inbounds i8, ptr %101, i64 %102
  store ptr %103, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %115, %40
  %105 = load i32, ptr %14, align 4, !tbaa !5
  %106 = load i32, ptr %11, align 4, !tbaa !5
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %108, label %118

108:                                              ; preds = %104
  %109 = load ptr, ptr %8, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct._cpRSA_private_key, ptr %109, i32 0, i32 7
  %111 = load ptr, ptr %110, align 8, !tbaa !24
  %112 = load i32, ptr %14, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds i64, ptr %111, i64 %113
  store i64 0, ptr %114, align 8, !tbaa !26
  br label %115

115:                                              ; preds = %108
  %116 = load i32, ptr %14, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %14, align 4, !tbaa !5
  br label %104, !llvm.loop !28

118:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %119 = load ptr, ptr %8, align 8, !tbaa !9
  %120 = getelementptr inbounds %struct._cpRSA_private_key, ptr %119, i32 0, i32 13
  %121 = load ptr, ptr %120, align 8, !tbaa !25
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = call ptr @gsModArithRSA()
  %124 = call i32 @gsModEngineInit(ptr noundef %121, ptr noundef null, i32 noundef %122, i32 noundef 2, ptr noundef %123)
  store i32 0, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %125

125:                                              ; preds = %118, %39, %32, %24, %17
  %126 = load i32, ptr %5, align 4
  ret i32 %126
}

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

; 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

declare void @rsaMontExpGetSize(i32 noundef, ptr noundef) #3

; 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

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

declare ptr @gsModArithRSA() #3

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_cpRSA_private_key", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 12}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !6, i64 20}
!18 = !{!12, !6, i64 24}
!19 = !{!12, !10, i64 40}
!20 = !{!12, !10, i64 48}
!21 = !{!12, !10, i64 56}
!22 = !{!12, !10, i64 64}
!23 = !{!12, !10, i64 72}
!24 = !{!12, !10, i64 32}
!25 = !{!12, !10, i64 80}
!26 = !{!27, !27, i64 0}
!27 = !{!"long long", !7, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"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"

; Function Attrs: nounwind uwtable
define dso_local range(i32 -14, 1) i32 @ippsRSA_InitPrivateKeyType1(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca i32, align 4
  %6 = icmp eq ptr %2, null
  br i1 %6, label %41, label %7

7:                                                ; preds = %4
  %8 = add i32 %0, -16385
  %or.cond = icmp ult i32 %8, -16377
  br i1 %or.cond, label %41, label %9

9:                                                ; preds = %7
  %10 = icmp slt i32 %1, 1
  %.not = icmp sgt i32 %1, %0
  %or.cond49 = or i1 %10, %.not
  br i1 %or.cond49, label %41, label %11

11:                                               ; preds = %9
  %12 = tail call i32 @cpSizeof_RSA_privateKey1(i32 noundef %0, i32 noundef %0)
  %13 = icmp sgt i32 %12, %3
  br i1 %13, label %41, label %._crit_edge

._crit_edge:                                      ; preds = %11
  %14 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %2)
  %15 = trunc i64 %14 to i32
  %16 = xor i32 %15, 1381187889
  store i32 %16, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %0, ptr %17, align 4, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %1, ptr %18, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %2, i64 12
  %20 = getelementptr inbounds i8, ptr %2, i64 40
  %21 = add nuw nsw i32 %0, 63
  %22 = lshr i32 %21, 6
  %23 = add nuw nsw i32 %0, 31
  %24 = lshr i32 %23, 5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %19, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %20, i8 0, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @rsaMontExpGetSize(i32 noundef %24, ptr noundef nonnull %5) #5
  %25 = getelementptr inbounds i8, ptr %2, i64 88
  %26 = call i64 @IPP_INT_PTR(ptr noundef nonnull %25)
  %27 = sub i64 0, %26
  %28 = and i64 %27, 7
  %29 = getelementptr i8, ptr %25, i64 %28
  %30 = getelementptr inbounds i8, ptr %2, i64 32
  store ptr %29, ptr %30, align 8, !tbaa !13
  %31 = shl nuw nsw i32 %22, 3
  %32 = zext nneg i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %25, i64 %32
  %34 = getelementptr inbounds i8, ptr %2, i64 80
  store ptr %33, ptr %34, align 8, !tbaa !14
  %35 = add nsw i32 %22, -1
  %36 = zext nneg i32 %35 to i64
  %37 = shl nuw nsw i64 %36, 3
  %38 = add nuw nsw i64 %37, 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %29, i8 0, i64 %38, i1 false), !tbaa !15
  %39 = call ptr @gsModArithRSA() #5
  %40 = call i32 @gsModEngineInit(ptr noundef nonnull %33, ptr noundef null, i32 noundef %0, i32 noundef 2, ptr noundef %39) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  br label %41

41:                                               ; preds = %11, %9, %7, %4, %._crit_edge
  %.045 = phi i32 [ 0, %._crit_edge ], [ -8, %4 ], [ -14, %7 ], [ -5, %9 ], [ -9, %11 ]
  ret i32 %.045
}

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

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

declare void @rsaMontExpGetSize(i32 noundef, ptr noundef) local_unnamed_addr #3

; 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

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

declare ptr @gsModArithRSA() local_unnamed_addr #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 4}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !10, i64 32}
!14 = !{!6, !10, i64 80}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass