Secure and Practical Splitting of IoT Device Functionalities