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

; 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_sha256(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 [64 x i32], align 16
  %13 = alloca [8 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 256, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 32, 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 %84

18:                                               ; preds = %3
  %19 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %19, ptr %11, align 4, !tbaa !9
  %20 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  store i32 1779033703, ptr %20, align 16, !tbaa !9
  %21 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 1
  store i32 -1150833019, ptr %21, align 4, !tbaa !9
  %22 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 2
  store i32 1013904242, ptr %22, align 8, !tbaa !9
  %23 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 3
  store i32 -1521486534, ptr %23, align 4, !tbaa !9
  %24 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 4
  store i32 1359893119, ptr %24, align 16, !tbaa !9
  %25 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 5
  store i32 -1694144372, ptr %25, align 4, !tbaa !9
  %26 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 6
  store i32 528734635, ptr %26, align 8, !tbaa !9
  %27 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 7
  store i32 1541459225, ptr %27, align 4, !tbaa !9
  store i8 1, ptr %8, align 1, !tbaa !11
  br label %28

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

41:                                               ; preds = %28
  store i8 0, ptr %8, align 1, !tbaa !11
  br label %42

42:                                               ; preds = %41, %28
  %43 = getelementptr inbounds [64 x i8], ptr %9, i64 0, i64 0
  %44 = getelementptr inbounds [64 x i32], ptr %12, i64 0, i64 0
  call void @prepare_wt(ptr noundef %43, ptr noundef %44)
  %45 = getelementptr inbounds [64 x i32], ptr %12, i64 0, i64 0
  %46 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  call void @compute_hash_value(ptr noundef %45, ptr noundef %46)
  br label %47

47:                                               ; preds = %42
  %48 = load i8, ptr %8, align 1, !tbaa !11
  %49 = zext i8 %48 to i32
  %50 = icmp eq i32 %49, 1
  br i1 %50, label %28, label %51, !llvm.loop !12

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

84:                                               ; preds = %51, %17
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 256, 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
  %85 = load i1, ptr %4, align 1
  ret i1 %85
}

; 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_sha256(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 [64 x i32], align 16
  %7 = 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 256, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 32, 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 1779033703, i32 -1150833019, i32 1013904242, i32 -1521486534>, ptr %7, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %7, i64 16
  store <4 x i32> <i32 1359893119, i32 -1694144372, i32 528734635, i32 1541459225>, 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 = getelementptr inbounds i8, ptr %2, i64 16
  %20 = load <4 x i32>, ptr %10, align 16, !tbaa !5
  store <4 x i32> %20, ptr %19, align 4, !tbaa !5
  br label %21

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