; LLVM IR from travisdowns/sort-bench :: bench.ll (Z11fill_linearmmPm)

; 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: mustprogress nounwind uwtable
define dso_local void @_Z11fill_linearmmPm(i64 noundef %0, i64 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %40, %3
  %12 = load i64, ptr %7, align 8, !tbaa !5
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = icmp ult i64 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %41

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %34, %16
  %18 = load i64, ptr %9, align 8, !tbaa !5
  %19 = load i64, ptr %4, align 8, !tbaa !5
  %20 = icmp ule i64 %18, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %17
  %22 = load i64, ptr %7, align 8, !tbaa !5
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = icmp ult i64 %22, %23
  br label %25

25:                                               ; preds = %21, %17
  %26 = phi i1 [ false, %17 ], [ %24, %21 ]
  br i1 %26, label %28, label %27

27:                                               ; preds = %25
  store i32 4, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %40

28:                                               ; preds = %25
  %29 = load i64, ptr %10, align 8, !tbaa !5
  %30 = mul i64 %29, 72340172838076673
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = load i64, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds i64, ptr %31, i64 %32
  store i64 %30, ptr %33, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %28
  %35 = load i64, ptr %10, align 8, !tbaa !5
  %36 = add i64 %35, 17
  %37 = and i64 %36, 255
  store i64 %37, ptr %10, align 8, !tbaa !5
  %38 = load i64, ptr %7, align 8, !tbaa !5
  %39 = add i64 %38, 1
  store i64 %39, ptr %7, align 8, !tbaa !5
  br label %17, !llvm.loop !11

40:                                               ; preds = %27
  br label %11, !llvm.loop !13

41:                                               ; preds = %15
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @_Z11fill_linearmmPm(i64 noundef %0, i64 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge, label %.preheader.preheader.preheader

.preheader.preheader.preheader:                   ; preds = %3
  %xtraiter = and i64 %1, 3
  %4 = icmp ult i64 %1, 4
  br i1 %4, label %._crit_edge.loopexit.unr-lcssa, label %.preheader.preheader.preheader.new

.preheader.preheader.preheader.new:               ; preds = %.preheader.preheader.preheader
  %unroll_iter = and i64 %1, -4
  br label %.preheader.preheader

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.preheader.preheader, %.preheader.preheader.preheader
  %.013.unr = phi i64 [ 0, %.preheader.preheader.preheader ], [ %28, %.preheader.preheader ]
  %.112.unr = phi i64 [ 0, %.preheader.preheader.preheader ], [ %29, %.preheader.preheader ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.preheader.preheader.epil

.preheader.preheader.epil:                        ; preds = %._crit_edge.loopexit.unr-lcssa, %.preheader.preheader.epil
  %.013.epil = phi i64 [ %8, %.preheader.preheader.epil ], [ %.013.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.112.epil = phi i64 [ %9, %.preheader.preheader.epil ], [ %.112.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.preheader.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %5 = mul nuw i64 %.013.epil, 72340172838076673
  %6 = getelementptr inbounds i64, ptr %2, i64 %.112.epil
  store i64 %5, ptr %6, align 8, !tbaa !5
  %7 = add nuw nsw i64 %.013.epil, 17
  %8 = and i64 %7, 255
  %9 = add nuw i64 %.112.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.preheader.preheader.epil, !llvm.loop !9

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.preheader.preheader.epil, %3
  ret void

.preheader.preheader:                             ; preds = %.preheader.preheader, %.preheader.preheader.preheader.new
  %.013 = phi i64 [ 0, %.preheader.preheader.preheader.new ], [ %28, %.preheader.preheader ]
  %.112 = phi i64 [ 0, %.preheader.preheader.preheader.new ], [ %29, %.preheader.preheader ]
  %niter = phi i64 [ 0, %.preheader.preheader.preheader.new ], [ %niter.next.3, %.preheader.preheader ]
  %10 = mul nuw i64 %.013, 72340172838076673
  %11 = getelementptr inbounds i64, ptr %2, i64 %.112
  store i64 %10, ptr %11, align 8, !tbaa !5
  %12 = add nuw nsw i64 %.013, 17
  %13 = and i64 %12, 255
  %14 = or disjoint i64 %.112, 1
  %15 = mul nuw i64 %13, 72340172838076673
  %16 = getelementptr inbounds i64, ptr %2, i64 %14
  store i64 %15, ptr %16, align 8, !tbaa !5
  %17 = add nuw nsw i64 %.013, 34
  %18 = and i64 %17, 255
  %19 = or disjoint i64 %.112, 2
  %20 = mul nuw i64 %18, 72340172838076673
  %21 = getelementptr inbounds i64, ptr %2, i64 %19
  store i64 %20, ptr %21, align 8, !tbaa !5
  %22 = add nuw nsw i64 %.013, 51
  %23 = and i64 %22, 255
  %24 = or disjoint i64 %.112, 3
  %25 = mul nuw i64 %23, 72340172838076673
  %26 = getelementptr inbounds i64, ptr %2, i64 %24
  store i64 %25, ptr %26, align 8, !tbaa !5
  %27 = add nuw nsw i64 %.013, 68
  %28 = and i64 %27, 255
  %29 = add nuw i64 %.112, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.preheader.preheader, !llvm.loop !11
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: write) 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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