Program: 45380
Project: 45380
Buggy source:
void emitCode(AbcWriter out,Abc abc,Method m) throws IOException {
  int emit_code_trace_phase=pushTracePhase("String_Node_Str");
  addTraceAttr("String_Node_Str",m);
  Map<Block,Integer> padding=new HashMap<Block,Integer>();
  Deque<Block> code=schedule(m.entry.to);
  Map<Block,AbcWriter> writers=new HashMap<Block,AbcWriter>();
  BitSet labels=new BitSet();
  BitSet done=new BitSet();
  for (  Block b : code) {
    done.set(b.id);
    for (    Edge e : b.succ())     if (done.get(e.to.id)) {
      labels.set(e.to.id);
    }
  }
  Map<Block,Integer> pos=new HashMap<Block,Integer>();
  Map<Block,Integer> blockends=new HashMap<Block,Integer>();
  int code_len=0;
  Deque<Block> work=new ArrayDeque<Block>(code);
  while (!work.isEmpty()) {
    Block b=work.removeFirst();
    int block_trace_phase=pushTracePhase("String_Node_Str");
    addTraceAttr("String_Node_Str",b);
    addTraceAttr("String_Node_Str",code_len);
    pos.put(b,code_len);
    AbcWriter w=new AbcWriter();
    writers.put(b,w);
    if (labels.get(b.id)) {
      addTraceAttr("String_Node_Str");
      w.write(OP_label);
    }
    emitBlock(w,b,abc);
    code_len+=w.size();
    Expr last=b.last();
    if (last.succ.length == 0) {
      w.write(last.op);
      code_len++;
      traceEntry("String_Node_Str","String_Node_Str",opNames[last.op]);
    }
 else     if (isJump(last)) {
      traceEntry("String_Node_Str","String_Node_Str",last.succ[0].to);
      if (work.isEmpty() || last.succ[0].to != work.peekFirst()) {
        code_len+=4;
        padding.put(b,4);
        addTraceAttr("String_Node_Str",false);
      }
 else       addTraceAttr("String_Node_Str",true);
    }
 else     if (isBranch(last)) {
      if (work.isEmpty() || last.succ[0].to != work.peekFirst()) {
        code_len+=8;
        padding.put(b,8);
      }
 else {
        code_len+=4;
        padding.put(b,4);
      }
    }
 else {
      assert(last.op == OP_lookupswitch);
      int switch_size=1 + out.sizeOfU30(last.succ.length) + 3 * last.succ.length;
      code_len+=switch_size;
      padding.put(b,switch_size);
    }
    blockends.put(b,code_len);
    unwindTrace(block_trace_phase);
  }
  out.writeU30(code_len);
  int code_start=out.size();
  traceEntry("String_Node_Str","String_Node_Str",code_start);
  for (  Block b : code) {
    int write_block_trace_phase=pushTracePhase("String_Node_Str");
    addTraceAttr("String_Node_Str",b);
    addTraceAttr("String_Node_Str",b.postorder);
    addTraceAttr("String_Node_Str",out.size());
    addTraceAttr("String_Node_Str",out.size() - code_start);
    writers.get(b).writeTo(out);
    if (padding.containsKey(b)) {
      Expr last=b.last();
      int trace_phase_jump=pushTracePhase("String_Node_Str");
      addTraceAttr(last);
      addTraceAttr("String_Node_Str",opNames[last.op]);
      addTraceAttr("String_Node_Str",padding.get(b));
      if (isBranch(last)) {
        addTraceAttr("String_Node_Str");
        emitBranch(out,last.op,last.succ[1].to,code_start,pos);
        padding.put(b,padding.get(b) - 4);
      }
      if (padding.get(b) == 4) {
        traceEntry("String_Node_Str");
        addTraceAttr("String_Node_Str",last.succ[0].id);
        emitBranch(out,OP_jump,last.succ[0].to,code_start,pos);
      }
      if (last.op == OP_lookupswitch) {
        emitLookupswitch(out,last,code_start,pos);
      }
      unwindTrace(trace_phase_jump);
    }
    unwindTrace(write_block_trace_phase);
  }
  out.writeU30(m.handlers.length);
  for (  Handler h : m.handlers) {
    int from=code_len;
    int to=0;
    for (    Block b : code) {
      for (      Edge x : b.xsucc) {
        if (x.to == h.entry) {
          if (pos.get(b) < from)           from=pos.get(b);
          if (blockends.get(b) > to)           to=blockends.get(b);
        }
      }
    }
    out.writeU30(from);
    out.writeU30(to);
    int off=pos.get(h.entry);
    verboseStatus("String_Node_Str" + h.entry + "String_Node_Str"+ from+ "String_Node_Str"+ to+ "String_Node_Str"+ off);
    out.writeU30(off);
    out.writeU30(abc.typeRef(h.type));
    if (h.name != null)     out.writeU30(abc.namePool.id(h.name));
 else     out.writeU30(0);
  }
  unwindTrace(emit_code_trace_phase);
}

Fixed version (ground truth):
void emitCode(AbcWriter out,Abc abc,Method m) throws IOException {
  int emit_code_trace_phase=pushTracePhase("String_Node_Str");
  addTraceAttr("String_Node_Str",m);
  Map<Block,Integer> padding=new HashMap<Block,Integer>();
  Deque<Block> code=schedule(m.entry.to);
  Map<Block,AbcWriter> writers=new HashMap<Block,AbcWriter>();
  BitSet labels=new BitSet();
  BitSet done=new BitSet();
  for (  Block b : code) {
    done.set(b.id);
    for (    Edge e : b.succ())     if (done.get(e.to.id)) {
      labels.set(e.to.id);
    }
  }
  Map<Block,Integer> pos=new HashMap<Block,Integer>();
  Map<Block,Integer> blockends=new HashMap<Block,Integer>();
  int code_len=0;
  Deque<Block> work=new ArrayDeque<Block>(code);
  while (!work.isEmpty()) {
    Block b=work.removeFirst();
    int block_trace_phase=pushTracePhase("String_Node_Str");
    addTraceAttr("String_Node_Str",b);
    addTraceAttr("String_Node_Str",code_len);
    pos.put(b,code_len);
    AbcWriter w=new AbcWriter();
    writers.put(b,w);
    if (labels.get(b.id)) {
      addTraceAttr("String_Node_Str");
      w.write(OP_label);
    }
    emitBlock(w,b,abc);
    code_len+=w.size();
    Expr last=b.last();
    if (last.succ.length == 0) {
      w.write(last.op);
      code_len++;
      traceEntry("String_Node_Str","String_Node_Str",opNames[last.op]);
    }
 else     if (isJump(last)) {
      traceEntry("String_Node_Str","String_Node_Str",last.succ[0].to);
      if (work.isEmpty() || last.succ[0].to != work.peekFirst()) {
        code_len+=4;
        padding.put(b,4);
        addTraceAttr("String_Node_Str",false);
      }
 else       addTraceAttr("String_Node_Str",true);
    }
 else     if (isBranch(last)) {
      if (work.isEmpty() || last.succ[0].to != work.peekFirst()) {
        code_len+=8;
        padding.put(b,8);
      }
 else {
        code_len+=4;
        padding.put(b,4);
      }
    }
 else {
      assert(last.op == OP_lookupswitch);
      int switch_size=1 + out.sizeOfU30(last.succ.length) + 3 * last.succ.length;
      code_len+=switch_size;
      padding.put(b,switch_size);
    }
    blockends.put(b,code_len);
    unwindTrace(block_trace_phase);
  }
  out.writeU30(code_len);
  int code_start=out.size();
  traceEntry("String_Node_Str","String_Node_Str",code_start);
  for (  Block b : code) {
    int write_block_trace_phase=pushTracePhase("String_Node_Str");
    addTraceAttr("String_Node_Str",b);
    addTraceAttr("String_Node_Str",b.postorder);
    addTraceAttr("String_Node_Str",out.size());
    addTraceAttr("String_Node_Str",out.size() - code_start);
    writers.get(b).writeTo(out);
    if (padding.containsKey(b)) {
      Expr last=b.last();
      int trace_phase_jump=pushTracePhase("String_Node_Str");
      addTraceAttr(last);
      addTraceAttr("String_Node_Str",opNames[last.op]);
      addTraceAttr("String_Node_Str",padding.get(b));
      if (isBranch(last)) {
        addTraceAttr("String_Node_Str");
        emitBranch(out,last.op,last.succ[1].to,code_start,pos);
        padding.put(b,padding.get(b) - 4);
      }
      if (padding.get(b) == 4) {
        traceEntry("String_Node_Str");
        addTraceAttr("String_Node_Str",last.succ[0].id);
        emitBranch(out,OP_jump,last.succ[0].to,code_start,pos);
      }
      if (last.op == OP_lookupswitch) {
        emitLookupswitch(out,last,code_start,pos);
      }
      unwindTrace(trace_phase_jump);
    }
    unwindTrace(write_block_trace_phase);
  }
  out.writeU30(m.handlers.length);
  for (  Handler h : m.handlers) {
    int from=code_len;
    int to=0;
    for (    Block b : code) {
      for (      Edge x : b.xsucc) {
        if (x.to == h.entry) {
          if (pos.get(b) < from)           from=pos.get(b);
          if (blockends.get(b) > to)           to=blockends.get(b);
        }
      }
    }
    out.writeU30(from);
    out.writeU30(to);
    int off;
    if (h.entry != null)     off=pos.get(h.entry);
 else {
      off=0;
    }
    verboseStatus("String_Node_Str" + h.entry + "String_Node_Str"+ from+ "String_Node_Str"+ to+ "String_Node_Str"+ off);
    out.writeU30(off);
    out.writeU30(abc.typeRef(h.type));
    if (h.name != null)     out.writeU30(abc.namePool.id(h.name));
 else     out.writeU30(0);
  }
  unwindTrace(emit_code_trace_phase);
}