To sneak onto the emperor’s flagship go near the fleet with a boat and wait until it is night. Jump into the water and dive until you are near the search area. You can come up for air in areas where there is no light nearby. When you are near the emperor’s flagship save the game as it is easy to make mistakes. Dive under the emperor’s flagship to the east end of the ship and swim to the anchor:
Climb up the anchor.
To find the missing part of the mechanism go out of the room with the door in it through the door to the right. Keep going straight ahead (don’t go into the cave to the right) until you find another mechanism on the wall to the right:
Take the lever from it and go back to the mechanism next to the door.
To sneak into the stables go to the side of the stables and climb up the the platform near the left corner of the stables:
Climb up to the roof and go through the door. Climb down the ladder and pick up the key next to the sleeping guard. Use the key to let Ciri in.