Besides by changing from :

    } else {
        if ((x) == -1))
            return -1;

to

    } else if ((x) == -1) {
            return -1;

Everything else inside the else if after the return -1 becomes dead

Yes it becomes dead, but there is nothing left in the 'else if' block.

Regards,
Michal