title: Converting an inline-asm x87 fsqrt function from C++ to C for x86-64
body: <p>I was looking at different methods to compute the square root, and one in particular (sqrt14 from <a href="https://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi" rel="nofollow noreferrer">here</a>) caught my attention, unfortunately it was written in C++ (it only uses assembly), it's difficult for me to translate it back to C - if that's possible.</p>
  <pre><code>double inline __declspec (naked) __fastcall sqrt14(double n)
  {
      _asm fld qword ptr [esp+4]
      _asm fsqrt
      _asm ret 8
  } 
  </code></pre>
  <p>As can be seen <a href="https://stackoverflow.com/a/61350/13227011">here</a>, inserting assembly in C++ is different from C.</p>
  <p>I wanted to ask you if it was possible to have a C equivalent, and if so, can I ask you to write it? If it's useful, my architecture is 64bits.</p>
  <p>I suspect that the function declaration will be like this one:</p>
  <pre><code>double inline __attribute__((fastcall, naked)) sqrt14(double n);
  </code></pre>
  <p>... but I don't know enough about assembly to do the rest...</p>