; LLVM IR from sympiler/nasoq :: src/common/Util.ll (ZN5nasoq16rhsInitBlockedLTEmmPmPiS0_PdS2_)

; 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 @_ZN5nasoq16rhsInitBlockedLTEmmPmPiS0_PdS2_(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #1 {
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i64 %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !9
  store ptr %6, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %15, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %31, %7
  %21 = load i32, ptr %15, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = load i64, ptr %8, align 8, !tbaa !5
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %26, label %25

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

26:                                               ; preds = %20
  %27 = load ptr, ptr %14, align 8, !tbaa !9
  %28 = load i32, ptr %15, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  store double 0.000000e+00, ptr %30, align 8, !tbaa !13
  br label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %15, align 4, !tbaa !11
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %15, align 4, !tbaa !11
  br label %20, !llvm.loop !15

34:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %35

35:                                               ; preds = %77, %34
  %36 = load i32, ptr %16, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = load i64, ptr %8, align 8, !tbaa !5
  %39 = icmp ult i64 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  br label %80

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  %42 = load ptr, ptr %10, align 8, !tbaa !9
  %43 = load i32, ptr %16, align 4, !tbaa !11
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i64, ptr %42, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !5
  %47 = trunc i64 %46 to i32
  store i32 %47, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %71, %41
  %49 = load i32, ptr %18, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = load ptr, ptr %10, align 8, !tbaa !9
  %52 = load i32, ptr %16, align 4, !tbaa !11
  %53 = add nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i64, ptr %51, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !5
  %57 = icmp ult i64 %50, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %48
  store i32 8, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  br label %76

59:                                               ; preds = %48
  %60 = load ptr, ptr %13, align 8, !tbaa !9
  %61 = load i32, ptr %18, align 4, !tbaa !11
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds double, ptr %60, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !13
  %65 = load ptr, ptr %14, align 8, !tbaa !9
  %66 = load i32, ptr %16, align 4, !tbaa !11
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %65, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !13
  %70 = fadd double %69, %64
  store double %70, ptr %68, align 8, !tbaa !13
  br label %71

71:                                               ; preds = %59
  %72 = load i32, ptr %18, align 4, !tbaa !11
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %18, align 4, !tbaa !11
  %74 = load i32, ptr %19, align 4, !tbaa !11
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %19, align 4, !tbaa !11
  br label %48, !llvm.loop !17

76:                                               ; preds = %58
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %16, align 4, !tbaa !11
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %16, align 4, !tbaa !11
  br label %35, !llvm.loop !18

80:                                               ; preds = %40
  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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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: readwrite) uwtable
define dso_local void @_ZN5nasoq16rhsInitBlockedLTEmmPmPiS0_PdS2_(i64 noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readnone %3, ptr nocapture noundef readnone %4, ptr nocapture noundef readonly %5, ptr nocapture noundef %6) local_unnamed_addr #0 {
  %.not = icmp eq i64 %0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph29.preheader

.lr.ph29.preheader:                               ; preds = %7
  %8 = shl nuw i64 %0, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 %8, i1 false), !tbaa !5
  %.pre = load i64, ptr %2, align 8, !tbaa !9
  %invariant.gep = getelementptr i8, ptr %5, i64 8
  %invariant.gep36 = getelementptr i8, ptr %5, i64 16
  %invariant.gep38 = getelementptr i8, ptr %5, i64 24
  br label %.lr.ph29

.loopexit:                                        ; preds = %.prol.loopexit, %.lr.ph27.new, %.lr.ph29
  %exitcond.not = icmp eq i64 %indvars.iv.next34, %0
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph29, !llvm.loop !11

._crit_edge:                                      ; preds = %.loopexit, %7
  ret void

.lr.ph29:                                         ; preds = %.lr.ph29.preheader, %.loopexit
  %9 = phi i64 [ %.pre, %.lr.ph29.preheader ], [ %11, %.loopexit ]
  %indvars.iv33 = phi i64 [ 0, %.lr.ph29.preheader ], [ %indvars.iv.next34, %.loopexit ]
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %10 = getelementptr inbounds i64, ptr %2, i64 %indvars.iv.next34
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %sext = shl i64 %9, 32
  %12 = ashr exact i64 %sext, 32
  %13 = icmp ugt i64 %11, %12
  br i1 %13, label %.lr.ph27, label %.loopexit

.lr.ph27:                                         ; preds = %.lr.ph29
  %14 = getelementptr inbounds double, ptr %6, i64 %indvars.iv33
  %.promoted = load double, ptr %14, align 8, !tbaa !5
  %15 = sub i64 %11, %9
  %xtraiter = and i64 %15, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %.lr.ph27, %.prol.preheader
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.prol.preheader ], [ %12, %.lr.ph27 ]
  %16 = phi double [ %19, %.prol.preheader ], [ %.promoted, %.lr.ph27 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.prol.preheader ], [ 0, %.lr.ph27 ]
  %17 = getelementptr inbounds double, ptr %5, i64 %indvars.iv.prol
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = fadd double %18, %16
  store double %19, ptr %14, align 8, !tbaa !5
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %.prol.preheader, !llvm.loop !13

.prol.loopexit:                                   ; preds = %.prol.preheader, %.lr.ph27
  %indvars.iv.unr = phi i64 [ %12, %.lr.ph27 ], [ %indvars.iv.next.prol, %.prol.preheader ]
  %.unr = phi double [ %.promoted, %.lr.ph27 ], [ %19, %.prol.preheader ]
  %20 = sub i64 %12, %11
  %21 = icmp ugt i64 %20, -4
  br i1 %21, label %.loopexit, label %.lr.ph27.new

.lr.ph27.new:                                     ; preds = %.prol.loopexit, %.lr.ph27.new
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph27.new ], [ %indvars.iv.unr, %.prol.loopexit ]
  %22 = phi double [ %31, %.lr.ph27.new ], [ %.unr, %.prol.loopexit ]
  %23 = getelementptr inbounds double, ptr %5, i64 %indvars.iv
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fadd double %24, %22
  store double %25, ptr %14, align 8, !tbaa !5
  %gep = getelementptr double, ptr %invariant.gep, i64 %indvars.iv
  %26 = load double, ptr %gep, align 8, !tbaa !5
  %27 = fadd double %26, %25
  store double %27, ptr %14, align 8, !tbaa !5
  %gep37 = getelementptr double, ptr %invariant.gep36, i64 %indvars.iv
  %28 = load double, ptr %gep37, align 8, !tbaa !5
  %29 = fadd double %28, %27
  store double %29, ptr %14, align 8, !tbaa !5
  %gep39 = getelementptr double, ptr %invariant.gep38, i64 %indvars.iv
  %30 = load double, ptr %gep39, align 8, !tbaa !5
  %31 = fadd double %30, %29
  store double %31, ptr %14, align 8, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %32 = icmp ugt i64 %11, %indvars.iv.next.3
  br i1 %32, label %.lr.ph27.new, label %.loopexit, !llvm.loop !15
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !12}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass