title: Optimization with bitwise operator
body: <p>I'm writing a software for an embedded system that will do many input readings (including frequency) in a very short time, and thus the main loop needs to be as fast as possible.</p>
  
  <p>I'm having trouble deciding how to implement the following code, though. Which version of the code would run faster? Would the compiler optimize the code automatically? Is an AND operation slower than an assignment?</p>
  
  <p>First Code:</p>
  
  <pre><code>   if ((a&amp;b) == (b&amp;c))
     {
       if (a&amp;b)
         //something;
       else
         //something else;
     }
  </code></pre>
  
  <p>Second code:</p>
  
  <pre><code> int p;
   if ((p = (a&amp;b)) == (b&amp;c))
     {
       if (p)
         //something;
       else
         //something else;
     }
  </code></pre>