public bool TryMatch(StatementCollection statements, out int startIndex, out Statement result, out int replacedStatementsCount)
        {
            replacedStatementsCount = 0;
            startIndex = -1;
            result     = null;
            bool inlinedSuccessfully = false;

            if (statements.Count == 0)
            {
                return(false);
            }

            HashSet <VariableDefinition> markedForRemoval = new HashSet <VariableDefinition>();

            List <int> positionsToInline = GetStatementsToInline(statements);

            for (int i = positionsToInline.Count - 1; i >= 0; i--)
            {
                int index = positionsToInline[i];

                ExpressionStatement defineExpression = statements[index] as ExpressionStatement;
                VariableDefinition  variable         = ((defineExpression.Expression as BinaryExpression).Left as VariableReferenceExpression).Variable.Resolve();

                if (index == statements.Count - 1 || !string.IsNullOrEmpty(defineExpression.Label))
                {
                    markedForRemoval.Add(variable);
                    continue;
                }

                List <Instruction> instructions = new List <Instruction>(defineExpression.Expression.MappedInstructions);
                instructions.AddRange((defineExpression.Expression as BinaryExpression).Left.UnderlyingSameMethodInstructions);
                Expression value = (defineExpression.Expression as BinaryExpression).Right.CloneAndAttachInstructions(instructions);

                ICodeNode resultNode;
                if (inliner.TryInlineVariable(variable, value, statements[index + 1], ShouldInlineAggressively(variable), out resultNode))
                {
                    statements.RemoveAt(index);
                    inlinedSuccessfully = true;
                    markedForRemoval.Add(variable);
                    methodContext.RemoveVariable(variable);
                    // the statement containing the inlined variable is not at index, since we removed the variable declaration statement
                    statements[index] = (Statement)this.dereferencer.Visit(statements[index]);
                }
            }

            foreach (VariableDefinition variable in markedForRemoval)
            {
                patternsContext.VariableToSingleAssignmentMap.Remove(variable);
                patternsContext.VariableToDefineUseCountContext.Remove(variable);
            }

            return(inlinedSuccessfully);
        }