I have a fully functional software for a special hardware. I don't think it would be any good if you try that on some other hardware.
My tests has been made both by additions to my software and also by direct manipulating things in my monitoring software where I can access all memory and ports.
According to my understanding, you should do the following to set a PIO_4 to output:
Bit 24 in PINENABLE0, address 0x4000 C1C0, should be 1 but that is default on reset so it should not be necessary to change.
Enable GPIO clock (bit 6) in SYSAHBCLKCTRL, address 0x4004 8080, also default on reset.
Set port as output by writing a 1 in correct position (0x10 for PIO_4) in GPIO direction port register (DIR0, address 0xA000 2000)
Pin should now be output and should be possible to set to 0/1 by writing 0/0x10 to GPIO port pin register (PIN0, address 0xA000 2100)
I have checked actual register contents.
I think this has something to do with the wake-up pin functionality on this pin.