; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z8quat_mul4QuatS_)

; 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"

%union.Quat = type { [4 x float] }
%struct.anon.17 = type { float, float, float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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 nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_Z8quat_mul4QuatS_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) #2 {
  %5 = alloca %union.Quat, align 4
  %6 = alloca %union.Quat, align 4
  %7 = alloca %union.Quat, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 0
  store <2 x float> %0, ptr %16, align 4
  %17 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 1
  store <2 x float> %1, ptr %17, align 4
  %18 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 0
  store <2 x float> %2, ptr %18, align 4
  %19 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 1
  store <2 x float> %3, ptr %19, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %20 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 3
  %21 = load float, ptr %20, align 4, !tbaa !5
  store float %21, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %22 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 0
  %23 = load float, ptr %22, align 4, !tbaa !5
  store float %23, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %24 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !5
  store float %25, ptr %10, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %26 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 2
  %27 = load float, ptr %26, align 4, !tbaa !5
  store float %27, ptr %11, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %28 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 3
  %29 = load float, ptr %28, align 4, !tbaa !5
  store float %29, ptr %12, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %30 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !5
  store float %31, ptr %13, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %32 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 1
  %33 = load float, ptr %32, align 4, !tbaa !5
  store float %33, ptr %14, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %34 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 2
  %35 = load float, ptr %34, align 4, !tbaa !5
  store float %35, ptr %15, align 4, !tbaa !8
  %36 = load float, ptr %8, align 4, !tbaa !8
  %37 = load float, ptr %12, align 4, !tbaa !8
  %38 = load float, ptr %9, align 4, !tbaa !8
  %39 = load float, ptr %13, align 4, !tbaa !8
  %40 = fmul float %38, %39
  %41 = fneg float %40
  %42 = call float @llvm.fmuladd.f32(float %36, float %37, float %41)
  %43 = load float, ptr %10, align 4, !tbaa !8
  %44 = load float, ptr %14, align 4, !tbaa !8
  %45 = fneg float %43
  %46 = call float @llvm.fmuladd.f32(float %45, float %44, float %42)
  %47 = load float, ptr %11, align 4, !tbaa !8
  %48 = load float, ptr %15, align 4, !tbaa !8
  %49 = fneg float %47
  %50 = call float @llvm.fmuladd.f32(float %49, float %48, float %46)
  %51 = getelementptr inbounds %struct.anon.17, ptr %5, i32 0, i32 3
  store float %50, ptr %51, align 4, !tbaa !5
  %52 = load float, ptr %8, align 4, !tbaa !8
  %53 = load float, ptr %13, align 4, !tbaa !8
  %54 = load float, ptr %9, align 4, !tbaa !8
  %55 = load float, ptr %12, align 4, !tbaa !8
  %56 = fmul float %54, %55
  %57 = call float @llvm.fmuladd.f32(float %52, float %53, float %56)
  %58 = load float, ptr %10, align 4, !tbaa !8
  %59 = load float, ptr %15, align 4, !tbaa !8
  %60 = call float @llvm.fmuladd.f32(float %58, float %59, float %57)
  %61 = load float, ptr %11, align 4, !tbaa !8
  %62 = load float, ptr %14, align 4, !tbaa !8
  %63 = fneg float %61
  %64 = call float @llvm.fmuladd.f32(float %63, float %62, float %60)
  %65 = getelementptr inbounds %struct.anon.17, ptr %5, i32 0, i32 0
  store float %64, ptr %65, align 4, !tbaa !5
  %66 = load float, ptr %8, align 4, !tbaa !8
  %67 = load float, ptr %14, align 4, !tbaa !8
  %68 = load float, ptr %9, align 4, !tbaa !8
  %69 = load float, ptr %15, align 4, !tbaa !8
  %70 = fmul float %68, %69
  %71 = fneg float %70
  %72 = call float @llvm.fmuladd.f32(float %66, float %67, float %71)
  %73 = load float, ptr %10, align 4, !tbaa !8
  %74 = load float, ptr %12, align 4, !tbaa !8
  %75 = call float @llvm.fmuladd.f32(float %73, float %74, float %72)
  %76 = load float, ptr %11, align 4, !tbaa !8
  %77 = load float, ptr %13, align 4, !tbaa !8
  %78 = call float @llvm.fmuladd.f32(float %76, float %77, float %75)
  %79 = getelementptr inbounds %struct.anon.17, ptr %5, i32 0, i32 1
  store float %78, ptr %79, align 4, !tbaa !5
  %80 = load float, ptr %8, align 4, !tbaa !8
  %81 = load float, ptr %15, align 4, !tbaa !8
  %82 = load float, ptr %9, align 4, !tbaa !8
  %83 = load float, ptr %14, align 4, !tbaa !8
  %84 = fmul float %82, %83
  %85 = call float @llvm.fmuladd.f32(float %80, float %81, float %84)
  %86 = load float, ptr %10, align 4, !tbaa !8
  %87 = load float, ptr %13, align 4, !tbaa !8
  %88 = fneg float %86
  %89 = call float @llvm.fmuladd.f32(float %88, float %87, float %85)
  %90 = load float, ptr %11, align 4, !tbaa !8
  %91 = load float, ptr %12, align 4, !tbaa !8
  %92 = call float @llvm.fmuladd.f32(float %90, float %91, float %89)
  %93 = getelementptr inbounds %struct.anon.17, ptr %5, i32 0, i32 2
  store float %92, ptr %93, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %94 = getelementptr inbounds %union.Quat, ptr %5, i32 0, i32 0
  %95 = load { <2 x float>, <2 x float> }, ptr %94, align 4
  ret { <2 x float>, <2 x float> } %95
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, 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(none) uwtable
define dso_local { <2 x float>, <2 x float> } @_Z8quat_mul4QuatS_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) local_unnamed_addr #0 {
  %.sroa.032.0.vec.extract = extractelement <2 x float> %0, i64 0
  %5 = fneg float %.sroa.032.0.vec.extract
  %6 = shufflevector <2 x float> %3, <2 x float> %2, <4 x i32> <i32 1, i32 0, i32 2, i32 3>
  %7 = insertelement <2 x float> %0, float %5, i64 1
  %8 = shufflevector <2 x float> %7, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 1, i32 0>
  %9 = fmul <4 x float> %6, %8
  %10 = shufflevector <2 x float> %1, <2 x float> poison, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
  %11 = shufflevector <2 x float> %2, <2 x float> %3, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
  %12 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %10, <4 x float> %11, <4 x float> %9)
  %13 = shufflevector <2 x float> %0, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %14 = fneg <2 x float> %0
  %15 = shufflevector <2 x float> %13, <2 x float> %14, <2 x i32> <i32 0, i32 3>
  %16 = shufflevector <2 x float> %15, <2 x float> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
  %17 = shufflevector <2 x float> %3, <2 x float> %2, <4 x i32> <i32 0, i32 1, i32 3, i32 2>
  %18 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %16, <4 x float> %17, <4 x float> %12)
  %19 = shufflevector <2 x float> %1, <2 x float> poison, <2 x i32> <i32 poison, i32 0>
  %20 = fneg <2 x float> %1
  %21 = shufflevector <2 x float> %20, <2 x float> %19, <2 x i32> <i32 0, i32 3>
  %22 = shufflevector <2 x float> %21, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %23 = shufflevector <2 x float> %2, <2 x float> %3, <4 x i32> <i32 1, i32 0, i32 2, i32 3>
  %24 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %22, <4 x float> %23, <4 x float> %18)
  %25 = shufflevector <4 x float> %24, <4 x float> poison, <2 x i32> <i32 0, i32 1>
  %26 = shufflevector <4 x float> %24, <4 x float> poison, <2 x i32> <i32 3, i32 2>
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %25, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %26, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="64" "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)"}


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