squaring a number using bitwise multiplication or using *
Negative input causes undefined behavior
If input1 is negative, your code reaches the end of function without returning a value.  Either you should return something such as 0 in that case, or you should make the input type be unsigned.
Simplification using math
Your expression (2*(input1+1)+1) evaluates to 2*input1+3.  So to minimize the work done, you could do:
if (input1 &gt; 0) {
    input1 += input1 + 3;
    return input1 * input1;
}

This has two adds, one multiply, and zero shifts.  This is one less shift than the code in &quot;code1&quot; and one less multiply than the code in &quot;code2&quot;, so it should be faster than either of them.