; LLVM IR from romerojosh/zefr :: src/funcs.ll (ZN4Quat5crossERKS_)

; 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.Quat = type { [4 x double] }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Quat5crossERKS_(ptr dead_on_unwind noalias writable sret(%struct.Quat) align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  call void @_ZN4QuatC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %7 = getelementptr inbounds %struct.Quat, ptr %6, i32 0, i32 0
  %8 = getelementptr inbounds [4 x double], ptr %7, i64 0, i64 2
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %10, i32 noundef 3)
  %12 = getelementptr inbounds %struct.Quat, ptr %6, i32 0, i32 0
  %13 = getelementptr inbounds [4 x double], ptr %12, i64 0, i64 3
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %15, i32 noundef 2)
  %17 = fmul double %14, %16
  %18 = fneg double %17
  %19 = call double @llvm.fmuladd.f64(double %9, double %11, double %18)
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 1)
  store double %19, ptr %20, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.Quat, ptr %6, i32 0, i32 0
  %22 = getelementptr inbounds [4 x double], ptr %21, i64 0, i64 3
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %24, i32 noundef 1)
  %26 = getelementptr inbounds %struct.Quat, ptr %6, i32 0, i32 0
  %27 = getelementptr inbounds [4 x double], ptr %26, i64 0, i64 1
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %29, i32 noundef 3)
  %31 = fmul double %28, %30
  %32 = fneg double %31
  %33 = call double @llvm.fmuladd.f64(double %23, double %25, double %32)
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 2)
  store double %33, ptr %34, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.Quat, ptr %6, i32 0, i32 0
  %36 = getelementptr inbounds [4 x double], ptr %35, i64 0, i64 1
  %37 = load double, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %38, i32 noundef 2)
  %40 = getelementptr inbounds %struct.Quat, ptr %6, i32 0, i32 0
  %41 = getelementptr inbounds [4 x double], ptr %40, i64 0, i64 2
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %43, i32 noundef 1)
  %45 = fmul double %42, %44
  %46 = fneg double %45
  %47 = call double @llvm.fmuladd.f64(double %37, double %39, double %46)
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 3)
  store double %47, ptr %48, align 8, !tbaa !9
  ret void
}

attributes #0 = { 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 = { 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" }

!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}


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

%struct.Quat = type { [4 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
declare dso_local noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Quat5crossERKS_(ptr dead_on_unwind noalias nonnull writable sret(%struct.Quat) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) local_unnamed_addr #1 align 2 {
  tail call void @_ZN4QuatC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %4 = getelementptr inbounds i8, ptr %1, i64 16
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 3)
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = tail call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 2)
  %10 = fneg double %8
  %11 = fmul double %9, %10
  %12 = tail call double @llvm.fmuladd.f64(double %5, double %6, double %11)
  %13 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 1)
  store double %12, ptr %13, align 8, !tbaa !5
  %14 = load double, ptr %7, align 8, !tbaa !5
  %15 = tail call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 1)
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = tail call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 3)
  %19 = fneg double %17
  %20 = fmul double %18, %19
  %21 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %20)
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 2)
  store double %21, ptr %22, align 8, !tbaa !5
  %23 = load double, ptr %16, align 8, !tbaa !5
  %24 = tail call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 2)
  %25 = load double, ptr %4, align 8, !tbaa !5
  %26 = tail call noundef double @_ZNK4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 1)
  %27 = fneg double %25
  %28 = fmul double %26, %27
  %29 = tail call double @llvm.fmuladd.f64(double %23, double %24, double %28)
  %30 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4QuatixEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef 3)
  store double %29, ptr %30, align 8, !tbaa !5
  ret void
}

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

!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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass