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

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

12:                                               ; preds = %3
  store i32 -8, ptr %4, align 4
  br label %115

13:                                               ; preds = %3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._cpRSA_private_key, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = call i64 @IPP_UINT_PTR(ptr noundef %17)
  %19 = trunc i64 %18 to i32
  %20 = xor i32 %16, %19
  %21 = icmp eq i32 %20, 1381187889
  br i1 %21, label %23, label %22

22:                                               ; preds = %13
  store i32 -13, ptr %4, align 4
  br label %115

23:                                               ; preds = %13
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %67

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

35:                                               ; preds = %26
  store i32 -13, ptr %4, align 4
  br label %115

36:                                               ; preds = %26
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._cpRSA_private_key, ptr %37, i32 0, i32 3
  %39 = load i32, ptr %38, align 4, !tbaa !14
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %42, label %41

41:                                               ; preds = %36
  store i32 -1013, ptr %4, align 4
  br label %115

42:                                               ; preds = %36
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._cpBigNum, ptr %43, i32 0, i32 3
  %45 = load i32, ptr %44, align 4, !tbaa !15
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._cpRSA_private_key, ptr %46, i32 0, i32 3
  %48 = load i32, ptr %47, align 4, !tbaa !14
  %49 = add nsw i32 %48, 64
  %50 = sub nsw i32 %49, 1
  %51 = sdiv i32 %50, 64
  %52 = icmp slt i32 %45, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %42
  store i32 -6, ptr %4, align 4
  br label %115

54:                                               ; preds = %42
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._cpRSA_private_key, ptr %55, i32 0, i32 13
  %57 = load ptr, ptr %56, align 8, !tbaa !16
  %58 = getelementptr inbounds %struct._gsModEngine, ptr %57, i32 0, i32 8
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._cpRSA_private_key, ptr %60, i32 0, i32 13
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = getelementptr inbounds %struct._gsModEngine, ptr %62, i32 0, i32 3
  %64 = load i32, ptr %63, align 8, !tbaa !20
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = call ptr @BN_Set(ptr noundef %59, i32 noundef %64, ptr noundef %65)
  br label %67

67:                                               ; preds = %54, %23
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %114

70:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._cpRSA_private_key, ptr %71, i32 0, i32 4
  %73 = load i32, ptr %72, align 8, !tbaa !21
  %74 = add nsw i32 %73, 64
  %75 = sub nsw i32 %74, 1
  %76 = sdiv i32 %75, 64
  store i32 %76, ptr %8, align 4, !tbaa !22
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._cpRSA_private_key, ptr %77, i32 0, i32 7
  %79 = load ptr, ptr %78, align 8, !tbaa !23
  %80 = load i32, ptr %8, align 4, !tbaa !22
  %81 = call i32 @cpFix_BNU(ptr noundef %79, i32 noundef %80)
  store i32 %81, ptr %8, align 4, !tbaa !22
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._cpBigNum, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !12
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = call i64 @IPP_UINT_PTR(ptr noundef %85)
  %87 = trunc i64 %86 to i32
  %88 = xor i32 %84, %87
  %89 = icmp eq i32 %88, 1112098638
  br i1 %89, label %91, label %90

90:                                               ; preds = %70
  store i32 -13, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %111

91:                                               ; preds = %70
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._cpRSA_private_key, ptr %92, i32 0, i32 3
  %94 = load i32, ptr %93, align 4, !tbaa !14
  %95 = icmp sgt i32 %94, 0
  br i1 %95, label %97, label %96

96:                                               ; preds = %91
  store i32 -1013, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %111

97:                                               ; preds = %91
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct._cpBigNum, ptr %98, i32 0, i32 3
  %100 = load i32, ptr %99, align 4, !tbaa !15
  %101 = load i32, ptr %8, align 4, !tbaa !22
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %103, label %104

103:                                              ; preds = %97
  store i32 -6, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %111

104:                                              ; preds = %97
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._cpRSA_private_key, ptr %105, i32 0, i32 7
  %107 = load ptr, ptr %106, align 8, !tbaa !23
  %108 = load i32, ptr %8, align 4, !tbaa !22
  %109 = load ptr, ptr %6, align 8, !tbaa !5
  %110 = call ptr @BN_Set(ptr noundef %107, i32 noundef %108, ptr noundef %109)
  store i32 0, ptr %9, align 4
  br label %111

111:                                              ; preds = %104, %103, %96, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %112 = load i32, ptr %9, align 4
  switch i32 %112, label %117 [
    i32 0, label %113
    i32 1, label %115
  ]

113:                                              ; preds = %111
  br label %114

114:                                              ; preds = %113, %67
  store i32 0, ptr %4, align 4
  br label %115

115:                                              ; preds = %114, %111, %53, %41, %35, %22, %12
  %116 = load i32, ptr %4, align 4
  ret i32 %116

117:                                              ; preds = %111
  unreachable
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @BN_Set(ptr noundef, i32 noundef, 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 i32 @cpFix_BNU(ptr noundef, i32 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 = { 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 = !{!13, !11, i64 0}
!13 = !{!"_cpBigNum", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24}
!14 = !{!10, !11, i64 12}
!15 = !{!13, !11, i64 12}
!16 = !{!10, !6, i64 80}
!17 = !{!18, !6, i64 48}
!18 = !{!"_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, !19, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !6, i64 104}
!19 = !{!"long long", !7, i64 0}
!20 = !{!18, !11, i64 16}
!21 = !{!10, !11, i64 16}
!22 = !{!11, !11, i64 0}
!23 = !{!10, !6, i64 32}


; 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 noundef i32 @ippsRSA_GetPrivateKeyType1(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %2, null
  br i1 %4, label %.thread, label %5

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

11:                                               ; preds = %5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %36, label %12

12:                                               ; preds = %11
  %13 = load i32, ptr %0, align 8, !tbaa !11
  %14 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %0)
  %15 = trunc i64 %14 to i32
  %16 = xor i32 %13, %15
  %17 = icmp eq i32 %16, 1112098638
  br i1 %17, label %18, label %.thread

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %2, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %22, label %.thread

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = add nuw nsw i32 %20, 63
  %26 = lshr i32 %25, 6
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %.thread, label %28

28:                                               ; preds = %22
  %29 = getelementptr inbounds i8, ptr %2, i64 80
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = getelementptr inbounds i8, ptr %30, i64 48
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %30, i64 16
  %34 = load i32, ptr %33, align 8, !tbaa !19
  %35 = tail call ptr @BN_Set(ptr noundef %32, i32 noundef %34, ptr noundef nonnull %0)
  br label %36

36:                                               ; preds = %28, %11
  %.not31 = icmp eq ptr %1, null
  br i1 %.not31, label %.thread, label %37

37:                                               ; preds = %36
  %38 = getelementptr inbounds i8, ptr %2, i64 16
  %39 = load i32, ptr %38, align 8, !tbaa !20
  %40 = add nsw i32 %39, 63
  %41 = sdiv i32 %40, 64
  %42 = getelementptr inbounds i8, ptr %2, i64 32
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = tail call i32 @cpFix_BNU(ptr noundef %43, i32 noundef %41)
  %45 = load i32, ptr %1, align 8, !tbaa !11
  %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 %.thread

50:                                               ; preds = %37
  %51 = getelementptr inbounds i8, ptr %2, i64 12
  %52 = load i32, ptr %51, align 4, !tbaa !13
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %54, label %.thread

54:                                               ; preds = %50
  %55 = getelementptr inbounds i8, ptr %1, i64 12
  %56 = load i32, ptr %55, align 4, !tbaa !14
  %57 = icmp slt i32 %56, %44
  br i1 %57, label %.thread, label %58

58:                                               ; preds = %54
  %59 = load ptr, ptr %42, align 8, !tbaa !21
  %60 = tail call ptr @BN_Set(ptr noundef %59, i32 noundef %44, ptr noundef nonnull %1)
  br label %.thread

.thread:                                          ; preds = %54, %50, %37, %36, %58, %22, %18, %12, %5, %3
  %.1 = phi i32 [ -8, %3 ], [ -13, %5 ], [ -13, %12 ], [ -1013, %18 ], [ -6, %22 ], [ 0, %58 ], [ 0, %36 ], [ -6, %54 ], [ -1013, %50 ], [ -13, %37 ]
  ret i32 %.1
}

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

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

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

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 = !{!12, !7, i64 0}
!12 = !{!"_cpBigNum", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!13 = !{!6, !7, i64 12}
!14 = !{!12, !7, i64 12}
!15 = !{!6, !10, i64 80}
!16 = !{!17, !10, i64 48}
!17 = !{!"_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, !18, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !7, i64 96, !7, i64 100, !10, i64 104}
!18 = !{!"long long", !8, i64 0}
!19 = !{!17, !7, i64 16}
!20 = !{!6, !7, i64 16}
!21 = !{!6, !10, i64 32}


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