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

; 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 @ippsGFpInv(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
  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
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp eq ptr null, %10
  br i1 %11, label %12, label %13

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

13:                                               ; preds = %3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp eq ptr null, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  store i32 -8, ptr %4, align 4
  br label %94

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

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

21:                                               ; preds = %17
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._cpGFp, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = call i64 @IPP_UINT_PTR(ptr noundef %25)
  %27 = trunc i64 %26 to i32
  %28 = xor i32 %24, %27
  %29 = icmp eq i32 %28, 1129136455
  br i1 %29, label %31, label %30

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

31:                                               ; preds = %21
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._cpGFpElement, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !12
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call i64 @IPP_UINT_PTR(ptr noundef %35)
  %37 = trunc i64 %36 to i32
  %38 = xor i32 %34, %37
  %39 = icmp eq i32 %38, 1129136456
  br i1 %39, label %41, label %40

40:                                               ; preds = %31
  store i32 -13, ptr %4, align 4
  br label %94

41:                                               ; preds = %31
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._cpGFpElement, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !12
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call i64 @IPP_UINT_PTR(ptr noundef %45)
  %47 = trunc i64 %46 to i32
  %48 = xor i32 %44, %47
  %49 = icmp eq i32 %48, 1129136456
  br i1 %49, label %51, label %50

50:                                               ; preds = %41
  store i32 -13, ptr %4, align 4
  br label %94

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

62:                                               ; preds = %51
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._cpGFpElement, ptr %63, i32 0, i32 1
  %65 = load i32, ptr %64, align 4, !tbaa !15
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._gsModEngine, ptr %66, i32 0, i32 3
  %68 = load i32, ptr %67, align 8, !tbaa !16
  %69 = icmp ne i32 %65, %68
  br i1 %69, label %70, label %71

70:                                               ; preds = %62, %51
  store i32 -11, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %93

71:                                               ; preds = %62
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct._cpGFpElement, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !19
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._gsModEngine, ptr %75, i32 0, i32 3
  %77 = load i32, ptr %76, align 8, !tbaa !16
  %78 = call i32 @cpGFpElementIsEquChunk(ptr noundef %74, i32 noundef %77, i64 noundef 0)
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %81

80:                                               ; preds = %71
  store i32 -10, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %93

81:                                               ; preds = %71
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._cpGFpElement, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !19
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._cpGFpElement, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !19
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = call ptr @cpGFpxInv(ptr noundef %84, ptr noundef %87, ptr noundef %88)
  %90 = icmp ne ptr null, %89
  %91 = zext i1 %90 to i64
  %92 = select i1 %90, i32 0, i32 -5
  store i32 %92, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %93

93:                                               ; preds = %81, %80, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %94

94:                                               ; preds = %93, %50, %40, %30, %20, %16, %12
  %95 = load i32, ptr %4, align 4
  ret i32 %95
}

; 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 i32 @cpGFpElementIsEquChunk(ptr noundef, i32 noundef, i64 noundef) #1

declare ptr @cpGFpxInv(ptr noundef, ptr noundef, ptr noundef) #3

; 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, !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 = !{!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 @ippsGFpInv(ptr noundef %0, ptr noundef %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.cond26 = or i1 %or.cond, %6
  br i1 %or.cond26, 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 = load i32, ptr %1, align 8, !tbaa !11
  %21 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %1)
  %22 = trunc i64 %21 to i32
  %23 = xor i32 %20, %22
  %24 = icmp eq i32 %23, 1129136456
  br i1 %24, label %25, label %45

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

32:                                               ; preds = %25
  %33 = getelementptr inbounds i8, ptr %1, i64 4
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %.not23 = icmp eq i32 %34, %29
  br i1 %.not23, label %35, label %45

35:                                               ; preds = %32
  %36 = getelementptr inbounds i8, ptr %0, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = tail call i32 @cpGFpElementIsEquChunk(ptr noundef %37, i32 noundef %29, i64 noundef 0)
  %.not24 = icmp eq i32 %38, 0
  br i1 %.not24, label %39, label %45

39:                                               ; preds = %35
  %40 = getelementptr inbounds i8, ptr %1, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  %42 = load ptr, ptr %36, align 8, !tbaa !18
  %43 = tail call ptr @cpGFpxInv(ptr noundef %41, ptr noundef %42, ptr noundef nonnull %27) #3
  %.not25 = icmp eq ptr %43, null
  %44 = select i1 %.not25, i32 -5, i32 0
  br label %45

45:                                               ; preds = %39, %32, %25, %35, %19, %13, %7, %3
  %.1 = phi i32 [ -8, %3 ], [ -13, %7 ], [ -13, %13 ], [ -13, %19 ], [ %44, %39 ], [ -11, %32 ], [ -11, %25 ], [ -10, %35 ]
  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 i32 @cpGFpElementIsEquChunk(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

declare ptr @cpGFpxInv(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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 = !{!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 = !{!12, !10, i64 8}


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