; LLVM IR from sympiler/nasoq :: src/common/Util.ll (ZN5nasoq14rhsInitBlockedEmmPmPiS0_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 @_ZN5nasoq14rhsInitBlockedEmmPmPiS0_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
  %20 = alloca i64, align 8
  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 %21

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

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

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

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

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

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

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

42:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  %43 = load ptr, ptr %10, align 8, !tbaa !9
  %44 = load i32, ptr %16, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i64, ptr %43, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = trunc i64 %47 to i32
  store i32 %48, 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 %49

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

59:                                               ; preds = %49
  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 %88

60:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #2
  %61 = load ptr, ptr %11, align 8, !tbaa !9
  %62 = load ptr, ptr %12, align 8, !tbaa !9
  %63 = load i32, ptr %16, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i64, ptr %62, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !5
  %67 = load i32, ptr %19, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = add i64 %66, %68
  %70 = getelementptr inbounds i32, ptr %61, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  store i64 %72, ptr %20, align 8, !tbaa !5
  %73 = load ptr, ptr %13, align 8, !tbaa !9
  %74 = load i32, ptr %18, align 4, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds double, ptr %73, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !13
  %78 = load ptr, ptr %14, align 8, !tbaa !9
  %79 = load i64, ptr %20, align 8, !tbaa !5
  %80 = getelementptr inbounds double, ptr %78, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !13
  %82 = fadd double %81, %77
  store double %82, ptr %80, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  br label %83

83:                                               ; preds = %60
  %84 = load i32, ptr %18, align 4, !tbaa !11
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %18, align 4, !tbaa !11
  %86 = load i32, ptr %19, align 4, !tbaa !11
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %19, align 4, !tbaa !11
  br label %49, !llvm.loop !17

88:                                               ; preds = %59
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %16, align 4, !tbaa !11
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %16, align 4, !tbaa !11
  br label %36, !llvm.loop !18

92:                                               ; preds = %41
  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 @_ZN5nasoq14rhsInitBlockedEmmPmPiS0_PdS2_(i64 noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %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.ph34.preheader

.lr.ph34.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
  br label %.lr.ph34

.loopexit.loopexit.unr-lcssa:                     ; preds = %27, %.lr.ph32
  %indvars.iv37.unr = phi i64 [ %20, %.lr.ph32 ], [ %indvars.iv.next38.1, %27 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph32 ], [ %indvars.iv.next.1, %27 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.loopexit.loopexit.epilog-lcssa

.loopexit.loopexit.epilog-lcssa:                  ; preds = %.loopexit.loopexit.unr-lcssa
  %9 = getelementptr i32, ptr %24, i64 %indvars.iv.unr
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds double, ptr %5, i64 %indvars.iv37.unr
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds double, ptr %6, i64 %11
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fadd double %13, %15
  store double %16, ptr %14, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit.epilog-lcssa, %.loopexit.loopexit.unr-lcssa, %.lr.ph34
  %exitcond.not = icmp eq i64 %indvars.iv.next43, %0
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph34, !llvm.loop !13

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

.lr.ph34:                                         ; preds = %.lr.ph34.preheader, %.loopexit
  %17 = phi i64 [ %.pre, %.lr.ph34.preheader ], [ %19, %.loopexit ]
  %indvars.iv42 = phi i64 [ 0, %.lr.ph34.preheader ], [ %indvars.iv.next43, %.loopexit ]
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %18 = getelementptr inbounds i64, ptr %2, i64 %indvars.iv.next43
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %sext = shl i64 %17, 32
  %20 = ashr exact i64 %sext, 32
  %21 = icmp ugt i64 %19, %20
  br i1 %21, label %.lr.ph32, label %.loopexit

.lr.ph32:                                         ; preds = %.lr.ph34
  %22 = getelementptr inbounds i64, ptr %4, i64 %indvars.iv42
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = getelementptr i32, ptr %3, i64 %23
  %25 = sub i64 %19, %20
  %.neg = add nsw i64 %20, 1
  %xtraiter = and i64 %25, 1
  %26 = icmp eq i64 %19, %.neg
  br i1 %26, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph32.new

.lr.ph32.new:                                     ; preds = %.lr.ph32
  %unroll_iter = and i64 %25, -2
  br label %27

27:                                               ; preds = %27, %.lr.ph32.new
  %indvars.iv37 = phi i64 [ %20, %.lr.ph32.new ], [ %indvars.iv.next38.1, %27 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph32.new ], [ %indvars.iv.next.1, %27 ]
  %niter = phi i64 [ 0, %.lr.ph32.new ], [ %niter.next.1, %27 ]
  %28 = getelementptr i32, ptr %24, i64 %indvars.iv
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds double, ptr %5, i64 %indvars.iv37
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %6, i64 %30
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = fadd double %32, %34
  store double %35, ptr %33, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %36 = getelementptr i32, ptr %24, i64 %indvars.iv.next
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %gep = getelementptr double, ptr %invariant.gep, i64 %indvars.iv37
  %39 = load double, ptr %gep, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %6, i64 %38
  %41 = load double, ptr %40, align 8, !tbaa !5
  %42 = fadd double %39, %41
  store double %42, ptr %40, align 8, !tbaa !5
  %indvars.iv.next38.1 = add nuw nsw i64 %indvars.iv37, 2
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %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 %.loopexit.loopexit.unr-lcssa, label %27, !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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