; LLVM IR from zeux/meshoptimizer :: demo/main.ll (Z9hashRangePKcm)

; 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 noundef i32 @_Z9hashRangePKcm(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 1540483477, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 24, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %9

9:                                                ; preds = %12, %2
  %10 = load i64, ptr %4, align 8, !tbaa !9
  %11 = icmp uge i64 %10, 4
  br i1 %11, label %12, label %32

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !11
  store i32 %14, ptr %8, align 4, !tbaa !11
  %15 = load i32, ptr %8, align 4, !tbaa !11
  %16 = mul i32 %15, 1540483477
  store i32 %16, ptr %8, align 4, !tbaa !11
  %17 = load i32, ptr %8, align 4, !tbaa !11
  %18 = lshr i32 %17, 24
  %19 = load i32, ptr %8, align 4, !tbaa !11
  %20 = xor i32 %19, %18
  store i32 %20, ptr %8, align 4, !tbaa !11
  %21 = load i32, ptr %8, align 4, !tbaa !11
  %22 = mul i32 %21, 1540483477
  store i32 %22, ptr %8, align 4, !tbaa !11
  %23 = load i32, ptr %7, align 4, !tbaa !11
  %24 = mul i32 %23, 1540483477
  store i32 %24, ptr %7, align 4, !tbaa !11
  %25 = load i32, ptr %8, align 4, !tbaa !11
  %26 = load i32, ptr %7, align 4, !tbaa !11
  %27 = xor i32 %26, %25
  store i32 %27, ptr %7, align 4, !tbaa !11
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 4
  store ptr %29, ptr %3, align 8, !tbaa !5
  %30 = load i64, ptr %4, align 8, !tbaa !9
  %31 = sub i64 %30, 4
  store i64 %31, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %9, !llvm.loop !13

32:                                               ; preds = %9
  %33 = load i32, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %33
}

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 = !{!"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 = !{!12, !12, i64 0}
!12 = !{!"int", !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: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef i32 @_Z9hashRangePKcm(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp ugt i64 %1, 3
  br i1 %3, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %4 = add i64 %1, -4
  %5 = icmp ult i64 %4, 4
  br i1 %5, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %6 = lshr i64 %4, 2
  %7 = add nuw nsw i64 %6, 1
  %unroll_iter = and i64 %7, 9223372036854775806
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.015 = phi ptr [ %0, %.lr.ph.preheader.new ], [ %23, %.lr.ph ]
  %.01114 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %22, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %8 = load i32, ptr %.015, align 4, !tbaa !5
  %9 = mul i32 %8, 1540483477
  %10 = lshr i32 %9, 24
  %11 = xor i32 %10, %9
  %12 = mul i32 %11, 1540483477
  %13 = mul i32 %.01114, 1540483477
  %14 = xor i32 %12, %13
  %15 = getelementptr inbounds i8, ptr %.015, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = mul i32 %16, 1540483477
  %18 = lshr i32 %17, 24
  %19 = xor i32 %18, %17
  %20 = mul i32 %19, 1540483477
  %21 = mul i32 %14, 1540483477
  %22 = xor i32 %20, %21
  %23 = getelementptr inbounds i8, ptr %.015, i64 8
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1.not = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1.not, label %._crit_edge.loopexit.unr-lcssa.loopexit, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa.loopexit:          ; preds = %.lr.ph
  %24 = mul i32 %22, 1540483477
  br label %._crit_edge.loopexit.unr-lcssa

._crit_edge.loopexit.unr-lcssa:                   ; preds = %._crit_edge.loopexit.unr-lcssa.loopexit, %.lr.ph.preheader
  %.lcssa.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %22, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.015.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %23, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.01114.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %24, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %25 = and i64 %4, 4
  %lcmp.mod.not.not = icmp eq i64 %25, 0
  br i1 %lcmp.mod.not.not, label %.lr.ph.epil, label %._crit_edge

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %26 = load i32, ptr %.015.unr, align 4, !tbaa !5
  %27 = mul i32 %26, 1540483477
  %28 = lshr i32 %27, 24
  %29 = xor i32 %28, %27
  %30 = mul i32 %29, 1540483477
  %31 = xor i32 %30, %.01114.unr
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %2
  %.011.lcssa = phi i32 [ 0, %2 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %31, %.lr.ph.epil ]
  ret i32 %.011.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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 = !{!"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: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass