Yes, the rules are complex and oftentimes there will be debate. There are grey areas in the law, and sometimes the auditor will have a view and the taxpayer will have a view. Ultimately it's up to the courts to resolve those situations. All of that is fair game and it falls within that tax avoidance, which, as you say, is legal. It's tax evasion that everyone agrees has to be stopped.
On October 27th, 2014. See this statement in context.