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

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

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

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

14:                                               ; preds = %3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr null, %15
  br i1 %16, label %17, label %18

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

18:                                               ; preds = %14
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._cpGFpEC, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call i64 @IPP_UINT_PTR(ptr noundef %22)
  %24 = trunc i64 %23 to i32
  %25 = xor i32 %21, %24
  %26 = icmp eq i32 %25, 1129136461
  br i1 %26, label %28, label %27

27:                                               ; preds = %18
  store i32 -13, ptr %4, align 4
  br label %104

28:                                               ; preds = %18
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._cpGFpEC, ptr %29, i32 0, i32 3
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  store i32 -13, ptr %4, align 4
  br label %104

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._cpGFpEC, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds %struct._cpGFp, ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = getelementptr inbounds %struct._gsModEngine, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !17
  %42 = icmp slt i32 1, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %34
  store i32 -14, ptr %4, align 4
  br label %104

44:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call i32 @ippsGFpECESGetSize_SM2(ptr noundef %45, ptr noundef %8)
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  store i32 -6, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %103

51:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %52 = call i32 @ippsHashGetSize_rmf(ptr noundef %10)
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = call i64 @IPP_UINT_PTR(ptr noundef %53)
  %55 = trunc i64 %54 to i32
  %56 = xor i32 1129136468, %55
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %57, i32 0, i32 0
  store i32 %56, ptr %58, align 8, !tbaa !20
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._cpGFpEC, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = getelementptr inbounds %struct._cpGFp, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = getelementptr inbounds %struct._gsModEngine, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !22
  %66 = add nsw i32 %65, 7
  %67 = ashr i32 %66, 3
  %68 = mul nsw i32 %67, 2
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %69, i32 0, i32 2
  store i32 %68, ptr %70, align 8, !tbaa !23
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %71, i64 80
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %73, i32 0, i32 1
  store ptr %72, ptr %74, align 8, !tbaa !24
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i64 80
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %77, i32 0, i32 2
  %79 = load i32, ptr %78, align 8, !tbaa !23
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds i8, ptr %76, i64 %80
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %82, i32 0, i32 8
  store ptr %81, ptr %83, align 8, !tbaa !25
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %84, i64 80
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %86, i32 0, i32 2
  %88 = load i32, ptr %87, align 8, !tbaa !23
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i8, ptr %85, i64 %89
  %91 = load i32, ptr %10, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i8, ptr %90, i64 %92
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %94, i32 0, i32 9
  store ptr %93, ptr %95, align 8, !tbaa !26
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %96, i32 0, i32 8
  %98 = load ptr, ptr %97, align 8, !tbaa !25
  %99 = call ptr @ippsHashMethod_SM3_TT()
  %100 = call i32 @ippsHashInit_rmf(ptr noundef %98, ptr noundef %99)
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._cpStateECES_SM2, ptr %101, i32 0, i32 3
  store i32 0, ptr %102, align 4, !tbaa !27
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %103

103:                                              ; preds = %51, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %104

104:                                              ; preds = %103, %43, %33, %27, %17, %13
  %105 = load i32, ptr %4, align 4
  ret i32 %105
}

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

declare i32 @ippsHashGetSize_rmf(ptr noundef) #3

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

declare ptr @ippsHashMethod_SM3_TT() #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_cpGFpEC", !10, i64 0, !10, i64 4, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, 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}
!13 = !{!12, !10, i64 16}
!14 = !{!12, !6, i64 8}
!15 = !{!16, !6, i64 8}
!16 = !{!"_cpGFp", !10, i64 0, !10, i64 4, !6, i64 8}
!17 = !{!18, !10, i64 8}
!18 = !{!"_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, !19, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !6, i64 104}
!19 = !{!"long long", !7, i64 0}
!20 = !{!21, !10, i64 0}
!21 = !{!"_cpStateECES_SM2", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !7, i64 60, !7, i64 61, !6, i64 64, !6, i64 72}
!22 = !{!18, !10, i64 12}
!23 = !{!21, !10, i64 16}
!24 = !{!21, !6, i64 8}
!25 = !{!21, !6, i64 64}
!26 = !{!21, !6, i64 72}
!27 = !{!21, !10, i64 20}


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

8:                                                ; preds = %3
  %9 = load i32, ptr %0, align 8, !tbaa !5
  %10 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %0)
  %11 = trunc i64 %10 to i32
  %12 = xor i32 %9, %11
  %13 = icmp eq i32 %12, 1129136461
  br i1 %13, label %14, label %56

14:                                               ; preds = %8
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %56, label %17

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = icmp sgt i32 %23, 1
  br i1 %24, label %56, label %25

25:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %26 = call i32 @ippsGFpECESGetSize_SM2(ptr noundef nonnull %0, ptr noundef nonnull %4) #4
  %27 = load i32, ptr %4, align 4, !tbaa !18
  %28 = icmp sgt i32 %27, %2
  br i1 %28, label %55, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %30 = call i32 @ippsHashGetSize_rmf(ptr noundef nonnull %5) #4
  %31 = call i64 @IPP_UINT_PTR(ptr noundef nonnull %1)
  %32 = trunc i64 %31 to i32
  %33 = xor i32 %32, 1129136468
  store i32 %33, ptr %1, align 8, !tbaa !19
  %34 = load ptr, ptr %18, align 8, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %36, i64 12
  %38 = load i32, ptr %37, align 4, !tbaa !21
  %39 = add nsw i32 %38, 7
  %40 = ashr i32 %39, 2
  %41 = and i32 %40, -2
  %42 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %41, ptr %42, align 8, !tbaa !22
  %43 = getelementptr inbounds i8, ptr %1, i64 80
  %44 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %43, ptr %44, align 8, !tbaa !23
  %45 = sext i32 %41 to i64
  %46 = getelementptr inbounds i8, ptr %43, i64 %45
  %47 = getelementptr inbounds i8, ptr %1, i64 64
  store ptr %46, ptr %47, align 8, !tbaa !24
  %48 = load i32, ptr %5, align 4, !tbaa !18
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %46, i64 %49
  %51 = getelementptr inbounds i8, ptr %1, i64 72
  store ptr %50, ptr %51, align 8, !tbaa !25
  %52 = call ptr @ippsHashMethod_SM3_TT() #4
  %53 = call i32 @ippsHashInit_rmf(ptr noundef nonnull %46, ptr noundef %52) #4
  %54 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 0, ptr %54, align 4, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  br label %55

55:                                               ; preds = %25, %29
  %.0 = phi i32 [ 0, %29 ], [ -6, %25 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %56

56:                                               ; preds = %17, %14, %8, %3, %55
  %.1 = phi i32 [ %.0, %55 ], [ -8, %3 ], [ -13, %8 ], [ -13, %14 ], [ -14, %17 ]
  ret i32 %.1
}

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

declare i32 @ippsHashGetSize_rmf(ptr noundef) local_unnamed_addr #3

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

declare ptr @ippsHashMethod_SM3_TT() local_unnamed_addr #3

; 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 = !{!6, !10, i64 8}
!13 = !{!14, !10, i64 8}
!14 = !{!"_cpGFp", !7, i64 0, !7, i64 4, !10, i64 8}
!15 = !{!16, !7, i64 8}
!16 = !{!"_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, !17, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !7, i64 96, !7, i64 100, !10, i64 104}
!17 = !{!"long long", !8, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !7, i64 0}
!20 = !{!"_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}
!21 = !{!16, !7, i64 12}
!22 = !{!20, !7, i64 16}
!23 = !{!20, !10, i64 8}
!24 = !{!20, !10, i64 64}
!25 = !{!20, !10, i64 72}
!26 = !{!20, !7, i64 20}


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