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

19:                                               ; preds = %57, %5
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %60

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

33:                                               ; preds = %49, %24
  %34 = load i32, ptr %17, align 4, !tbaa !9
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = icmp ult i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %52

38:                                               ; preds = %33
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = load float, ptr %39, align 4, !tbaa !11
  %41 = load ptr, ptr %16, align 8, !tbaa !5
  %42 = load float, ptr %41, align 4, !tbaa !11
  %43 = load float, ptr %14, align 4, !tbaa !11
  %44 = call float @llvm.fmuladd.f32(float %40, float %42, float %43)
  store float %44, ptr %14, align 4, !tbaa !11
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 4
  store ptr %46, ptr %15, align 8, !tbaa !5
  %47 = load ptr, ptr %16, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i64 4
  store ptr %48, ptr %16, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %38
  %50 = load i32, ptr %17, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %17, align 4, !tbaa !9
  br label %33, !llvm.loop !13

52:                                               ; preds = %37
  %53 = load float, ptr %14, align 4, !tbaa !11
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  store float %53, ptr %54, align 4, !tbaa !11
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 4
  store ptr %56, ptr %11, align 8, !tbaa !5
  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 4, ptr %14) #3
  br label %57

57:                                               ; preds = %52
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = add i32 %58, 1
  store i32 %59, ptr %12, align 4, !tbaa !9
  br label %19, !llvm.loop !15

60:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, 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 = !{!"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(readwrite, inaccessiblemem: none) uwtable
define dso_local void @mul_mat_vec_f32_2(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr 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_edge31, label %.lr.ph30

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

.lr.ph.us.preheader:                              ; preds = %.lr.ph30
  %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.ph30.split.preheader:                         ; preds = %.lr.ph30
  %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_edge31

.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 ]
  %.02227.us = phi ptr [ %39, %._crit_edge.us ], [ %2, %.lr.ph.us.preheader ]
  %9 = trunc nuw i64 %indvars.iv to i32
  %10 = mul i32 %9, %4
  %11 = zext i32 %10 to i64
  %12 = shl nuw nsw i64 %11, 2
  %13 = getelementptr inbounds i8, ptr %0, i64 %12
  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
  %.01825.us = phi ptr [ %33, %.lr.ph.us.new ], [ %1, %.lr.ph.us ]
  %.01924.us = phi ptr [ %32, %.lr.ph.us.new ], [ %13, %.lr.ph.us ]
  %.02023.us = phi float [ %31, %.lr.ph.us.new ], [ 0.000000e+00, %.lr.ph.us ]
  %niter = phi i32 [ %niter.next.3, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %14 = load float, ptr %.01924.us, align 4, !tbaa !5
  %15 = load float, ptr %.01825.us, align 4, !tbaa !5
  %16 = tail call float @llvm.fmuladd.f32(float %14, float %15, float %.02023.us)
  %17 = getelementptr inbounds i8, ptr %.01924.us, i64 4
  %18 = getelementptr inbounds i8, ptr %.01825.us, i64 4
  %19 = load float, ptr %17, align 4, !tbaa !5
  %20 = load float, ptr %18, align 4, !tbaa !5
  %21 = tail call float @llvm.fmuladd.f32(float %19, float %20, float %16)
  %22 = getelementptr inbounds i8, ptr %.01924.us, i64 8
  %23 = getelementptr inbounds i8, ptr %.01825.us, i64 8
  %24 = load float, ptr %22, align 4, !tbaa !5
  %25 = load float, ptr %23, align 4, !tbaa !5
  %26 = tail call float @llvm.fmuladd.f32(float %24, float %25, float %21)
  %27 = getelementptr inbounds i8, ptr %.01924.us, i64 12
  %28 = getelementptr inbounds i8, ptr %.01825.us, i64 12
  %29 = load float, ptr %27, align 4, !tbaa !5
  %30 = load float, ptr %28, align 4, !tbaa !5
  %31 = tail call float @llvm.fmuladd.f32(float %29, float %30, float %26)
  %32 = getelementptr inbounds i8, ptr %.01924.us, i64 16
  %33 = getelementptr inbounds i8, ptr %.01825.us, i64 16
  %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 ], [ %31, %.lr.ph.us.new ]
  %.01825.us.unr = phi ptr [ %1, %.lr.ph.us ], [ %33, %.lr.ph.us.new ]
  %.01924.us.unr = phi ptr [ %13, %.lr.ph.us ], [ %32, %.lr.ph.us.new ]
  %.02023.us.unr = phi float [ 0.000000e+00, %.lr.ph.us ], [ %31, %.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
  %.01825.us.epil = phi ptr [ %38, %.epil.preheader ], [ %.01825.us.unr, %._crit_edge.us.unr-lcssa ]
  %.01924.us.epil = phi ptr [ %37, %.epil.preheader ], [ %.01924.us.unr, %._crit_edge.us.unr-lcssa ]
  %.02023.us.epil = phi float [ %36, %.epil.preheader ], [ %.02023.us.unr, %._crit_edge.us.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.unr-lcssa ]
  %34 = load float, ptr %.01924.us.epil, align 4, !tbaa !5
  %35 = load float, ptr %.01825.us.epil, align 4, !tbaa !5
  %36 = tail call float @llvm.fmuladd.f32(float %34, float %35, float %.02023.us.epil)
  %37 = getelementptr inbounds i8, ptr %.01924.us.epil, i64 4
  %38 = getelementptr inbounds i8, ptr %.01825.us.epil, i64 4
  %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 ], [ %36, %.epil.preheader ]
  store float %.lcssa, ptr %.02227.us, align 4, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %.02227.us, i64 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond35.not = icmp eq i64 %indvars.iv.next, %6
  br i1 %exitcond35.not, label %._crit_edge31, label %.lr.ph.us, !llvm.loop !13

._crit_edge31:                                    ; preds = %._crit_edge.us, %.lr.ph30.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(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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass