; LLVM IR from ysyesilyurt/ComputerGraphics :: ForwardRenderingPipeline/Helpers.ll (Z24multiplyMatrixWithMatrix7Matrix4S_)

; 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 { [4 x [4 x double]] }

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

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

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

declare void @_ZN7Matrix4C1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z24multiplyMatrixWithMatrix7Matrix4S_(ptr dead_on_unwind noalias writable sret(%class.Matrix4) align 8 %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  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
  call void @_ZN7Matrix4C1Ev(ptr noundef nonnull align 8 dereferenceable(128) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

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

15:                                               ; preds = %12
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %64

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

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

20:                                               ; preds = %17
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %60

21:                                               ; preds = %17
  store double 0.000000e+00, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %45, %21
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = icmp slt i32 %23, 4
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %48

26:                                               ; preds = %22
  %27 = getelementptr inbounds %class.Matrix4, ptr %1, i32 0, i32 0
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [4 x [4 x double]], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %11, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [4 x double], ptr %30, i64 0, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds %class.Matrix4, ptr %2, i32 0, i32 0
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [4 x [4 x double]], ptr %35, i64 0, i64 %37
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [4 x double], ptr %38, i64 0, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = load double, ptr %7, align 8, !tbaa !11
  %44 = call double @llvm.fmuladd.f64(double %34, double %42, double %43)
  store double %44, ptr %7, align 8, !tbaa !11
  br label %45

45:                                               ; preds = %26
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %11, align 4, !tbaa !9
  br label %22, !llvm.loop !13

48:                                               ; preds = %25
  %49 = load double, ptr %7, align 8, !tbaa !11
  %50 = getelementptr inbounds %class.Matrix4, ptr %0, i32 0, i32 0
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [4 x [4 x double]], ptr %50, i64 0, i64 %52
  %54 = load i32, ptr %10, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [4 x double], ptr %53, i64 0, i64 %55
  store double %49, ptr %56, align 8, !tbaa !11
  br label %57

57:                                               ; preds = %48
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %10, align 4, !tbaa !9
  br label %17, !llvm.loop !15

60:                                               ; preds = %20
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %8, align 4, !tbaa !9
  br label %12, !llvm.loop !16

64:                                               ; preds = %15
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { 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 = !{!"double", !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"

%class.Matrix4 = type { [4 x [4 x double]] }

declare void @_ZN7Matrix4C1Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z24multiplyMatrixWithMatrix7Matrix4S_(ptr dead_on_unwind noalias nonnull writable sret(%class.Matrix4) align 8 %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
.preheader16:
  tail call void @_ZN7Matrix4C1Ev(ptr noundef nonnull align 8 dereferenceable(128) %0)
  %3 = load double, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 32
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %2, i64 64
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %2, i64 96
  %13 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %14 = insertelement <2 x double> poison, double %3, i64 0
  %15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
  %16 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %13, <2 x double> zeroinitializer)
  %17 = load <2 x double>, ptr %6, align 8, !tbaa !5
  %18 = insertelement <2 x double> poison, double %5, i64 0
  %19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
  %20 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %17, <2 x double> %16)
  %21 = load <2 x double>, ptr %9, align 8, !tbaa !5
  %22 = insertelement <2 x double> poison, double %8, i64 0
  %23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
  %24 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %21, <2 x double> %20)
  %25 = load <2 x double>, ptr %12, align 8, !tbaa !5
  %26 = insertelement <2 x double> poison, double %11, i64 0
  %27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
  %28 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %25, <2 x double> %24)
  store <2 x double> %28, ptr %0, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %2, i64 16
  %30 = getelementptr inbounds i8, ptr %2, i64 48
  %31 = getelementptr inbounds i8, ptr %2, i64 80
  %32 = getelementptr inbounds i8, ptr %2, i64 112
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = load <2 x double>, ptr %29, align 8, !tbaa !5
  %35 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %34, <2 x double> zeroinitializer)
  %36 = load <2 x double>, ptr %30, align 8, !tbaa !5
  %37 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %36, <2 x double> %35)
  %38 = load <2 x double>, ptr %31, align 8, !tbaa !5
  %39 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %38, <2 x double> %37)
  %40 = load <2 x double>, ptr %32, align 8, !tbaa !5
  %41 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %40, <2 x double> %39)
  store <2 x double> %41, ptr %33, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %1, i64 32
  %43 = load double, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %1, i64 40
  %45 = load double, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %1, i64 48
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %1, i64 56
  %49 = load double, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %0, i64 32
  %51 = insertelement <2 x double> poison, double %43, i64 0
  %52 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> zeroinitializer
  %53 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %13, <2 x double> zeroinitializer)
  %54 = insertelement <2 x double> poison, double %45, i64 0
  %55 = shufflevector <2 x double> %54, <2 x double> poison, <2 x i32> zeroinitializer
  %56 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %17, <2 x double> %53)
  %57 = insertelement <2 x double> poison, double %47, i64 0
  %58 = shufflevector <2 x double> %57, <2 x double> poison, <2 x i32> zeroinitializer
  %59 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %58, <2 x double> %21, <2 x double> %56)
  %60 = insertelement <2 x double> poison, double %49, i64 0
  %61 = shufflevector <2 x double> %60, <2 x double> poison, <2 x i32> zeroinitializer
  %62 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %61, <2 x double> %25, <2 x double> %59)
  store <2 x double> %62, ptr %50, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %0, i64 48
  %64 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %52, <2 x double> %34, <2 x double> zeroinitializer)
  %65 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %55, <2 x double> %36, <2 x double> %64)
  %66 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %58, <2 x double> %38, <2 x double> %65)
  %67 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %61, <2 x double> %40, <2 x double> %66)
  store <2 x double> %67, ptr %63, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %1, i64 64
  %69 = load double, ptr %68, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %1, i64 72
  %71 = load double, ptr %70, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %1, i64 80
  %73 = load double, ptr %72, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %1, i64 88
  %75 = load double, ptr %74, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %0, i64 64
  %77 = insertelement <2 x double> poison, double %69, i64 0
  %78 = shufflevector <2 x double> %77, <2 x double> poison, <2 x i32> zeroinitializer
  %79 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %78, <2 x double> %13, <2 x double> zeroinitializer)
  %80 = insertelement <2 x double> poison, double %71, i64 0
  %81 = shufflevector <2 x double> %80, <2 x double> poison, <2 x i32> zeroinitializer
  %82 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %81, <2 x double> %17, <2 x double> %79)
  %83 = insertelement <2 x double> poison, double %73, i64 0
  %84 = shufflevector <2 x double> %83, <2 x double> poison, <2 x i32> zeroinitializer
  %85 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %84, <2 x double> %21, <2 x double> %82)
  %86 = insertelement <2 x double> poison, double %75, i64 0
  %87 = shufflevector <2 x double> %86, <2 x double> poison, <2 x i32> zeroinitializer
  %88 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %87, <2 x double> %25, <2 x double> %85)
  store <2 x double> %88, ptr %76, align 8, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %0, i64 80
  %90 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %78, <2 x double> %34, <2 x double> zeroinitializer)
  %91 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %81, <2 x double> %36, <2 x double> %90)
  %92 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %84, <2 x double> %38, <2 x double> %91)
  %93 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %87, <2 x double> %40, <2 x double> %92)
  store <2 x double> %93, ptr %89, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %1, i64 96
  %95 = load double, ptr %94, align 8, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %1, i64 104
  %97 = load double, ptr %96, align 8, !tbaa !5
  %98 = getelementptr inbounds i8, ptr %1, i64 112
  %99 = load double, ptr %98, align 8, !tbaa !5
  %100 = getelementptr inbounds i8, ptr %1, i64 120
  %101 = load double, ptr %100, align 8, !tbaa !5
  %102 = getelementptr inbounds i8, ptr %0, i64 96
  %103 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %104 = insertelement <2 x double> poison, double %95, i64 0
  %105 = shufflevector <2 x double> %104, <2 x double> poison, <2 x i32> zeroinitializer
  %106 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %105, <2 x double> %103, <2 x double> zeroinitializer)
  %107 = load <2 x double>, ptr %6, align 8, !tbaa !5
  %108 = insertelement <2 x double> poison, double %97, i64 0
  %109 = shufflevector <2 x double> %108, <2 x double> poison, <2 x i32> zeroinitializer
  %110 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %109, <2 x double> %107, <2 x double> %106)
  %111 = load <2 x double>, ptr %9, align 8, !tbaa !5
  %112 = insertelement <2 x double> poison, double %99, i64 0
  %113 = shufflevector <2 x double> %112, <2 x double> poison, <2 x i32> zeroinitializer
  %114 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %113, <2 x double> %111, <2 x double> %110)
  %115 = load <2 x double>, ptr %12, align 8, !tbaa !5
  %116 = insertelement <2 x double> poison, double %101, i64 0
  %117 = shufflevector <2 x double> %116, <2 x double> poison, <2 x i32> zeroinitializer
  %118 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %117, <2 x double> %115, <2 x double> %114)
  store <2 x double> %118, ptr %102, align 8, !tbaa !5
  %119 = getelementptr inbounds i8, ptr %0, i64 112
  %120 = load <2 x double>, ptr %29, align 8, !tbaa !5
  %121 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %105, <2 x double> %120, <2 x double> zeroinitializer)
  %122 = load <2 x double>, ptr %30, align 8, !tbaa !5
  %123 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %109, <2 x double> %122, <2 x double> %121)
  %124 = load <2 x double>, ptr %31, align 8, !tbaa !5
  %125 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %113, <2 x double> %124, <2 x double> %123)
  %126 = load <2 x double>, ptr %32, align 8, !tbaa !5
  %127 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %117, <2 x double> %126, <2 x double> %125)
  store <2 x double> %127, ptr %119, align 8, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

attributes #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 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) }

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


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