anchor.diff:      ir.Primitive thenValue = thenBuilder.visit(node.thenExpression);
       ir.Primitive elseValue = elseBuilder.visit(node.elseExpression);
   
  -    // Construct a join in the same way as for if statements, see visitIf.
  -    // There is always control flow out of expressions so thenBuilder.isOpen
  -    // and elseBuilder.isOpen.  There is an extra join-point continuation
  -    // parameter for the expression value.
  -    assert(assignedVars.length == thenBuilder.freeVars.length);
  -    assert(assignedVars.length == elseBuilder.freeVars.length);
  -    assert(assignedVars.length <= thenBuilder.assignedVars.length);
  -    assert(assignedVars.length <= elseBuilder.assignedVars.length);
  -    List<ir.Parameter> parameters = <ir.Parameter>[];
       List<ir.Primitive> thenArguments = <ir.Primitive>[];
       List<ir.Primitive> elseArguments = <ir.Primitive>[];
  -    for (int i = 0; i < assignedVars.length; ++i) {
  -      ir.Definition thenAssignment = thenBuilder.assignedVars[i];
  -      ir.Definition elseAssignment = elseBuilder.assignedVars[i];
  -      if (thenAssignment != null || elseAssignment != null) {
  -        ir.Parameter parameter = new ir.Parameter(null);
  -        parameters.add(parameter);
  -        thenArguments.add(thenAssignment == null
  -                              ? thenBuilder.freeVars[i]
  -                              : thenAssignment);
  -        elseArguments.add(elseAssignment == null
  -                              ? elseBuilder.freeVars[i]
  -                              : elseAssignment);
  -      }
  -    }
  +    List<ir.Parameter> parameters =
  +        createJoinParameters(thenBuilder, thenArguments,
  +                             elseBuilder, elseArguments);
       // Add a continuation parameter for the result of the expression.
       ir.Parameter resultParameter = new ir.Parameter(null);
       parameters.add(resultParameter);
  
positive.code:     return null;
    }
  
    ir.Primitive visitIf(ast.If node) {
      assert(isOpen);
      ir.Primitive condition = visit(node.condition);
  
negative.code:     thenContinuation.body = thenBuilder.root;
      elseContinuation.body = elseBuilder.root;
  
      // Capture free occurrences in the then and else bodies and add join
      // continuation parameters as assignments reaching the join body.  This is
      // done after creating invocations of the join continuation so free join
      // continuation arguments are properly captured.
      captureFreeVariables(thenBuilder, elseBuilder, parameters);
  
      ir.Expression branch =
          new ir.LetCont(thenContinuation,
  