; LLVM IR from fast-pack/FastPFOR :: src/benchbitpacking.ll (ZN11FastPForLib7ZRandom4seedEj)

; 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.FastPForLib::ZRandom" = type <{ [625 x i32], [4 x i8], [624 x ptr], i32, [4 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 nounwind uwtable
define dso_local void @_ZN11FastPForLib7ZRandom4seedEj(ptr noundef nonnull align 8 dereferenceable(7500) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %"class.FastPForLib::ZRandom", ptr %7, i32 0, i32 3
  store i32 0, ptr %8, align 8, !tbaa !11
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = getelementptr inbounds %"class.FastPForLib::ZRandom", ptr %7, i32 0, i32 0
  %11 = getelementptr inbounds [625 x i32], ptr %10, i64 0, i64 0
  store i32 %9, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %29, %2
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 624
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %32

16:                                               ; preds = %12
  %17 = getelementptr inbounds %"class.FastPForLib::ZRandom", ptr %7, i32 0, i32 0
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = sub nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [625 x i32], ptr %17, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = mul i32 69069, %22
  %24 = add i32 1, %23
  %25 = getelementptr inbounds %"class.FastPForLib::ZRandom", ptr %7, i32 0, i32 0
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [625 x i32], ptr %25, i64 0, i64 %27
  store i32 %24, ptr %28, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %16
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %5, align 4, !tbaa !9
  br label %12, !llvm.loop !13

32:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %49, %32
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 624
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %52

37:                                               ; preds = %33
  %38 = getelementptr inbounds %"class.FastPForLib::ZRandom", ptr %7, i32 0, i32 0
  %39 = getelementptr inbounds [625 x i32], ptr %38, i64 0, i64 0
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = add nsw i32 %40, 397
  %42 = srem i32 %41, 624
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %39, i64 %43
  %45 = getelementptr inbounds %"class.FastPForLib::ZRandom", ptr %7, i32 0, i32 2
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [624 x ptr], ptr %45, i64 0, i64 %47
  store ptr %44, ptr %48, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %37
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %6, align 4, !tbaa !9
  br label %33, !llvm.loop !15

52:                                               ; preds = %36
  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 = !{!"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 = !{!12, !10, i64 7496}
!12 = !{!"_ZTSN11FastPForLib7ZRandomE", !7, i64 0, !7, i64 2504, !10, i64 7496}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 @_ZN11FastPForLib7ZRandom4seedEj(ptr noundef nonnull align 8 dereferenceable(7500) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 7496
  store i32 0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %0, align 8, !tbaa !10
  br label %18

.preheader:                                       ; preds = %18
  %4 = getelementptr inbounds i8, ptr %0, i64 2504
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %.preheader
  %index = phi i64 [ 0, %.preheader ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i64> [ <i64 0, i64 1>, %.preheader ], [ %vec.ind.next, %vector.body ]
  %step.add = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %5 = icmp ult <2 x i64> %vec.ind, <i64 227, i64 227>
  %6 = icmp ult <2 x i64> %step.add, <i64 227, i64 227>
  %7 = select <2 x i1> %5, <2 x i64> <i64 397, i64 397>, <2 x i64> <i64 4294967069, i64 4294967069>
  %8 = select <2 x i1> %6, <2 x i64> <i64 397, i64 397>, <2 x i64> <i64 4294967069, i64 4294967069>
  %9 = add nuw <2 x i64> %7, %vec.ind
  %10 = add nuw <2 x i64> %8, %step.add
  %11 = and <2 x i64> %9, <i64 4294967295, i64 4294967295>
  %12 = and <2 x i64> %10, <i64 4294967295, i64 4294967295>
  %13 = getelementptr inbounds i32, ptr %0, <2 x i64> %11
  %14 = getelementptr inbounds i32, ptr %0, <2 x i64> %12
  %15 = getelementptr inbounds [624 x ptr], ptr %4, i64 0, i64 %index
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  store <2 x ptr> %13, ptr %15, align 8, !tbaa !11
  store <2 x ptr> %14, ptr %16, align 8, !tbaa !11
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %17 = icmp eq i64 %index.next, 624
  br i1 %17, label %middle.block, label %vector.body, !llvm.loop !13

18:                                               ; preds = %29, %2
  %19 = phi i32 [ %1, %2 ], [ %31, %29 ]
  %indvars.iv = phi i64 [ 1, %2 ], [ %indvars.iv.next.3, %29 ]
  %20 = mul i32 %19, 69069
  %21 = add i32 %20, 1
  %22 = getelementptr inbounds [625 x i32], ptr %0, i64 0, i64 %indvars.iv
  store i32 %21, ptr %22, align 4, !tbaa !10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = mul i32 %21, 69069
  %24 = add i32 %23, 1
  %25 = getelementptr inbounds [625 x i32], ptr %0, i64 0, i64 %indvars.iv.next
  store i32 %24, ptr %25, align 4, !tbaa !10
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %26 = mul i32 %24, 69069
  %27 = add i32 %26, 1
  %28 = getelementptr inbounds [625 x i32], ptr %0, i64 0, i64 %indvars.iv.next.1
  store i32 %27, ptr %28, align 4, !tbaa !10
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %exitcond.not.2 = icmp eq i64 %indvars.iv.next.2, 624
  br i1 %exitcond.not.2, label %.preheader, label %29, !llvm.loop !17

29:                                               ; preds = %18
  %30 = mul i32 %27, 69069
  %31 = add i32 %30, 1
  %32 = getelementptr inbounds [625 x i32], ptr %0, i64 0, i64 %indvars.iv.next.2
  store i32 %31, ptr %32, align 4, !tbaa !10
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  br label %18

middle.block:                                     ; preds = %vector.body
  ret void
}

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, !9, i64 7496}
!6 = !{!"_ZTSN11FastPForLib7ZRandomE", !7, i64 0, !7, i64 2504, !9, i64 7496}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14, !15, !16}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !14}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass