You do not assign output in some cases. You have a series of
if this
if that
if theother
output=1
else
output=0;
end
end
end
Consider what would happen if "this" is not true: it would never get to try "that" and "the other" to assign to output.
One way of handling this is to assign 0 to output before the "if" structure and then only assign 1 in the case you can prove that it is "perfect". In all the other cases output would stay 0 which is what you want.
But you should also look at the "&" and "&&" operators
if this & that & theother