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

; 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._cpGFpECPoint = type { i32, i32, i32, ptr }
%struct._cpGFpEC = type { i32, i32, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct._cpGFp = 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 @ippsGFpECTstPointInSubgroup(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %struct._cpGFpECPoint, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = icmp eq ptr null, %12
  br i1 %13, label %14, label %15

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

15:                                               ; preds = %4
  %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 %5, align 4
  br label %100

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

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

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

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

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

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

37:                                               ; preds = %27
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._cpGFpEC, ptr %38, i32 0, i32 3
  %40 = load i32, ptr %39, align 8, !tbaa !12
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %37
  store i32 -13, ptr %5, align 4
  br label %100

43:                                               ; preds = %37
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._cpGFpECPoint, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call i64 @IPP_UINT_PTR(ptr noundef %47)
  %49 = trunc i64 %48 to i32
  %50 = xor i32 %46, %49
  %51 = icmp eq i32 %50, 1129136462
  br i1 %51, label %53, label %52

52:                                               ; preds = %43
  store i32 -13, ptr %5, align 4
  br label %100

53:                                               ; preds = %43
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._cpGFpECPoint, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !15
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._cpGFpEC, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = getelementptr inbounds %struct._cpGFp, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !17
  %62 = getelementptr inbounds %struct._gsModEngine, ptr %61, i32 0, i32 3
  %63 = load i32, ptr %62, align 8, !tbaa !19
  %64 = icmp ne i32 %56, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %53
  store i32 -11, ptr %5, align 4
  br label %100

66:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = call i32 @ippsGFpECTstPoint(ptr noundef %67, ptr noundef %10, ptr noundef %68)
  %70 = load i32, ptr %10, align 4, !tbaa !22
  %71 = icmp eq i32 0, %70
  br i1 %71, label %72, label %97

72:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = call ptr @cpEcGFpGetPool(i32 noundef 1, ptr noundef %73)
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = call ptr @cpEcGFpInitPoint(ptr noundef %11, ptr noundef %74, i32 noundef 0, ptr noundef %75)
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct._cpGFpEC, ptr %78, i32 0, i32 13
  %80 = load ptr, ptr %79, align 8, !tbaa !23
  %81 = getelementptr inbounds %struct._gsModEngine, ptr %80, i32 0, i32 8
  %82 = load ptr, ptr %81, align 8, !tbaa !24
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct._cpGFpEC, ptr %83, i32 0, i32 5
  %85 = load i32, ptr %84, align 8, !tbaa !25
  %86 = add nsw i32 %85, 64
  %87 = sub nsw i32 %86, 1
  %88 = sdiv i32 %87, 64
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = call ptr @gfec_MulPoint(ptr noundef %11, ptr noundef %77, ptr noundef %82, i32 noundef %88, ptr noundef %89, ptr noundef %90)
  %92 = call i32 @gfec_IsPointAtInfinity(ptr noundef %11)
  %93 = icmp ne i32 %92, 0
  %94 = zext i1 %93 to i64
  %95 = select i1 %93, i32 0, i32 12
  store i32 %95, ptr %10, align 4, !tbaa !22
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  call void @cpEcGFpReleasePool(i32 noundef 1, ptr noundef %96)
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  br label %97

97:                                               ; preds = %72, %66
  %98 = load i32, ptr %10, align 4, !tbaa !22
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %98, ptr %99, align 4, !tbaa !22
  store i32 0, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %100

100:                                              ; preds = %97, %65, %52, %42, %36, %26, %22, %18, %14
  %101 = load i32, ptr %5, align 4
  ret i32 %101
}

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

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @cpEcGFpReleasePool(i32 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, !11, i64 0}
!10 = !{!"_cpGFpEC", !11, i64 0, !11, i64 4, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !11, i64 68, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!14, !11, i64 0}
!14 = !{!"_cpGFpECPoint", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16}
!15 = !{!14, !11, i64 8}
!16 = !{!10, !6, i64 8}
!17 = !{!18, !6, i64 8}
!18 = !{!"_cpGFp", !11, i64 0, !11, i64 4, !6, i64 8}
!19 = !{!20, !11, i64 16}
!20 = !{!"_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, !21, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !6, i64 104}
!21 = !{!"long long", !7, i64 0}
!22 = !{!11, !11, i64 0}
!23 = !{!10, !6, i64 80}
!24 = !{!20, !6, i64 48}
!25 = !{!10, !11, i64 24}


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

%struct._cpGFpECPoint = type { i32, i32, i32, ptr }

; Function Attrs: nounwind uwtable
define dso_local range(i32 -13, 1) i32 @ippsGFpECTstPointInSubgroup(ptr noundef %0, ptr noundef writeonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca i32, align 4
  %6 = alloca %struct._cpGFpECPoint, align 8
  %7 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %8 = insertelement <4 x ptr> %7, ptr %1, i64 1
  %9 = insertelement <4 x ptr> %8, ptr %2, i64 2
  %10 = insertelement <4 x ptr> %9, ptr %3, i64 3
  %11 = icmp eq <4 x ptr> %10, zeroinitializer
  %12 = bitcast <4 x i1> %11 to i4
  %.not30 = icmp eq i4 %12, 0
  br i1 %.not30, label %13, label %57

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

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %2, i64 16
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %.not = icmp eq i32 %21, 0
  br i1 %.not, label %57, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %0, align 8, !tbaa !12
  %24 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %0)
  %25 = trunc i64 %24 to i32
  %26 = xor i32 %23, %25
  %27 = icmp eq i32 %26, 1129136462
  br i1 %27, label %28, label %57

28:                                               ; preds = %22
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  %30 = load i32, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %2, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %36 = load i32, ptr %35, align 8, !tbaa !18
  %.not26 = icmp eq i32 %30, %36
  br i1 %.not26, label %37, label %57

37:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %38 = call i32 @ippsGFpECTstPoint(ptr noundef nonnull %0, ptr noundef nonnull %5, ptr noundef nonnull %2) #4
  %39 = load i32, ptr %5, align 4, !tbaa !21
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %55

41:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  %42 = call ptr @cpEcGFpGetPool(i32 noundef 1, ptr noundef nonnull %2)
  %43 = call ptr @cpEcGFpInitPoint(ptr noundef nonnull %6, ptr noundef %42, i32 noundef 0, ptr noundef nonnull %2)
  %44 = getelementptr inbounds i8, ptr %2, i64 80
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  %46 = getelementptr inbounds i8, ptr %45, i64 48
  %47 = load ptr, ptr %46, align 8, !tbaa !23
  %48 = getelementptr inbounds i8, ptr %2, i64 24
  %49 = load i32, ptr %48, align 8, !tbaa !24
  %50 = add nsw i32 %49, 63
  %51 = sdiv i32 %50, 64
  %52 = call ptr @gfec_MulPoint(ptr noundef nonnull %6, ptr noundef nonnull %0, ptr noundef %47, i32 noundef %51, ptr noundef nonnull %2, ptr noundef nonnull %3) #4
  %53 = call i32 @gfec_IsPointAtInfinity(ptr noundef nonnull %6)
  %.not27 = icmp eq i32 %53, 0
  %54 = select i1 %.not27, i32 12, i32 0
  store i32 %54, ptr %5, align 4, !tbaa !21
  call void @cpEcGFpReleasePool(i32 noundef 1, ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  %.pre = load i32, ptr %5, align 4, !tbaa !21
  br label %55

55:                                               ; preds = %41, %37
  %56 = phi i32 [ %.pre, %41 ], [ %39, %37 ]
  store i32 %56, ptr %1, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %57

57:                                               ; preds = %28, %22, %19, %13, %4, %55
  %.0 = phi i32 [ 0, %55 ], [ -8, %4 ], [ -13, %13 ], [ -13, %19 ], [ -13, %22 ], [ -11, %28 ]
  ret i32 %.0
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

declare i32 @ippsGFpECTstPoint(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

declare ptr @gfec_MulPoint(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

; Function Attrs: mustprogress 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 = { mustprogress 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, !7, i64 0}
!6 = !{!"_cpGFpEC", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 68, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !7, i64 0}
!13 = !{!"_cpGFpECPoint", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!14 = !{!13, !7, i64 8}
!15 = !{!6, !10, i64 8}
!16 = !{!17, !10, i64 8}
!17 = !{!"_cpGFp", !7, i64 0, !7, i64 4, !10, i64 8}
!18 = !{!19, !7, i64 16}
!19 = !{!"_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, !20, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !7, i64 96, !7, i64 100, !10, i64 104}
!20 = !{!"long long", !8, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!6, !10, i64 80}
!23 = !{!19, !10, i64 48}
!24 = !{!6, !7, i64 24}


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