Read branch counts branch counts.

@param in   the in
@param code the code
@param size the size
@return the branch counts
@throws IOException the io exception
425585
protected BranchCounts readBranchCounts(final BitInputStream in,
    final Bits code, final long size) throws IOException {
    final BranchCounts branchCounts = new BranchCounts(code, size);
    final CodeType currentCodeType = this.getType(code);
    long maximum = size;

    // Get terminals
    if (currentCodeType == CodeType.Unknown) {
      branchCounts.terminals = this.readTerminalCount(in, maximum);
    }
    else if (currentCodeType == CodeType.Terminal) {
      branchCounts.terminals = size;
    }
    else {
      branchCounts.terminals = 0;
    }
    maximum -= branchCounts.terminals;

    // Get zero-suffixed primary
    if (maximum > 0) {
      assert Thread.currentThread().getStackTrace().length < 100;
      branchCounts.zeroCount = this.readZeroBranchSize(in, maximum, code);
    }
    maximum -= branchCounts.zeroCount;
    branchCounts.oneCount = maximum;
    return branchCounts;
  }
268971
public final static int readExtendedMediumInt(IoBuffer in) {
        int result = in.getInt();
        result = (result >>> 8) | ((result & 0x000000ff) << 24);
        return result;
    }
262797
public void readFields(DataInput in) throws IOException {
    int appIdLength = in.readInt();
    this.appId = new byte[appIdLength];
    in.readFully(appId);
    this.maxCount = in.readInt();
  }
572147
public static int readUntil (final StringBuilder out, final String in, final int start, final char... end)
  {
    int pos = start;
    while (pos < in.length ())
    {
      final char ch = in.charAt (pos);
      if (ch == '\\' && pos + 1 < in.length ())
      {
        pos = _escape (out, in.charAt (pos + 1), pos);
      }
      else
      {
        boolean endReached = false;
        for (final char element : end)
        {
          if (ch == element)
          {
            endReached = true;
            break;
          }
        }
        if (endReached)
          break;
        out.append (ch);
      }
      pos++;
    }

    return pos == in.length () ? -1 : pos;
  }
311454
@Override
    public void sawOpcode(int seen) {
        if (isInitializer) {
            lookForCustomThreadFactoriesInConstructors(seen);
            return;
        }

        try {
            stack.precomputation(this);

            if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)) {
                processInvoke();
            }
            // TODO Should not include private methods
            else if (seen == Const.ARETURN) {
                removeFieldsThatGetReturned();
            } else if (seen == Const.PUTFIELD) {
                XField f = getXFieldOperand();
                if (f != null) {
                    reportOverwrittenField(f);
                }
            } else if (seen == Const.IFNONNULL) {
                // indicates a null check, which means that we get an exemption
                // until the end of the branch
                OpcodeStack.Item nullCheckItem = stack.getStackItem(0);
                XField fieldWhichWasNullChecked = nullCheckItem.getXField();
                if (fieldWhichWasNullChecked != null) {
                    exemptExecutors.put(fieldWhichWasNullChecked, Integer.valueOf(getPC() + getBranchOffset()));
                }
            }
        } finally {
            stack.sawOpcode(this, seen);
        }
    }
1081791
public String find(PushbackReader in, int size) throws IOException, SyntaxErrorException
    {
        if (acceptEmpty)
        {
            throw new IllegalArgumentException("using find for  '" + expression + "'  that accepts empty string");
        }
        InputReader reader = Input.getInstance(in, size);
        int rc = find(reader);
        reader.release();
        if (rc == 1)
        {
            return reader.getString();
        }
        else
        {
            throw new SyntaxErrorException("string matching  '" + expression + "'  not found");
        }
    }
457828
public String[] split(PushbackReader in, int bufferSize) throws IOException
    {
        return split(in, bufferSize, Integer.MAX_VALUE);
    }
1129681
public long readExecutionCount (Path dir) throws IOException {
    State state = loadState(fs, dir);
    return Long.parseLong(state.getProp(CompactionSlaEventHelper.EXEC_COUNT_TOTAL, "0"));
  }
829766
public void readAll(InputStream in) throws IOException {
    int read = 0;
    do {
      grow(length);
      read = data.setBytes(length, in, data.length() - length);
      if (read > 0) {
        length += read;
      }
    } while (in.available() > 0);
  }
71217
public void ifle(String target) throws IOException
    {
        if (wideIndex)
        {
            out.writeByte(NOT_IFLE);
            out.writeShort(WIDEFIXOFFSET);
            Branch branch = createBranch(target);
            out.writeByte(GOTO_W);
            out.writeInt(branch);
        }
        else
        {
            Branch branch = createBranch(target);
            out.writeOpCode(IFLE);
            out.writeShort(branch);
        }
    }
26932
public void ifge(String target) throws IOException
    {
        if (wideIndex)
        {
            out.writeByte(NOT_IFGE);
            out.writeShort(WIDEFIXOFFSET);
            Branch branch = createBranch(target);
            out.writeByte(GOTO_W);
            out.writeInt(branch);
        }
        else
        {
            Branch branch = createBranch(target);
            out.writeOpCode(IFGE);
            out.writeShort(branch);
        }
    }
463808
public static int getNumberOfLines(Reader in) throws IOException {
    LineNumberReader lnr = new LineNumberReader(in);
    lnr.skip(Long.MAX_VALUE);
    in.close();
    return lnr.getLineNumber();
  }
34023
public void read(NutDataInputStream in, long startcode) throws IOException {
    this.startcode = startcode;
    forwardPtr = in.readVarLong();
    if (forwardPtr > 4096) {
      long expected = in.getCRC();
      checksum = in.readInt();
      if (checksum != expected) {
        // TODO This code path has never been tested.
        throw new IOException(
            String.format("invalid header checksum %X want %X", expected, checksum));
      }
    }

    in.resetCRC();
    end = in.offset() + forwardPtr - 4; // 4 bytes for footer CRC
  }
400845
public final static int readMdLinkId(final StringBuilder out, final String in, final int start)
    {
        int pos = start;
        int counter = 1;
        while (pos < in.length())
        {
            final char ch = in.charAt(pos);
            boolean endReached = false;
            switch (ch)
            {
            case '\n':
                out.append(' ');
                break;
            case '[':
                counter++;
                out.append(ch);
                break;
            case ']':
                counter--;
                if (counter == 0)
                {
                    endReached = true;
                }
                else
                {
                    out.append(ch);
                }
                break;
            default:
                out.append(ch);
                break;
            }
            if (endReached)
            {
                break;
            }
            pos++;
        }

        return (pos == in.length()) ? -1 : pos;
    }
743459
public static int readInt(DataInput in) throws IOException {
        byte len=in.readByte();
        if(len == 0)
            return 0;
        return makeInt(in, len);
    }
567584
static byte[] readFile(
      InputStream in, long expectedSize) throws IOException {
    if (expectedSize > Integer.MAX_VALUE) {
      throw new OutOfMemoryError("file is too large to fit in a byte array: "
          + expectedSize + " bytes");
    }

    // some special files may return size 0 but have content, so read
    // the file normally in that case
    return expectedSize == 0
        ? ByteStreams.toByteArray(in)
        : ByteStreams.toByteArray(in, (int) expectedSize);
  }
1252227
@Override
    public void sawOpcode(int seen) {
        if (seen == Const.INVOKEINTERFACE) {
            String clsName = getClassConstantOperand();
            String methodName = getNameConstantOperand();

            if (queryClasses.contains(clsName) && queryMethods.contains(methodName)) {
                queryLocations.add(Integer.valueOf(getPC()));
            }
        } else if (OpcodeUtils.isBranch(seen)) {
            int branchTarget = getBranchTarget();
            int pc = getPC();
            if (branchTarget < pc) {
                loops.add(new LoopLocation(branchTarget, pc));
            }
        }
    }