; LLVM IR from alibaba/BladeDISC :: tao_compiler/mlir/ral/ral_md5.ll (ZN3tao3ral3MD56updateEPKhj)

; 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.tao::ral::MD5" = type { i8, [64 x i8], [2 x i32], [4 x i32], [16 x i8] }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3tao3ral3MD59transformEPKh(ptr noundef nonnull align 4 dereferenceable(108), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3tao3ral3MD56updateEPKhj(ptr noundef nonnull align 4 dereferenceable(108) %0, ptr noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %11 = getelementptr inbounds %"class.tao::ral::MD5", ptr %10, i32 0, i32 2
  %12 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 0
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = udiv i32 %13, 8
  %15 = urem i32 %14, 64
  store i32 %15, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = shl i32 %16, 3
  %18 = getelementptr inbounds %"class.tao::ral::MD5", ptr %10, i32 0, i32 2
  %19 = getelementptr inbounds [2 x i32], ptr %18, i64 0, i64 0
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = add i32 %20, %17
  store i32 %21, ptr %19, align 4, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = shl i32 %22, 3
  %24 = icmp ult i32 %21, %23
  br i1 %24, label %25, label %30

25:                                               ; preds = %3
  %26 = getelementptr inbounds %"class.tao::ral::MD5", ptr %10, i32 0, i32 2
  %27 = getelementptr inbounds [2 x i32], ptr %26, i64 0, i64 1
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = add i32 %28, 1
  store i32 %29, ptr %27, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %25, %3
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = lshr i32 %31, 29
  %33 = getelementptr inbounds %"class.tao::ral::MD5", ptr %10, i32 0, i32 2
  %34 = getelementptr inbounds [2 x i32], ptr %33, i64 0, i64 1
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = add i32 %35, %32
  store i32 %36, ptr %34, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = sub i32 64, %37
  store i32 %38, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = icmp uge i32 %39, %40
  br i1 %41, label %42, label %67

42:                                               ; preds = %30
  %43 = getelementptr inbounds %"class.tao::ral::MD5", ptr %10, i32 0, i32 1
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds [64 x i8], ptr %43, i64 0, i64 %45
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %46, ptr align 1 %47, i64 %49, i1 false)
  %50 = getelementptr inbounds %"class.tao::ral::MD5", ptr %10, i32 0, i32 1
  %51 = getelementptr inbounds [64 x i8], ptr %50, i64 0, i64 0
  call void @_ZN3tao3ral3MD59transformEPKh(ptr noundef nonnull align 4 dereferenceable(108) %10, ptr noundef %51)
  %52 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %52, ptr %9, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %63, %42
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = add i32 %54, 64
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = icmp ule i32 %55, %56
  br i1 %57, label %58, label %66

58:                                               ; preds = %53
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %59, i64 %61
  call void @_ZN3tao3ral3MD59transformEPKh(ptr noundef nonnull align 4 dereferenceable(108) %10, ptr noundef %62)
  br label %63

63:                                               ; preds = %58
  %64 = load i32, ptr %9, align 4, !tbaa !9
  %65 = add i32 %64, 64
  store i32 %65, ptr %9, align 4, !tbaa !9
  br label %53, !llvm.loop !11

66:                                               ; preds = %53
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %68

67:                                               ; preds = %30
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %67, %66
  %69 = getelementptr inbounds %"class.tao::ral::MD5", ptr %10, i32 0, i32 1
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds [64 x i8], ptr %69, i64 0, i64 %71
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds i8, ptr %73, i64 %75
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = sub i32 %77, %78
  %80 = zext i32 %79 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %72, ptr align 1 %76, i64 %80, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 uwtable
declare dso_local void @_ZN3tao3ral3MD59transformEPKh(ptr noundef nonnull align 4 dereferenceable(108), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3tao3ral3MD56updateEPKhj(ptr noundef nonnull align 4 dereferenceable(108) %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
._crit_edge:
  %3 = getelementptr inbounds i8, ptr %0, i64 68
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = lshr i32 %4, 3
  %6 = and i32 %5, 63
  %7 = shl i32 %2, 3
  %8 = add i32 %4, %7
  store i32 %8, ptr %3, align 4, !tbaa !5
  %9 = icmp ult i32 %8, %7
  %10 = getelementptr inbounds i8, ptr %0, i64 72
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = zext i1 %9 to i32
  %13 = add i32 %11, %12
  %14 = lshr i32 %2, 29
  %15 = getelementptr inbounds i8, ptr %0, i64 72
  %16 = add i32 %13, %14
  store i32 %16, ptr %15, align 4, !tbaa !5
  %17 = sub nuw nsw i32 64, %6
  %.not = icmp ugt i32 %17, %2
  br i1 %.not, label %28, label %18

18:                                               ; preds = %._crit_edge
  %19 = getelementptr inbounds i8, ptr %0, i64 1
  %20 = zext nneg i32 %6 to i64
  %21 = getelementptr inbounds [64 x i8], ptr %19, i64 0, i64 %20
  %22 = zext nneg i32 %17 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %21, ptr noundef nonnull align 1 dereferenceable(1) %1, i64 %22, i1 false)
  tail call void @_ZN3tao3ral3MD59transformEPKh(ptr noundef nonnull align 4 dereferenceable(108) %0, ptr noundef nonnull %19)
  %23 = sub nuw nsw i32 128, %6
  %.not2425 = icmp ugt i32 %23, %2
  br i1 %.not2425, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %18, %.lr.ph
  %24 = phi i32 [ %27, %.lr.ph ], [ %23, %18 ]
  %.026 = phi i32 [ %24, %.lr.ph ], [ %17, %18 ]
  %25 = zext i32 %.026 to i64
  %26 = getelementptr inbounds i8, ptr %1, i64 %25
  tail call void @_ZN3tao3ral3MD59transformEPKh(ptr noundef nonnull align 4 dereferenceable(108) %0, ptr noundef %26)
  %27 = add i32 %24, 64
  %.not24 = icmp ugt i32 %27, %2
  br i1 %.not24, label %.loopexit, label %.lr.ph, !llvm.loop !9

28:                                               ; preds = %._crit_edge
  %29 = zext nneg i32 %6 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %18, %28
  %.020 = phi i64 [ %29, %28 ], [ 0, %18 ], [ 0, %.lr.ph ]
  %.1 = phi i32 [ 0, %28 ], [ %17, %18 ], [ %24, %.lr.ph ]
  %30 = getelementptr inbounds i8, ptr %0, i64 1
  %31 = getelementptr inbounds [64 x i8], ptr %30, i64 0, i64 %.020
  %32 = zext i32 %.1 to i64
  %33 = getelementptr inbounds i8, ptr %1, i64 %32
  %34 = sub i32 %2, %.1
  %35 = zext i32 %34 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %31, ptr align 1 %33, i64 %35, i1 false)
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass