This paper presents a stylized model of the world economy to study how the cross- country differences in the institutional quality (IQ) of the domestic credit markets shape the patterns of international capital flows when such IQ differences also cause productivity differences across countries. Institution affects productivity by changing the composition of credit across heterogeneous investment projects with different productivity. Such institution-induced productivity differences are shown to have effects on the investment and capital flows that are opposite of exogenous productivity differences. This implies that the overall effect of IQ could generate U-shaped responses of the investment and capital flows, which means, among other things, that capital flows out from middle-income countries and flows into both low-income and high-income countries, and that, starting from a very low IQ, a country could experience both a growth and a current account surplus after a successful institutional reform. More generally, it provides some cautions when interpreting the empirical evidence on the role of productivity differences and institutional differences on capital flows.