Factional warfare, patronage battles and years of electoral decline have left the party on its last legs as it heads for a bruising outcome in South Africa’s municipal elections in November.