; LLVM IR from BabitMF/bmf :: bmf_lite/src/algorithm/modules/operators/utils (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"

%"class.bmf_lite::SHA256" = type { [64 x i8], i32, i64, [8 x i32] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8bmf_lite6SHA2566updateEPKhm(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef %1, i64 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %34, %3
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = icmp ult i64 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %37

14:                                               ; preds = %9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %15, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = getelementptr inbounds %"class.bmf_lite::SHA256", ptr %8, i32 0, i32 0
  %20 = getelementptr inbounds %"class.bmf_lite::SHA256", ptr %8, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !12
  %22 = add i32 %21, 1
  store i32 %22, ptr %20, align 8, !tbaa !12
  %23 = zext i32 %21 to i64
  %24 = getelementptr inbounds [64 x i8], ptr %19, i64 0, i64 %23
  store i8 %18, ptr %24, align 1, !tbaa !11
  %25 = getelementptr inbounds %"class.bmf_lite::SHA256", ptr %8, i32 0, i32 1
  %26 = load i32, ptr %25, align 8, !tbaa !12
  %27 = icmp eq i32 %26, 64
  br i1 %27, label %28, label %33

28:                                               ; preds = %14
  call void @_ZN8bmf_lite6SHA2569transformEv(ptr noundef nonnull align 8 dereferenceable(112) %8)
  %29 = getelementptr inbounds %"class.bmf_lite::SHA256", ptr %8, i32 0, i32 2
  %30 = load i64, ptr %29, align 8, !tbaa !15
  %31 = add i64 %30, 512
  store i64 %31, ptr %29, align 8, !tbaa !15
  %32 = getelementptr inbounds %"class.bmf_lite::SHA256", ptr %8, i32 0, i32 1
  store i32 0, ptr %32, align 8, !tbaa !12
  br label %33

33:                                               ; preds = %28, %14
  br label %34

34:                                               ; preds = %33
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = add i64 %35, 1
  store i64 %36, ptr %7, align 8, !tbaa !9
  br label %9, !llvm.loop !16

37:                                               ; preds = %13
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8bmf_lite6SHA2569transformEv(ptr noundef nonnull align 8 dereferenceable(112)) #2 align 2

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

attributes #0 = { mustprogress 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 = { mustprogress 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 #3 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 64}
!13 = !{!"_ZTSN8bmf_lite6SHA256E", !7, i64 0, !14, i64 64, !10, i64 72, !7, i64 80}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !10, i64 72}
!16 = distinct !{!16, !17}
!17 = !{!"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: mustprogress nounwind uwtable
define dso_local void @_ZN8bmf_lite6SHA2566updateEPKhm(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 align 2 {
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %.pre = load i32, ptr %4, align 8, !tbaa !5
  br label %6

._crit_edge:                                      ; preds = %18, %3
  ret void

6:                                                ; preds = %.lr.ph, %18
  %7 = phi i32 [ %.pre, %.lr.ph ], [ %19, %18 ]
  %.05 = phi i64 [ 0, %.lr.ph ], [ %20, %18 ]
  %8 = getelementptr inbounds i8, ptr %1, i64 %.05
  %9 = load i8, ptr %8, align 1, !tbaa !11
  %10 = add i32 %7, 1
  store i32 %10, ptr %4, align 8, !tbaa !5
  %11 = zext i32 %7 to i64
  %12 = getelementptr inbounds [64 x i8], ptr %0, i64 0, i64 %11
  store i8 %9, ptr %12, align 1, !tbaa !11
  %13 = load i32, ptr %4, align 8, !tbaa !5
  %14 = icmp eq i32 %13, 64
  br i1 %14, label %15, label %18

15:                                               ; preds = %6
  tail call void @_ZN8bmf_lite6SHA2569transformEv(ptr noundef nonnull align 8 dereferenceable(112) %0)
  %16 = load i64, ptr %5, align 8, !tbaa !12
  %17 = add i64 %16, 512
  store i64 %17, ptr %5, align 8, !tbaa !12
  store i32 0, ptr %4, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %6, %15
  %19 = phi i32 [ %13, %6 ], [ 0, %15 ]
  %20 = add nuw i64 %.05, 1
  %exitcond.not = icmp eq i64 %20, %2
  br i1 %exitcond.not, label %._crit_edge, label %6, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8bmf_lite6SHA2569transformEv(ptr noundef nonnull align 8 dereferenceable(112)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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, !9, i64 64}
!6 = !{!"_ZTSN8bmf_lite6SHA256E", !7, i64 0, !9, i64 64, !10, i64 72, !7, i64 80}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !10, i64 72}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass