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

; 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._cpStateECES_SM2 = type { i32, ptr, i32, i32, i32, [32 x i8], i8, i8, ptr, ptr }

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

6:                                                ; preds = %1
  store i32 -8, ptr %2, align 4
  br label %42

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call i64 @IPP_UINT_PTR(ptr noundef %11)
  %13 = trunc i64 %12 to i32
  %14 = xor i32 %10, %13
  %15 = icmp eq i32 %14, 1129136468
  br i1 %15, label %17, label %16

16:                                               ; preds = %7
  store i32 -13, ptr %2, align 4
  br label %42

17:                                               ; preds = %7
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 4, !tbaa !12
  %21 = icmp ne i32 %20, 1
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  store i32 -13, ptr %2, align 4
  br label %42

23:                                               ; preds = %17
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %24, i32 0, i32 9
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = call ptr @ippsHashMethod_SM3_TT()
  %28 = call i32 @ippsHashInit_rmf(ptr noundef %26, ptr noundef %27)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !15
  %35 = sdiv i32 %34, 2
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %36, i32 0, i32 9
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = call i32 @ippsHashUpdate_rmf(ptr noundef %31, i32 noundef %35, ptr noundef %38)
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %40, i32 0, i32 3
  store i32 2, ptr %41, align 4, !tbaa !12
  store i32 0, ptr %2, align 4
  br label %42

42:                                               ; preds = %23, %22, %16, %6
  %43 = load i32, ptr %2, align 4
  ret i32 %43
}

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

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

declare ptr @ippsHashMethod_SM3_TT() #2

declare i32 @ippsHashUpdate_rmf(ptr noundef, i32 noundef, ptr noundef) #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" }

!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 = !{!"_cpStateECES_SM2", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !7, i64 28, !7, i64 60, !7, i64 61, !6, i64 64, !6, i64 72}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 20}
!13 = !{!10, !6, i64 72}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !11, i64 16}


; 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 @ippsGFpECESStart_SM2(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %24, label %3

3:                                                ; preds = %1
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %0)
  %6 = trunc i64 %5 to i32
  %7 = xor i32 %4, %6
  %8 = icmp eq i32 %7, 1129136468
  br i1 %8, label %9, label %24

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 20
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %.not = icmp eq i32 %11, 1
  br i1 %.not, label %12, label %24

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 72
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = tail call ptr @ippsHashMethod_SM3_TT() #3
  %16 = tail call i32 @ippsHashInit_rmf(ptr noundef %14, ptr noundef %15) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load i32, ptr %19, align 8, !tbaa !14
  %21 = sdiv i32 %20, 2
  %22 = load ptr, ptr %13, align 8, !tbaa !12
  %23 = tail call i32 @ippsHashUpdate_rmf(ptr noundef %18, i32 noundef %21, ptr noundef %22) #3
  store i32 2, ptr %10, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %9, %3, %1, %12
  %.0 = phi i32 [ 0, %12 ], [ -8, %1 ], [ -13, %3 ], [ -13, %9 ]
  ret i32 %.0
}

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

declare i32 @ippsHashInit_rmf(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @ippsHashMethod_SM3_TT() local_unnamed_addr #2

declare i32 @ippsHashUpdate_rmf(ptr noundef, i32 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 = !{!"_cpStateECES_SM2", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !7, i64 24, !8, i64 28, !8, i64 60, !8, i64 61, !10, i64 64, !10, i64 72}
!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 20}
!12 = !{!6, !10, i64 72}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !7, i64 16}


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