title: GCC/g++ cout << vs. printf()
body: <ul>
  <li>Why does <code>printf("hello world")</code> ends up using more CPU instructions in the assembled code (not considering the standard library used) than <code>cout &lt;&lt; "hello world"</code>?</li>
  </ul>
  
  <p>For C++ we have:</p>
  
  <pre><code>movl    $.LC0, %esi
  movl    $_ZSt4cout, %edi
  call    _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
  </code></pre>
  
  <p>For C:</p>
  
  <pre><code>movl    $.LC0, %eax
  movq    %rax, %rdi
  movl    $0, %eax
  call    printf
  </code></pre>
  
  <ul>
  <li>WHAT are line 2 from the C++ code and lines 2,3 from the C code for?</li>
  </ul>
  
  <p>I'm using gcc version 4.5.2</p>