Branes, orientifolds and chiral gauge theories