title: asm volatile function's output for the provided code
body: <p>Can somebody explain be what is the following function doing:</p>
  
  <pre><code> inline int atomic_exchange_and_add( int * pw, int dv )
  {
   int r;
    __asm__ __volatile__
   (
      "lock\n\t"
      "xadd %1, %0":
      "=m"( *pw ), "=r"( r ): // outputs (%0, %1)
      "m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1)
      "memory", "cc" // clobbers
   );
  }
  </code></pre>
  
  <p>Below is its call:</p>
  
  <pre><code>void weak_release() // nothrow
  {
      if( atomic_exchange_and_add( &amp;weak_count_, -1 ) == 1 )
      {
          destroy();
      }
  }
  </code></pre>
  
  <p>Thanks in advance</p>