Add cld and std for controlling the direction flag
Clear direction flag before calling a C function

This is required by the ABI.
Fix indentation inconsistency