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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsDLPSetDP(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 %125

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 %125

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 %125

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 %125

36:                                               ; preds = %26
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._cpBigNum, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %42

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

42:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._cpDLP, ptr %43, i32 0, i32 9
  %45 = load ptr, ptr %44, align 8, !tbaa !16
  %46 = call ptr @cpBN_zero(ptr noundef %45)
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._cpDLP, ptr %47, i32 0, i32 10
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = call ptr @cpBN_zero(ptr noundef %49)
  %51 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %51, label %122 [
    i32 1, label %52
    i32 2, label %75
    i32 4, label %98
  ]

52:                                               ; preds = %42
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._cpDLP, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 4, !tbaa !18
  %56 = and i32 %55, -2
  store i32 %56, ptr %54, align 4, !tbaa !18
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._cpDLP, ptr %57, i32 0, i32 5
  %59 = load ptr, ptr %58, align 8, !tbaa !19
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._cpBigNum, ptr %60, i32 0, i32 4
  %62 = load ptr, ptr %61, align 8, !tbaa !20
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = call i32 @cpBN_bitsize(ptr noundef %63)
  %65 = call ptr @gsModArithDLP()
  %66 = call i32 @gsModEngineInit(ptr noundef %59, ptr noundef %62, i32 noundef %64, i32 noundef 6, ptr noundef %65)
  store i32 %66, ptr %8, align 4, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = icmp eq i32 0, %67
  br i1 %68, label %69, label %74

69:                                               ; preds = %52
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._cpDLP, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !18
  %73 = or i32 %72, 1
  store i32 %73, ptr %71, align 4, !tbaa !18
  br label %74

74:                                               ; preds = %69, %52
  br label %123

75:                                               ; preds = %42
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._cpDLP, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !18
  %79 = and i32 %78, -3
  store i32 %79, ptr %77, align 4, !tbaa !18
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._cpDLP, ptr %80, i32 0, i32 7
  %82 = load ptr, ptr %81, align 8, !tbaa !21
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._cpBigNum, ptr %83, i32 0, i32 4
  %85 = load ptr, ptr %84, align 8, !tbaa !20
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = call i32 @cpBN_bitsize(ptr noundef %86)
  %88 = call ptr @gsModArithDLP()
  %89 = call i32 @gsModEngineInit(ptr noundef %82, ptr noundef %85, i32 noundef %87, i32 noundef 6, ptr noundef %88)
  store i32 %89, ptr %8, align 4, !tbaa !9
  %90 = load i32, ptr %8, align 4, !tbaa !9
  %91 = icmp eq i32 0, %90
  br i1 %91, label %92, label %97

92:                                               ; preds = %75
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._cpDLP, ptr %93, i32 0, i32 1
  %95 = load i32, ptr %94, align 4, !tbaa !18
  %96 = or i32 %95, 2
  store i32 %96, ptr %94, align 4, !tbaa !18
  br label %97

97:                                               ; preds = %92, %75
  br label %123

98:                                               ; preds = %42
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct._cpDLP, ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 4, !tbaa !18
  %102 = and i32 %101, -5
  store i32 %102, ptr %100, align 4, !tbaa !18
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct._cpDLP, ptr %103, i32 0, i32 1
  %105 = load i32, ptr %104, align 4, !tbaa !18
  %106 = and i32 %105, 1
  %107 = icmp ne i32 %106, 0
  br i1 %107, label %108, label %120

108:                                              ; preds = %98
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._cpDLP, ptr %109, i32 0, i32 8
  %111 = load ptr, ptr %110, align 8, !tbaa !22
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = load ptr, ptr %7, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct._cpDLP, ptr %113, i32 0, i32 5
  %115 = load ptr, ptr %114, align 8, !tbaa !19
  call void @cpMontEnc_BN(ptr noundef %111, ptr noundef %112, ptr noundef %115)
  %116 = load ptr, ptr %7, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct._cpDLP, ptr %116, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !18
  %119 = or i32 %118, 4
  store i32 %119, ptr %117, align 4, !tbaa !18
  br label %121

120:                                              ; preds = %98
  store i32 -1013, ptr %8, align 4, !tbaa !9
  br label %121

121:                                              ; preds = %120, %108
  br label %123

122:                                              ; preds = %42
  store i32 -5, ptr %8, align 4, !tbaa !9
  br label %123

123:                                              ; preds = %122, %121, %97, %74
  %124 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %124, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %125

125:                                              ; preds = %123, %41, %35, %25, %21, %11
  %126 = load i32, ptr %4, align 4
  ret i32 %126
}

; 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

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

declare i32 @gsModEngineInit(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #3

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

declare ptr @gsModArithDLP() #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpMontEnc_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 = !{!14, !10, i64 4}
!16 = !{!12, !6, i64 56}
!17 = !{!12, !6, i64 64}
!18 = !{!12, !10, i64 4}
!19 = !{!12, !6, i64 24}
!20 = !{!14, !6, i64 16}
!21 = !{!12, !6, i64 40}
!22 = !{!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 @ippsDLPSetDP(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %2, null
  br i1 %4, label %66, 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 %66

11:                                               ; preds = %5
  %12 = icmp eq ptr %0, null
  br i1 %12, label %66, 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 %66

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %0, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %66, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %2, i64 56
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = tail call ptr @cpBN_zero(ptr noundef %25)
  %27 = getelementptr inbounds i8, ptr %2, i64 64
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = tail call ptr @cpBN_zero(ptr noundef %28)
  switch i32 %1, label %66 [
    i32 1, label %30
    i32 2, label %42
    i32 4, label %54
  ]

30:                                               ; preds = %23
  %31 = getelementptr inbounds i8, ptr %2, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !16
  %33 = and i32 %32, -2
  store i32 %33, ptr %31, align 4, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %2, i64 24
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %0, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = tail call i32 @cpBN_bitsize(ptr noundef nonnull %0)
  %39 = tail call ptr @gsModArithDLP() #3
  %40 = tail call i32 @gsModEngineInit(ptr noundef %35, ptr noundef %37, i32 noundef %38, i32 noundef 6, ptr noundef %39) #3
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %.sink.split, label %66

42:                                               ; preds = %23
  %43 = getelementptr inbounds i8, ptr %2, i64 4
  %44 = load i32, ptr %43, align 4, !tbaa !16
  %45 = and i32 %44, -3
  store i32 %45, ptr %43, align 4, !tbaa !16
  %46 = getelementptr inbounds i8, ptr %2, i64 40
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  %48 = getelementptr inbounds i8, ptr %0, i64 16
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = tail call i32 @cpBN_bitsize(ptr noundef nonnull %0)
  %51 = tail call ptr @gsModArithDLP() #3
  %52 = tail call i32 @gsModEngineInit(ptr noundef %47, ptr noundef %49, i32 noundef %50, i32 noundef 6, ptr noundef %51) #3
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %.sink.split, label %66

54:                                               ; preds = %23
  %55 = getelementptr inbounds i8, ptr %2, i64 4
  %56 = load i32, ptr %55, align 4, !tbaa !16
  %57 = and i32 %56, -5
  store i32 %57, ptr %55, align 4, !tbaa !16
  %58 = and i32 %56, 1
  %.not = icmp eq i32 %58, 0
  br i1 %.not, label %66, label %59

59:                                               ; preds = %54
  %60 = getelementptr inbounds i8, ptr %2, i64 48
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = getelementptr inbounds i8, ptr %2, i64 24
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  tail call void @cpMontEnc_BN(ptr noundef %61, ptr noundef nonnull %0, ptr noundef %63)
  br label %.sink.split

.sink.split:                                      ; preds = %42, %30, %59
  %.sink = phi ptr [ %55, %59 ], [ %31, %30 ], [ %43, %42 ]
  %64 = load i32, ptr %.sink, align 4, !tbaa !16
  %65 = or i32 %64, %1
  store i32 %65, ptr %.sink, align 4, !tbaa !16
  br label %66

66:                                               ; preds = %.sink.split, %30, %42, %54, %23, %19, %13, %11, %5, %3
  %.029 = phi i32 [ -8, %3 ], [ -13, %5 ], [ -8, %11 ], [ -13, %13 ], [ -5, %19 ], [ %52, %42 ], [ %40, %30 ], [ -1013, %54 ], [ -5, %23 ], [ 0, %.sink.split ]
  ret i32 %.029
}

; 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 @cpBN_zero(ptr noundef) local_unnamed_addr #1

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

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

declare ptr @gsModArithDLP() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpMontEnc_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 = !{!12, !7, i64 4}
!14 = !{!6, !10, i64 56}
!15 = !{!6, !10, i64 64}
!16 = !{!6, !7, i64 4}
!17 = !{!6, !10, i64 24}
!18 = !{!12, !10, i64 16}
!19 = !{!6, !10, i64 40}
!20 = !{!6, !10, i64 48}


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