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

; 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: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt6fill_nIPdiiET_S1_T0_RKT1_(ptr noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5nasoq14spmv_csc_smallEiiPiS0_PdS1_S1_(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #3 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store i32 %0, ptr %9, align 4, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !9
  store ptr %3, ptr %12, align 8, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %20 = load ptr, ptr %15, align 8, !tbaa !9
  %21 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !5
  %22 = call noundef ptr @_ZSt6fill_nIPdiiET_S1_T0_RKT1_(ptr noundef %20, i32 noundef %21, ptr noundef nonnull align 4 dereferenceable(4) %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  %23 = load ptr, ptr %11, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %31

25:                                               ; preds = %7
  %26 = load ptr, ptr %14, align 8, !tbaa !9
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %31

28:                                               ; preds = %25
  %29 = load ptr, ptr %15, align 8, !tbaa !9
  %30 = icmp ne ptr %29, null
  br i1 %30, label %32, label %31

31:                                               ; preds = %28, %25, %7
  store i32 0, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %81

32:                                               ; preds = %28
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %77, %32
  %34 = load i32, ptr %17, align 4, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %80

37:                                               ; preds = %33
  %38 = load ptr, ptr %11, align 8, !tbaa !9
  %39 = load i32, ptr %17, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  store i32 %42, ptr %16, align 4, !tbaa !5
  br label %43

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

52:                                               ; preds = %43
  %53 = load ptr, ptr %13, align 8, !tbaa !9
  %54 = load i32, ptr %16, 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 !11
  %58 = load ptr, ptr %14, align 8, !tbaa !9
  %59 = load i32, ptr %17, 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 !11
  %63 = load ptr, ptr %15, align 8, !tbaa !9
  %64 = load ptr, ptr %12, align 8, !tbaa !9
  %65 = load i32, ptr %16, 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 !11
  %72 = call double @llvm.fmuladd.f64(double %57, double %62, double %71)
  store double %72, ptr %70, align 8, !tbaa !11
  br label %73

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

76:                                               ; preds = %43
  br label %77

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

80:                                               ; preds = %33
  store i32 1, ptr %8, align 4
  store i32 1, ptr %19, align 4
  br label %81

81:                                               ; preds = %80, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %82 = load i32, ptr %8, align 4
  ret i32 %82
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"double", !7, i64 0}
!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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; 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 #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN5nasoq14spmv_csc_smallEiiPiS0_PdS1_S1_(i32 noundef %0, i32 noundef %1, ptr noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr noundef readonly %5, ptr noundef %6) local_unnamed_addr #3 {
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  store i32 0, ptr %8, align 4, !tbaa !5
  %9 = call noundef ptr @_ZSt6fill_nIPdiiET_S1_T0_RKT1_(ptr noundef %6, i32 noundef %0, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  %10 = icmp ne ptr %2, null
  %11 = icmp ne ptr %5, null
  %or.cond = and i1 %10, %11
  %12 = icmp ne ptr %6, null
  %or.cond3 = and i1 %or.cond, %12
  br i1 %or.cond3, label %.preheader, label %.loopexit29

.preheader:                                       ; preds = %7
  %13 = icmp sgt i32 %1, 0
  br i1 %13, label %.lr.ph32.preheader, label %.loopexit29

.lr.ph32.preheader:                               ; preds = %.preheader
  %wide.trip.count37 = zext nneg i32 %1 to i64
  %.pre = load i32, ptr %2, align 4, !tbaa !5
  br label %.lr.ph32

.loopexit:                                        ; preds = %.prol.loopexit, %.lr.ph.new, %.lr.ph32
  %exitcond38.not = icmp eq i64 %indvars.iv.next35, %wide.trip.count37
  br i1 %exitcond38.not, label %.loopexit29, label %.lr.ph32, !llvm.loop !9

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %.loopexit
  %14 = phi i32 [ %.pre, %.lr.ph32.preheader ], [ %16, %.loopexit ]
  %indvars.iv34 = phi i64 [ 0, %.lr.ph32.preheader ], [ %indvars.iv.next35, %.loopexit ]
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %15 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv.next35
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = icmp slt i32 %14, %16
  br i1 %17, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph32
  %18 = getelementptr inbounds double, ptr %5, i64 %indvars.iv34
  %19 = sext i32 %14 to i64
  %wide.trip.count = sext i32 %16 to i64
  %20 = sub nsw i64 %wide.trip.count, %19
  %xtraiter = and i64 %20, 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
  %21 = getelementptr inbounds double, ptr %4, i64 %19
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = load double, ptr %18, align 8, !tbaa !11
  %24 = getelementptr inbounds i32, ptr %3, i64 %19
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds double, ptr %6, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = call double @llvm.fmuladd.f64(double %22, double %23, double %28)
  store double %29, ptr %27, align 8, !tbaa !11
  %indvars.iv.next.prol = add nsw i64 %19, 1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph
  %indvars.iv.unr = phi i64 [ %19, %.lr.ph ], [ %indvars.iv.next.prol, %.prol.loopexit.unr-lcssa ]
  %30 = add nsw i64 %wide.trip.count, -1
  %31 = icmp eq i64 %30, %19
  br i1 %31, 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 ]
  %32 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = load double, ptr %18, align 8, !tbaa !11
  %35 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %6, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !11
  %40 = call double @llvm.fmuladd.f64(double %33, double %34, double %39)
  store double %40, ptr %38, align 8, !tbaa !11
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %41 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.next
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = load double, ptr %18, align 8, !tbaa !11
  %44 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv.next
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %6, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !11
  %49 = call double @llvm.fmuladd.f64(double %42, double %43, double %48)
  store double %49, ptr %47, align 8, !tbaa !11
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %.loopexit, label %.lr.ph.new, !llvm.loop !13

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !10}


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