; LLVM IR from stonne-simulator/stonne :: pytorch-frontend/third_party/NNPACK/src/scalar/blas/sdotxf.ll_nnp_sdotxf2 (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_sdotxf2__scalar(ptr noalias noundef align 4 dereferenceable(4) %0, ptr noalias noundef align 4 dereferenceable(8) %1, i64 noundef %2, ptr noalias noundef align 4 dereferenceable(8) %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 ptr, align 8
  %14 = alloca ptr, align 8
  %15 = 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
  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 %13) #3
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %16, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %17 = load ptr, ptr %13, align 8, !tbaa !5
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = getelementptr inbounds float, ptr %17, i64 %18
  store ptr %19, ptr %14, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %24, %5
  %21 = load i64, ptr %10, align 8, !tbaa !9
  %22 = add i64 %21, -1
  store i64 %22, ptr %10, align 8, !tbaa !9
  %23 = icmp ne i64 %21, 0
  br i1 %23, label %24, label %40

24:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds float, ptr %25, i32 1
  store ptr %26, ptr %6, align 8, !tbaa !5
  %27 = load float, ptr %25, align 4, !tbaa !11
  store float %27, ptr %15, align 4, !tbaa !11
  %28 = load float, ptr %15, align 4, !tbaa !11
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = getelementptr inbounds float, ptr %29, i32 1
  store ptr %30, ptr %13, align 8, !tbaa !5
  %31 = load float, ptr %29, align 4, !tbaa !11
  %32 = load float, ptr %11, align 4, !tbaa !11
  %33 = call float @llvm.fmuladd.f32(float %28, float %31, float %32)
  store float %33, ptr %11, align 4, !tbaa !11
  %34 = load float, ptr %15, align 4, !tbaa !11
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  %36 = getelementptr inbounds float, ptr %35, i32 1
  store ptr %36, ptr %14, align 8, !tbaa !5
  %37 = load float, ptr %35, align 4, !tbaa !11
  %38 = load float, ptr %12, align 4, !tbaa !11
  %39 = call float @llvm.fmuladd.f32(float %34, float %37, float %38)
  store float %39, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %20, !llvm.loop !13

40:                                               ; preds = %20
  %41 = load float, ptr %11, align 4, !tbaa !11
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds float, ptr %42, i64 0
  store float %41, ptr %43, align 4, !tbaa !11
  %44 = load float, ptr %12, align 4, !tbaa !11
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds float, ptr %45, i64 1
  store float %44, ptr %46, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, 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: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @nnp_sdotxf2__scalar(ptr noalias nocapture noundef readonly align 4 dereferenceable(4) %0, ptr noalias nocapture noundef readonly align 4 dereferenceable(8) %1, i64 noundef %2, ptr noalias nocapture noundef writeonly align 4 dereferenceable(8) %3, i64 noundef %4) local_unnamed_addr #0 {
  %.not19 = icmp eq i64 %4, 0
  br i1 %.not19, label %._crit_edge, label %.lr.ph.preheader

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

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.lcssa.unr = phi <2 x float> [ poison, %.lr.ph.preheader ], [ %18, %.lr.ph.prol ]
  %.025.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %8, %.lr.ph.prol ]
  %.01424.unr = phi ptr [ %6, %.lr.ph.preheader ], [ %12, %.lr.ph.prol ]
  %.01523.unr = phi ptr [ %1, %.lr.ph.preheader ], [ %10, %.lr.ph.prol ]
  %.01820.unr = phi i64 [ %4, %.lr.ph.preheader ], [ %7, %.lr.ph.prol ]
  %.unr = phi <2 x float> [ zeroinitializer, %.lr.ph.preheader ], [ %18, %.lr.ph.prol ]
  %19 = icmp eq i64 %4, 1
  br i1 %19, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.025 = phi ptr [ %33, %.lr.ph ], [ %.025.unr, %.lr.ph.prol.loopexit ]
  %.01424 = phi ptr [ %37, %.lr.ph ], [ %.01424.unr, %.lr.ph.prol.loopexit ]
  %.01523 = phi ptr [ %35, %.lr.ph ], [ %.01523.unr, %.lr.ph.prol.loopexit ]
  %.01820 = phi i64 [ %32, %.lr.ph ], [ %.01820.unr, %.lr.ph.prol.loopexit ]
  %20 = phi <2 x float> [ %43, %.lr.ph ], [ %.unr, %.lr.ph.prol.loopexit ]
  %21 = getelementptr inbounds i8, ptr %.025, i64 4
  %22 = load float, ptr %.025, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %.01523, i64 4
  %24 = load float, ptr %.01523, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.01424, i64 4
  %26 = load float, ptr %.01424, align 4, !tbaa !5
  %27 = insertelement <2 x float> poison, float %22, i64 0
  %28 = shufflevector <2 x float> %27, <2 x float> poison, <2 x i32> zeroinitializer
  %29 = insertelement <2 x float> poison, float %24, i64 0
  %30 = insertelement <2 x float> %29, float %26, i64 1
  %31 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %28, <2 x float> %30, <2 x float> %20)
  %32 = add i64 %.01820, -2
  %33 = getelementptr inbounds i8, ptr %.025, i64 8
  %34 = load float, ptr %21, align 4, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.01523, i64 8
  %36 = load float, ptr %23, align 4, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %.01424, i64 8
  %38 = load float, ptr %25, align 4, !tbaa !5
  %39 = insertelement <2 x float> poison, float %34, i64 0
  %40 = shufflevector <2 x float> %39, <2 x float> poison, <2 x i32> zeroinitializer
  %41 = insertelement <2 x float> poison, float %36, i64 0
  %42 = insertelement <2 x float> %41, float %38, i64 1
  %43 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %40, <2 x float> %42, <2 x float> %31)
  %.not.1 = icmp eq i64 %32, 0
  br i1 %.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %5
  %44 = phi <2 x float> [ zeroinitializer, %5 ], [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %43, %.lr.ph ]
  store <2 x float> %44, ptr %3, 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>) #1

attributes #0 = { 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 #1 = { 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,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass