; LLVM IR from MRPT/mrpt :: 3rdparty/xspublic/xstypes (xsquaternion)

; 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.XsQuaternion = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { double, double, double, 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: nounwind uwtable
define dso_local void @XsQuaternion_multiply(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.XsQuaternion, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.anon, ptr %16, i32 0, i32 0
  %18 = load double, ptr %17, align 8, !tbaa !9
  store double %18, ptr %7, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.XsQuaternion, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.anon, ptr %20, i32 0, i32 1
  %22 = load double, ptr %21, align 8, !tbaa !9
  store double %22, ptr %8, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.XsQuaternion, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.anon, ptr %24, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !9
  store double %26, ptr %9, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.XsQuaternion, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.anon, ptr %28, i32 0, i32 3
  %30 = load double, ptr %29, align 8, !tbaa !9
  store double %30, ptr %10, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.XsQuaternion, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.anon, ptr %32, i32 0, i32 0
  %34 = load double, ptr %33, align 8, !tbaa !9
  store double %34, ptr %11, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.XsQuaternion, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.anon, ptr %36, i32 0, i32 1
  %38 = load double, ptr %37, align 8, !tbaa !9
  store double %38, ptr %12, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.XsQuaternion, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %struct.anon, ptr %40, i32 0, i32 2
  %42 = load double, ptr %41, align 8, !tbaa !9
  store double %42, ptr %13, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.XsQuaternion, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.anon, ptr %44, i32 0, i32 3
  %46 = load double, ptr %45, align 8, !tbaa !9
  store double %46, ptr %14, align 8, !tbaa !10
  %47 = load double, ptr %7, align 8, !tbaa !10
  %48 = load double, ptr %11, align 8, !tbaa !10
  %49 = load double, ptr %8, align 8, !tbaa !10
  %50 = load double, ptr %12, align 8, !tbaa !10
  %51 = fmul double %49, %50
  %52 = fneg double %51
  %53 = call double @llvm.fmuladd.f64(double %47, double %48, double %52)
  %54 = load double, ptr %9, align 8, !tbaa !10
  %55 = load double, ptr %13, align 8, !tbaa !10
  %56 = fneg double %54
  %57 = call double @llvm.fmuladd.f64(double %56, double %55, double %53)
  %58 = load double, ptr %10, align 8, !tbaa !10
  %59 = load double, ptr %14, align 8, !tbaa !10
  %60 = fneg double %58
  %61 = call double @llvm.fmuladd.f64(double %60, double %59, double %57)
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.XsQuaternion, ptr %62, i32 0, i32 0
  %64 = getelementptr inbounds %struct.anon, ptr %63, i32 0, i32 0
  store double %61, ptr %64, align 8, !tbaa !9
  %65 = load double, ptr %8, align 8, !tbaa !10
  %66 = load double, ptr %11, align 8, !tbaa !10
  %67 = load double, ptr %7, align 8, !tbaa !10
  %68 = load double, ptr %12, align 8, !tbaa !10
  %69 = fmul double %67, %68
  %70 = call double @llvm.fmuladd.f64(double %65, double %66, double %69)
  %71 = load double, ptr %10, align 8, !tbaa !10
  %72 = load double, ptr %13, align 8, !tbaa !10
  %73 = fneg double %71
  %74 = call double @llvm.fmuladd.f64(double %73, double %72, double %70)
  %75 = load double, ptr %9, align 8, !tbaa !10
  %76 = load double, ptr %14, align 8, !tbaa !10
  %77 = call double @llvm.fmuladd.f64(double %75, double %76, double %74)
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.XsQuaternion, ptr %78, i32 0, i32 0
  %80 = getelementptr inbounds %struct.anon, ptr %79, i32 0, i32 1
  store double %77, ptr %80, align 8, !tbaa !9
  %81 = load double, ptr %9, align 8, !tbaa !10
  %82 = load double, ptr %11, align 8, !tbaa !10
  %83 = load double, ptr %10, align 8, !tbaa !10
  %84 = load double, ptr %12, align 8, !tbaa !10
  %85 = fmul double %83, %84
  %86 = call double @llvm.fmuladd.f64(double %81, double %82, double %85)
  %87 = load double, ptr %7, align 8, !tbaa !10
  %88 = load double, ptr %13, align 8, !tbaa !10
  %89 = call double @llvm.fmuladd.f64(double %87, double %88, double %86)
  %90 = load double, ptr %8, align 8, !tbaa !10
  %91 = load double, ptr %14, align 8, !tbaa !10
  %92 = fneg double %90
  %93 = call double @llvm.fmuladd.f64(double %92, double %91, double %89)
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.XsQuaternion, ptr %94, i32 0, i32 0
  %96 = getelementptr inbounds %struct.anon, ptr %95, i32 0, i32 2
  store double %93, ptr %96, align 8, !tbaa !9
  %97 = load double, ptr %10, align 8, !tbaa !10
  %98 = load double, ptr %11, align 8, !tbaa !10
  %99 = load double, ptr %9, align 8, !tbaa !10
  %100 = load double, ptr %12, align 8, !tbaa !10
  %101 = fmul double %99, %100
  %102 = fneg double %101
  %103 = call double @llvm.fmuladd.f64(double %97, double %98, double %102)
  %104 = load double, ptr %8, align 8, !tbaa !10
  %105 = load double, ptr %13, align 8, !tbaa !10
  %106 = call double @llvm.fmuladd.f64(double %104, double %105, double %103)
  %107 = load double, ptr %7, align 8, !tbaa !10
  %108 = load double, ptr %14, align 8, !tbaa !10
  %109 = call double @llvm.fmuladd.f64(double %107, double %108, double %106)
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.XsQuaternion, ptr %110, i32 0, i32 0
  %112 = getelementptr inbounds %struct.anon, ptr %111, i32 0, i32 3
  store double %109, ptr %112, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @XsQuaternion_multiply(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load double, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %13 = load <2 x double>, ptr %4, align 8, !tbaa !5
  %14 = extractelement <2 x double> %12, i64 1
  %15 = fneg double %14
  %16 = fneg <2 x double> %13
  %17 = insertelement <2 x double> poison, double %7, i64 0
  %18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
  %19 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> <i32 poison, i32 0>
  %20 = insertelement <2 x double> %19, double %15, i64 0
  %21 = fmul <2 x double> %18, %20
  %22 = insertelement <2 x double> poison, double %5, 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> %12, <2 x double> %23, <2 x double> %21)
  %25 = insertelement <2 x double> poison, double %9, i64 0
  %26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
  %27 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %16, <2 x double> %26, <2 x double> %24)
  %28 = shufflevector <2 x double> %16, <2 x double> %13, <2 x i32> <i32 1, i32 2>
  %29 = insertelement <2 x double> poison, double %11, i64 0
  %30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
  %31 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> %30, <2 x double> %27)
  store <2 x double> %31, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %2, i64 16
  %33 = shufflevector <2 x double> %13, <2 x double> %16, <2 x i32> <i32 1, i32 2>
  %34 = fmul <2 x double> %33, %18
  %35 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %13, <2 x double> %23, <2 x double> %34)
  %36 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %12, <2 x double> %26, <2 x double> %35)
  %37 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %30, <2 x double> %36)
  store <2 x double> %37, ptr %32, 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>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass