title: How to force compiler to generate conditional move by using inline assembly
body: <p>I've spent several hours trying to convert the following code to inline assembly (GCC) but in vain:</p>
  <pre><code>int new_low = mid + 1;
  int new_high = mid - 1;
  
  if (middle &lt; key) {
      low = new_low;
  }
  
  if (!(middle &lt; key)) {
      high = new_high;
  }
  </code></pre>
  <p>I want the compiler to optimize away those ifs and instead use conditional move. Unfortunately, the compiler keeps generating jumps. I tried writing inline assembly, but I am not good at it and there is some issue with the register clobbering and I can't get it right. What I am doing wrong?</p>
  <pre><code>__asm__ (
      &quot;cmp %[array_middle], %[key];&quot;
      &quot;cmovb %[new_low], %[low];&quot;
      &quot;cmovae %[new_high], %[high];&quot;
      : [low] &quot;=&amp;r&quot;(low), [high] &quot;=&amp;r&quot;(high)
      : [new_low] &quot;r&quot;(new_low), [new_high] &quot;r&quot;(new_high), [array_middle] &quot;r&quot;(middle), [key] &quot;r&quot;(key)
      : &quot;cc&quot;
  );
  </code></pre>