; LLVM IR from raphaelsenn/elastic-collision :: src/vector2.ll (ZN7Vector23addES_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.Vector2 = type { double, double }

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZN7Vector23addES_d(ptr noundef nonnull align 8 dereferenceable(16) %0, double %1, double %2, double noundef %3) #0 align 2 {
  %5 = alloca %class.Vector2, align 8
  %6 = alloca %class.Vector2, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  store double %1, ptr %9, align 8
  %10 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  store double %2, ptr %10, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store double %3, ptr %8, align 8, !tbaa !9
  %11 = load ptr, ptr %7, align 8
  %12 = getelementptr inbounds %class.Vector2, ptr %6, i32 0, i32 0
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = load double, ptr %8, align 8, !tbaa !9
  %15 = getelementptr inbounds %class.Vector2, ptr %11, i32 0, i32 0
  %16 = load double, ptr %15, align 8, !tbaa !11
  %17 = call double @llvm.fmuladd.f64(double %13, double %14, double %16)
  store double %17, ptr %15, align 8, !tbaa !11
  %18 = getelementptr inbounds %class.Vector2, ptr %6, i32 0, i32 1
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = load double, ptr %8, align 8, !tbaa !9
  %21 = getelementptr inbounds %class.Vector2, ptr %11, i32 0, i32 1
  %22 = load double, ptr %21, align 8, !tbaa !13
  %23 = call double @llvm.fmuladd.f64(double %19, double %20, double %22)
  store double %23, ptr %21, align 8, !tbaa !13
  %24 = getelementptr inbounds %class.Vector2, ptr %11, i32 0, i32 0
  %25 = load double, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %class.Vector2, ptr %11, i32 0, i32 1
  %27 = load double, ptr %26, align 8, !tbaa !13
  call void @_ZN7Vector2C1Edd(ptr noundef nonnull align 8 dereferenceable(16) %5, double noundef %25, double noundef %27)
  %28 = load { double, double }, ptr %5, align 8
  ret { double, double } %28
}

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

declare void @_ZN7Vector2C1Edd(ptr, double, double)

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 = !{!"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, !10, i64 0}
!12 = !{!"_ZTS7Vector2", !10, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}


; 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.Vector2 = type { double, double }

; Function Attrs: mustprogress uwtable
define dso_local { double, double } @_ZN7Vector23addES_d(ptr nocapture noundef nonnull align 8 dereferenceable(16) %0, double %1, double %2, double noundef %3) local_unnamed_addr #0 align 2 {
  %5 = alloca %class.Vector2, align 8
  %6 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %7 = insertelement <2 x double> poison, double %1, i64 0
  %8 = insertelement <2 x double> %7, double %2, i64 1
  %9 = insertelement <2 x double> poison, double %3, i64 0
  %10 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> zeroinitializer
  %11 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %8, <2 x double> %10, <2 x double> %6)
  store <2 x double> %11, ptr %0, align 8, !tbaa !5
  %12 = extractelement <2 x double> %11, i64 0
  %13 = extractelement <2 x double> %11, i64 1
  call void @_ZN7Vector2C1Edd(ptr noundef nonnull align 8 dereferenceable(16) %5, double noundef %12, double noundef %13)
  %.fca.0.load = load double, ptr %5, align 8
  %.fca.0.insert = insertvalue { double, double } poison, double %.fca.0.load, 0
  %.fca.1.gep = getelementptr inbounds i8, ptr %5, i64 8
  %.fca.1.load = load double, ptr %.fca.1.gep, align 8
  %.fca.1.insert = insertvalue { double, double } %.fca.0.insert, double %.fca.1.load, 1
  ret { double, double } %.fca.1.insert
}

declare void @_ZN7Vector2C1Edd(ptr, double, double) 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,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass