This was an assignment to combine C and Assembly code.  The program masks all but the last 8 or 16 bits and then flips those remaining bits.