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

; 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._cpGFpMethod = type { i32, i32, ptr, ptr, ptr }

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

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

12:                                               ; preds = %3
  %13 = load ptr, ptr %7, align 8, !tbaa !9
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %16

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

16:                                               ; preds = %12
  %17 = load ptr, ptr %6, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct._cpGFpMethod, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = and i32 %19, 4096
  %21 = icmp ne i32 4096, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  store i32 -5, ptr %4, align 4
  br label %52

23:                                               ; preds = %16
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct._cpGFpMethod, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = icmp ne ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %23
  store i32 -5, ptr %4, align 4
  br label %52

29:                                               ; preds = %23
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct._cpGFpMethod, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !14
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = icmp ne i32 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %29
  store i32 -5, ptr %4, align 4
  br label %52

36:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !9
  %39 = call i32 @cpGFpInitGFp(i32 noundef %37, ptr noundef %38)
  store i32 %39, ptr %8, align 4, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = icmp eq i32 0, %40
  br i1 %41, label %42, label %50

42:                                               ; preds = %36
  %43 = load ptr, ptr %6, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct._cpGFpMethod, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = load ptr, ptr %7, align 8, !tbaa !9
  %49 = call i32 @cpGFpSetGFp(ptr noundef %45, i32 noundef %46, ptr noundef %47, ptr noundef %48)
  br label %50

50:                                               ; preds = %42, %36
  %51 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %51, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %52

52:                                               ; preds = %50, %35, %28, %22, %15, %11
  %53 = load i32, ptr %4, align 4
  ret i32 %53
}

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

declare i32 @cpGFpInitGFp(i32 noundef, ptr noundef) #2

declare i32 @cpGFpSetGFp(ptr noundef, i32 noundef, ptr noundef, ptr 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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_cpGFpMethod", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !6, i64 4}


; 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 i32 @ippsGFpInitFixed(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %1, null
  %5 = icmp eq ptr %2, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %21, label %6

6:                                                ; preds = %3
  %7 = load i32, ptr %1, align 8, !tbaa !5
  %8 = and i32 %7, 4096
  %.not.not = icmp eq i32 %8, 0
  br i1 %.not.not, label %21, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %21, label %12

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %.not17 = icmp eq i32 %14, %0
  br i1 %.not17, label %15, label %21

15:                                               ; preds = %12
  %16 = tail call i32 @cpGFpInitGFp(i32 noundef %0, ptr noundef nonnull %2) #2
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = load ptr, ptr %10, align 8, !tbaa !11
  %20 = tail call i32 @cpGFpSetGFp(ptr noundef %19, i32 noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %2) #2
  br label %21

21:                                               ; preds = %15, %18, %12, %9, %6, %3
  %.0 = phi i32 [ -8, %3 ], [ -5, %6 ], [ -5, %9 ], [ -5, %12 ], [ 0, %18 ], [ %16, %15 ]
  ret i32 %.0
}

declare i32 @cpGFpInitGFp(i32 noundef, ptr noundef) local_unnamed_addr #1

declare i32 @cpGFpSetGFp(ptr noundef, i32 noundef, ptr noundef, ptr 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 = { "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 = { 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 = !{!"_cpGFpMethod", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 4}


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