Your problem is operator precedence: + operator have a priority over ^ operator so that your expression is evaluated as
return (count1(t->left) + count1(t->right) + (t->left == NULL)) ^ (t->right == NULL);
To correct this, you need to use brackets to change the evaluation order:
return count1(t->left) + count1(t->right) + ((t->left == NULL) ^ (t->right == NULL));