; LLVM IR from sejja/3D-Software-Rasterizer :: Rasterizer/Engine/Math/Matrix4.ll (ZNK7Matrix4mlERKS_)

; 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"

%class.Matrix4 = type { %union.anon }
%union.anon = type { [4 x [4 x float]] }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7Matrix4mlERKS_(ptr dead_on_unwind noalias writable sret(%class.Matrix4) align 4 %0, ptr noundef nonnull align 4 dereferenceable(64) %1, ptr noundef nonnull align 4 dereferenceable(64) %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @_ZN7Matrix4C1Ev(ptr noundef nonnull align 4 dereferenceable(64) %0)
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %11

11:                                               ; preds = %92, %3
  %12 = load i8, ptr %7, align 1, !tbaa !9
  %13 = zext i8 %12 to i32
  %14 = icmp slt i32 %13, 4
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  br label %95

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  store i8 0, ptr %9, align 1, !tbaa !9
  br label %17

17:                                               ; preds = %88, %16
  %18 = load i8, ptr %9, align 1, !tbaa !9
  %19 = zext i8 %18 to i32
  %20 = icmp slt i32 %19, 4
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  br label %91

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

88:                                               ; preds = %22
  %89 = load i8, ptr %9, align 1, !tbaa !9
  %90 = add i8 %89, 1
  store i8 %90, ptr %9, align 1, !tbaa !9
  br label %17, !llvm.loop !10

91:                                               ; preds = %21
  br label %92

92:                                               ; preds = %91
  %93 = load i8, ptr %7, align 1, !tbaa !9
  %94 = add i8 %93, 1
  store i8 %94, ptr %7, align 1, !tbaa !9
  br label %11, !llvm.loop !12

95:                                               ; preds = %15
  ret void
}

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

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

declare void @_ZN7Matrix4C1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress 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 willreturn memory(argmem: readwrite) }
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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; 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"

%class.Matrix4 = type { %union.anon }
%union.anon = type { [4 x [4 x float]] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7Matrix4mlERKS_(ptr dead_on_unwind noalias writable sret(%class.Matrix4) align 4 %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(64) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(64) %2) local_unnamed_addr #0 align 2 {
.preheader:
  tail call void @_ZN7Matrix4C1Ev(ptr noundef nonnull align 4 dereferenceable(64) %0)
  %3 = getelementptr inbounds i8, ptr %2, i64 16
  %4 = getelementptr inbounds i8, ptr %2, i64 32
  %5 = getelementptr inbounds i8, ptr %2, i64 48
  %6 = load <4 x float>, ptr %1, align 4
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = load <4 x float>, ptr %7, align 4
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load <4 x float>, ptr %9, align 4
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = load <4 x float>, ptr %11, align 4
  %13 = load <4 x float>, ptr %2, align 4, !tbaa !5
  %14 = load <4 x float>, ptr %3, align 4, !tbaa !5
  %15 = shufflevector <4 x float> %8, <4 x float> poison, <4 x i32> zeroinitializer
  %16 = fmul <4 x float> %15, %14
  %17 = shufflevector <4 x float> %6, <4 x float> poison, <4 x i32> zeroinitializer
  %18 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %17, <4 x float> %13, <4 x float> %16)
  %19 = load <4 x float>, ptr %4, align 4, !tbaa !5
  %20 = shufflevector <4 x float> %10, <4 x float> poison, <4 x i32> zeroinitializer
  %21 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %20, <4 x float> %19, <4 x float> %18)
  %22 = load <4 x float>, ptr %5, align 4, !tbaa !5
  %23 = shufflevector <4 x float> %12, <4 x float> poison, <4 x i32> zeroinitializer
  %24 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %23, <4 x float> %22, <4 x float> %21)
  %25 = load <4 x float>, ptr %0, align 4, !tbaa !5
  %26 = fadd <4 x float> %25, %24
  store <4 x float> %26, ptr %0, align 4, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 16
  %28 = load <4 x float>, ptr %27, align 4
  %29 = getelementptr inbounds i8, ptr %1, i64 20
  %30 = load <4 x float>, ptr %29, align 4
  %31 = getelementptr inbounds i8, ptr %1, i64 24
  %32 = load <4 x float>, ptr %31, align 4
  %33 = getelementptr inbounds i8, ptr %1, i64 28
  %34 = load <4 x float>, ptr %33, align 4
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = shufflevector <4 x float> %30, <4 x float> poison, <4 x i32> zeroinitializer
  %37 = fmul <4 x float> %36, %14
  %38 = shufflevector <4 x float> %28, <4 x float> poison, <4 x i32> zeroinitializer
  %39 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %38, <4 x float> %13, <4 x float> %37)
  %40 = shufflevector <4 x float> %32, <4 x float> poison, <4 x i32> zeroinitializer
  %41 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %40, <4 x float> %19, <4 x float> %39)
  %42 = shufflevector <4 x float> %34, <4 x float> poison, <4 x i32> zeroinitializer
  %43 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %42, <4 x float> %22, <4 x float> %41)
  %44 = load <4 x float>, ptr %35, align 4, !tbaa !5
  %45 = fadd <4 x float> %44, %43
  store <4 x float> %45, ptr %35, align 4, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %1, i64 32
  %47 = load <4 x float>, ptr %46, align 4
  %48 = getelementptr inbounds i8, ptr %1, i64 36
  %49 = load <4 x float>, ptr %48, align 4
  %50 = getelementptr inbounds i8, ptr %1, i64 40
  %51 = load <4 x float>, ptr %50, align 4
  %52 = getelementptr inbounds i8, ptr %1, i64 44
  %53 = load <4 x float>, ptr %52, align 4
  %54 = getelementptr inbounds i8, ptr %0, i64 32
  %55 = shufflevector <4 x float> %49, <4 x float> poison, <4 x i32> zeroinitializer
  %56 = shufflevector <4 x float> %47, <4 x float> poison, <4 x i32> zeroinitializer
  %57 = shufflevector <4 x float> %51, <4 x float> poison, <4 x i32> zeroinitializer
  %58 = shufflevector <4 x float> %53, <4 x float> poison, <4 x i32> zeroinitializer
  %59 = load <4 x float>, ptr %54, align 4, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %1, i64 48
  %61 = load <4 x float>, ptr %60, align 4
  %62 = getelementptr inbounds i8, ptr %1, i64 52
  %63 = load float, ptr %62, align 4, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %1, i64 56
  %65 = load float, ptr %64, align 4, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %1, i64 60
  %67 = load float, ptr %66, align 4, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %0, i64 48
  %69 = load <4 x float>, ptr %3, align 4, !tbaa !5
  %70 = shufflevector <4 x float> %69, <4 x float> %14, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
  %71 = fmul <4 x float> %55, %70
  %72 = load <4 x float>, ptr %2, align 4, !tbaa !5
  %73 = shufflevector <4 x float> %72, <4 x float> %13, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
  %74 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %56, <4 x float> %73, <4 x float> %71)
  %75 = load <4 x float>, ptr %4, align 4, !tbaa !5
  %76 = shufflevector <4 x float> %75, <4 x float> %19, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
  %77 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %57, <4 x float> %76, <4 x float> %74)
  %78 = load <4 x float>, ptr %5, align 4, !tbaa !5
  %79 = shufflevector <4 x float> %78, <4 x float> %22, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
  %80 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %58, <4 x float> %79, <4 x float> %77)
  %81 = fadd <4 x float> %59, %80
  store <4 x float> %81, ptr %54, align 4, !tbaa !5
  %82 = insertelement <4 x float> poison, float %63, i64 0
  %83 = shufflevector <4 x float> %82, <4 x float> poison, <4 x i32> zeroinitializer
  %84 = fmul <4 x float> %83, %69
  %85 = shufflevector <4 x float> %61, <4 x float> poison, <4 x i32> zeroinitializer
  %86 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %85, <4 x float> %72, <4 x float> %84)
  %87 = insertelement <4 x float> poison, float %65, i64 0
  %88 = shufflevector <4 x float> %87, <4 x float> poison, <4 x i32> zeroinitializer
  %89 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %88, <4 x float> %75, <4 x float> %86)
  %90 = insertelement <4 x float> poison, float %67, 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> %91, <4 x float> %78, <4 x float> %89)
  %93 = load <4 x float>, ptr %68, align 4, !tbaa !5
  %94 = fadd <4 x float> %93, %92
  store <4 x float> %94, ptr %68, align 4, !tbaa !5
  ret void
}

declare void @_ZN7Matrix4C1Ev(ptr) local_unnamed_addr

; 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 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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