; LLVM IR from sympiler/nasoq :: src/matrixVector/spmv_CSC.ll (ZN5nasoq8spmv_cscEiPmPiPdS2_S2_)

; 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: mustprogress uwtable
define dso_local noundef i32 @_ZN5nasoq8spmv_cscEiPmPiPdS2_S2_(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !9
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %18 = load ptr, ptr %13, align 8, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !5
  %20 = call noundef ptr @_ZSt6fill_nIPdiiET_S1_T0_RKT1_(ptr noundef %18, i32 noundef %19, ptr noundef nonnull align 4 dereferenceable(4) %16)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %21 = load ptr, ptr %9, align 8, !tbaa !9
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %29

23:                                               ; preds = %6
  %24 = load ptr, ptr %12, align 8, !tbaa !9
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %29

26:                                               ; preds = %23
  %27 = load ptr, ptr %13, align 8, !tbaa !9
  %28 = icmp ne ptr %27, null
  br i1 %28, label %30, label %29

29:                                               ; preds = %26, %23, %6
  store i32 0, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %81

30:                                               ; preds = %26
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %77, %30
  %32 = load i32, ptr %15, align 4, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %35, label %80

35:                                               ; preds = %31
  %36 = load ptr, ptr %9, align 8, !tbaa !9
  %37 = load i32, ptr %15, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i64, ptr %36, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = trunc i64 %40 to i32
  store i32 %41, ptr %14, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %73, %35
  %43 = load i32, ptr %14, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = load ptr, ptr %9, align 8, !tbaa !9
  %46 = load i32, ptr %15, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i64, ptr %45, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !11
  %51 = icmp ult i64 %44, %50
  br i1 %51, label %52, label %76

52:                                               ; preds = %42
  %53 = load ptr, ptr %11, align 8, !tbaa !9
  %54 = load i32, ptr %14, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds double, ptr %53, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !13
  %58 = load ptr, ptr %12, align 8, !tbaa !9
  %59 = load i32, ptr %15, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %58, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !13
  %63 = load ptr, ptr %13, align 8, !tbaa !9
  %64 = load ptr, ptr %10, align 8, !tbaa !9
  %65 = load i32, ptr %14, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i32, ptr %64, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %63, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !13
  %72 = call double @llvm.fmuladd.f64(double %57, double %62, double %71)
  store double %72, ptr %70, align 8, !tbaa !13
  br label %73

73:                                               ; preds = %52
  %74 = load i32, ptr %14, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %14, align 4, !tbaa !5
  br label %42, !llvm.loop !15

76:                                               ; preds = %42
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %15, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %15, align 4, !tbaa !5
  br label %31, !llvm.loop !17

80:                                               ; preds = %31
  store i32 1, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %81

81:                                               ; preds = %80, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %82 = load i32, ptr %7, align 4
  ret i32 %82
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6fill_nIPdiiET_S1_T0_RKT1_(ptr noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

attributes #0 = { mustprogress 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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"int", !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 = !{!"long", !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}


; 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 uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN5nasoq8spmv_cscEiPmPiPdS2_S2_(i32 noundef %0, ptr noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr noundef readonly %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  %8 = call noundef ptr @_ZSt6fill_nIPdiiET_S1_T0_RKT1_(ptr noundef %5, i32 noundef %0, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  %9 = icmp ne ptr %1, null
  %10 = icmp ne ptr %4, null
  %or.cond = and i1 %9, %10
  %11 = icmp ne ptr %5, null
  %or.cond3 = and i1 %or.cond, %11
  br i1 %or.cond3, label %.preheader, label %.loopexit30

.preheader:                                       ; preds = %6
  %12 = icmp sgt i32 %0, 0
  br i1 %12, label %.lr.ph33.preheader, label %.loopexit30

.lr.ph33.preheader:                               ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %0 to i64
  %.pre = load i64, ptr %1, align 8, !tbaa !9
  br label %.lr.ph33

.loopexit:                                        ; preds = %.prol.loopexit, %.lr.ph.new, %.lr.ph33
  %exitcond.not = icmp eq i64 %indvars.iv.next36, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit30, label %.lr.ph33, !llvm.loop !11

.lr.ph33:                                         ; preds = %.lr.ph33.preheader, %.loopexit
  %13 = phi i64 [ %.pre, %.lr.ph33.preheader ], [ %15, %.loopexit ]
  %indvars.iv35 = phi i64 [ 0, %.lr.ph33.preheader ], [ %indvars.iv.next36, %.loopexit ]
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %14 = getelementptr inbounds i64, ptr %1, i64 %indvars.iv.next36
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %sext = shl i64 %13, 32
  %16 = ashr exact i64 %sext, 32
  %17 = icmp ugt i64 %15, %16
  br i1 %17, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph33
  %18 = getelementptr inbounds double, ptr %4, i64 %indvars.iv35
  %19 = sub i64 %15, %13
  %.neg = add nsw i64 %16, 1
  %xtraiter = and i64 %19, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %.lr.ph
  %20 = getelementptr inbounds double, ptr %3, i64 %16
  %21 = load double, ptr %20, align 8, !tbaa !13
  %22 = load double, ptr %18, align 8, !tbaa !13
  %23 = getelementptr inbounds i32, ptr %2, i64 %16
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %5, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !13
  %28 = call double @llvm.fmuladd.f64(double %21, double %22, double %27)
  store double %28, ptr %26, align 8, !tbaa !13
  %indvars.iv.next.prol = add nuw nsw i64 %16, 1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph
  %indvars.iv.unr = phi i64 [ %16, %.lr.ph ], [ %indvars.iv.next.prol, %.prol.loopexit.unr-lcssa ]
  %29 = icmp eq i64 %15, %.neg
  br i1 %29, label %.loopexit, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.prol.loopexit, %.lr.ph.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph.new ], [ %indvars.iv.unr, %.prol.loopexit ]
  %30 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %31 = load double, ptr %30, align 8, !tbaa !13
  %32 = load double, ptr %18, align 8, !tbaa !13
  %33 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %5, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !13
  %38 = call double @llvm.fmuladd.f64(double %31, double %32, double %37)
  store double %38, ptr %36, align 8, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next
  %40 = load double, ptr %39, align 8, !tbaa !13
  %41 = load double, ptr %18, align 8, !tbaa !13
  %42 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %5, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !13
  %47 = call double @llvm.fmuladd.f64(double %40, double %41, double %46)
  store double %47, ptr %45, align 8, !tbaa !13
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %48 = icmp ugt i64 %15, %indvars.iv.next.1
  br i1 %48, label %.lr.ph.new, label %.loopexit, !llvm.loop !15

.loopexit30:                                      ; preds = %.loopexit, %.preheader, %6
  %.025 = phi i32 [ 0, %6 ], [ 1, %.preheader ], [ 1, %.loopexit ]
  ret i32 %.025
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6fill_nIPdiiET_S1_T0_RKT1_(ptr noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"int", !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 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !12}


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