Code may vary where you live
Yes. You are going to create a "Shared Neutral" circuit. This isn't difficult or dangerous, but you should do some labeling in the panel and the box itself.
First, it looks like the receptacle is a 30A/220V grounded receptacle (the wire itself may also be 30A -typical for an electric dryer- but that doesn't matter since you are using 20A breakers and receptacles). You are going to share the neutral and ground wires for these (2) new circuits by wire-nutting the two circuits in your first location (the junction inside the GFCI).
Shut off power to the 40 amp double pole breaker.
Assuming you have a red, black, white, and green/bare wire:
The red is one hot.
The black is the second hot.
The white is the neutral for both.
The green/bare is the ground for both.
Assuming that the "red" circuit will be the GFCI at this location, connect the Red to the hot\line side of the GFCI, make a pigtailed white wire to do the same. On the load side of the GFCI, run the continuation of the circuit.
Using the Black wire and another pigtailed neutral, junction these to the line that is going to the other room.
To be a good citizen: Label the inside of the box "Shared Neutral". Extra points if you "tie" the two hots together with a piece of white electrical tape with some extra length so it looks like a little "flag" that says "Shared Neutral". Double extra points if you label the cover plate so that someone sees it before they make any future modifications.
Go to your panel. If you are not comfortable working in the panel, shut off the main power and probably have a friend hold 1 or 2 flashlights for you.
Disconnect the (2) hot wires from the 40 amp double pole breaker (I assume these will be red and black). LEAVE the neutral and ground in place.
Remove the breaker and simply replace it with (2) 20 Amp breakers. Keep the same position in the panel OR make sure that the breakers are on OPPOSITE poles -as if they were a single 220 volt circuit. IT IS IMPERATIVE THAT THEY ARE NOT BOTH ON THE SAME POLE OR YOU RUN THE RISK OF SENDING 40 AMPS THOUGH THE NEUTRAL ON THE SAME POLE (If you need further explanation, please ask -this is the most important safety step). Some people will disagree and will say to use a 20 Amp double pole breaker. The problem with this is that it inaccurately appears to be (1) 220 volt circuit instead of (2) 110 volt circuits with a shared neutral. There is an exception to this rule below.*
LABEL The panel cover by bracketing the (2) circuit labels and write "Shared Neutral".
Extra points: inside the panel, tie the (2) hots together (the red & black) with a piece of white electrical tape that says "Shared Neutral".
NOTE: You will NOT be able to split the circuit after the GFCI ...so don't think you can give GFCI protection to both circuits with (1) GFCI receptacle. If you want the other circuit to be GFCI protected, you must use another GFCI receptacle in the first location of the second (black) circuit. You also will not be able to use a single pole GFCI breaker on either circuit. You must either use (2) GFCI receptacles as above. Alternatively, you may use (1) double-pole (220volt) GFCI circuit breaker -but you should still label the circuit as "Shared Neutral".
- EXCEPTION TO THE (2) 20 AMP CIRCUIT BREAKER RULE: If you want these circuits to be AFCI protected you must use (1) double pole (220 volt) AFCI circuit breaker. You should still label the circuits as "Shared Neutral".
...That was fun to write! :D