Romanus clamore prius undique orto quam satis cerneret se circumuentum esse sensit, et ante in frontem lateraque pugnari coeptum est quam satis instrueretur acies aut expediri arma stringique gladii possent.
I’m having trouble with quam satis, which occurs twice in this sentence. Do those two words function as a unit, or does the quam go with the preceding prius (in the first instance) and the preceding ante (in the second)?