code: private static int decodeCopyWith4ByteOffset(byte tag, ByteBuf in, ByteBuf out, int writtenSoFar) {
          if (in.readableBytes() < 4) {
              return NOT_ENOUGH_INPUT;
          }
  
          int initialIndex = out.writerIndex();
          int length = 1 + (tag >> 2 & 0x03F);
  
          // This should arguably be an unsigned int for consistency with the other offset types,
          // but we're unlikely to see offsets larger than Integer.MAX_VALUE in the wild.
          int offset = ByteBufUtil.swapInt(in.readInt());
  
          validateOffset(offset, writtenSoFar);
  
          out.markReaderIndex();
          if (offset < length) {
              int copies = length / offset;
              for (; copies > 0; copies--) {
                  out.readerIndex(initialIndex - offset);
                  out.readBytes(out, offset);
              }
              if (length % offset != 0) {
                  out.readerIndex(initialIndex - offset);
                  out.readBytes(out, length % offset);
              }
          } else {
              out.readerIndex(initialIndex - offset);
              out.readBytes(out, length);
          }
          out.resetReaderIndex();
  
          return length;
      }
docs: Reads a compressed reference offset and length from the supplied input
  buffer, seeks back to the appropriate place in the input buffer and
  writes the found data to the supplied output stream.
  
  @param tag The tag used to identify this as a copy is also used to encode
  the length and part of the offset
  @param in The input buffer to read from
  @param out The output buffer to write to
  @return The number of bytes appended to the output buffer, or -1 to indicate
  "try again later"
  @throws DecompressionException If the read offset is invalid