title: c library x86/x64 assembler
body: <p>Is there a C library for assembling a x86/x64 assembly string to opcodes?</p>
  
  <p>Example code:</p>
  
  <pre><code>/* size_t assemble(char *string, int asm_flavor, char *out, size_t max_size); */
  
  unsigned char bytes[32];
  size_t size = assemble("xor eax, eax\n"
                         "inc eax\n"
                         "ret",
                         asm_x64, &amp;bytes, 32);
  
  for(int i = 0; i &lt; size; i++) {
      printf("%02x ", bytes[i]);
  }
  
  /* Output: 31 C0 40 C3 */
  </code></pre>
  
  <p>I have looked at <a href="https://code.google.com/p/asmpure/">asmpure</a>, however it needs modifications to run on non-windows machines.</p>
  
  <p>I actually both need an assembler and a disassembler, is there a library which provides both?</p>