Do the comparison again
controlling on country of origin. E.g., how do US citizen students with families from Japan compare with students still in Japan? Instead of Japan, substitute Canada, India, Pakistan, the Philippines, South Korea, England, Germany, Finland, Sweden, Norway, the Baltic countries, the Balkan countries,
Austria, Switzerland, Israel, Poland, Russia, France, Spain, Italy, Singapore, Turkey, Iraq, Iran, the Gulf States, North Africa including Egypt, West Africa, Central Sub-Saharan Africa, East Africa, South Africa, Mexico, Brazil, ....
The US is a uniquely diverse country, and such a diverse country necessarily will have a tough time competing
in average performance scores with better countries that are not diverse and, instead, have a quite uniform culture. So, right away on average scores, the US will have a tough time competing with much of Europe and the better Asian countries.
Also understand that the famous, prestigious US universities -- Harvard, Princeton, Yale, Cornell, MIT, Johns Hopkins, NYU, Columbia, most of the SUNY schools, most of the Big Ten, CMU, Chicago, U. Washington, most of the University of California campuses, Stanford, Caltech, University of Texas, Rice, Georgia Tech, etc. are RESEARCH universities and do not concentrate on technical or vocational training for software developer positions where H1Bs are common.