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

; 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._cpHashAttr = type { i32, i32, i32, i32, [2 x i64] }
%struct._cpGFp = type { i32, i32, ptr }
%struct._cpGFpElement = type { i32, i32, ptr }
%struct._gsModEngine = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr, i32, i32, ptr }

@cpHashAlgAttr = external constant [0 x %struct._cpHashAttr], align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsGFpSetElementHash(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca [64 x i8], align 16
  %15 = alloca [9 x i64], align 16
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = call i32 @cpValidHashAlg(i32 noundef %20)
  store i32 %21, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = icmp eq i32 0, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %5
  store i32 -14, ptr %6, align 4
  br label %120

25:                                               ; preds = %5
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %28, label %29

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

29:                                               ; preds = %25
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %29
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 -8, ptr %6, align 4
  br label %120

36:                                               ; preds = %32, %29
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = icmp eq ptr null, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  store i32 -8, ptr %6, align 4
  br label %120

40:                                               ; preds = %36
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = icmp eq ptr null, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %40
  store i32 -8, ptr %6, align 4
  br label %120

44:                                               ; preds = %40
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._cpGFp, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !11
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = call i64 @IPP_UINT_PTR(ptr noundef %48)
  %50 = trunc i64 %49 to i32
  %51 = xor i32 %47, %50
  %52 = icmp eq i32 %51, 1129136455
  br i1 %52, label %54, label %53

53:                                               ; preds = %44
  store i32 -13, ptr %6, align 4
  br label %120

54:                                               ; preds = %44
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._cpGFpElement, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !13
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = call i64 @IPP_UINT_PTR(ptr noundef %58)
  %60 = trunc i64 %59 to i32
  %61 = xor i32 %57, %60
  %62 = icmp eq i32 %61, 1129136456
  br i1 %62, label %64, label %63

63:                                               ; preds = %54
  store i32 -13, ptr %6, align 4
  br label %120

64:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._cpGFp, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  store ptr %67, ptr %12, align 8, !tbaa !5
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._gsModEngine, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !16
  %71 = icmp eq ptr %70, null
  br i1 %71, label %73, label %72

72:                                               ; preds = %64
  store i32 -5, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %119

73:                                               ; preds = %64
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._cpGFpElement, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !19
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._gsModEngine, ptr %77, i32 0, i32 3
  %79 = load i32, ptr %78, align 8, !tbaa !20
  %80 = icmp ne i32 %76, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %73
  store i32 -11, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %119

82:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 64, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 72, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = load i32, ptr %8, align 4, !tbaa !9
  %85 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = call i32 @ippsHashMessage(ptr noundef %83, i32 noundef %84, ptr noundef %85, i32 noundef %86)
  store i32 %87, ptr %16, align 4, !tbaa !9
  %88 = load i32, ptr %16, align 4, !tbaa !9
  %89 = icmp eq i32 0, %88
  br i1 %89, label %90, label %117

90:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._gsModEngine, ptr %91, i32 0, i32 3
  %93 = load i32, ptr %92, align 8, !tbaa !20
  store i32 %93, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %94 = load i32, ptr %11, align 4, !tbaa !9
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds [0 x %struct._cpHashAttr], ptr @cpHashAlgAttr, i64 0, i64 %95
  %97 = getelementptr inbounds %struct._cpHashAttr, ptr %96, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !21
  store i32 %98, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %99 = getelementptr inbounds [9 x i64], ptr %15, i64 0, i64 0
  %100 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  %101 = load i32, ptr %18, align 4, !tbaa !9
  %102 = call i32 @cpFromOctStr_BNU(ptr noundef %99, ptr noundef %100, i32 noundef %101)
  store i32 %102, ptr %19, align 4, !tbaa !9
  %103 = getelementptr inbounds [9 x i64], ptr %15, i64 0, i64 0
  %104 = load i32, ptr %19, align 4, !tbaa !9
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct._gsModEngine, ptr %105, i32 0, i32 8
  %107 = load ptr, ptr %106, align 8, !tbaa !23
  %108 = load i32, ptr %17, align 4, !tbaa !9
  %109 = call i32 @cpMod_BNU(ptr noundef %103, i32 noundef %104, ptr noundef %107, i32 noundef %108)
  store i32 %109, ptr %19, align 4, !tbaa !9
  %110 = load ptr, ptr %9, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct._cpGFpElement, ptr %110, i32 0, i32 2
  %112 = load ptr, ptr %111, align 8, !tbaa !24
  %113 = getelementptr inbounds [9 x i64], ptr %15, i64 0, i64 0
  %114 = load i32, ptr %19, align 4, !tbaa !9
  %115 = load ptr, ptr %12, align 8, !tbaa !5
  %116 = call ptr @cpGFpSet(ptr noundef %112, ptr noundef %113, i32 noundef %114, ptr noundef %115)
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %117

117:                                              ; preds = %90, %82
  %118 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %118, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %14) #4
  br label %119

119:                                              ; preds = %117, %81, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %120

120:                                              ; preds = %119, %63, %53, %43, %39, %35, %28, %24
  %121 = load i32, ptr %6, align 4
  ret i32 %121
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpValidHashAlg(i32 noundef) #1

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpMod_BNU(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #1

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

%struct._cpHashAttr = type { i32, i32, i32, i32, [2 x i64] }

@cpHashAlgAttr = external local_unnamed_addr constant [0 x %struct._cpHashAttr], align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @ippsGFpSetElementHash(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca [64 x i8], align 16
  %7 = alloca [9 x i64], align 16
  %8 = tail call i32 @cpValidHashAlg(i32 noundef %4)
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %55, label %10

10:                                               ; preds = %5
  %11 = icmp slt i32 %1, 0
  br i1 %11, label %55, label %12

12:                                               ; preds = %10
  %13 = icmp ne i32 %1, 0
  %14 = icmp eq ptr %0, null
  %or.cond.not38 = and i1 %14, %13
  %15 = icmp eq ptr %2, null
  %or.cond34 = or i1 %or.cond.not38, %15
  %16 = icmp eq ptr %3, null
  %or.cond35 = or i1 %or.cond34, %16
  br i1 %or.cond35, label %55, label %17

17:                                               ; preds = %12
  %18 = load i32, ptr %3, align 8, !tbaa !5
  %19 = tail call i64 @IPP_UINT_PTR(ptr noundef nonnull %3)
  %20 = trunc i64 %19 to i32
  %21 = xor i32 %18, %20
  %22 = icmp eq i32 %21, 1129136455
  br i1 %22, label %23, label %55

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

29:                                               ; preds = %23
  %30 = getelementptr inbounds i8, ptr %3, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %55

34:                                               ; preds = %29
  %35 = getelementptr inbounds i8, ptr %2, i64 4
  %36 = load i32, ptr %35, align 4, !tbaa !17
  %37 = getelementptr inbounds i8, ptr %31, i64 16
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %.not = icmp eq i32 %36, %38
  br i1 %.not, label %39, label %55

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %7) #4
  %40 = call i32 @ippsHashMessage(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %6, i32 noundef %8) #4
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %54

42:                                               ; preds = %39
  %43 = load i32, ptr %37, align 8, !tbaa !18
  %44 = zext i32 %8 to i64
  %45 = getelementptr inbounds [0 x %struct._cpHashAttr], ptr @cpHashAlgAttr, i64 0, i64 %44, i32 1
  %46 = load i32, ptr %45, align 4, !tbaa !19
  %47 = call i32 @cpFromOctStr_BNU(ptr noundef nonnull %7, ptr noundef nonnull %6, i32 noundef %46) #4
  %48 = getelementptr inbounds i8, ptr %31, i64 48
  %49 = load ptr, ptr %48, align 8, !tbaa !21
  %50 = call i32 @cpMod_BNU(ptr noundef nonnull %7, i32 noundef %47, ptr noundef %49, i32 noundef %43)
  %51 = getelementptr inbounds i8, ptr %2, i64 8
  %52 = load ptr, ptr %51, align 8, !tbaa !22
  %53 = call ptr @cpGFpSet(ptr noundef %52, ptr noundef nonnull %7, i32 noundef %50, ptr noundef nonnull %31) #4
  br label %54

54:                                               ; preds = %42, %39
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #4
  br label %55

55:                                               ; preds = %54, %29, %34, %23, %17, %12, %10, %5
  %.1 = phi i32 [ -14, %5 ], [ -15, %10 ], [ -8, %12 ], [ -13, %17 ], [ -13, %23 ], [ %40, %54 ], [ -5, %29 ], [ -11, %34 ]
  ret i32 %.1
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpValidHashAlg(i32 noundef) local_unnamed_addr #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 @ippsHashMessage(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpMod_BNU(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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


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