Adding branch optimization for the fifo

Testing both situation that the pointer exceeds end or begin. Adding
unlikely to optimize the cpu branching.

Signed-off-by: Chen, Yiqun
Working test

The reliable test codes. We cannot simply count the line because it's
binary data which means the lines may not be correctly counted as I
don't append '\0' at each string read from fifo.

Signed-off-by: Chen, Yiqun