; LLVM IR from china-hai/yd_crypto :: src/hash (yd_sha1)

; 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_sha1(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 [80 x i32], align 16
  %13 = alloca [5 x i32], align 16
  %14 = 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 320, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 20, ptr %13) #2
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp ugt i32 %15, 536870911
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %69

18:                                               ; preds = %3
  %19 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %19, ptr %11, align 4, !tbaa !9
  %20 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 0
  store i32 1732584193, ptr %20, align 16, !tbaa !9
  %21 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 1
  store i32 -271733879, ptr %21, align 4, !tbaa !9
  %22 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 2
  store i32 -1732584194, ptr %22, align 8, !tbaa !9
  %23 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 3
  store i32 271733878, ptr %23, align 4, !tbaa !9
  %24 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 4
  store i32 -1009589776, ptr %24, align 16, !tbaa !9
  store i8 1, ptr %8, align 1, !tbaa !11
  br label %25

25:                                               ; preds = %44, %18
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = sub i32 %26, %27
  store i32 %28, ptr %10, align 4, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %29, i64 %31
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %35 = call zeroext i1 @padding_bits(ptr noundef %32, i32 noundef %33, ptr noundef %11, ptr noundef %34)
  %36 = zext i1 %35 to i32
  %37 = icmp eq i32 1, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %25
  store i8 0, ptr %8, align 1, !tbaa !11
  br label %39

39:                                               ; preds = %38, %25
  %40 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %41 = getelementptr inbounds [80 x i32], ptr %12, i64 0, i64 0
  call void @prepare_wt(ptr noundef %40, ptr noundef %41)
  %42 = getelementptr inbounds [80 x i32], ptr %12, i64 0, i64 0
  %43 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 0
  call void @compute_hash_value(ptr noundef %42, ptr noundef %43)
  br label %44

44:                                               ; preds = %39
  %45 = load i8, ptr %8, align 1, !tbaa !11
  %46 = zext i8 %45 to i32
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %25, label %48, !llvm.loop !12

48:                                               ; preds = %44
  %49 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 0
  %50 = load i32, ptr %49, align 16, !tbaa !9
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %51, i64 0
  store i32 %50, ptr %52, align 4, !tbaa !9
  %53 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 1
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds i32, ptr %55, i64 1
  store i32 %54, ptr %56, align 4, !tbaa !9
  %57 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 2
  %58 = load i32, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds i32, ptr %59, i64 2
  store i32 %58, ptr %60, align 4, !tbaa !9
  %61 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 3
  %62 = load i32, ptr %61, align 4, !tbaa !9
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds i32, ptr %63, i64 3
  store i32 %62, ptr %64, align 4, !tbaa !9
  %65 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 4
  %66 = load i32, ptr %65, align 16, !tbaa !9
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds i32, ptr %67, i64 4
  store i32 %66, ptr %68, align 4, !tbaa !9
  store i1 true, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %69

69:                                               ; preds = %48, %17
  call void @llvm.lifetime.end.p0(i64 20, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 320, 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
  %70 = load i1, ptr %4, align 1
  ret i1 %70
}

; 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_wt(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @compute_hash_value(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_sha1(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 [80 x i32], align 16
  %7 = alloca [5 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 320, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %7) #2
  %8 = icmp ult i32 %1, 536870912
  br i1 %8, label %9, label %21

9:                                                ; preds = %3
  store i32 %1, ptr %5, align 4, !tbaa !5
  store <4 x i32> <i32 1732584193, i32 -271733879, i32 -1732584194, i32 271733878>, ptr %7, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 -1009589776, ptr %10, align 16, !tbaa !5
  br label %11

11:                                               ; preds = %11, %9
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = sub i32 %1, %12
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds i8, ptr %0, i64 %14
  %16 = call zeroext i1 @padding_bits(ptr noundef %15, i32 noundef %1, ptr noundef nonnull %5, ptr noundef nonnull %4)
  call void @prepare_wt(ptr noundef nonnull %4, ptr noundef nonnull %6)
  call void @compute_hash_value(ptr noundef nonnull %6, ptr noundef nonnull %7)
  br i1 %16, label %17, label %11, !llvm.loop !9

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

21:                                               ; preds = %3, %17
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 320, 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 %8
}

; 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_wt(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @compute_hash_value(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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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