Efficient and Correct Transactional Memory Programs Combining Snapshot Isolation and Static Analysis