```\nfunction safeTransferFrom(\n    ERC20 token,\n    address from,\n    address to,\n    uint256 amount\n) internal {\n    bool callStatus;\n\n    assembly {\n        // Get a pointer to some free memory.\n        let freeMemoryPointer := mload(0x40)\n\n        // Write the abi-encoded calldata to memory piece by piece:\n        mstore(\n            freeMemoryPointer,\n            0x23b872dd00000000000000000000000000000000000000000000000000000000\n        ) // Begin with the function selector.\n        mstore(\n            add(freeMemoryPointer, 4),\n            and(from, 0xffffffffffffffffffffffffffffffffffffffff)\n        ) // Mask and append the "from" argument.\n        mstore(\n            add(freeMemoryPointer, 36),\n            and(to, 0xffffffffffffffffffffffffffffffffffffffff)\n        ) // Mask and append the "to" argument.\n        mstore(add(freeMemoryPointer, 68), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.\n\n        // Call the token and store if it succeeded or not.\n        // We use 100 because the calldata length is 4 + 32 * 3.\n        callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0)\n    }\n\n    require(\n        didLastOptionalReturnCallSucceed(callStatus),\n        "TRANSFER_FROM_FAILED"\n    );\n}\n```\n