title: Find "edges" in 32 bits word bitpattern
body: <p>Im trying to find the most efficient algorithm to count "edges" in a bit-pattern. An edge meaning a change from 0 to 1 or 1 to 0. I am sampling each bit every 250 us and shifting it into a 32 bit unsigned variable. </p>
  
  <p>This is my algorithm so far</p>
  
  <pre><code>void CountEdges(void)
  {
      uint_least32_t feedback_samples_copy = feedback_samples;
      signal_edges = 0;
  
      while (feedback_samples_copy &gt; 0)
      {
          uint_least8_t flank_information = (feedback_samples_copy &amp; 0x03);
  
          if (flank_information == 0x01 || flank_information == 0x02)
          {
              signal_edges++;
          }
  
          feedback_samples_copy &gt;&gt;= 1;
      }
  }
  </code></pre>
  
  <p>It needs to be at least 2 or 3 times as fast.</p>