Interesting. It's not so much that the logic was reversed, but rather that your server appears to be adding the slashes, even though get_magic_quotes_gpc() was returning 0. So you could just have removed the branch completely, and hard-coded the calls to stripslashes(..) and addslashes(..) respectively.
One other thought - perhaps there's some quoting going on at the database connection, not on the web site, and this is the cause of the problem.