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

; 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._cpBigNum = type { i32, i32, i32, i32, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @cpPackBigNumCtx(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %7, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  call void @CopyBlock(ptr noundef %8, ptr noundef %9, i32 noundef 32)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._cpBigNum, ptr %10, i32 0, i32 4
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = call i64 @IPP_INT_PTR(ptr noundef %12)
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call i64 @IPP_INT_PTR(ptr noundef %14)
  %16 = sub nsw i64 %13, %15
  %17 = sub nsw i64 %16, 32
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %6, align 4, !tbaa !12
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._cpBigNum, ptr %19, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = call i64 @IPP_INT_PTR(ptr noundef %21)
  %23 = inttoptr i64 %22 to ptr
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call i64 @IPP_INT_PTR(ptr noundef %24)
  %26 = sub i64 0, %25
  %27 = getelementptr inbounds i8, ptr %23, i64 %26
  %28 = load i32, ptr %6, align 4, !tbaa !12
  %29 = sext i32 %28 to i64
  %30 = sub i64 0, %29
  %31 = getelementptr inbounds i8, ptr %27, i64 %30
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._cpBigNum, ptr %32, i32 0, i32 4
  store ptr %31, ptr %33, align 8, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._cpBigNum, ptr %34, i32 0, i32 5
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = call i64 @IPP_INT_PTR(ptr noundef %36)
  %38 = inttoptr i64 %37 to ptr
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = call i64 @IPP_INT_PTR(ptr noundef %39)
  %41 = sub i64 0, %40
  %42 = getelementptr inbounds i8, ptr %38, i64 %41
  %43 = load i32, ptr %6, align 4, !tbaa !12
  %44 = sext i32 %43 to i64
  %45 = sub i64 0, %44
  %46 = getelementptr inbounds i8, ptr %42, i64 %45
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._cpBigNum, ptr %47, i32 0, i32 5
  store ptr %46, ptr %48, align 8, !tbaa !13
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._cpBigNum, ptr %49, i32 0, i32 4
  %51 = load ptr, ptr %50, align 8, !tbaa !9
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._cpBigNum, ptr %53, i32 0, i32 4
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = call i64 @IPP_UINT_PTR(ptr noundef %55)
  %57 = getelementptr inbounds i8, ptr %52, i64 %56
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._cpBigNum, ptr %58, i32 0, i32 3
  %60 = load i32, ptr %59, align 4, !tbaa !14
  %61 = mul nsw i32 %60, 8
  call void @CopyBlock(ptr noundef %51, ptr noundef %57, i32 noundef %61)
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._cpBigNum, ptr %62, i32 0, i32 5
  %64 = load ptr, ptr %63, align 8, !tbaa !13
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._cpBigNum, ptr %66, i32 0, i32 5
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  %69 = call i64 @IPP_UINT_PTR(ptr noundef %68)
  %70 = getelementptr inbounds i8, ptr %65, i64 %69
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._cpBigNum, ptr %71, i32 0, i32 3
  %73 = load i32, ptr %72, align 4, !tbaa !14
  %74 = mul nsw i32 %73, 8
  call void @CopyBlock(ptr noundef %64, ptr noundef %70, i32 noundef %74)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @CopyBlock(ptr noundef, ptr noundef, i32 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr 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 = { 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 #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, !6, i64 16}
!10 = !{!"_cpBigNum", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 24}
!14 = !{!10, !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 void @cpPackBigNumCtx(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @CopyBlock(ptr noundef %0, ptr noundef %1, i32 noundef 32)
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call i64 @IPP_INT_PTR(ptr noundef %4)
  %6 = tail call i64 @IPP_INT_PTR(ptr noundef %0)
  %7 = sub nsw i64 %5, %6
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = tail call i64 @IPP_INT_PTR(ptr noundef %8)
  %10 = inttoptr i64 %9 to ptr
  %11 = tail call i64 @IPP_INT_PTR(ptr noundef %0)
  %12 = sub i64 0, %11
  %13 = getelementptr inbounds i8, ptr %10, i64 %12
  %14 = shl i64 %7, 32
  %sext = add i64 %14, -137438953472
  %15 = ashr exact i64 %sext, 32
  %16 = sub nsw i64 0, %15
  %17 = getelementptr inbounds i8, ptr %13, i64 %16
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %17, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = tail call i64 @IPP_INT_PTR(ptr noundef %20)
  %22 = inttoptr i64 %21 to ptr
  %23 = tail call i64 @IPP_INT_PTR(ptr noundef %0)
  %24 = sub i64 0, %23
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  %26 = getelementptr inbounds i8, ptr %25, i64 %16
  %27 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %26, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load ptr, ptr %18, align 8, !tbaa !5
  %30 = tail call i64 @IPP_UINT_PTR(ptr noundef %29)
  %31 = getelementptr inbounds i8, ptr %1, i64 %30
  %32 = getelementptr inbounds i8, ptr %0, i64 12
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = shl nsw i32 %33, 3
  tail call void @CopyBlock(ptr noundef %28, ptr noundef %31, i32 noundef %34)
  %35 = load ptr, ptr %19, align 8, !tbaa !11
  %36 = load ptr, ptr %27, align 8, !tbaa !11
  %37 = tail call i64 @IPP_UINT_PTR(ptr noundef %36)
  %38 = getelementptr inbounds i8, ptr %1, i64 %37
  %39 = load i32, ptr %32, align 4, !tbaa !12
  %40 = shl nsw i32 %39, 3
  tail call void @CopyBlock(ptr noundef %35, ptr noundef %38, i32 noundef %40)
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @IPP_UINT_PTR(ptr 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, !10, i64 16}
!6 = !{!"_cpBigNum", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !7, i64 12}


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