; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Quaternion.ll (ZN12R3Quaternion8MultiplyERKS_)

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { inlinehint 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 #4 = { 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++ 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"

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12R3Quaternion8MultiplyERKS_(ptr nocapture noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #1 align 2 {
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 0)
  %11 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 1)
  %12 = fneg double %5
  %13 = fmul double %11, %12
  %14 = tail call double @llvm.fmuladd.f64(double %3, double %10, double %13)
  %15 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 2)
  %16 = fneg double %7
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %15, double %14)
  %18 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 3)
  %19 = fneg double %9
  %20 = tail call double @llvm.fmuladd.f64(double %19, double %18, double %17)
  store double %20, ptr %0, align 8, !tbaa !5
  %21 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 1)
  %22 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 0)
  %23 = fmul double %5, %22
  %24 = tail call double @llvm.fmuladd.f64(double %3, double %21, double %23)
  %25 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 3)
  %26 = tail call double @llvm.fmuladd.f64(double %7, double %25, double %24)
  %27 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 2)
  %28 = tail call double @llvm.fmuladd.f64(double %19, double %27, double %26)
  store double %28, ptr %4, align 8, !tbaa !5
  %29 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 2)
  %30 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 3)
  %31 = fmul double %30, %12
  %32 = tail call double @llvm.fmuladd.f64(double %3, double %29, double %31)
  %33 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 0)
  %34 = tail call double @llvm.fmuladd.f64(double %7, double %33, double %32)
  %35 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 1)
  %36 = tail call double @llvm.fmuladd.f64(double %9, double %35, double %34)
  store double %36, ptr %6, align 8, !tbaa !5
  %37 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 3)
  %38 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 2)
  %39 = fmul double %5, %38
  %40 = tail call double @llvm.fmuladd.f64(double %3, double %37, double %39)
  %41 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 1)
  %42 = tail call double @llvm.fmuladd.f64(double %16, double %41, double %40)
  %43 = tail call noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef 0)
  %44 = tail call double @llvm.fmuladd.f64(double %9, double %43, double %42)
  store double %44, ptr %8, align 8, !tbaa !5
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_ZNK12R3QuaternionixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { inlinehint 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 = !{!"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