; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R4Matrix.ll (ZmlRK8R4MatrixS1_)

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

; 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 double @llvm.fmuladd.f64(double, double, double) #1

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

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

9:                                                ; preds = %88, %3
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 4
  br i1 %11, label %12, label %91

12:                                               ; preds = %9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %13

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

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

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

87:                                               ; preds = %13
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %7, align 4, !tbaa !9
  br label %9, !llvm.loop !15

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

declare void @_ZN8R4MatrixC1Ev(ptr)

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

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

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

declare void @_ZN8R4MatrixC1Ev(ptr) local_unnamed_addr

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


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