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

; 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._cpHashCtx_rmf = type { i32, ptr, i32, [128 x i8], i64, i64, [8 x i64] }

@computeZa_user_id_hash_sm2.ctx = external hidden global %struct._cpHashCtx_rmf, align 8

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

26:                                               ; preds = %10
  store i32 -8, ptr %11, align 4
  br label %109

27:                                               ; preds = %10
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = icmp eq ptr null, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  store i32 -8, ptr %11, align 4
  br label %109

31:                                               ; preds = %27
  %32 = load i32, ptr %14, align 4, !tbaa !9
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  %35 = load i32, ptr %15, align 4, !tbaa !9
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %34, %31
  store i32 -5, ptr %11, align 4
  br label %109

38:                                               ; preds = %34
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = icmp sgt i32 %39, 8191
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 -5, ptr %11, align 4
  br label %109

42:                                               ; preds = %38
  %43 = load ptr, ptr %16, align 8, !tbaa !5
  %44 = icmp eq ptr null, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %42
  store i32 -8, ptr %11, align 4
  br label %109

46:                                               ; preds = %42
  %47 = load ptr, ptr %17, align 8, !tbaa !5
  %48 = icmp eq ptr null, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %46
  store i32 -8, ptr %11, align 4
  br label %109

50:                                               ; preds = %46
  %51 = load ptr, ptr %18, align 8, !tbaa !5
  %52 = icmp eq ptr null, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  store i32 -8, ptr %11, align 4
  br label %109

54:                                               ; preds = %50
  %55 = load ptr, ptr %19, align 8, !tbaa !5
  %56 = icmp eq ptr null, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  store i32 -8, ptr %11, align 4
  br label %109

58:                                               ; preds = %54
  %59 = load ptr, ptr %20, align 8, !tbaa !5
  %60 = icmp eq ptr null, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %58
  store i32 -8, ptr %11, align 4
  br label %109

62:                                               ; preds = %58
  %63 = load ptr, ptr %21, align 8, !tbaa !5
  %64 = icmp eq ptr null, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %62
  store i32 -8, ptr %11, align 4
  br label %109

66:                                               ; preds = %62
  %67 = call ptr @ippsHashMethod_SM3_TT()
  %68 = call i32 @ippsHashInit_rmf(ptr noundef @computeZa_user_id_hash_sm2.ctx, ptr noundef %67)
  call void @llvm.lifetime.start.p0(i64 2, ptr %22) #4
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = mul nsw i32 %69, 8
  %71 = and i32 %70, 65535
  %72 = trunc i32 %71 to i16
  store i16 %72, ptr %22, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %23) #4
  %73 = load i16, ptr %22, align 2, !tbaa !11
  %74 = zext i16 %73 to i32
  %75 = ashr i32 %74, 8
  %76 = trunc i32 %75 to i8
  %77 = getelementptr inbounds [2 x i8], ptr %23, i64 0, i64 0
  store i8 %76, ptr %77, align 1, !tbaa !13
  %78 = load i16, ptr %22, align 2, !tbaa !11
  %79 = zext i16 %78 to i32
  %80 = and i32 %79, 255
  %81 = trunc i32 %80 to i8
  %82 = getelementptr inbounds [2 x i8], ptr %23, i64 0, i64 1
  store i8 %81, ptr %82, align 1, !tbaa !13
  %83 = getelementptr inbounds [2 x i8], ptr %23, i64 0, i64 0
  %84 = call i32 @ippsHashUpdate_rmf(ptr noundef %83, i32 noundef 2, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = load i32, ptr %14, align 4, !tbaa !9
  %87 = call i32 @ippsHashUpdate_rmf(ptr noundef %85, i32 noundef %86, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %88 = load ptr, ptr %16, align 8, !tbaa !5
  %89 = load i32, ptr %15, align 4, !tbaa !9
  %90 = call i32 @ippsHashUpdate_rmf(ptr noundef %88, i32 noundef %89, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %91 = load ptr, ptr %17, align 8, !tbaa !5
  %92 = load i32, ptr %15, align 4, !tbaa !9
  %93 = call i32 @ippsHashUpdate_rmf(ptr noundef %91, i32 noundef %92, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %94 = load ptr, ptr %18, align 8, !tbaa !5
  %95 = load i32, ptr %15, align 4, !tbaa !9
  %96 = call i32 @ippsHashUpdate_rmf(ptr noundef %94, i32 noundef %95, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %97 = load ptr, ptr %19, align 8, !tbaa !5
  %98 = load i32, ptr %15, align 4, !tbaa !9
  %99 = call i32 @ippsHashUpdate_rmf(ptr noundef %97, i32 noundef %98, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %100 = load ptr, ptr %20, align 8, !tbaa !5
  %101 = load i32, ptr %15, align 4, !tbaa !9
  %102 = call i32 @ippsHashUpdate_rmf(ptr noundef %100, i32 noundef %101, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %103 = load ptr, ptr %21, align 8, !tbaa !5
  %104 = load i32, ptr %15, align 4, !tbaa !9
  %105 = call i32 @ippsHashUpdate_rmf(ptr noundef %103, i32 noundef %104, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = call i32 @ippsHashFinal_rmf(ptr noundef %106, ptr noundef @computeZa_user_id_hash_sm2.ctx)
  %108 = getelementptr inbounds [2 x i8], ptr %23, i64 0, i64 0
  call void @PurgeBlock(ptr noundef %108, i32 noundef 2)
  store i32 0, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %22) #4
  br label %109

109:                                              ; preds = %66, %65, %61, %57, %53, %49, %45, %41, %37, %30, %26
  %110 = load i32, ptr %11, align 4
  ret i32 %110
}

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

declare ptr @ippsHashMethod_SM3_TT() #1

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

declare i32 @ippsHashUpdate_rmf(ptr noundef, i32 noundef, ptr noundef) #1

declare i32 @ippsHashFinal_rmf(ptr noundef, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PurgeBlock(ptr noundef, i32 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 = { "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 = { 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 #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, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!7, !7, i64 0}


; 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._cpHashCtx_rmf = type { i32, ptr, i32, [128 x i8], i64, i64, [8 x i64] }

@computeZa_user_id_hash_sm2.ctx = external hidden global %struct._cpHashCtx_rmf, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 -8, 1) i32 @computeZa_user_id_hash_sm2(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9) local_unnamed_addr #0 {
  %11 = alloca [2 x i8], align 1
  %12 = icmp eq ptr %0, null
  %13 = icmp eq ptr %1, null
  %or.cond40 = or i1 %12, %13
  br i1 %or.cond40, label %44, label %14

14:                                               ; preds = %10
  %15 = icmp slt i32 %3, 1
  %16 = add i32 %2, -8192
  %17 = icmp ult i32 %16, -8191
  %or.cond41 = or i1 %17, %15
  br i1 %or.cond41, label %44, label %18

18:                                               ; preds = %14
  %19 = insertelement <4 x ptr> poison, ptr %4, i64 0
  %20 = insertelement <4 x ptr> %19, ptr %5, i64 1
  %21 = insertelement <4 x ptr> %20, ptr %6, i64 2
  %22 = insertelement <4 x ptr> %21, ptr %7, i64 3
  %23 = icmp eq <4 x ptr> %22, zeroinitializer
  %24 = icmp eq ptr %8, null
  %25 = icmp eq ptr %9, null
  %26 = bitcast <4 x i1> %23 to i4
  %27 = icmp ne i4 %26, 0
  %op.rdx = or i1 %27, %24
  %op.rdx49 = or i1 %op.rdx, %25
  br i1 %op.rdx49, label %44, label %28

28:                                               ; preds = %18
  %29 = tail call ptr @ippsHashMethod_SM3_TT() #4
  %30 = tail call i32 @ippsHashInit_rmf(ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx, ptr noundef %29) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %11) #4
  %31 = lshr i32 %2, 5
  %32 = trunc nuw i32 %31 to i8
  store i8 %32, ptr %11, align 1, !tbaa !5
  %.tr = trunc i32 %2 to i8
  %33 = shl i8 %.tr, 3
  %34 = getelementptr inbounds i8, ptr %11, i64 1
  store i8 %33, ptr %34, align 1, !tbaa !5
  %35 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %11, i32 noundef 2, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %36 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %1, i32 noundef %2, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %37 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %4, i32 noundef %3, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %38 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %5, i32 noundef %3, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %39 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %6, i32 noundef %3, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %40 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %7, i32 noundef %3, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %41 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %8, i32 noundef %3, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %42 = call i32 @ippsHashUpdate_rmf(ptr noundef nonnull %9, i32 noundef %3, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  %43 = call i32 @ippsHashFinal_rmf(ptr noundef nonnull %0, ptr noundef nonnull @computeZa_user_id_hash_sm2.ctx) #4
  call void @PurgeBlock(ptr noundef nonnull %11, i32 noundef 2)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %11) #4
  br label %44

44:                                               ; preds = %18, %14, %10, %28
  %.0 = phi i32 [ 0, %28 ], [ -8, %10 ], [ -5, %14 ], [ -8, %18 ]
  ret i32 %.0
}

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

declare ptr @ippsHashMethod_SM3_TT() 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 @ippsHashUpdate_rmf(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @PurgeBlock(ptr noundef, i32 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 = { "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 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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