GodBolt: Enter C, get Assembly
Try with gcc 6.2 options -Ofast -march=native:<p><pre><code>  int square(int num) {
    int a = 0;
    for (int x = 0; x < num; x+=2) {
      if (!(x % 2)) {
        a += x;
      }
   }
    return a;
  }
</code></pre>
All kinds of loop unrolling and vector instructions.
Now remove the "!"