I would create a temp
branch on C that I will play with, let's suppose that main is on D (not specified, but):
git branch -b temp C
# let's go back to A, keeping _all_ of C's content so you can decide what to keep:
git reset --soft A
# now get the files the way you would like to get it for A (you can compare with A and B, just so that you _really_ get what you want.
# when you are done
git commit -m "new A"
# temp is on the new A
# let's go back to C
git checkout C
# let's put it on top of temp
git reset --soft temp
# Get the files you want the to be on B (compare with HEAD~1 and B.. and C)
# when you are done
git commit -m "new B"
# let's put temp where we are
git branch -f temp
# finally, let's move whatever is left over from C that is not part of B
git checkout C
git reset --soft temp
git commit -m "New C"
git branch -f temp
# at this moment C and temp are exactly the same
git checkout temp
git cherry-pick D
# temp is like the branch you want
... and that's it.
If actually C is what you would like B to be like, with some changes on A, then follow the recipe about "new A", then
git checkout C
git reset --soft temp
git commit -m "New B"
git branch -f temp
git checkout temp
git cherry-pick D