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

; 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._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 void @InitGFpxCtx(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._cpGFp, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %16, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._gsModEngine, ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = mul nsw i32 %17, %20
  store i32 %21, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._gsModEngine, ptr %23, i32 0, i32 4
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = mul nsw i32 %22, %25
  store i32 %26, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  store ptr %28, ptr %12, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = call i64 @IPP_UINT_PTR(ptr noundef %29)
  %31 = trunc i64 %30 to i32
  %32 = xor i32 1129136455, %31
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._cpGFp, ptr %33, i32 0, i32 0
  store i32 %32, ptr %34, align 8, !tbaa !17
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._cpGFp, ptr %36, i32 0, i32 2
  store ptr %35, ptr %37, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._cpGFp, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  store ptr %40, ptr %13, align 8, !tbaa !5
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  call void @PadBlock(i8 noundef zeroext 0, ptr noundef %41, i32 noundef 112)
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 112
  store ptr %43, ptr %12, align 8, !tbaa !5
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %13, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._gsModEngine, ptr %45, i32 0, i32 0
  store ptr %44, ptr %46, align 8, !tbaa !18
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._gsModEngine, ptr %48, i32 0, i32 1
  store i32 %47, ptr %49, align 8, !tbaa !19
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._gsModEngine, ptr %50, i32 0, i32 2
  store i32 0, ptr %51, align 4, !tbaa !20
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._gsModEngine, ptr %53, i32 0, i32 3
  store i32 %52, ptr %54, align 8, !tbaa !13
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._gsModEngine, ptr %56, i32 0, i32 4
  store i32 %55, ptr %57, align 4, !tbaa !16
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._gsModEngine, ptr %59, i32 0, i32 5
  store i32 %58, ptr %60, align 8, !tbaa !21
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._cpGFpMethod, ptr %61, i32 0, i32 3
  %63 = load ptr, ptr %62, align 8, !tbaa !22
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._gsModEngine, ptr %64, i32 0, i32 6
  store ptr %63, ptr %65, align 8, !tbaa !24
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._gsModEngine, ptr %67, i32 0, i32 8
  store ptr %66, ptr %68, align 8, !tbaa !25
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = mul nsw i32 %69, 8
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = sext i32 %70 to i64
  %73 = getelementptr inbounds i8, ptr %71, i64 %72
  store ptr %73, ptr %12, align 8, !tbaa !5
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = load ptr, ptr %13, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._gsModEngine, ptr %75, i32 0, i32 16
  store ptr %74, ptr %76, align 8, !tbaa !26
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._gsModEngine, ptr %77, i32 0, i32 15
  store i32 14, ptr %78, align 4, !tbaa !27
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._gsModEngine, ptr %79, i32 0, i32 14
  store i32 0, ptr %80, align 8, !tbaa !28
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._gsModEngine, ptr %81, i32 0, i32 8
  %83 = load ptr, ptr %82, align 8, !tbaa !25
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = call ptr @cpGFpElementPad(ptr noundef %83, i32 noundef %84, i64 noundef 0)
  call void @llvm.lifetime.end.p0(i64 8, 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 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PadBlock(i8 noundef zeroext, ptr noundef, i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementPad(ptr noundef, i32 noundef, i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_cpGFp", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!14, !10, i64 16}
!14 = !{!"_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, !15, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !6, i64 104}
!15 = !{!"long long", !7, i64 0}
!16 = !{!14, !10, i64 20}
!17 = !{!12, !10, i64 0}
!18 = !{!14, !6, i64 0}
!19 = !{!14, !10, i64 8}
!20 = !{!14, !10, i64 12}
!21 = !{!14, !10, i64 24}
!22 = !{!23, !6, i64 16}
!23 = !{!"_cpGFpMethod", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24}
!24 = !{!14, !6, i64 32}
!25 = !{!14, !6, i64 48}
!26 = !{!14, !6, i64 104}
!27 = !{!14, !10, i64 100}
!28 = !{!14, !10, i64 96}


; 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 void @InitGFpxCtx(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = mul nsw i32 %8, %1
  %10 = getelementptr inbounds i8, ptr %6, i64 20
  %11 = load i32, ptr %10, align 4, !tbaa !14
  %12 = mul nsw i32 %11, %1
  %13 = getelementptr inbounds i8, ptr %3, i64 16
  %14 = tail call i64 @IPP_UINT_PTR(ptr noundef %3)
  %15 = trunc i64 %14 to i32
  %16 = xor i32 %15, 1129136455
  store i32 %16, ptr %3, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %13, ptr %17, align 8, !tbaa !5
  tail call void @PadBlock(i8 noundef zeroext 0, ptr noundef nonnull %13, i32 noundef 112)
  %18 = getelementptr inbounds i8, ptr %3, i64 128
  store ptr %6, ptr %13, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %1, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %3, i64 28
  store i32 0, ptr %20, align 4, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %3, i64 32
  store i32 %9, ptr %21, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %3, i64 36
  store i32 %12, ptr %22, align 4, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %3, i64 40
  store i32 %9, ptr %23, align 8, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %2, i64 16
  %25 = load ptr, ptr %24, align 8, !tbaa !20
  %26 = getelementptr inbounds i8, ptr %3, i64 48
  store ptr %25, ptr %26, align 8, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %3, i64 64
  store ptr %18, ptr %27, align 8, !tbaa !23
  %28 = shl nsw i32 %9, 3
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %18, i64 %29
  %31 = getelementptr inbounds i8, ptr %3, i64 120
  store ptr %30, ptr %31, align 8, !tbaa !24
  %32 = getelementptr inbounds i8, ptr %3, i64 116
  store i32 14, ptr %32, align 4, !tbaa !25
  %33 = getelementptr inbounds i8, ptr %3, i64 112
  store i32 0, ptr %33, align 8, !tbaa !26
  %34 = tail call ptr @cpGFpElementPad(ptr noundef nonnull %18, i32 noundef %9, i64 noundef 0)
  ret void
}

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

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass