; LLVM IR from EntityFX/anybench :: src/benchmarks/generic/scimark2 (SparseCompRow)

; 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: nounwind uwtable
define dso_local void @SparseCompRow_matmult(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6) #1 {
  %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
  %18 = alloca double, align 8
  %19 = alloca i32, align 4
  %20 = 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
  store i32 %6, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %77, %7
  %22 = load i32, ptr %15, align 4, !tbaa !5
  %23 = load i32, ptr %14, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %25, label %80

25:                                               ; preds = %21
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %73, %25
  %27 = load i32, ptr %16, align 4, !tbaa !5
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %76

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  store double 0.000000e+00, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %31 = load ptr, ptr %11, align 8, !tbaa !9
  %32 = load i32, ptr %16, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %31, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  store i32 %35, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %36 = load ptr, ptr %11, align 8, !tbaa !9
  %37 = load i32, ptr %16, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %36, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  store i32 %41, ptr %20, align 4, !tbaa !5
  %42 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %42, ptr %17, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %64, %30
  %44 = load i32, ptr %17, align 4, !tbaa !5
  %45 = load i32, ptr %20, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %67

47:                                               ; preds = %43
  %48 = load ptr, ptr %13, align 8, !tbaa !9
  %49 = load ptr, ptr %12, align 8, !tbaa !9
  %50 = load i32, ptr %17, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr %49, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %48, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = load ptr, ptr %10, align 8, !tbaa !9
  %58 = load i32, ptr %17, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = load double, ptr %18, align 8, !tbaa !11
  %63 = call double @llvm.fmuladd.f64(double %56, double %61, double %62)
  store double %63, ptr %18, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %47
  %65 = load i32, ptr %17, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %17, align 4, !tbaa !5
  br label %43, !llvm.loop !13

67:                                               ; preds = %43
  %68 = load double, ptr %18, align 8, !tbaa !11
  %69 = load ptr, ptr %9, align 8, !tbaa !9
  %70 = load i32, ptr %16, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds double, ptr %69, i64 %71
  store double %68, ptr %72, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  br label %73

73:                                               ; preds = %67
  %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 %26, !llvm.loop !15

76:                                               ; preds = %26
  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 %21, !llvm.loop !16

80:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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/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}
!16 = distinct !{!16, !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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @SparseCompRow_matmult(i32 noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = icmp sgt i32 %6, 0
  %9 = icmp sgt i32 %0, 0
  %or.cond = and i1 %8, %9
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge31

.preheader.us.preheader:                          ; preds = %7
  %.pre.pre = load i32, ptr %3, align 4, !tbaa !5
  %wide.trip.count37 = zext nneg i32 %0 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge29.us
  %.030.us = phi i32 [ %60, %._crit_edge29.us ], [ 0, %.preheader.us.preheader ]
  br label %10

10:                                               ; preds = %.preheader.us, %._crit_edge.us
  %11 = phi i32 [ %.pre.pre, %.preheader.us ], [ %13, %._crit_edge.us ]
  %indvars.iv34 = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next35, %._crit_edge.us ]
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %12 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv.next35
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = icmp slt i32 %11, %13
  br i1 %14, label %.lr.ph.us.preheader, label %._crit_edge.us

.lr.ph.us.preheader:                              ; preds = %10
  %15 = sext i32 %11 to i64
  %wide.trip.count = sext i32 %13 to i64
  %16 = sub nsw i64 %wide.trip.count, %15
  %xtraiter = and i64 %16, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.us.prol.loopexit, label %.lr.ph.us.prol

.lr.ph.us.prol:                                   ; preds = %.lr.ph.us.preheader, %.lr.ph.us.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.lr.ph.us.prol ], [ %15, %.lr.ph.us.preheader ]
  %.02326.us.prol = phi double [ %24, %.lr.ph.us.prol ], [ 0.000000e+00, %.lr.ph.us.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.us.prol ], [ 0, %.lr.ph.us.preheader ]
  %17 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv.prol
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds double, ptr %5, i64 %19
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.prol
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %.02326.us.prol)
  %indvars.iv.next.prol = add 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 %.lr.ph.us.prol.loopexit, label %.lr.ph.us.prol, !llvm.loop !11

.lr.ph.us.prol.loopexit:                          ; preds = %.lr.ph.us.prol, %.lr.ph.us.preheader
  %.lcssa.unr = phi double [ poison, %.lr.ph.us.preheader ], [ %24, %.lr.ph.us.prol ]
  %indvars.iv.unr = phi i64 [ %15, %.lr.ph.us.preheader ], [ %indvars.iv.next.prol, %.lr.ph.us.prol ]
  %.02326.us.unr = phi double [ 0.000000e+00, %.lr.ph.us.preheader ], [ %24, %.lr.ph.us.prol ]
  %25 = sub nsw i64 %15, %wide.trip.count
  %26 = icmp ugt i64 %25, -4
  br i1 %26, label %._crit_edge.us, label %.lr.ph.us

._crit_edge.us:                                   ; preds = %.lr.ph.us.prol.loopexit, %.lr.ph.us, %10
  %.023.lcssa.us = phi double [ 0.000000e+00, %10 ], [ %.lcssa.unr, %.lr.ph.us.prol.loopexit ], [ %59, %.lr.ph.us ]
  %27 = getelementptr inbounds double, ptr %1, i64 %indvars.iv34
  store double %.023.lcssa.us, ptr %27, align 8, !tbaa !9
  %exitcond38.not = icmp eq i64 %indvars.iv.next35, %wide.trip.count37
  br i1 %exitcond38.not, label %._crit_edge29.us, label %10, !llvm.loop !13

.lr.ph.us:                                        ; preds = %.lr.ph.us.prol.loopexit, %.lr.ph.us
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph.us ], [ %indvars.iv.unr, %.lr.ph.us.prol.loopexit ]
  %.02326.us = phi double [ %59, %.lr.ph.us ], [ %.02326.us.unr, %.lr.ph.us.prol.loopexit ]
  %28 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds double, ptr %5, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = tail call double @llvm.fmuladd.f64(double %32, double %34, double %.02326.us)
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %36 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv.next
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %5, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = tail call double @llvm.fmuladd.f64(double %40, double %42, double %35)
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %44 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv.next.1
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %5, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next.1
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = tail call double @llvm.fmuladd.f64(double %48, double %50, double %43)
  %indvars.iv.next.2 = add nsw i64 %indvars.iv, 3
  %52 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv.next.2
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds double, ptr %5, i64 %54
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next.2
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = tail call double @llvm.fmuladd.f64(double %56, double %58, double %51)
  %indvars.iv.next.3 = add nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge.us, label %.lr.ph.us, !llvm.loop !15

._crit_edge29.us:                                 ; preds = %._crit_edge.us
  %60 = add nuw nsw i32 %.030.us, 1
  %exitcond39.not = icmp eq i32 %60, %6
  br i1 %exitcond39.not, label %._crit_edge31, label %.preheader.us, !llvm.loop !16

._crit_edge31:                                    ; preds = %._crit_edge29.us, %7
  ret void
}

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

attributes #0 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


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