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

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

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

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

22:                                               ; preds = %3
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = icmp sgt i32 512, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store i32 -6, ptr %4, align 4
  br label %88

26:                                               ; preds = %22
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = icmp sgt i32 160, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i32 -6, ptr %4, align 4
  br label %88

30:                                               ; preds = %26
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp sge i32 %31, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  store i32 -6, ptr %4, align 4
  br label %88

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = call i32 @cpMontExp_WinSize(i32 noundef %36)
  store i32 %37, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %38 = load i32, ptr %14, align 4, !tbaa !5
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %40, label %41

40:                                               ; preds = %35
  br label %45

41:                                               ; preds = %35
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = call i32 @cpMontExpScratchBufferSize(i32 noundef %42, i32 noundef %43, i32 noundef 1)
  br label %45

45:                                               ; preds = %41, %40
  %46 = phi i32 [ 0, %40 ], [ %44, %41 ]
  store i32 %46, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = add nsw i32 %47, 31
  %49 = ashr i32 %48, 5
  store i32 %49, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = add nsw i32 %50, 31
  %52 = ashr i32 %51, 5
  store i32 %52, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = call i32 @cpMontExpScratchBufferSize(i32 noundef %53, i32 noundef %54, i32 noundef 2)
  store i32 %55, ptr %18, align 4, !tbaa !5
  %56 = load i32, ptr %16, align 4, !tbaa !5
  %57 = call i32 @ippsBigNumGetSize(i32 noundef %56, ptr noundef %8)
  %58 = load i32, ptr %17, align 4, !tbaa !5
  %59 = call i32 @ippsBigNumGetSize(i32 noundef %58, ptr noundef %9)
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = call i32 @gsModEngineGetSize(i32 noundef %60, i32 noundef 6, ptr noundef %10)
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = call i32 @gsModEngineGetSize(i32 noundef %62, i32 noundef 6, ptr noundef %11)
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = call i32 @ippsPrimeGetSize(i32 noundef %64, ptr noundef %12)
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = call i32 @cpBigNumListGetSize(i32 noundef %67, i32 noundef 8)
  store i32 %68, ptr %13, align 4, !tbaa !5
  %69 = load i32, ptr %10, align 4, !tbaa !5
  %70 = add nsw i32 112, %69
  %71 = load i32, ptr %11, align 4, !tbaa !5
  %72 = add nsw i32 %70, %71
  %73 = load i32, ptr %8, align 4, !tbaa !5
  %74 = add nsw i32 %72, %73
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = add nsw i32 %74, %75
  %77 = load i32, ptr %8, align 4, !tbaa !5
  %78 = add nsw i32 %76, %77
  %79 = load i32, ptr %12, align 4, !tbaa !5
  %80 = add nsw i32 %78, %79
  %81 = load i32, ptr %18, align 4, !tbaa !5
  %82 = add nsw i32 %80, %81
  %83 = load i32, ptr %13, align 4, !tbaa !5
  %84 = add nsw i32 %82, %83
  %85 = load i32, ptr %15, align 4, !tbaa !5
  %86 = add nsw i32 %84, %85
  %87 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 %86, ptr %87, align 4, !tbaa !5
  store i32 0, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %88

88:                                               ; preds = %45, %34, %29, %25, %21
  %89 = load i32, ptr %4, align 4
  ret i32 %89
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i32 @cpMontExp_WinSize(i32 noundef) #2

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

declare i32 @ippsBigNumGetSize(i32 noundef, ptr noundef) #2

declare i32 @gsModEngineGetSize(i32 noundef, i32 noundef, ptr noundef) #2

declare i32 @ippsPrimeGetSize(i32 noundef, ptr noundef) #2

declare i32 @cpBigNumListGetSize(i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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}


; 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 -8, 1) i32 @ippsDLPGetSize(i32 noundef %0, i32 noundef %1, ptr noundef writeonly %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = icmp eq ptr %2, null
  br i1 %9, label %45, label %10

10:                                               ; preds = %3
  %11 = icmp sgt i32 %0, 511
  %12 = icmp sgt i32 %1, 159
  %or.cond.not29 = and i1 %11, %12
  %.not = icmp slt i32 %1, %0
  %or.cond26 = and i1 %.not, %or.cond.not29
  br i1 %or.cond26, label %13, label %45

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %14 = tail call i32 @cpMontExp_WinSize(i32 noundef %1) #3
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %19, label %16

16:                                               ; preds = %13
  %17 = tail call i32 @cpMontExpScratchBufferSize(i32 noundef %0, i32 noundef %1, i32 noundef 1)
  %18 = add i32 %17, 112
  br label %19

19:                                               ; preds = %13, %16
  %20 = phi i32 [ %18, %16 ], [ 112, %13 ]
  %21 = add nuw nsw i32 %0, 31
  %22 = lshr i32 %21, 5
  %23 = add nuw nsw i32 %1, 31
  %24 = lshr i32 %23, 5
  %25 = tail call i32 @cpMontExpScratchBufferSize(i32 noundef %0, i32 noundef %1, i32 noundef 2)
  %26 = call i32 @ippsBigNumGetSize(i32 noundef %22, ptr noundef nonnull %4) #3
  %27 = call i32 @ippsBigNumGetSize(i32 noundef %24, ptr noundef nonnull %5) #3
  %28 = call i32 @gsModEngineGetSize(i32 noundef %0, i32 noundef 6, ptr noundef nonnull %6) #3
  %29 = call i32 @gsModEngineGetSize(i32 noundef %1, i32 noundef 6, ptr noundef nonnull %7) #3
  %30 = call i32 @ippsPrimeGetSize(i32 noundef %0, ptr noundef nonnull %8) #3
  %31 = add nuw nsw i32 %0, 1
  %32 = call i32 @cpBigNumListGetSize(i32 noundef %31, i32 noundef 8) #3
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %factor = shl i32 %35, 1
  %38 = add i32 %20, %25
  %39 = add i32 %38, %32
  %40 = add i32 %39, %33
  %41 = add i32 %40, %34
  %42 = add i32 %41, %36
  %43 = add i32 %42, %factor
  %44 = add i32 %43, %37
  store i32 %44, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %45

45:                                               ; preds = %10, %3, %19
  %.0 = phi i32 [ 0, %19 ], [ -8, %3 ], [ -6, %10 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i32 @cpMontExp_WinSize(i32 noundef) local_unnamed_addr #2

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

declare i32 @ippsBigNumGetSize(i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @gsModEngineGetSize(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @ippsPrimeGetSize(i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @cpBigNumListGetSize(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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