How many coffins would that have required?
Few, which is the point. Obama pulled us out while the ISF were still getting on their feet. Once we left, three thngs happened:
1) The ISF lost the technical enablers and tactical intel we provided that increased their effectiveness.
2) Malaki was free to start playing sectarian games with the government and army. Competent leaders were replaced with political hacks with the result that competent formations fractured over time, and then broke when pressed by DAESH/ISIL.
3) The Iranians came in and filled the vacuum we left. They encouraged sectarianism to both weaken Iraq by exacerbating tensions and increase their influence among the Shia Arabs.
The Iranians are not Arabs and don’t mind seeing Arabs, even Shia Arabs, kill each other off if it improves Iran’s position in the region.