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

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

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

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

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

21:                                               ; preds = %17
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp eq ptr null, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  store i32 -8, ptr %6, align 4
  br label %106

25:                                               ; preds = %21
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = icmp eq ptr null, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store i32 -8, ptr %6, align 4
  br label %106

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

38:                                               ; preds = %29
  store i32 -13, ptr %6, align 4
  br label %106

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

48:                                               ; preds = %39
  store i32 -13, ptr %6, align 4
  br label %106

49:                                               ; preds = %39
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._cpGFpElement, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !12
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = call i64 @IPP_UINT_PTR(ptr noundef %53)
  %55 = trunc i64 %54 to i32
  %56 = xor i32 %52, %55
  %57 = icmp eq i32 %56, 1129136456
  br i1 %57, label %59, label %58

58:                                               ; preds = %49
  store i32 -13, ptr %6, align 4
  br label %106

59:                                               ; preds = %49
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._cpBigNum, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !14
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = call i64 @IPP_UINT_PTR(ptr noundef %63)
  %65 = trunc i64 %64 to i32
  %66 = xor i32 %62, %65
  %67 = icmp eq i32 %66, 1112098638
  br i1 %67, label %69, label %68

68:                                               ; preds = %59
  store i32 -13, ptr %6, align 4
  br label %106

69:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._cpGFp, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !16
  store ptr %72, ptr %12, align 8, !tbaa !5
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._cpGFpElement, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !17
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._gsModEngine, ptr %76, i32 0, i32 3
  %78 = load i32, ptr %77, align 8, !tbaa !18
  %79 = icmp ne i32 %75, %78
  br i1 %79, label %88, label %80

80:                                               ; preds = %69
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._cpGFpElement, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !17
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._gsModEngine, ptr %84, i32 0, i32 3
  %86 = load i32, ptr %85, align 8, !tbaa !18
  %87 = icmp ne i32 %83, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %80, %69
  store i32 -11, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %105

89:                                               ; preds = %80
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._cpGFpElement, ptr %90, i32 0, i32 2
  %92 = load ptr, ptr %91, align 8, !tbaa !21
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._cpGFpElement, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !21
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct._cpBigNum, ptr %96, i32 0, i32 4
  %98 = load ptr, ptr %97, align 8, !tbaa !22
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct._cpBigNum, ptr %99, i32 0, i32 2
  %101 = load i32, ptr %100, align 8, !tbaa !23
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  %104 = call ptr @cpGFpxExp(ptr noundef %92, ptr noundef %95, ptr noundef %98, i32 noundef %101, ptr noundef %102, ptr noundef %103)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %105

105:                                              ; preds = %89, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %106

106:                                              ; preds = %105, %68, %58, %48, %38, %28, %24, %20, %16
  %107 = load i32, ptr %6, align 4
  ret i32 %107
}

; 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 ptr @cpGFpxExp(ptr noundef, ptr noundef, ptr noundef, i32 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 = !{!15, !11, i64 0}
!15 = !{!"_cpBigNum", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24}
!16 = !{!10, !6, i64 8}
!17 = !{!13, !11, i64 4}
!18 = !{!19, !11, i64 16}
!19 = !{!"_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, !20, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !6, i64 104}
!20 = !{!"long long", !7, i64 0}
!21 = !{!13, !6, i64 8}
!22 = !{!15, !6, i64 16}
!23 = !{!15, !11, 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 @ippsGFpExp(ptr noundef %0, ptr 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 %1, 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
  %.not31 = icmp eq i4 %11, 0
  br i1 %.not31, label %12, label %56

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

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

24:                                               ; preds = %18
  %25 = load i32, ptr %2, align 8, !tbaa !11
  %26 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %2)
  %27 = trunc i64 %26 to i32
  %28 = xor i32 %25, %27
  %29 = icmp eq i32 %28, 1129136456
  br i1 %29, label %30, label %56

30:                                               ; preds = %24
  %31 = load i32, ptr %1, align 8, !tbaa !13
  %32 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %1)
  %33 = trunc i64 %32 to i32
  %34 = xor i32 %31, %33
  %35 = icmp eq i32 %34, 1112098638
  br i1 %35, label %36, label %56

36:                                               ; preds = %30
  %37 = getelementptr inbounds i8, ptr %3, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %0, i64 4
  %40 = load i32, ptr %39, align 4, !tbaa !16
  %41 = getelementptr inbounds i8, ptr %38, i64 16
  %42 = load i32, ptr %41, align 8, !tbaa !17
  %.not = icmp eq i32 %40, %42
  br i1 %.not, label %43, label %56

43:                                               ; preds = %36
  %44 = getelementptr inbounds i8, ptr %2, i64 4
  %45 = load i32, ptr %44, align 4, !tbaa !16
  %.not28 = icmp eq i32 %45, %40
  br i1 %.not28, label %46, label %56

46:                                               ; preds = %43
  %47 = getelementptr inbounds i8, ptr %2, i64 8
  %48 = load ptr, ptr %47, align 8, !tbaa !20
  %49 = getelementptr inbounds i8, ptr %0, i64 8
  %50 = load ptr, ptr %49, align 8, !tbaa !20
  %51 = getelementptr inbounds i8, ptr %1, i64 16
  %52 = load ptr, ptr %51, align 8, !tbaa !21
  %53 = getelementptr inbounds i8, ptr %1, i64 8
  %54 = load i32, ptr %53, align 8, !tbaa !22
  %55 = tail call ptr @cpGFpxExp(ptr noundef %48, ptr noundef %50, ptr noundef %52, i32 noundef %54, ptr noundef nonnull %38, ptr noundef %4) #3
  br label %56

56:                                               ; preds = %46, %43, %36, %30, %24, %18, %12, %5
  %.1 = phi i32 [ -8, %5 ], [ -13, %12 ], [ -13, %18 ], [ -13, %24 ], [ -13, %30 ], [ 0, %46 ], [ -11, %43 ], [ -11, %36 ]
  ret i32 %.1
}

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

declare ptr @cpGFpxExp(ptr noundef, ptr noundef, ptr noundef, i32 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 = !{!14, !7, i64 0}
!14 = !{!"_cpBigNum", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!15 = !{!6, !10, i64 8}
!16 = !{!12, !7, i64 4}
!17 = !{!18, !7, i64 16}
!18 = !{!"_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, !19, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !7, i64 96, !7, i64 100, !10, i64 104}
!19 = !{!"long long", !8, i64 0}
!20 = !{!12, !10, i64 8}
!21 = !{!14, !10, i64 16}
!22 = !{!14, !7, i64 8}


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