China stocks gain on bargain-buying after slump