Why does this loopback device creation malfunction?

From the first sight sizelimit variable is calculated incorrectly, thus target read-only loop device exceeds the size of /dev/sdb2 device. The result of (End - Start)* size of sector = sizelimit is 78001344 and it should be used during loop device creation to resolve the issue.