BP halves dividend after record loss in second quarter