[Demonstration 1]

[Buggy Method]
public List<Map> generateNewBoardStateFromPlayerMove() {
    if (isMoveValidAdjacentMove()) {
        doMove();
        // player can go again if he jumps
        return BoardState.generateBoardState(theBoard, false);
    } else {
        return BoardState.generateBoardState(theBoard, true);
    }
}

[Buggy Hunk]
if ( isMoveValidAdjacentMove() ) {

[Patch]
if ( isMoveValidAdjacentMove() || isMoveValidJumpMove()) {

[Demonstration 2]

[Buggy Method]
@Override
public Expr comp(final QueryContext ctx) throws QueryException {
    compHoist(ctx);
    compWhere(ctx);
    final boolean grp = ctx.grouping;
    ctx.grouping = group != null;
    // optimize for/let clauses
    final int vs = ctx.vars.size();
    for (int f = 0; f < fl.length; ++f) {
        final ForLet flt = fl[f];
        flt.comp(ctx);
        // bind variable if it contains a value or occurs only once
        if (flt.expr.isValue() || count(flt.var, f) == 1)
            flt.bind(ctx);
        /* ...or if all inner clauses return only one item. This rewriting would
       * disallow repeated evaluations of the same expression, but it prevents
       * index-based rewritings (e.g. for XMark 9)
      boolean one = true;
      for(int g = f + 1; g < fl.length; g++) one &= fl[g].size() == 1;
      if(flt.expr.value() || count(flt.var, f) == 1 && one) flt.bind(ctx);
      */
    }
    // optimize where clause
    boolean empty = false;
    if (where != null) {
        where = checkUp(where, ctx).comp(ctx).compEbv(ctx);
        if (where.isValue()) {
            // test is always false: no results
            empty = !where.ebv(ctx, input).bool(input);
            if (!empty) {
                // always true: test can be skipped
                ctx.compInfo(OPTREMOVE, description(), where);
                where = null;
            }
        }
    }
    if (group != null)
        group.comp(ctx);
    if (order != null)
        order.comp(ctx);
    ret = ret.comp(ctx);
    ctx.vars.size(vs);
    ctx.grouping = grp;
    // remove FLWOR expression if WHERE clause always returns false
    if (empty) {
        ctx.compInfo(OPTREMOVE, description(), where);
        return Empty.SEQ;
    }
    // check if return always yields an empty sequence
    if (ret == Empty.SEQ) {
        ctx.compInfo(OPTFLWOR);
        return ret;
    }
    // remove declarations of statically bound or unused variables
    for (int f = 0; f < fl.length; ++f) {
        final ForLet l = fl[f];
        // do not optimize non-deterministic expressions. example:
        // let $a := file:write('file', 'content') return ...
        if (l.var.expr() != null || l.simple(true) && count(l.var, f) == 0 && !l.expr.uses(Use.NDT)) {
            ctx.compInfo(OPTVAR, l.var);
            fl = Array.delete(fl, f--);
        }
    }
    // no clauses left: simplify expression
    // an optional order clause can be safely ignored
    if (fl.length == 0) {
        // if where clause exists: where A return B -> if A then B else ()
        // otherwise: return B -> B
        ctx.compInfo(OPTFLWOR);
        return where != null ? new If(input, where, ret, Empty.SEQ) : ret;
    }
    // remove FLWOR expression if a FOR clause yields an empty sequence
    for (final ForLet f : fl) {
        if (f instanceof For && f.isEmpty()) {
            ctx.compInfo(OPTFLWOR);
            return Empty.SEQ;
        }
    }
    // compute number of results to speed up count() operations
    if (where == null && group == null) {
        size = ret.size();
        if (size != -1) {
            // multiply loop runs
            for (final ForLet f : fl) {
                final long s = f.size();
                if (s == -1) {
                    size = s;
                    break;
                }
                size *= s;
            }
        }
    }
    type = SeqType.get(ret.type().type, size);
    compHoist(ctx);
    return this;
}

[Buggy Hunk]
if(f instanceof For && f.isEmpty()) {

[Patch]
if(f instanceof For && f.size() == 0) {

[Demonstration 3]

[Buggy Method]
@Test
public void validValues() {
    BranchMatcher branchMatcher = new BranchMatcher(branches);
    for (String value : validBranches) {
        assertTrue(value, branchMatcher.matches(value));
    }
}

[Buggy Hunk]
BranchMatcher branchMatcher = new BranchMatcher(branches);

[Patch]
BranchMatcher branchMatcher = new BranchMatcher(branches, mode);