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

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

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

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

21:                                               ; preds = %12
  store i32 -13, ptr %4, align 4
  br label %99

22:                                               ; preds = %12
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = icmp eq ptr null, %23
  br i1 %24, label %25, label %26

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

26:                                               ; preds = %22
  %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 !13
  %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 %99

36:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  %37 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %37, label %96 [
    i32 1, label %38
    i32 2, label %59
    i32 4, label %80
  ]

38:                                               ; preds = %36
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._cpDLP, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !15
  %42 = and i32 %41, 1
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %57

44:                                               ; preds = %38
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._cpDLP, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !16
  %48 = add nsw i32 %47, 31
  %49 = ashr i32 %48, 5
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._cpDLP, ptr %50, i32 0, i32 5
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = getelementptr inbounds %struct._gsModEngine, ptr %52, i32 0, i32 8
  %54 = load ptr, ptr %53, align 8, !tbaa !18
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call i32 @ippsSet_BN(i32 noundef 1, i32 noundef %49, ptr noundef %54, ptr noundef %55)
  store i32 %56, ptr %8, align 4, !tbaa !9
  br label %58

57:                                               ; preds = %38
  store i32 -1013, ptr %8, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %57, %44
  br label %97

59:                                               ; preds = %36
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._cpDLP, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 4, !tbaa !15
  %63 = and i32 %62, 2
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %78

65:                                               ; preds = %59
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._cpDLP, ptr %66, i32 0, i32 3
  %68 = load i32, ptr %67, align 4, !tbaa !21
  %69 = add nsw i32 %68, 31
  %70 = ashr i32 %69, 5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._cpDLP, ptr %71, i32 0, i32 7
  %73 = load ptr, ptr %72, align 8, !tbaa !22
  %74 = getelementptr inbounds %struct._gsModEngine, ptr %73, i32 0, i32 8
  %75 = load ptr, ptr %74, align 8, !tbaa !18
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = call i32 @ippsSet_BN(i32 noundef 1, i32 noundef %70, ptr noundef %75, ptr noundef %76)
  store i32 %77, ptr %8, align 4, !tbaa !9
  br label %79

78:                                               ; preds = %59
  store i32 -1013, ptr %8, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %78, %65
  br label %97

80:                                               ; preds = %36
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._cpDLP, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !15
  %84 = and i32 %83, 4
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %94

86:                                               ; preds = %80
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._cpDLP, ptr %88, i32 0, i32 8
  %90 = load ptr, ptr %89, align 8, !tbaa !23
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._cpDLP, ptr %91, i32 0, i32 5
  %93 = load ptr, ptr %92, align 8, !tbaa !17
  call void @cpMontDec_BN(ptr noundef %87, ptr noundef %90, ptr noundef %93)
  br label %95

94:                                               ; preds = %80
  store i32 -1013, ptr %8, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %94, %86
  br label %97

96:                                               ; preds = %36
  store i32 -5, ptr %8, align 4, !tbaa !9
  br label %97

97:                                               ; preds = %96, %95, %79, %58
  %98 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %98, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %99

99:                                               ; preds = %97, %35, %25, %21, %11
  %100 = load i32, ptr %4, align 4
  ret i32 %100
}

; 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 i32 @ippsSet_BN(i32 noundef, i32 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpMontDec_BN(ptr noundef, ptr noundef, ptr 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 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_cpDLP", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104}
!13 = !{!14, !10, i64 0}
!14 = !{!"_cpBigNum", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24}
!15 = !{!12, !10, i64 4}
!16 = !{!12, !10, i64 8}
!17 = !{!12, !6, i64 24}
!18 = !{!19, !6, i64 48}
!19 = !{!"_gsModEngine", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !20, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !6, i64 104}
!20 = !{!"long long", !7, i64 0}
!21 = !{!12, !10, i64 12}
!22 = !{!12, !6, i64 40}
!23 = !{!12, !6, i64 48}


; 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 i32 @ippsDLPGetDP(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %2, null
  br i1 %4, label %57, 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, 541346896
  br i1 %10, label %11, label %57

11:                                               ; preds = %5
  %12 = icmp eq ptr %0, null
  br i1 %12, label %57, label %13

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

19:                                               ; preds = %13
  switch i32 %1, label %57 [
    i32 1, label %20
    i32 2, label %34
    i32 4, label %48
  ]

20:                                               ; preds = %19
  %21 = getelementptr inbounds i8, ptr %2, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = and i32 %22, 1
  %.not24 = icmp eq i32 %23, 0
  br i1 %.not24, label %57, label %24

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %2, i64 8
  %26 = load i32, ptr %25, align 8, !tbaa !14
  %27 = add nsw i32 %26, 31
  %28 = ashr i32 %27, 5
  %29 = getelementptr inbounds i8, ptr %2, i64 24
  %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 = tail call i32 @ippsSet_BN(i32 noundef 1, i32 noundef %28, ptr noundef %32, ptr noundef nonnull %0) #3
  br label %57

34:                                               ; preds = %19
  %35 = getelementptr inbounds i8, ptr %2, i64 4
  %36 = load i32, ptr %35, align 4, !tbaa !13
  %37 = and i32 %36, 2
  %.not23 = icmp eq i32 %37, 0
  br i1 %.not23, label %57, label %38

38:                                               ; preds = %34
  %39 = getelementptr inbounds i8, ptr %2, i64 12
  %40 = load i32, ptr %39, align 4, !tbaa !19
  %41 = add nsw i32 %40, 31
  %42 = ashr i32 %41, 5
  %43 = getelementptr inbounds i8, ptr %2, i64 40
  %44 = load ptr, ptr %43, align 8, !tbaa !20
  %45 = getelementptr inbounds i8, ptr %44, i64 48
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = tail call i32 @ippsSet_BN(i32 noundef 1, i32 noundef %42, ptr noundef %46, ptr noundef nonnull %0) #3
  br label %57

48:                                               ; preds = %19
  %49 = getelementptr inbounds i8, ptr %2, i64 4
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = and i32 %50, 4
  %.not = icmp eq i32 %51, 0
  br i1 %.not, label %57, label %52

52:                                               ; preds = %48
  %53 = getelementptr inbounds i8, ptr %2, i64 48
  %54 = load ptr, ptr %53, align 8, !tbaa !21
  %55 = getelementptr inbounds i8, ptr %2, i64 24
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  tail call void @cpMontDec_BN(ptr noundef nonnull %0, ptr noundef %54, ptr noundef %56)
  br label %57

57:                                               ; preds = %24, %38, %52, %20, %34, %48, %19, %13, %11, %5, %3
  %.020 = phi i32 [ -8, %3 ], [ -13, %5 ], [ -8, %11 ], [ -13, %13 ], [ 0, %52 ], [ %47, %38 ], [ %33, %24 ], [ -1013, %20 ], [ -1013, %34 ], [ -1013, %48 ], [ -5, %19 ]
  ret i32 %.020
}

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpMontDec_BN(ptr noundef, ptr noundef, 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" }
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, !7, i64 0}
!6 = !{!"_cpDLP", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104}
!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 4}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !10, i64 24}
!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 = !{!6, !7, i64 12}
!20 = !{!6, !10, i64 40}
!21 = !{!6, !10, i64 48}


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