#include <cstdint>
#include <iostream>

extern "C" {
  void fmadd( float const * a,
              float const * b,
              float const * c,
              float       * d );
  void fmla_vector( float const * a,
                    float const * b,
                    float       * c );
  void fmla_by_element( float const * a,
                        float const * b,
                        float       * c );
};

int main( int    argc,
          char * argv[] ) {

  float l_a[4]   = { 0 };
  float l_b[4]   = { 0 };
  float l_c[4]   = { 0 };
  float l_d[4]   = { 0 };

  // FMADD: scalar multiply-add, d = a * b + c
  l_a[0] =  0;  l_a[1] =  1; l_a[2] =  2;  l_a[3] =  3;
  l_b[0] =  4;  l_b[1] =  5; l_b[2] =  6;  l_b[3] =  7;
  l_c[0] =  8;  l_c[1] =  9; l_c[2] = 10;  l_c[3] = 11;
  fmadd( l_a,
         l_b,
         l_c,
         l_d );

  std::cout << "FMADD: ";
  for( int i = 0; i < 4; ++i ) {
    std::cout << l_d[i] << " ";
  }
  std::cout << std::endl;

  // FMLA (vector): element-wise multiply-add, c += a * b
  l_a[0] =  0;  l_a[1] =  1; l_a[2] =  2;  l_a[3] =  3;
  l_b[0] =  4;  l_b[1] =  5; l_b[2] =  6;  l_b[3] =  7;
  l_c[0] =  8;  l_c[1] =  9; l_c[2] = 10;  l_c[3] = 11;
  fmla_vector( l_a,
               l_b,
               l_c );
  std::cout << "FMLA (vector): ";
  for( int i = 0; i < 4; ++i ) {
    std::cout << l_c[i] << " ";
  }
  std::cout << std::endl;

  // FMLA (by element): broadcast multiply-add, c += a * b[2]
  l_a[0] =  0;  l_a[1] =  1; l_a[2] =  2;  l_a[3] =  3;
  l_b[0] =  4;  l_b[1] =  5; l_b[2] =  6;  l_b[3] =  7;
  l_c[0] =  8;  l_c[1] =  9; l_c[2] = 10;  l_c[3] = 11;
  fmla_by_element( l_a,
                   l_b,
                   l_c );
  std::cout << "FMLA (by element): ";
  for( int i = 0; i < 4; ++i ) {
    std::cout << l_c[i] << " ";
  }
  std::cout << std::endl;

  return EXIT_SUCCESS;
}
