; LLVM IR from stonne-simulator/stonne :: pytorch-frontend/third_party/NNPACK/src/scalar/blas/sdotxf.ll_nnp_sdotxf3 (scalar)

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; 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 @nnp_sdotxf3__scalar(ptr noalias noundef align 4 dereferenceable(4) %0, ptr noalias noundef align 4 dereferenceable(12) %1, i64 noundef %2, ptr noalias noundef align 4 dereferenceable(12) %3, i64 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i64 %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store float 0.000000e+00, ptr %13, align 4, !tbaa !11
  store float 0.000000e+00, ptr %12, align 4, !tbaa !11
  store float 0.000000e+00, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %18, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %19 = load ptr, ptr %14, align 8, !tbaa !5
  %20 = load i64, ptr %8, align 8, !tbaa !9
  %21 = getelementptr inbounds float, ptr %19, i64 %20
  store ptr %21, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %22 = load ptr, ptr %15, align 8, !tbaa !5
  %23 = load i64, ptr %8, align 8, !tbaa !9
  %24 = getelementptr inbounds float, ptr %22, i64 %23
  store ptr %24, ptr %16, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %29, %5
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = add i64 %26, -1
  store i64 %27, ptr %10, align 8, !tbaa !9
  %28 = icmp ne i64 %26, 0
  br i1 %28, label %29, label %51

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds float, ptr %30, i32 1
  store ptr %31, ptr %6, align 8, !tbaa !5
  %32 = load float, ptr %30, align 4, !tbaa !11
  store float %32, ptr %17, align 4, !tbaa !11
  %33 = load float, ptr %17, align 4, !tbaa !11
  %34 = load ptr, ptr %14, align 8, !tbaa !5
  %35 = getelementptr inbounds float, ptr %34, i32 1
  store ptr %35, ptr %14, align 8, !tbaa !5
  %36 = load float, ptr %34, align 4, !tbaa !11
  %37 = load float, ptr %11, align 4, !tbaa !11
  %38 = call float @llvm.fmuladd.f32(float %33, float %36, float %37)
  store float %38, ptr %11, align 4, !tbaa !11
  %39 = load float, ptr %17, align 4, !tbaa !11
  %40 = load ptr, ptr %15, align 8, !tbaa !5
  %41 = getelementptr inbounds float, ptr %40, i32 1
  store ptr %41, ptr %15, align 8, !tbaa !5
  %42 = load float, ptr %40, align 4, !tbaa !11
  %43 = load float, ptr %12, align 4, !tbaa !11
  %44 = call float @llvm.fmuladd.f32(float %39, float %42, float %43)
  store float %44, ptr %12, align 4, !tbaa !11
  %45 = load float, ptr %17, align 4, !tbaa !11
  %46 = load ptr, ptr %16, align 8, !tbaa !5
  %47 = getelementptr inbounds float, ptr %46, i32 1
  store ptr %47, ptr %16, align 8, !tbaa !5
  %48 = load float, ptr %46, align 4, !tbaa !11
  %49 = load float, ptr %13, align 4, !tbaa !11
  %50 = call float @llvm.fmuladd.f32(float %45, float %48, float %49)
  store float %50, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %25, !llvm.loop !13

51:                                               ; preds = %25
  %52 = load float, ptr %11, align 4, !tbaa !11
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds float, ptr %53, i64 0
  store float %52, ptr %54, align 4, !tbaa !11
  %55 = load float, ptr %12, align 4, !tbaa !11
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds float, ptr %56, i64 1
  store float %55, ptr %57, align 4, !tbaa !11
  %58 = load float, ptr %13, align 4, !tbaa !11
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds float, ptr %59, i64 2
  store float %58, ptr %60, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @nnp_sdotxf3__scalar(ptr noalias nocapture noundef readonly align 4 dereferenceable(4) %0, ptr noalias nocapture noundef readonly align 4 dereferenceable(12) %1, i64 noundef %2, ptr noalias nocapture noundef writeonly align 4 dereferenceable(12) %3, i64 noundef %4) local_unnamed_addr #1 {
  %.not28 = icmp eq i64 %4, 0
  br i1 %.not28, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  %6 = getelementptr inbounds float, ptr %1, i64 %2
  %7 = getelementptr inbounds float, ptr %6, i64 %2
  %xtraiter = and i64 %4, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %8 = add nsw i64 %4, -1
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load float, ptr %0, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 4
  %12 = load float, ptr %1, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %6, i64 4
  %14 = load float, ptr %6, align 4, !tbaa !5
  %15 = insertelement <2 x float> poison, float %10, i64 0
  %16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> zeroinitializer
  %17 = insertelement <2 x float> poison, float %12, i64 0
  %18 = insertelement <2 x float> %17, float %14, i64 1
  %19 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %16, <2 x float> %18, <2 x float> zeroinitializer)
  %20 = getelementptr inbounds i8, ptr %7, i64 4
  %21 = load float, ptr %7, align 4, !tbaa !5
  %22 = tail call float @llvm.fmuladd.f32(float %10, float %21, float 0.000000e+00)
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.lcssa45.unr = phi <2 x float> [ poison, %.lr.ph.preheader ], [ %19, %.lr.ph.prol ]
  %.lcssa.unr = phi float [ poison, %.lr.ph.preheader ], [ %22, %.lr.ph.prol ]
  %.036.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %9, %.lr.ph.prol ]
  %.02135.unr = phi ptr [ %7, %.lr.ph.preheader ], [ %20, %.lr.ph.prol ]
  %.02234.unr = phi ptr [ %6, %.lr.ph.preheader ], [ %13, %.lr.ph.prol ]
  %.02333.unr = phi ptr [ %1, %.lr.ph.preheader ], [ %11, %.lr.ph.prol ]
  %.02432.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %22, %.lr.ph.prol ]
  %.02729.unr = phi i64 [ %4, %.lr.ph.preheader ], [ %8, %.lr.ph.prol ]
  %.unr = phi <2 x float> [ zeroinitializer, %.lr.ph.preheader ], [ %19, %.lr.ph.prol ]
  %23 = icmp eq i64 %4, 1
  br i1 %23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.036 = phi ptr [ %40, %.lr.ph ], [ %.036.unr, %.lr.ph.prol.loopexit ]
  %.02135 = phi ptr [ %51, %.lr.ph ], [ %.02135.unr, %.lr.ph.prol.loopexit ]
  %.02234 = phi ptr [ %44, %.lr.ph ], [ %.02234.unr, %.lr.ph.prol.loopexit ]
  %.02333 = phi ptr [ %42, %.lr.ph ], [ %.02333.unr, %.lr.ph.prol.loopexit ]
  %.02432 = phi float [ %53, %.lr.ph ], [ %.02432.unr, %.lr.ph.prol.loopexit ]
  %.02729 = phi i64 [ %39, %.lr.ph ], [ %.02729.unr, %.lr.ph.prol.loopexit ]
  %24 = phi <2 x float> [ %50, %.lr.ph ], [ %.unr, %.lr.ph.prol.loopexit ]
  %25 = getelementptr inbounds i8, ptr %.036, i64 4
  %26 = load float, ptr %.036, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.02333, i64 4
  %28 = load float, ptr %.02333, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.02234, i64 4
  %30 = load float, ptr %.02234, align 4, !tbaa !5
  %31 = insertelement <2 x float> poison, float %26, i64 0
  %32 = shufflevector <2 x float> %31, <2 x float> poison, <2 x i32> zeroinitializer
  %33 = insertelement <2 x float> poison, float %28, i64 0
  %34 = insertelement <2 x float> %33, float %30, i64 1
  %35 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %32, <2 x float> %34, <2 x float> %24)
  %36 = getelementptr inbounds i8, ptr %.02135, i64 4
  %37 = load float, ptr %.02135, align 4, !tbaa !5
  %38 = tail call float @llvm.fmuladd.f32(float %26, float %37, float %.02432)
  %39 = add i64 %.02729, -2
  %40 = getelementptr inbounds i8, ptr %.036, i64 8
  %41 = load float, ptr %25, align 4, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %.02333, i64 8
  %43 = load float, ptr %27, align 4, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %.02234, i64 8
  %45 = load float, ptr %29, align 4, !tbaa !5
  %46 = insertelement <2 x float> poison, float %41, i64 0
  %47 = shufflevector <2 x float> %46, <2 x float> poison, <2 x i32> zeroinitializer
  %48 = insertelement <2 x float> poison, float %43, i64 0
  %49 = insertelement <2 x float> %48, float %45, i64 1
  %50 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %47, <2 x float> %49, <2 x float> %35)
  %51 = getelementptr inbounds i8, ptr %.02135, i64 8
  %52 = load float, ptr %36, align 4, !tbaa !5
  %53 = tail call float @llvm.fmuladd.f32(float %41, float %52, float %38)
  %.not.1 = icmp eq i64 %39, 0
  br i1 %.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %5
  %.024.lcssa = phi float [ 0.000000e+00, %5 ], [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %53, %.lr.ph ]
  %54 = phi <2 x float> [ zeroinitializer, %5 ], [ %.lcssa45.unr, %.lr.ph.prol.loopexit ], [ %50, %.lr.ph ]
  store <2 x float> %54, ptr %3, align 4, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %3, i64 8
  store float %.024.lcssa, ptr %55, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2

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

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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