; LLVM IR from Dovyski/opengl-demos :: src/moving-plane/Point.ll (ZNK5Point5crossERKS_)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5Point1xEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5Point1yEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5Point1zEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

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

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

declare void @_ZN5PointC1Eddd(ptr, double, double, double)

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 8}
!10 = !{!"_ZTS5Point", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, 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.Point = type { double, double, double }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5Point1xEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5Point1yEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5Point1zEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

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

declare void @_ZN5PointC1Eddd(ptr, double, double, double) local_unnamed_addr

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


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