; LLVM IR from ggml-org/ggml :: tests (test-vec0)

; 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 @mul_mat_vec_f32_1(ptr noalias noundef %0, ptr noalias noundef %1, ptr noalias noundef %2, i32 noundef %3, i32 noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %53, %5
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp ult i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %56

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = mul i32 %24, %25
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %23, i64 %27
  store ptr %28, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %29, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store float 0.000000e+00, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %44, %22
  %31 = load i32, ptr %16, align 4, !tbaa !9
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = icmp ult i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %47

35:                                               ; preds = %30
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = getelementptr inbounds float, ptr %36, i32 1
  store ptr %37, ptr %13, align 8, !tbaa !5
  %38 = load float, ptr %36, align 32, !tbaa !11
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = getelementptr inbounds float, ptr %39, i32 1
  store ptr %40, ptr %14, align 8, !tbaa !5
  %41 = load float, ptr %39, align 32, !tbaa !11
  %42 = load float, ptr %15, align 4, !tbaa !11
  %43 = call float @llvm.fmuladd.f32(float %38, float %41, float %42)
  store float %43, ptr %15, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %35
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = add i32 %45, 1
  store i32 %46, ptr %16, align 4, !tbaa !9
  br label %30, !llvm.loop !13

47:                                               ; preds = %34
  %48 = load float, ptr %15, align 4, !tbaa !11
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds float, ptr %49, i64 %51
  store float %48, ptr %52, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %53

53:                                               ; preds = %47
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = add i32 %54, 1
  store i32 %55, ptr %11, align 4, !tbaa !9
  br label %17, !llvm.loop !15

56:                                               ; preds = %21
  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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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 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 @mul_mat_vec_f32_1(ptr noalias nocapture noundef readonly %0, ptr noalias nocapture noundef readonly %1, ptr noalias nocapture noundef writeonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %5
  %.not27 = icmp eq i32 %4, 0
  %6 = zext i32 %3 to i64
  br i1 %.not27, label %.lr.ph25.split.preheader, label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %.lr.ph25
  %xtraiter = and i32 %4, 3
  %7 = icmp ult i32 %4, 4
  %unroll_iter = and i32 %4, -4
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br label %.lr.ph.us

.lr.ph25.split.preheader:                         ; preds = %.lr.ph25
  %8 = shl nuw nsw i64 %6, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %2, i8 0, i64 %8, i1 false), !tbaa !5
  br label %._crit_edge26

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge.us ], [ 0, %.lr.ph.us.preheader ]
  %9 = trunc nuw i64 %indvars.iv to i32
  %10 = mul i32 %9, %4
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds float, ptr %0, i64 %11
  br i1 %7, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new

.lr.ph.us.new:                                    ; preds = %.lr.ph.us, %.lr.ph.us.new
  %.01521.us = phi float [ %32, %.lr.ph.us.new ], [ 0.000000e+00, %.lr.ph.us ]
  %.01620.us = phi ptr [ %30, %.lr.ph.us.new ], [ %1, %.lr.ph.us ]
  %.01719.us = phi ptr [ %28, %.lr.ph.us.new ], [ %12, %.lr.ph.us ]
  %niter = phi i32 [ %niter.next.3, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %13 = getelementptr inbounds i8, ptr %.01719.us, i64 4
  %14 = load float, ptr %.01719.us, align 32, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.01620.us, i64 4
  %16 = load float, ptr %.01620.us, align 32, !tbaa !5
  %17 = tail call float @llvm.fmuladd.f32(float %14, float %16, float %.01521.us)
  %18 = getelementptr inbounds i8, ptr %.01719.us, i64 8
  %19 = load float, ptr %13, align 32, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %.01620.us, i64 8
  %21 = load float, ptr %15, align 32, !tbaa !5
  %22 = tail call float @llvm.fmuladd.f32(float %19, float %21, float %17)
  %23 = getelementptr inbounds i8, ptr %.01719.us, i64 12
  %24 = load float, ptr %18, align 32, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.01620.us, i64 12
  %26 = load float, ptr %20, align 32, !tbaa !5
  %27 = tail call float @llvm.fmuladd.f32(float %24, float %26, float %22)
  %28 = getelementptr inbounds i8, ptr %.01719.us, i64 16
  %29 = load float, ptr %23, align 32, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.01620.us, i64 16
  %31 = load float, ptr %25, align 32, !tbaa !5
  %32 = tail call float @llvm.fmuladd.f32(float %29, float %31, float %27)
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new, !llvm.loop !9

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us.new, %.lr.ph.us
  %.lcssa.ph = phi float [ poison, %.lr.ph.us ], [ %32, %.lr.ph.us.new ]
  %.01521.us.unr = phi float [ 0.000000e+00, %.lr.ph.us ], [ %32, %.lr.ph.us.new ]
  %.01620.us.unr = phi ptr [ %1, %.lr.ph.us ], [ %30, %.lr.ph.us.new ]
  %.01719.us.unr = phi ptr [ %12, %.lr.ph.us ], [ %28, %.lr.ph.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.unr-lcssa, %.epil.preheader
  %.01521.us.epil = phi float [ %37, %.epil.preheader ], [ %.01521.us.unr, %._crit_edge.us.unr-lcssa ]
  %.01620.us.epil = phi ptr [ %35, %.epil.preheader ], [ %.01620.us.unr, %._crit_edge.us.unr-lcssa ]
  %.01719.us.epil = phi ptr [ %33, %.epil.preheader ], [ %.01719.us.unr, %._crit_edge.us.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.unr-lcssa ]
  %33 = getelementptr inbounds i8, ptr %.01719.us.epil, i64 4
  %34 = load float, ptr %.01719.us.epil, align 32, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.01620.us.epil, i64 4
  %36 = load float, ptr %.01620.us.epil, align 32, !tbaa !5
  %37 = tail call float @llvm.fmuladd.f32(float %34, float %36, float %.01521.us.epil)
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.us, label %.epil.preheader, !llvm.loop !11

._crit_edge.us:                                   ; preds = %.epil.preheader, %._crit_edge.us.unr-lcssa
  %.lcssa = phi float [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %37, %.epil.preheader ]
  %38 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  store float %.lcssa, ptr %38, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond30.not = icmp eq i64 %indvars.iv.next, %6
  br i1 %exitcond30.not, label %._crit_edge26, label %.lr.ph.us, !llvm.loop !13

._crit_edge26:                                    ; preds = %._crit_edge.us, %.lr.ph25.split.preheader, %5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }

!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"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}


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