; LLVM IR from ssvb/tinymembench :: util (aligned_block_copy_backwards)

; 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: 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: nounwind uwtable
define dso_local void @aligned_block_copy_backwards(ptr noalias noundef %0, ptr noalias noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %12, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = sdiv i32 %13, 8
  %15 = sub nsw i32 %14, 1
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = sext i32 %15 to i64
  %18 = getelementptr inbounds i64, ptr %16, i64 %17
  store ptr %18, ptr %5, align 8, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = sdiv i32 %19, 8
  %21 = sub nsw i32 %20, 1
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = sext i32 %21 to i64
  %24 = getelementptr inbounds i64, ptr %22, i64 %23
  store ptr %24, ptr %7, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %29, %3
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sub nsw i32 %26, 64
  store i32 %27, ptr %6, align 4, !tbaa !9
  %28 = icmp sge i32 %27, 0
  br i1 %28, label %29, label %78

29:                                               ; preds = %25
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds i64, ptr %30, i32 -1
  store ptr %31, ptr %5, align 8, !tbaa !5
  %32 = load i64, ptr %30, align 8, !tbaa !11
  store i64 %32, ptr %8, align 8, !tbaa !11
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds i64, ptr %33, i32 -1
  store ptr %34, ptr %5, align 8, !tbaa !5
  %35 = load i64, ptr %33, align 8, !tbaa !11
  store i64 %35, ptr %9, align 8, !tbaa !11
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds i64, ptr %36, i32 -1
  store ptr %37, ptr %5, align 8, !tbaa !5
  %38 = load i64, ptr %36, align 8, !tbaa !11
  store i64 %38, ptr %10, align 8, !tbaa !11
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds i64, ptr %39, i32 -1
  store ptr %40, ptr %5, align 8, !tbaa !5
  %41 = load i64, ptr %39, align 8, !tbaa !11
  store i64 %41, ptr %11, align 8, !tbaa !11
  %42 = load i64, ptr %8, align 8, !tbaa !11
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds i64, ptr %43, i32 -1
  store ptr %44, ptr %7, align 8, !tbaa !5
  store volatile i64 %42, ptr %43, align 8, !tbaa !11
  %45 = load i64, ptr %9, align 8, !tbaa !11
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds i64, ptr %46, i32 -1
  store ptr %47, ptr %7, align 8, !tbaa !5
  store volatile i64 %45, ptr %46, align 8, !tbaa !11
  %48 = load i64, ptr %10, align 8, !tbaa !11
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds i64, ptr %49, i32 -1
  store ptr %50, ptr %7, align 8, !tbaa !5
  store volatile i64 %48, ptr %49, align 8, !tbaa !11
  %51 = load i64, ptr %11, align 8, !tbaa !11
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds i64, ptr %52, i32 -1
  store ptr %53, ptr %7, align 8, !tbaa !5
  store volatile i64 %51, ptr %52, align 8, !tbaa !11
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds i64, ptr %54, i32 -1
  store ptr %55, ptr %5, align 8, !tbaa !5
  %56 = load i64, ptr %54, align 8, !tbaa !11
  store i64 %56, ptr %8, align 8, !tbaa !11
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds i64, ptr %57, i32 -1
  store ptr %58, ptr %5, align 8, !tbaa !5
  %59 = load i64, ptr %57, align 8, !tbaa !11
  store i64 %59, ptr %9, align 8, !tbaa !11
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds i64, ptr %60, i32 -1
  store ptr %61, ptr %5, align 8, !tbaa !5
  %62 = load i64, ptr %60, align 8, !tbaa !11
  store i64 %62, ptr %10, align 8, !tbaa !11
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds i64, ptr %63, i32 -1
  store ptr %64, ptr %5, align 8, !tbaa !5
  %65 = load i64, ptr %63, align 8, !tbaa !11
  store i64 %65, ptr %11, align 8, !tbaa !11
  %66 = load i64, ptr %8, align 8, !tbaa !11
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds i64, ptr %67, i32 -1
  store ptr %68, ptr %7, align 8, !tbaa !5
  store volatile i64 %66, ptr %67, align 8, !tbaa !11
  %69 = load i64, ptr %9, align 8, !tbaa !11
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds i64, ptr %70, i32 -1
  store ptr %71, ptr %7, align 8, !tbaa !5
  store volatile i64 %69, ptr %70, align 8, !tbaa !11
  %72 = load i64, ptr %10, align 8, !tbaa !11
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds i64, ptr %73, i32 -1
  store ptr %74, ptr %7, align 8, !tbaa !5
  store volatile i64 %72, ptr %73, align 8, !tbaa !11
  %75 = load i64, ptr %11, align 8, !tbaa !11
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = getelementptr inbounds i64, ptr %76, i32 -1
  store ptr %77, ptr %7, align 8, !tbaa !5
  store volatile i64 %75, ptr %76, align 8, !tbaa !11
  br label %25, !llvm.loop !13

78:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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: nofree norecurse nounwind uwtable
define dso_local void @aligned_block_copy_backwards(ptr noalias noundef %0, ptr noalias nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp sgt i32 %2, 63
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %5 = lshr i32 %2, 3
  %6 = add nsw i32 %5, -1
  %7 = zext nneg i32 %6 to i64
  %8 = getelementptr inbounds i64, ptr %0, i64 %7
  %9 = getelementptr inbounds i64, ptr %1, i64 %7
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.034 = phi ptr [ %29, %.lr.ph ], [ %9, %.lr.ph.preheader ]
  %.02933 = phi i32 [ %10, %.lr.ph ], [ %2, %.lr.ph.preheader ]
  %.03032 = phi ptr [ %34, %.lr.ph ], [ %8, %.lr.ph.preheader ]
  %10 = add nsw i32 %.02933, -64
  %11 = getelementptr inbounds i8, ptr %.034, i64 -8
  %12 = load i64, ptr %.034, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %.034, i64 -16
  %14 = load i64, ptr %11, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.034, i64 -24
  %16 = load i64, ptr %13, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.034, i64 -32
  %18 = load i64, ptr %15, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.03032, i64 -8
  store volatile i64 %12, ptr %.03032, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %.03032, i64 -16
  store volatile i64 %14, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.03032, i64 -24
  store volatile i64 %16, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %.03032, i64 -32
  store volatile i64 %18, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %.034, i64 -40
  %24 = load i64, ptr %17, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.034, i64 -48
  %26 = load i64, ptr %23, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.034, i64 -56
  %28 = load i64, ptr %25, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.034, i64 -64
  %30 = load i64, ptr %27, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %.03032, i64 -40
  store volatile i64 %24, ptr %22, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %.03032, i64 -48
  store volatile i64 %26, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.03032, i64 -56
  store volatile i64 %28, ptr %32, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %.03032, i64 -64
  store volatile i64 %30, ptr %33, align 8, !tbaa !5
  %35 = icmp ugt i32 %.02933, 127
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %3
  ret void
}

attributes #0 = { nofree norecurse 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, !6, i64 0}
!6 = !{!"long", !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,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass