; LLVM IR from Angelo1211/SoftwareRenderer :: src/matrix.ll (ZN7Matrix410matMultDirERK7Vector3IfE)

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

%struct.Vector3 = type { %union.anon, float }
%union.anon = type { [3 x float] }
%struct.anon = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Vector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef, i64 noundef) #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN7Matrix410matMultDirERK7Vector3IfE(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) #2 align 2 {
  %3 = alloca %struct.Vector3, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  call void @_ZN7Vector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(16) %3, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.Vector3, ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds %struct.anon, ptr %8, i32 0, i32 0
  %10 = load float, ptr %9, align 4, !tbaa !9
  %11 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 0, i64 noundef 0)
  %12 = load float, ptr %11, align 4, !tbaa !10
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Vector3, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.anon, ptr %14, i32 0, i32 1
  %16 = load float, ptr %15, align 4, !tbaa !9
  %17 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 0, i64 noundef 1)
  %18 = load float, ptr %17, align 4, !tbaa !10
  %19 = fmul float %16, %18
  %20 = call float @llvm.fmuladd.f32(float %10, float %12, float %19)
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Vector3, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.anon, ptr %22, i32 0, i32 2
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 0, i64 noundef 2)
  %26 = load float, ptr %25, align 4, !tbaa !10
  %27 = call float @llvm.fmuladd.f32(float %24, float %26, float %20)
  %28 = getelementptr inbounds %struct.Vector3, ptr %3, i32 0, i32 0
  %29 = getelementptr inbounds %struct.anon, ptr %28, i32 0, i32 0
  store float %27, ptr %29, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Vector3, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.anon, ptr %31, i32 0, i32 0
  %33 = load float, ptr %32, align 4, !tbaa !9
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 1, i64 noundef 0)
  %35 = load float, ptr %34, align 4, !tbaa !10
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Vector3, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 1
  %39 = load float, ptr %38, align 4, !tbaa !9
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 1, i64 noundef 1)
  %41 = load float, ptr %40, align 4, !tbaa !10
  %42 = fmul float %39, %41
  %43 = call float @llvm.fmuladd.f32(float %33, float %35, float %42)
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Vector3, ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct.anon, ptr %45, i32 0, i32 2
  %47 = load float, ptr %46, align 4, !tbaa !9
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 1, i64 noundef 2)
  %49 = load float, ptr %48, align 4, !tbaa !10
  %50 = call float @llvm.fmuladd.f32(float %47, float %49, float %43)
  %51 = getelementptr inbounds %struct.Vector3, ptr %3, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 1
  store float %50, ptr %52, align 4, !tbaa !9
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.Vector3, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon, ptr %54, i32 0, i32 0
  %56 = load float, ptr %55, align 4, !tbaa !9
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 2, i64 noundef 0)
  %58 = load float, ptr %57, align 4, !tbaa !10
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Vector3, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.anon, ptr %60, i32 0, i32 1
  %62 = load float, ptr %61, align 4, !tbaa !9
  %63 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 2, i64 noundef 1)
  %64 = load float, ptr %63, align 4, !tbaa !10
  %65 = fmul float %62, %64
  %66 = call float @llvm.fmuladd.f32(float %56, float %58, float %65)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.Vector3, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds %struct.anon, ptr %68, i32 0, i32 2
  %70 = load float, ptr %69, align 4, !tbaa !9
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %6, i64 noundef 2, i64 noundef 2)
  %72 = load float, ptr %71, align 4, !tbaa !10
  %73 = call float @llvm.fmuladd.f32(float %70, float %72, float %66)
  %74 = getelementptr inbounds %struct.Vector3, ptr %3, i32 0, i32 0
  %75 = getelementptr inbounds %struct.anon, ptr %74, i32 0, i32 2
  store float %73, ptr %75, align 4, !tbaa !9
  %76 = load { <2 x float>, <2 x float> }, ptr %3, align 4
  ret { <2 x float>, <2 x float> } %76
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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" }

!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 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}


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

%struct.Vector3 = type { %union.anon, float }
%union.anon = type { [3 x float] }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Vector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64), i64 noundef, i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN7Matrix410matMultDirERK7Vector3IfE(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %struct.Vector3, align 8
  call void @_ZN7Vector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(16) %3, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %4 = load float, ptr %1, align 4, !tbaa !5
  %5 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 0, i64 noundef 0)
  %6 = load float, ptr %5, align 4, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 0, i64 noundef 1)
  %10 = load float, ptr %9, align 4, !tbaa !8
  %11 = fmul float %8, %10
  %12 = call float @llvm.fmuladd.f32(float %4, float %6, float %11)
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 0, i64 noundef 2)
  %16 = load float, ptr %15, align 4, !tbaa !8
  %17 = call float @llvm.fmuladd.f32(float %14, float %16, float %12)
  store float %17, ptr %3, align 8, !tbaa !5
  %18 = load float, ptr %1, align 4, !tbaa !5
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 1, i64 noundef 0)
  %20 = load float, ptr %19, align 4, !tbaa !8
  %21 = load float, ptr %7, align 4, !tbaa !5
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 1, i64 noundef 1)
  %23 = load float, ptr %22, align 4, !tbaa !8
  %24 = fmul float %21, %23
  %25 = call float @llvm.fmuladd.f32(float %18, float %20, float %24)
  %26 = load float, ptr %13, align 4, !tbaa !5
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 1, i64 noundef 2)
  %28 = load float, ptr %27, align 4, !tbaa !8
  %29 = call float @llvm.fmuladd.f32(float %26, float %28, float %25)
  %30 = getelementptr inbounds i8, ptr %3, i64 4
  store float %29, ptr %30, align 4, !tbaa !5
  %31 = load float, ptr %1, align 4, !tbaa !5
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 2, i64 noundef 0)
  %33 = load float, ptr %32, align 4, !tbaa !8
  %34 = load float, ptr %7, align 4, !tbaa !5
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 2, i64 noundef 1)
  %36 = load float, ptr %35, align 4, !tbaa !8
  %37 = fmul float %34, %36
  %38 = call float @llvm.fmuladd.f32(float %31, float %33, float %37)
  %39 = load float, ptr %13, align 4, !tbaa !5
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7Matrix4clEmm(ptr noundef nonnull align 4 dereferenceable(64) %0, i64 noundef 2, i64 noundef 2)
  %41 = load float, ptr %40, align 4, !tbaa !8
  %42 = call float @llvm.fmuladd.f32(float %39, float %41, float %38)
  %43 = getelementptr inbounds i8, ptr %3, i64 8
  store float %42, ptr %43, align 8, !tbaa !5
  %.fca.0.load = load <2 x float>, ptr %3, align 8
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.fca.0.load, 0
  %.fca.1.load = load <2 x float>, ptr %43, align 8
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.fca.1.load, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

attributes #0 = { 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 #1 = { mustprogress 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"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass