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

; 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_fill(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
  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
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load i64, ptr %10, align 8, !tbaa !11
  store i64 %11, ptr %8, align 8, !tbaa !11
  br label %12

12:                                               ; preds = %16, %3
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = sub nsw i32 %13, 64
  store i32 %14, ptr %6, align 4, !tbaa !9
  %15 = icmp sge i32 %14, 0
  br i1 %15, label %16, label %41

16:                                               ; preds = %12
  %17 = load i64, ptr %8, align 8, !tbaa !11
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds i64, ptr %18, i32 1
  store ptr %19, ptr %7, align 8, !tbaa !5
  store volatile i64 %17, ptr %18, align 8, !tbaa !11
  %20 = load i64, ptr %8, align 8, !tbaa !11
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %21, i32 1
  store ptr %22, ptr %7, align 8, !tbaa !5
  store volatile i64 %20, ptr %21, align 8, !tbaa !11
  %23 = load i64, ptr %8, align 8, !tbaa !11
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds i64, ptr %24, i32 1
  store ptr %25, ptr %7, align 8, !tbaa !5
  store volatile i64 %23, ptr %24, align 8, !tbaa !11
  %26 = load i64, ptr %8, align 8, !tbaa !11
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds i64, ptr %27, i32 1
  store ptr %28, ptr %7, align 8, !tbaa !5
  store volatile i64 %26, ptr %27, align 8, !tbaa !11
  %29 = load i64, ptr %8, align 8, !tbaa !11
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds i64, ptr %30, i32 1
  store ptr %31, ptr %7, align 8, !tbaa !5
  store volatile i64 %29, ptr %30, align 8, !tbaa !11
  %32 = load i64, ptr %8, align 8, !tbaa !11
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds i64, ptr %33, i32 1
  store ptr %34, ptr %7, align 8, !tbaa !5
  store volatile i64 %32, ptr %33, align 8, !tbaa !11
  %35 = load i64, ptr %8, align 8, !tbaa !11
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds i64, ptr %36, i32 1
  store ptr %37, ptr %7, align 8, !tbaa !5
  store volatile i64 %35, ptr %36, align 8, !tbaa !11
  %38 = load i64, ptr %8, align 8, !tbaa !11
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds i64, ptr %39, i32 1
  store ptr %40, ptr %7, align 8, !tbaa !5
  store volatile i64 %38, ptr %39, align 8, !tbaa !11
  br label %12, !llvm.loop !13

41:                                               ; preds = %12
  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_fill(ptr noalias noundef %0, ptr noalias nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = icmp sgt i32 %2, 63
  br i1 %5, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %6 = add nsw i32 %2, -64
  %7 = and i32 %6, 64
  %lcmp.mod.not.not = icmp eq i32 %7, 0
  br i1 %lcmp.mod.not.not, label %.lr.ph.prol, label %.lr.ph.prol.loopexit

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %8 = add nsw i32 %2, -64
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store volatile i64 %4, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store volatile i64 %4, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store volatile i64 %4, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store volatile i64 %4, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  store volatile i64 %4, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  store volatile i64 %4, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  store volatile i64 %4, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 64
  store volatile i64 %4, ptr %15, align 8, !tbaa !5
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.021.unr = phi i32 [ %2, %.lr.ph.preheader ], [ %8, %.lr.ph.prol ]
  %.01820.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %16, %.lr.ph.prol ]
  %17 = icmp ult i32 %6, 64
  br i1 %17, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.021 = phi i32 [ %26, %.lr.ph ], [ %.021.unr, %.lr.ph.prol.loopexit ]
  %.01820 = phi ptr [ %34, %.lr.ph ], [ %.01820.unr, %.lr.ph.prol.loopexit ]
  %18 = getelementptr inbounds i8, ptr %.01820, i64 8
  store volatile i64 %4, ptr %.01820, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.01820, i64 16
  store volatile i64 %4, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %.01820, i64 24
  store volatile i64 %4, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.01820, i64 32
  store volatile i64 %4, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %.01820, i64 40
  store volatile i64 %4, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %.01820, i64 48
  store volatile i64 %4, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %.01820, i64 56
  store volatile i64 %4, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.01820, i64 64
  store volatile i64 %4, ptr %24, align 8, !tbaa !5
  %26 = add nsw i32 %.021, -128
  %27 = getelementptr inbounds i8, ptr %.01820, i64 72
  store volatile i64 %4, ptr %25, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %.01820, i64 80
  store volatile i64 %4, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.01820, i64 88
  store volatile i64 %4, ptr %28, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.01820, i64 96
  store volatile i64 %4, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %.01820, i64 104
  store volatile i64 %4, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %.01820, i64 112
  store volatile i64 %4, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.01820, i64 120
  store volatile i64 %4, ptr %32, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %.01820, i64 128
  store volatile i64 %4, ptr %33, align 8, !tbaa !5
  %35 = add i32 %.021, -192
  %36 = icmp ult i32 %35, -128
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass