; LLVM IR from idmillington/cyclone-physics :: src/core.ll (ZN7cyclone7Matrix317linearInterpolateERKS0_S2_d)

; 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.cyclone::Matrix3" = type { [9 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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7cyclone7Matrix317linearInterpolateERKS0_S2_d(ptr dead_on_unwind noalias writable sret(%"class.cyclone::Matrix3") align 8 %0, ptr noundef nonnull align 8 dereferenceable(72) %1, ptr noundef nonnull align 8 dereferenceable(72) %2, double noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  store double %3, ptr %7, align 8, !tbaa !9
  call void @_ZN7cyclone7Matrix3C2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %9

9:                                                ; preds = %35, %4
  %10 = load i32, ptr %8, align 4, !tbaa !11
  %11 = icmp ult i32 %10, 9
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %38

13:                                               ; preds = %9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.cyclone::Matrix3", ptr %14, i32 0, i32 0
  %16 = load i32, ptr %8, align 4, !tbaa !11
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds [9 x double], ptr %15, i64 0, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = load double, ptr %7, align 8, !tbaa !9
  %21 = fsub double 1.000000e+00, %20
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.cyclone::Matrix3", ptr %22, i32 0, i32 0
  %24 = load i32, ptr %8, align 4, !tbaa !11
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [9 x double], ptr %23, i64 0, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = load double, ptr %7, align 8, !tbaa !9
  %29 = fmul double %27, %28
  %30 = call double @llvm.fmuladd.f64(double %19, double %21, double %29)
  %31 = getelementptr inbounds %"class.cyclone::Matrix3", ptr %0, i32 0, i32 0
  %32 = load i32, ptr %8, align 4, !tbaa !11
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds [9 x double], ptr %31, i64 0, i64 %33
  store double %30, ptr %34, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %13
  %36 = load i32, ptr %8, align 4, !tbaa !11
  %37 = add i32 %36, 1
  store i32 %37, ptr %8, align 4, !tbaa !11
  br label %9, !llvm.loop !13

38:                                               ; preds = %12
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7cyclone7Matrix3C2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #3 align 2

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


; 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.cyclone::Matrix3" = type { [9 x double] }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7cyclone7Matrix317linearInterpolateERKS0_S2_d(ptr dead_on_unwind noalias nonnull writable sret(%"class.cyclone::Matrix3") align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %2, double noundef %3) local_unnamed_addr #1 align 2 {
  tail call void @_ZN7cyclone7Matrix3C2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %5 = fsub double 1.000000e+00, %3
  %6 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %7 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %8 = insertelement <2 x double> poison, double %3, i64 0
  %9 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> zeroinitializer
  %10 = fmul <2 x double> %7, %9
  %11 = insertelement <2 x double> poison, double %5, i64 0
  %12 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> zeroinitializer
  %13 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %6, <2 x double> %12, <2 x double> %10)
  store <2 x double> %13, ptr %0, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 16
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load <2 x double>, ptr %14, align 8, !tbaa !5
  %18 = load <2 x double>, ptr %15, align 8, !tbaa !5
  %19 = fmul <2 x double> %18, %9
  %20 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %17, <2 x double> %12, <2 x double> %19)
  store <2 x double> %20, ptr %16, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 32
  %22 = getelementptr inbounds i8, ptr %2, i64 32
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %24 = load <2 x double>, ptr %21, align 8, !tbaa !5
  %25 = load <2 x double>, ptr %22, align 8, !tbaa !5
  %26 = fmul <2 x double> %25, %9
  %27 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %24, <2 x double> %12, <2 x double> %26)
  store <2 x double> %27, ptr %23, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %1, i64 48
  %29 = getelementptr inbounds i8, ptr %2, i64 48
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  %31 = load <2 x double>, ptr %28, align 8, !tbaa !5
  %32 = load <2 x double>, ptr %29, align 8, !tbaa !5
  %33 = fmul <2 x double> %32, %9
  %34 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %12, <2 x double> %33)
  store <2 x double> %34, ptr %30, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %1, i64 64
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %2, i64 64
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = fmul double %38, %3
  %40 = tail call double @llvm.fmuladd.f64(double %36, double %5, double %39)
  %41 = getelementptr inbounds i8, ptr %0, i64 64
  store double %40, ptr %41, align 8, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7cyclone7Matrix3C2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #1 align 2

; 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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) }

!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,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass