Add bam_endpos(const bam1_t *)

This is used similarly to bam_cigar2rlen(), but checks that the record is
mapped according to both flags and cigar length before calculating rlen.

More tests of more exotic cigar strings should be added to fieldarith.sam.