That code is from a commercial Japanese anti-reverse engineering package, that's why it was so complicated. FYI.