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

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

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

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

18:                                               ; preds = %3
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp eq ptr null, %19
  br i1 %20, label %21, label %22

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

22:                                               ; preds = %18
  %23 = load ptr, ptr %7, 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 %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._cpGFp, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %30 = load ptr, ptr %7, 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, 1129136455
  br i1 %34, label %36, label %35

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

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

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

46:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._cpGFp, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  store ptr %49, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._cpGFpElement, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 4, !tbaa !15
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._gsModEngine, ptr %53, i32 0, i32 3
  %55 = load i32, ptr %54, align 8, !tbaa !16
  %56 = icmp ne i32 %52, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %46
  store i32 -11, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %98

58:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = call ptr @cpGFpBasic(ptr noundef %59)
  store ptr %60, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._gsModEngine, ptr %61, i32 0, i32 3
  %63 = load i32, ptr %62, align 8, !tbaa !16
  store i32 %63, ptr %11, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._gsModEngine, ptr %64, i32 0, i32 10
  %66 = load ptr, ptr %65, align 8, !tbaa !20
  store ptr %66, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._gsModEngine, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 8, !tbaa !16
  store i32 %69, ptr %13, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = load i32, ptr %11, align 4, !tbaa !19
  %72 = call i32 @cpFix_BNU(ptr noundef %70, i32 noundef %71)
  store i32 %72, ptr %11, align 4, !tbaa !19
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._cpGFpElement, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !21
  %76 = load i32, ptr %13, align 4, !tbaa !19
  %77 = call i32 @cpFix_BNU(ptr noundef %75, i32 noundef %76)
  store i32 %77, ptr %13, align 4, !tbaa !19
  %78 = load i32, ptr %11, align 4, !tbaa !19
  %79 = load i32, ptr %13, align 4, !tbaa !19
  %80 = icmp eq i32 %78, %79
  br i1 %80, label %81, label %90

81:                                               ; preds = %58
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._cpGFpElement, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  %85 = load i32, ptr %13, align 4, !tbaa !19
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = load i32, ptr %13, align 4, !tbaa !19
  %88 = call i32 @cpCmp_BNU(ptr noundef %84, i32 noundef %85, ptr noundef %86, i32 noundef %87)
  %89 = icmp eq i32 0, %88
  br label %90

90:                                               ; preds = %81, %58
  %91 = phi i1 [ false, %58 ], [ %89, %81 ]
  %92 = zext i1 %91 to i32
  store i32 %92, ptr %14, align 4, !tbaa !19
  %93 = load i32, ptr %14, align 4, !tbaa !19
  %94 = icmp eq i32 1, %93
  %95 = zext i1 %94 to i64
  %96 = select i1 %94, i32 0, i32 3
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %96, ptr %97, align 4, !tbaa !19
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %98

98:                                               ; preds = %90, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %99

99:                                               ; preds = %98, %45, %35, %25, %21, %17
  %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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpCmp_BNU(ptr noundef, i32 noundef, ptr noundef, i32 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 = { 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, !11, i64 0}
!10 = !{!"_cpGFp", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_cpGFpElement", !11, i64 0, !11, i64 4, !6, i64 8}
!14 = !{!10, !6, i64 8}
!15 = !{!13, !11, i64 4}
!16 = !{!17, !11, i64 16}
!17 = !{!"_gsModEngine", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !18, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !6, i64 104}
!18 = !{!"long long", !7, i64 0}
!19 = !{!11, !11, i64 0}
!20 = !{!17, !6, i64 64}
!21 = !{!13, !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 @ippsGFpIsUnityElement(ptr noundef %0, ptr noundef writeonly %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = or i1 %4, %5
  %6 = icmp eq ptr %2, null
  %or.cond30 = or i1 %or.cond, %6
  br i1 %or.cond30, label %45, label %7

7:                                                ; preds = %3
  %8 = load i32, ptr %2, align 8, !tbaa !5
  %9 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %2)
  %10 = trunc i64 %9 to i32
  %11 = xor i32 %8, %10
  %12 = icmp eq i32 %11, 1129136455
  br i1 %12, label %13, label %45

13:                                               ; preds = %7
  %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, 1129136456
  br i1 %18, label %19, label %45

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %2, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %0, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %21, i64 16
  %25 = load i32, ptr %24, align 8, !tbaa !15
  %.not = icmp eq i32 %23, %25
  br i1 %.not, label %26, label %45

26:                                               ; preds = %19
  %27 = tail call ptr @cpGFpBasic(ptr noundef nonnull %21)
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  %29 = load i32, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds i8, ptr %27, i64 64
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  %32 = load i32, ptr %24, align 8, !tbaa !15
  %33 = tail call i32 @cpFix_BNU(ptr noundef %31, i32 noundef %29)
  %34 = getelementptr inbounds i8, ptr %0, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !19
  %36 = tail call i32 @cpFix_BNU(ptr noundef %35, i32 noundef %32)
  %37 = icmp eq i32 %33, %36
  br i1 %37, label %38, label %43

38:                                               ; preds = %26
  %39 = load ptr, ptr %34, align 8, !tbaa !19
  %40 = tail call i32 @cpCmp_BNU(ptr noundef %39, i32 noundef %33, ptr noundef %31, i32 noundef %33)
  %41 = icmp eq i32 %40, 0
  %42 = select i1 %41, i32 0, i32 3
  br label %43

43:                                               ; preds = %38, %26
  %44 = phi i32 [ 3, %26 ], [ %42, %38 ]
  store i32 %44, ptr %1, align 4, !tbaa !20
  br label %45

45:                                               ; preds = %43, %19, %13, %7, %3
  %.1 = phi i32 [ -8, %3 ], [ -13, %7 ], [ -13, %13 ], [ 0, %43 ], [ -11, %19 ]
  ret i32 %.1
}

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

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

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

!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 = !{!6, !10, i64 8}
!14 = !{!12, !7, i64 4}
!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 = !{!16, !10, i64 64}
!19 = !{!12, !10, i64 8}
!20 = !{!7, !7, i64 0}


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