Int overflow detection for fractions + fix #23481

This is a set of functions for int overflow in ReducedFraction class
(from 
https://www.securecoding.cert.org/confluence/display/seccode/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow?showComments=false ),
and a fix of crash on import of a big MIDI file.
Int type is kept, no larger types are used.

The test MIDI file http://musescore.org/en/node/23481
is now imported without any crash or overflow:
https://drive.google.com/file/d/0B5alKuFoSol2Q0RPUHN6ME5ha3M/edit?usp=sharing

Fix for #23481 works well without overflow detection, but it is safer to use detection for possible future overflow cases. When overflow occurs abort() is invoked.

With the overflow detection the import of this file was slower: 2:05 s instead of 1:36 s.
But the overall long import time of big MIDI files is due to the quadratic complexity 
of some MIDI import algorithms (that is better to be fixed later).
With ordinary, smaller files the difference is negligible.