contract Proxy {

    /**
    * @dev Fallback function allowing to perform a delegatecall to the given implementation.
    * This function will return whatever the implementation call returns
    */
    function () public payable {
        address _impl = implementation();
        require(_impl != address(0));

        bool success = _impl.delegatecall(msg.data);
        assembly {
            let freememstart := mload(0x40)
            returndatacopy(freememstart, 0, returndatasize())
            switch success
            case 0 { revert(freememstart, returndatasize()) }
            default { return(freememstart, returndatasize()) }
        }
    }

    /**
    * @dev Tells the address of the implementation where every call will be delegated.
    * @return address of the implementation to which it will be delegated
    */
    function implementation() public view returns (address);
}
/**
 * @title Proxy
 * @dev Gives the possibility to delegate any call to a foreign implementation.
 */
function () public payable {
    address _impl = implementation();
    require(_impl != address(0));

    bool success = _impl.delegatecall(msg.data);
    assembly {
        let freememstart := mload(0x40)
        returndatacopy(freememstart, 0, returndatasize())
        switch success
        case 0 { revert(freememstart, returndatasize()) }
        default { return(freememstart, returndatasize()) }
    }
}

/**
 * @dev Fallback function allowing to perform a delegatecall to the given implementation.
 * This function will return whatever the implementation call returns
 */