; LLVM IR from china-hai/yd_crypto :: src/sm3 (yd_sm3)

; 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"

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @yd_sm3(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca [64 x i8], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [68 x i32], align 16
  %13 = alloca [64 x i32], align 16
  %14 = alloca [8 x i32], align 16
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 64, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 272, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 256, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #2
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp ugt i32 %16, 536870911
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %15, align 4
  br label %87

19:                                               ; preds = %3
  %20 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %20, ptr %11, align 4, !tbaa !9
  %21 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  store i32 1937774191, ptr %21, align 16, !tbaa !9
  %22 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 1
  store i32 1226093241, ptr %22, align 4, !tbaa !9
  %23 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 2
  store i32 388252375, ptr %23, align 8, !tbaa !9
  %24 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 3
  store i32 -628488704, ptr %24, align 4, !tbaa !9
  %25 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 4
  store i32 -1452330820, ptr %25, align 16, !tbaa !9
  %26 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 5
  store i32 372324522, ptr %26, align 4, !tbaa !9
  %27 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 6
  store i32 -477237683, ptr %27, align 8, !tbaa !9
  %28 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 7
  store i32 -1325724082, ptr %28, align 4, !tbaa !9
  store i8 1, ptr %8, align 1, !tbaa !11
  br label %29

29:                                               ; preds = %47, %19
  %30 = load i8, ptr %8, align 1, !tbaa !11
  %31 = zext i8 %30 to i32
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %54

33:                                               ; preds = %29
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = sub i32 %34, %35
  store i32 %36, ptr %10, align 4, !tbaa !9
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %37, i64 %39
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %43 = call zeroext i1 @padding_bits(ptr noundef %40, i32 noundef %41, ptr noundef %11, ptr noundef %42)
  %44 = zext i1 %43 to i32
  %45 = icmp eq i32 1, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %33
  store i8 0, ptr %8, align 1, !tbaa !11
  br label %47

47:                                               ; preds = %46, %33
  %48 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %49 = getelementptr inbounds [68 x i32], ptr %12, i64 0, i64 0
  %50 = getelementptr inbounds [64 x i32], ptr %13, i64 0, i64 0
  call void @prepare_w(ptr noundef %48, ptr noundef %49, ptr noundef %50)
  %51 = getelementptr inbounds [68 x i32], ptr %12, i64 0, i64 0
  %52 = getelementptr inbounds [64 x i32], ptr %13, i64 0, i64 0
  %53 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  call void @compute_sm3_value(ptr noundef %51, ptr noundef %52, ptr noundef %53)
  br label %29, !llvm.loop !12

54:                                               ; preds = %29
  %55 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 0
  %56 = load i32, ptr %55, align 16, !tbaa !9
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds i32, ptr %57, i64 0
  store i32 %56, ptr %58, align 4, !tbaa !9
  %59 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 1
  %60 = load i32, ptr %59, align 4, !tbaa !9
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds i32, ptr %61, i64 1
  store i32 %60, ptr %62, align 4, !tbaa !9
  %63 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 2
  %64 = load i32, ptr %63, align 8, !tbaa !9
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds i32, ptr %65, i64 2
  store i32 %64, ptr %66, align 4, !tbaa !9
  %67 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 3
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds i32, ptr %69, i64 3
  store i32 %68, ptr %70, align 4, !tbaa !9
  %71 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 4
  %72 = load i32, ptr %71, align 16, !tbaa !9
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds i32, ptr %73, i64 4
  store i32 %72, ptr %74, align 4, !tbaa !9
  %75 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 5
  %76 = load i32, ptr %75, align 4, !tbaa !9
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds i32, ptr %77, i64 5
  store i32 %76, ptr %78, align 4, !tbaa !9
  %79 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 6
  %80 = load i32, ptr %79, align 8, !tbaa !9
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds i32, ptr %81, i64 6
  store i32 %80, ptr %82, align 4, !tbaa !9
  %83 = getelementptr inbounds [8 x i32], ptr %14, i64 0, i64 7
  %84 = load i32, ptr %83, align 4, !tbaa !9
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = getelementptr inbounds i32, ptr %85, i64 7
  store i32 %84, ptr %86, align 4, !tbaa !9
  store i1 true, ptr %4, align 1
  store i32 1, ptr %15, align 4
  br label %87

87:                                               ; preds = %54, %18
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 256, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 272, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 64, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  %88 = load i1, ptr %4, align 1
  ret i1 %88
}

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @padding_bits(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @prepare_w(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @compute_sm3_value(ptr noundef, ptr noundef, ptr noundef) #0

; 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 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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 noundef zeroext i1 @yd_sm3(ptr noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = alloca [64 x i8], align 16
  %5 = alloca i32, align 4
  %6 = alloca [68 x i32], align 16
  %7 = alloca [64 x i32], align 16
  %8 = alloca [8 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 272, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %7) #2
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #2
  %9 = icmp ult i32 %1, 536870912
  br i1 %9, label %.critedge, label %20

.critedge:                                        ; preds = %3
  store i32 %1, ptr %5, align 4, !tbaa !5
  store <4 x i32> <i32 1937774191, i32 1226093241, i32 388252375, i32 -628488704>, ptr %8, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %8, i64 16
  store <4 x i32> <i32 -1452330820, i32 372324522, i32 -477237683, i32 -1325724082>, ptr %10, align 16, !tbaa !5
  br label %select.unfold

select.unfold:                                    ; preds = %.critedge, %select.unfold
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = sub i32 %1, %11
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %0, i64 %13
  %15 = call zeroext i1 @padding_bits(ptr noundef %14, i32 noundef %1, ptr noundef nonnull %5, ptr noundef nonnull %4)
  call void @prepare_w(ptr noundef nonnull %4, ptr noundef nonnull %6, ptr noundef nonnull %7)
  call void @compute_sm3_value(ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8)
  br i1 %15, label %16, label %select.unfold

16:                                               ; preds = %select.unfold
  %17 = load <4 x i32>, ptr %8, align 16, !tbaa !5
  store <4 x i32> %17, ptr %2, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %2, i64 16
  %19 = load <4 x i32>, ptr %10, align 16, !tbaa !5
  store <4 x i32> %19, ptr %18, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %3, %16
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #2
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 272, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #2
  ret i1 %9
}

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @padding_bits(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @prepare_w(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @compute_sm3_value(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass