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

; 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._cpGFp = type { i32, i32, ptr }
%struct._cpGFpElement = type { i32, i32, ptr }
%struct._gsModEngine = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr, i32, i32, ptr }
%struct._cpGFpMethod = type { i32, i32, ptr, ptr, ptr }

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

14:                                               ; preds = %5
  store i32 -8, ptr %6, align 4
  br label %103

15:                                               ; preds = %5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp eq ptr null, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store i32 -8, ptr %6, align 4
  br label %103

19:                                               ; preds = %15
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = icmp eq ptr null, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store i32 -8, ptr %6, align 4
  br label %103

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

26:                                               ; preds = %23
  store i32 -8, ptr %6, align 4
  br label %103

27:                                               ; preds = %23
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._cpGFp, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call i64 @IPP_UINT_PTR(ptr noundef %31)
  %33 = trunc i64 %32 to i32
  %34 = xor i32 %30, %33
  %35 = icmp eq i32 %34, 1129136455
  br i1 %35, label %37, label %36

36:                                               ; preds = %27
  store i32 -13, ptr %6, align 4
  br label %103

37:                                               ; preds = %27
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._cpGFpElement, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = call i64 @IPP_UINT_PTR(ptr noundef %41)
  %43 = trunc i64 %42 to i32
  %44 = xor i32 %40, %43
  %45 = icmp eq i32 %44, 1129136456
  br i1 %45, label %47, label %46

46:                                               ; preds = %37
  store i32 -13, ptr %6, align 4
  br label %103

47:                                               ; preds = %37
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._cpGFpElement, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !15
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._cpGFp, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds %struct._gsModEngine, ptr %53, i32 0, i32 3
  %55 = load i32, ptr %54, align 8, !tbaa !17
  %56 = icmp ne i32 %50, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %47
  store i32 -11, ptr %6, align 4
  br label %103

58:                                               ; preds = %47
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = icmp slt i32 %59, 2
  br i1 %60, label %64, label %61

61:                                               ; preds = %58
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = icmp sgt i32 %62, 8
  br i1 %63, label %64, label %65

64:                                               ; preds = %61, %58
  store i32 -5, ptr %6, align 4
  br label %103

65:                                               ; preds = %61
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._cpGFpMethod, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !20
  %69 = and i32 %68, 16777216
  %70 = icmp ne i32 16777216, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %65
  store i32 -5, ptr %6, align 4
  br label %103

72:                                               ; preds = %65
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._cpGFpMethod, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !22
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %84

77:                                               ; preds = %72
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._cpGFpMethod, ptr %79, i32 0, i32 1
  %81 = load i32, ptr %80, align 4, !tbaa !22
  %82 = icmp ne i32 %78, %81
  br i1 %82, label %83, label %84

83:                                               ; preds = %77
  store i32 -5, ptr %6, align 4
  br label %103

84:                                               ; preds = %77, %72
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  call void @InitGFpxCtx(ptr noundef %85, i32 noundef %86, ptr noundef %87, ptr noundef %88)
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._cpGFp, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !16
  %92 = getelementptr inbounds %struct._gsModEngine, ptr %91, i32 0, i32 8
  %93 = load ptr, ptr %92, align 8, !tbaa !23
  %94 = load ptr, ptr %9, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct._cpGFpElement, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !24
  %97 = load ptr, ptr %7, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct._cpGFp, ptr %97, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !16
  %100 = getelementptr inbounds %struct._gsModEngine, ptr %99, i32 0, i32 3
  %101 = load i32, ptr %100, align 8, !tbaa !17
  %102 = call ptr @cpGFpElementCopy(ptr noundef %93, ptr noundef %96, i32 noundef %101)
  store i32 0, ptr %6, align 4
  br label %103

103:                                              ; preds = %84, %83, %71, %64, %57, %46, %36, %26, %22, %18, %14
  %104 = load i32, ptr %6, align 4
  ret i32 %104
}

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

declare void @InitGFpxCtx(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementCopy(ptr noundef, ptr noundef, i32 noundef) #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" }

!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 = !{!"_cpGFp", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!14, !10, i64 0}
!14 = !{!"_cpGFpElement", !10, i64 0, !10, i64 4, !6, i64 8}
!15 = !{!14, !10, i64 4}
!16 = !{!12, !6, i64 8}
!17 = !{!18, !10, i64 16}
!18 = !{!"_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, !19, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !6, i64 104}
!19 = !{!"long long", !7, i64 0}
!20 = !{!21, !10, i64 0}
!21 = !{!"_cpGFpMethod", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24}
!22 = !{!21, !10, i64 4}
!23 = !{!18, !6, i64 48}
!24 = !{!14, !6, i64 8}


; 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 -13, 1) i32 @ippsGFpxInitBinomial(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %7 = insertelement <4 x ptr> %6, ptr %4, i64 1
  %8 = insertelement <4 x ptr> %7, ptr %2, i64 2
  %9 = insertelement <4 x ptr> %8, ptr %3, i64 3
  %10 = icmp eq <4 x ptr> %9, zeroinitializer
  %11 = bitcast <4 x i1> %10 to i4
  %.not37 = icmp eq i4 %11, 0
  br i1 %.not37, label %12, label %50

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

18:                                               ; preds = %12
  %19 = load i32, ptr %2, align 8, !tbaa !11
  %20 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %2)
  %21 = trunc i64 %20 to i32
  %22 = xor i32 %19, %21
  %23 = icmp eq i32 %22, 1129136456
  br i1 %23, label %24, label %50

24:                                               ; preds = %18
  %25 = getelementptr inbounds i8, ptr %2, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %30 = load i32, ptr %29, align 8, !tbaa !15
  %.not = icmp eq i32 %26, %30
  br i1 %.not, label %31, label %50

31:                                               ; preds = %24
  %32 = add i32 %1, -9
  %or.cond = icmp ult i32 %32, -7
  br i1 %or.cond, label %50, label %33

33:                                               ; preds = %31
  %34 = load i32, ptr %3, align 8, !tbaa !18
  %35 = and i32 %34, 16777216
  %.not30.not = icmp eq i32 %35, 0
  br i1 %.not30.not, label %50, label %36

36:                                               ; preds = %33
  %37 = getelementptr inbounds i8, ptr %3, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !20
  %.not31 = icmp eq i32 %38, 0
  %.not32 = icmp eq i32 %38, %1
  %or.cond33 = or i1 %.not31, %.not32
  br i1 %or.cond33, label %39, label %50

39:                                               ; preds = %36
  tail call void @InitGFpxCtx(ptr noundef nonnull %0, i32 noundef %1, ptr noundef nonnull %3, ptr noundef nonnull %4) #3
  %40 = getelementptr inbounds i8, ptr %4, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = getelementptr inbounds i8, ptr %41, i64 48
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = getelementptr inbounds i8, ptr %2, i64 8
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  %46 = load ptr, ptr %27, align 8, !tbaa !14
  %47 = getelementptr inbounds i8, ptr %46, i64 16
  %48 = load i32, ptr %47, align 8, !tbaa !15
  %49 = tail call ptr @cpGFpElementCopy(ptr noundef %43, ptr noundef %45, i32 noundef %48)
  br label %50

50:                                               ; preds = %36, %33, %31, %24, %18, %12, %5, %39
  %.0 = phi i32 [ 0, %39 ], [ -8, %5 ], [ -13, %12 ], [ -13, %18 ], [ -11, %24 ], [ -5, %31 ], [ -5, %33 ], [ -5, %36 ]
  ret i32 %.0
}

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

declare void @InitGFpxCtx(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementCopy(ptr noundef, ptr noundef, i32 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 = !{!"_cpGFp", !7, i64 0, !7, i64 4, !10, i64 8}
!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 = !{!"_cpGFpElement", !7, i64 0, !7, i64 4, !10, i64 8}
!13 = !{!12, !7, i64 4}
!14 = !{!6, !10, i64 8}
!15 = !{!16, !7, i64 16}
!16 = !{!"_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, !17, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !7, i64 96, !7, i64 100, !10, i64 104}
!17 = !{!"long long", !8, i64 0}
!18 = !{!19, !7, i64 0}
!19 = !{!"_cpGFpMethod", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!20 = !{!19, !7, i64 4}
!21 = !{!16, !10, i64 48}
!22 = !{!12, !10, i64 8}


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