While it's true that the average US high school graduate does poorly in math and science compared to the average high school graduate from other advanced economies, the average high school graduate isn't the typical competitor for computer programming or engineering jobs - the US college graduate who majored in engineering or computer science is. And those are as good or better than the comparable cohort from India or China - otherwise American students would be clamoring to attend Indian or Chinese universities rather than vice-versa.
So the claim that there's a shortage of well-qualified American engineers and programmers is a complete myth, peddled by Silicon Valley Oligarchs as a pretext for replacing expensive American workers with cheap H1B tech workers. They sell the lie using an apples to oranges comparison.
You are correct that American students in engineering or computer science are intelligent and inquisitive. Whites still make up over 50% of that cohort, but that doesn’t indicate competitiveness comparable to Asian students. Our statistics are going to be racially skewed, as we are still a majority white nation for now. Asians represent the fastest growing cohort overall, however.
That does not mean that white students are going to get jobs, because by and large, white American workers demand a higher salary than individuals coming from poorer east Asian countries. Yes, this is a problem of greed by American corporations. I see it regularly in my work, as I am employed by one of those big tech corporations. They are introducing austerity measures and letting go of talent by using stack ranking practices in the name of culling the herd to keep the best, but I’ve seen them retain people due to preferred race or gender over talent or capability. That does seem to be shifting back to merit-based ethics, but it’s going to be a long, hard slog only to likely swing back toward the DEI crap in the next 10 years based on what direction the political winds blow.