Inherent structure theory of local order in liquid and amorphous alloys. I. The nearly-free-electron case