function processAwait( cmd ) {
	var state;
	var body;
	var node;
	var tmp;
	var ast;

	// Wrap the command string in an async IIFE:
	tmp = '(async function __wrapper__() {' + cmd + '})()';

	// Attempt to parse the wrapped command string into an abstract syntax tree (AST):
	try {
		ast = parse( tmp, {
			'ecmaVersion': 'latest' // async/await is available starting in ECMAScript Version 10 and acorn supports through version 11 (2020)
		});
	} catch ( err ) {
		return err;
	}
	body = ast.body[ 0 ].expression.callee.body;

	// Split the wrapped command string into individual characters to allow transformation:
	tmp = tmp.split( '' );

	// Create a `state` object for tracking state as we walk the AST:
	state = {};
	state.body = body;
	state.ancestors = [];
	state.replace = replace;
	state.prepend = prepend;
	state.append = append;
	state.hasAwait = false;
	state.hasReturn = false;

	// Perform a recursive walk of the AST:
	walk.recursive( body, state, VISITORS );

	// Do not transform if either the command does not actually contain an `await` expression OR if there exists a top-level `return` which is not allowed:
	if ( state.hasAwait === false || state.hasReturn ) {
		return new Error( 'invalid argument. Provided command either does not contain an `await` expression or contains a top-level `return` which is not allowed.' );
	}
	// For an expression statement of the form `( expr );`, we do not want the left parenthesis before the `return` keyword, and, thus, we need to prepend a `return (` to the last AST node. Furthermore, we do not want the right parenthesis after the semicolon; in which case, as there can only be more right parentheses between `node.expression.end` and the semicolon, we can append a right parenthesis to `node.expression`.
	node = body.body[ body.body.length-1 ];
	if ( node.type === 'ExpressionStatement' ) {
		state.prepend( node, 'return (' );
		state.append( node.expression, ')' );
	} else if ( node.type === 'VariableDeclaration' ) {
		node = node.declarations[ node.declarations.length-1 ];
		state.append( node, '; return '+node.id.name+';' ); // return the assigned value of last declared variable
	} else if ( node.type === 'FunctionDeclaration' ) {
		state.append( node, '; return '+node.id.name+';' );
	}
	// Introduce logic for handling the result of the returned promise:
	tmp = wrapCommand( tmp.join( '' ) );
	if ( isSilentCommand( cmd ) ) {
		tmp += ';';
	}
	// Return the transformed command:
	return tmp;

	/**
	* Replaces a substring within the wrapped command.
	*
	* @private
	* @param {NonNegativeInteger} start - start index
	* @param {NonNegativeInteger} stop - end index
	* @param {string} str - replacement string
	*/
	function replace( start, stop, str ) {
		var i;
		for ( i = start; i < stop; i++ ) {
			tmp[ i ] = '';
		}
		if ( start === stop ) {
			str += tmp[ start ];
		}
		tmp[ start ] = str;
	}

	/**
	* Prepends a string to the wrapped command.
	*
	* @private
	* @param {Node} node - AST node
	* @param {string} str - string to prepend
	*/
	function prepend( node, str ) {
		tmp[ node.start ] = str + tmp[ node.start ];
	}

	/**
	* Appends a string to the wrapped command.
	*
	* @private
	* @param {Node} node - AST node
	* @param {string} str - string to append
	*/
	function append( node, str ) {
		tmp[ node.end-1] += str;
	}
}
Transforms a command containing a top-level `await` statement.

@private
@param {string} cmd - command string
@returns {(string|Error)} transformed command or an error