; LLVM IR from ifinver/FinEngine :: finengine/src/main/cpp/Matrix.ll (Z14matrixMultiplyPfS_S_)

; 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: mustprogress nounwind uwtable
define dso_local void @_Z14matrixMultiplyPfS_S_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [16 x float], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %85, %3
  %14 = load i32, ptr %10, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 4
  br i1 %15, label %16, label %88

16:                                               ; preds = %13
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %81, %16
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = icmp slt i32 %18, 4
  br i1 %19, label %20, label %84

20:                                               ; preds = %17
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds float, ptr %21, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !11
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = mul nsw i32 4, %27
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds float, ptr %26, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !11
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = add nsw i32 4, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %32, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !11
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = mul nsw i32 4, %39
  %41 = add nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %38, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !11
  %45 = fmul float %37, %44
  %46 = call float @llvm.fmuladd.f32(float %25, float %31, float %45)
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = add nsw i32 8, %48
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %47, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !11
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = mul nsw i32 4, %54
  %56 = add nsw i32 %55, 2
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds float, ptr %53, i64 %57
  %59 = load float, ptr %58, align 4, !tbaa !11
  %60 = call float @llvm.fmuladd.f32(float %52, float %59, float %46)
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = add nsw i32 12, %62
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %61, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !11
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = mul nsw i32 4, %68
  %70 = add nsw i32 %69, 3
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %67, i64 %71
  %73 = load float, ptr %72, align 4, !tbaa !11
  %74 = call float @llvm.fmuladd.f32(float %66, float %73, float %60)
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = mul nsw i32 4, %75
  %77 = load i32, ptr %11, align 4, !tbaa !9
  %78 = add nsw i32 %76, %77
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [16 x float], ptr %7, i64 0, i64 %79
  store float %74, ptr %80, align 4, !tbaa !11
  br label %81

81:                                               ; preds = %20
  %82 = load i32, ptr %11, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %11, align 4, !tbaa !9
  br label %17, !llvm.loop !13

84:                                               ; preds = %17
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %10, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %10, align 4, !tbaa !9
  br label %13, !llvm.loop !15

88:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %102, %88
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = icmp slt i32 %90, 16
  br i1 %91, label %93, label %92

92:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %105

93:                                               ; preds = %89
  %94 = load i32, ptr %12, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [16 x float], ptr %7, i64 0, i64 %95
  %97 = load float, ptr %96, align 4, !tbaa !11
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = load i32, ptr %12, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds float, ptr %98, i64 %100
  store float %97, ptr %101, align 4, !tbaa !11
  br label %102

102:                                              ; preds = %93
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %12, align 4, !tbaa !9
  br label %89, !llvm.loop !16

105:                                              ; preds = %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple 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}
!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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_Z14matrixMultiplyPfS_S_(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
.preheader28:
  %3 = load float, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %2, i64 4
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 12
  %9 = load float, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = getelementptr inbounds i8, ptr %1, i64 32
  %12 = getelementptr inbounds i8, ptr %1, i64 48
  %13 = getelementptr inbounds i8, ptr %2, i64 16
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %2, i64 20
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %2, i64 24
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %2, i64 28
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %2, i64 32
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %2, i64 36
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %2, i64 40
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %2, i64 44
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %2, i64 48
  %30 = load float, ptr %29, align 4, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %2, i64 52
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %2, i64 56
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %2, i64 60
  %36 = load float, ptr %35, align 4, !tbaa !5
  %37 = load float, ptr %1, align 4, !tbaa !5
  %38 = load float, ptr %10, align 4, !tbaa !5
  %39 = load float, ptr %11, align 4, !tbaa !5
  %40 = load float, ptr %12, align 4, !tbaa !5
  %41 = load <4 x float>, ptr %1, align 4, !tbaa !5
  %42 = load <4 x float>, ptr %10, align 4, !tbaa !5
  %43 = insertelement <4 x float> poison, float %5, i64 0
  %44 = shufflevector <4 x float> %43, <4 x float> poison, <4 x i32> zeroinitializer
  %45 = fmul <4 x float> %42, %44
  %46 = insertelement <4 x float> poison, float %3, i64 0
  %47 = shufflevector <4 x float> %46, <4 x float> poison, <4 x i32> zeroinitializer
  %48 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %41, <4 x float> %47, <4 x float> %45)
  %49 = load <4 x float>, ptr %11, align 4, !tbaa !5
  %50 = insertelement <4 x float> poison, float %7, i64 0
  %51 = shufflevector <4 x float> %50, <4 x float> poison, <4 x i32> zeroinitializer
  %52 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %49, <4 x float> %51, <4 x float> %48)
  %53 = load <4 x float>, ptr %12, align 4, !tbaa !5
  %54 = insertelement <4 x float> poison, float %9, i64 0
  %55 = shufflevector <4 x float> %54, <4 x float> poison, <4 x i32> zeroinitializer
  %56 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %53, <4 x float> %55, <4 x float> %52)
  store <4 x float> %56, ptr %0, align 4, !tbaa !5
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 16
  %57 = insertelement <4 x float> poison, float %16, i64 0
  %58 = shufflevector <4 x float> %57, <4 x float> poison, <4 x i32> zeroinitializer
  %59 = fmul <4 x float> %42, %58
  %60 = insertelement <4 x float> poison, float %14, i64 0
  %61 = shufflevector <4 x float> %60, <4 x float> poison, <4 x i32> zeroinitializer
  %62 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %41, <4 x float> %61, <4 x float> %59)
  %63 = insertelement <4 x float> poison, float %18, i64 0
  %64 = shufflevector <4 x float> %63, <4 x float> poison, <4 x i32> zeroinitializer
  %65 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %49, <4 x float> %64, <4 x float> %62)
  %66 = insertelement <4 x float> poison, float %20, i64 0
  %67 = shufflevector <4 x float> %66, <4 x float> poison, <4 x i32> zeroinitializer
  %68 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %53, <4 x float> %67, <4 x float> %65)
  store <4 x float> %68, ptr %.sroa.7.0..sroa_idx, align 4, !tbaa !5
  %.sroa.11.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 32
  %69 = insertelement <4 x float> poison, float %24, i64 0
  %70 = shufflevector <4 x float> %69, <4 x float> poison, <4 x i32> zeroinitializer
  %71 = fmul <4 x float> %42, %70
  %72 = insertelement <4 x float> poison, float %22, i64 0
  %73 = shufflevector <4 x float> %72, <4 x float> poison, <4 x i32> zeroinitializer
  %74 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %41, <4 x float> %73, <4 x float> %71)
  %75 = insertelement <4 x float> poison, float %26, i64 0
  %76 = shufflevector <4 x float> %75, <4 x float> poison, <4 x i32> zeroinitializer
  %77 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %49, <4 x float> %76, <4 x float> %74)
  %78 = insertelement <4 x float> poison, float %28, i64 0
  %79 = shufflevector <4 x float> %78, <4 x float> poison, <4 x i32> zeroinitializer
  %80 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %53, <4 x float> %79, <4 x float> %77)
  store <4 x float> %80, ptr %.sroa.11.0..sroa_idx, align 4, !tbaa !5
  %.sroa.15.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 48
  %81 = insertelement <4 x float> %42, float %38, i64 0
  %82 = insertelement <4 x float> poison, float %32, i64 0
  %83 = shufflevector <4 x float> %82, <4 x float> poison, <4 x i32> zeroinitializer
  %84 = fmul <4 x float> %81, %83
  %85 = insertelement <4 x float> %41, float %37, i64 0
  %86 = insertelement <4 x float> poison, float %30, i64 0
  %87 = shufflevector <4 x float> %86, <4 x float> poison, <4 x i32> zeroinitializer
  %88 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %85, <4 x float> %87, <4 x float> %84)
  %89 = insertelement <4 x float> %49, float %39, i64 0
  %90 = insertelement <4 x float> poison, float %34, i64 0
  %91 = shufflevector <4 x float> %90, <4 x float> poison, <4 x i32> zeroinitializer
  %92 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %89, <4 x float> %91, <4 x float> %88)
  %93 = insertelement <4 x float> %53, float %40, i64 0
  %94 = insertelement <4 x float> poison, float %36, i64 0
  %95 = shufflevector <4 x float> %94, <4 x float> poison, <4 x i32> zeroinitializer
  %96 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %93, <4 x float> %95, <4 x float> %92)
  store <4 x float> %96, ptr %.sroa.15.0..sroa_idx, align 4, !tbaa !5
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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 = { 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++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass