; LLVM IR from ysyesilyurt/ComputerGraphics :: ForwardRenderingPipeline/Helpers.ll (Z16crossProductVec34Vec3S_)

; 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.Vec3 = type <{ double, double, double, i32, [4 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16crossProductVec34Vec3S_(ptr dead_on_unwind noalias writable sret(%class.Vec3) align 8 %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  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 @_ZN4Vec3C1Ev(ptr noundef nonnull align 8 dereferenceable(28) %0)
  %7 = getelementptr inbounds %class.Vec3, ptr %1, i32 0, i32 1
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds %class.Vec3, ptr %2, i32 0, i32 2
  %10 = load double, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds %class.Vec3, ptr %2, i32 0, i32 1
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds %class.Vec3, ptr %1, i32 0, i32 2
  %14 = load double, ptr %13, align 8, !tbaa !13
  %15 = fmul double %12, %14
  %16 = fneg double %15
  %17 = call double @llvm.fmuladd.f64(double %8, double %10, double %16)
  %18 = getelementptr inbounds %class.Vec3, ptr %0, i32 0, i32 0
  store double %17, ptr %18, align 8, !tbaa !14
  %19 = getelementptr inbounds %class.Vec3, ptr %2, i32 0, i32 0
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds %class.Vec3, ptr %1, i32 0, i32 2
  %22 = load double, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %class.Vec3, ptr %1, i32 0, i32 0
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = getelementptr inbounds %class.Vec3, ptr %2, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !13
  %27 = fmul double %24, %26
  %28 = fneg double %27
  %29 = call double @llvm.fmuladd.f64(double %20, double %22, double %28)
  %30 = getelementptr inbounds %class.Vec3, ptr %0, i32 0, i32 1
  store double %29, ptr %30, align 8, !tbaa !9
  %31 = getelementptr inbounds %class.Vec3, ptr %1, i32 0, i32 0
  %32 = load double, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds %class.Vec3, ptr %2, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = getelementptr inbounds %class.Vec3, ptr %2, i32 0, i32 0
  %36 = load double, ptr %35, align 8, !tbaa !14
  %37 = getelementptr inbounds %class.Vec3, ptr %1, i32 0, i32 1
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = fmul double %36, %38
  %40 = fneg double %39
  %41 = call double @llvm.fmuladd.f64(double %32, double %34, double %40)
  %42 = getelementptr inbounds %class.Vec3, ptr %0, i32 0, i32 2
  store double %41, ptr %42, align 8, !tbaa !13
  ret void
}

declare void @_ZN4Vec3C1Ev(ptr noundef nonnull align 8 dereferenceable(28)) unnamed_addr #1

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

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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTS4Vec3", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, 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"

%class.Vec3 = type <{ double, double, double, i32, [4 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16crossProductVec34Vec3S_(ptr dead_on_unwind noalias nonnull writable sret(%class.Vec3) align 8 %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  tail call void @_ZN4Vec3C1Ev(ptr noundef nonnull align 8 dereferenceable(28) %0)
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = getelementptr inbounds i8, ptr %2, i64 16
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !11
  %9 = load double, ptr %2, align 8, !tbaa !12
  %10 = load double, ptr %1, align 8, !tbaa !12
  %11 = load <2 x double>, ptr %4, align 8, !tbaa !13
  %12 = insertelement <2 x double> poison, double %8, i64 0
  %13 = insertelement <2 x double> %12, double %10, i64 1
  %14 = fneg <2 x double> %13
  %15 = shufflevector <2 x double> %11, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %16 = insertelement <2 x double> %15, double %6, i64 1
  %17 = fmul <2 x double> %16, %14
  %18 = insertelement <2 x double> poison, double %6, i64 0
  %19 = insertelement <2 x double> %18, double %9, i64 1
  %20 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %19, <2 x double> %11, <2 x double> %17)
  store <2 x double> %20, ptr %0, align 8, !tbaa !13
  %21 = fneg double %9
  %22 = extractelement <2 x double> %11, i64 0
  %23 = fmul double %22, %21
  %24 = tail call double @llvm.fmuladd.f64(double %10, double %8, double %23)
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  store double %24, ptr %25, align 8, !tbaa !5
  ret void
}

declare void @_ZN4Vec3C1Ev(ptr noundef nonnull align 8 dereferenceable(28)) unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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>) #3

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 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !7, i64 16}
!6 = !{!"_ZTS4Vec3", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 0}
!13 = !{!7, !7, i64 0}


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