I translated a simple C program to x86_64 and it was slower
The assembly is not bad for a beginner but far from optimal. A few things that stand out from a quick glance:<p>1) Try to load things sequentially don’t load from offset 32, then 0, then 16.<p>2) Don’t use the loop instruction<p>3) this code:<p><pre><code>  dec  n
  cmp  n, 0
  jne  1b
</code></pre>
Can be replaced with:<p><pre><code>  sub n, 1
  jnz 1b
</code></pre>
Which will actually be executed by the processor as a single instruction (macro-op fusion).<p>4) Interleave your expensive instructions with less expensive ones. Try to interleave multiple dependency chains to let the processor see more of the parallelism.<p>Your two divisions one after another will be limited by available execution units capable of doing the divide.<p>5) Lastly align your loop labels to 16-byte offsets. The assembler will do this for you with the ALIGN directive.