; LLVM IR from intel/cryptography-primitives :: examples/utils/bignum.ll (ZN9BigNumbermLERKS_)

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

%class.BigNumber = type { ptr, ptr }

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

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

declare i32 @ippsRef_BN(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN9BigNumberaSERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN9BigNumbermLERKS_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %class.BigNumber, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %12 = call noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %13 = call i32 @ippsRef_BN(ptr noundef null, ptr noundef %5, ptr noundef null, ptr noundef %12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %14)
  %16 = call i32 @ippsRef_BN(ptr noundef null, ptr noundef %6, ptr noundef null, ptr noundef %15)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = add nsw i32 %17, %18
  store i32 %19, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = add nsw i32 %20, 31
  %22 = ashr i32 %21, 5
  call void @_ZN9BigNumberC1EPKji13IppsBigNumSGN(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef null, i32 noundef %22, i32 noundef 1)
  %23 = invoke noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
          to label %24 unwind label %34

24:                                               ; preds = %2
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = invoke noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %25)
          to label %27 unwind label %34

27:                                               ; preds = %24
  %28 = invoke noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %29 unwind label %34

29:                                               ; preds = %27
  %30 = invoke i32 @ippsMul_BN(ptr noundef %23, ptr noundef %26, ptr noundef %28)
          to label %31 unwind label %34

31:                                               ; preds = %29
  %32 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN9BigNumberaSERKS_(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %33 unwind label %34

33:                                               ; preds = %31
  call void @_ZN9BigNumberD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret ptr %11

34:                                               ; preds = %31, %29, %27, %24, %2
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %9, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %10, align 4
  call void @_ZN9BigNumberD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %38

38:                                               ; preds = %34
  %39 = load ptr, ptr %9, align 8
  %40 = load i32, ptr %10, align 4
  %41 = insertvalue { ptr, i32 } poison, ptr %39, 0
  %42 = insertvalue { ptr, i32 } %41, i32 %40, 1
  resume { ptr, i32 } %42
}

declare i32 @ippsMul_BN(ptr noundef, ptr noundef, ptr noundef) #1

declare void @_ZN9BigNumberD1Ev(ptr)

declare void @_ZN9BigNumberC1EPKji13IppsBigNumSGN(ptr, ptr, i32, i32)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { mustprogress 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

%class.BigNumber = type { ptr, ptr }

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

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

declare i32 @ippsRef_BN(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN9BigNumberaSERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN9BigNumbermLERKS_(ptr noundef nonnull returned align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %class.BigNumber, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %6 = tail call noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %7 = call i32 @ippsRef_BN(ptr noundef null, ptr noundef nonnull %3, ptr noundef null, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %8 = call noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %9 = call i32 @ippsRef_BN(ptr noundef null, ptr noundef nonnull %4, ptr noundef null, ptr noundef %8)
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  %12 = add i32 %10, 31
  %13 = add i32 %12, %11
  %14 = ashr i32 %13, 5
  call void @_ZN9BigNumberC1EPKji13IppsBigNumSGN(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef null, i32 noundef %14, i32 noundef 1)
  %15 = call noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %16 = call noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %17 = call noundef ptr @_ZNK9BigNumbercvP9_cpBigNumEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %18 = invoke i32 @ippsMul_BN(ptr noundef %15, ptr noundef %16, ptr noundef %17)
          to label %19 unwind label %22

19:                                               ; preds = %2
  %20 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN9BigNumberaSERKS_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %5)
          to label %21 unwind label %22

21:                                               ; preds = %19
  call void @_ZN9BigNumberD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret ptr %0

22:                                               ; preds = %19, %2
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN9BigNumberD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  resume { ptr, i32 } %23
}

declare i32 @ippsMul_BN(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN9BigNumberD1Ev(ptr) local_unnamed_addr

declare void @_ZN9BigNumberC1EPKji13IppsBigNumSGN(ptr, ptr, i32, i32) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { mustprogress 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 #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++ TBAA"}


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