Pakistan is a complex case, there are factions absolutely loyal to the CIA, factions leaning towards China. Then there is also the military which historically has close relations to China. Unfortunately though, Pakistan's real master is the CIA, but even if that's the case, its power to steer Pakistan against China are heavily resisted by localities in Pakistan and even the military itself which felt that IK was too close to China the past years.
Basically, yes, as shown by the coup, Pakistan daddy is the CIA, but there is huge internal resistance against these crooks. And even these crooks don't want to be against China, but they want a rebalancing. Well, that's my reading from an outsider's perspective.
Pakistan is most certainly not beholden to the CIA. If it was, they would never be able to get nukes which was opposed by US and Israel.
Pakistan's only motto is self preservation against the Indian onslaught. Pakistan was created to be the home of muslims in the Indian subcontinent and that is why it is the anti-thesis of the Hindu dominated India. Indian nationalists hate Pakistan to the core because they hate that India was ruled by Muslims for 600 years in the past and there are still 500 million muslims in the Indian Subcontinent. Hindu nationalists cannot accept such a large proportion of muslims which they think are outsiders and usurpers and must be eradicated.
Pakistan on the other hand still have nostalgia about the past times when muslims dominated the sub-continent. They know they cannot go back to the old times, but they still hope to preserve the Muslim presence in the subcontinent.
Before China was powerful, Pakistan relied on US and the west to survive against India. It was the US and west who provided pakistan with weapons, money and other help during the cold war. Pakistan still wants to keep US as a benefactor.
However, they understand that times have changed, US no longer wants to keep India down like it did during the cold war. So, the more Pro-India US becomes the more Pakistan has to rely on China. They don't like that getting too close to China might mean they may have to become an enemy of the west. So, they want steer clear of the US-China fight. They just want to focus on the China-India fight and utilize China for self-preservation.
China also understands Pakistan's situation and never forces Pakistan to be anti-US. They want Pakistan to be Pro-US and Pro-China. They just have to just be a bulwark against India.