BP CEO Hayward to be replaced in October by Robert Dudley as company makes record loss