Can someone provide info on how SafeERC20 works?

Hello, it seems SafeERC20 should handle ERC20 token transfer/transferfrom for smart contracts.

However, not quite sure what the assembly code does for the contract here, can someone provide some info about it or point to some sources on this?

The revert part:

            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);

This piece of assembly will take the result of a call and check if it reverted. If it reverted, it will check if there is a revert reason included, and in that case it will revert with that same reason, i.e. "bubble it up". If there is no revert reason, it will revert with a custom revert reason given by errorMessage.