static int encode_residual(FlacEncodeContext *ctx, int ch)

{

    int i, n;

    int min_order, max_order, opt_order, precision, omethod;

    int min_porder, max_porder;

    FlacFrame *frame;

    FlacSubframe *sub;

    int32_t coefs[MAX_LPC_ORDER][MAX_LPC_ORDER];

    int shift[MAX_LPC_ORDER];

    int32_t *res, *smp;

    frame = &ctx->frame;

    sub = &frame->subframes[ch];

    res = sub->residual;

    smp = sub->samples;

    n = frame->blocksize;

    /* CONSTANT */

    for(i=1; i<n; i++) {

        if(smp[i] != smp[0]) break;

    }

    if(i == n) {

        sub->type = sub->type_code = FLAC_SUBFRAME_CONSTANT;

        res[0] = smp[0];

        return sub->obits;

    }

    /* VERBATIM */

    if(n < 5) {

        sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM;

        encode_residual_verbatim(res, smp, n);

        return sub->obits * n;

    }

    min_order = ctx->options.min_prediction_order;

    max_order = ctx->options.max_prediction_order;

    min_porder = ctx->options.min_partition_order;

    max_porder = ctx->options.max_partition_order;

    precision = ctx->options.lpc_coeff_precision;

    omethod = ctx->options.prediction_order_method;

    /* FIXED */

    if(!ctx->options.use_lpc || max_order == 0 || (n <= max_order)) {

        uint32_t bits[MAX_FIXED_ORDER+1];

        if(max_order > MAX_FIXED_ORDER) max_order = MAX_FIXED_ORDER;

        opt_order = 0;

        bits[0] = UINT32_MAX;

        for(i=min_order; i<=max_order; i++) {

            encode_residual_fixed(res, smp, n, i);

            bits[i] = calc_rice_params_fixed(&sub->rc, min_porder, max_porder, res,

                                             n, i, sub->obits);

            if(bits[i] < bits[opt_order]) {

                opt_order = i;

            }

        }

        sub->order = opt_order;

        sub->type = FLAC_SUBFRAME_FIXED;

        sub->type_code = sub->type | sub->order;

        if(sub->order != max_order) {

            encode_residual_fixed(res, smp, n, sub->order);

            return calc_rice_params_fixed(&sub->rc, min_porder, max_porder, res, n,

                                          sub->order, sub->obits);

        }

        return bits[sub->order];

    }

    /* LPC */

    opt_order = ff_lpc_calc_coefs(&ctx->dsp, smp, n, max_order, precision, coefs,

                               shift, ctx->options.use_lpc, omethod, MAX_LPC_SHIFT, 0);

    if(omethod == ORDER_METHOD_2LEVEL ||

       omethod == ORDER_METHOD_4LEVEL ||

       omethod == ORDER_METHOD_8LEVEL) {

        int levels = 1 << omethod;

        uint32_t bits[levels];

        int order;

        int opt_index = levels-1;

        opt_order = max_order-1;

        bits[opt_index] = UINT32_MAX;

        for(i=levels-1; i>=0; i--) {

            order = min_order + (((max_order-min_order+1) * (i+1)) / levels)-1;

            if(order < 0) order = 0;

            encode_residual_lpc(res, smp, n, order+1, coefs[order], shift[order]);

            bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder,

                                           res, n, order+1, sub->obits, precision);

            if(bits[i] < bits[opt_index]) {

                opt_index = i;

                opt_order = order;

            }

        }

        opt_order++;

    } else if(omethod == ORDER_METHOD_SEARCH) {

        // brute-force optimal order search

        uint32_t bits[MAX_LPC_ORDER];

        opt_order = 0;

        bits[0] = UINT32_MAX;

        for(i=min_order-1; i<max_order; i++) {

            encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]);

            bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder,

                                           res, n, i+1, sub->obits, precision);

            if(bits[i] < bits[opt_order]) {

                opt_order = i;

            }

        }

        opt_order++;

    } else if(omethod == ORDER_METHOD_LOG) {

        uint32_t bits[MAX_LPC_ORDER];

        int step;

        opt_order= min_order - 1 + (max_order-min_order)/3;

        memset(bits, -1, sizeof(bits));

        for(step=16 ;step; step>>=1){

            int last= opt_order;

            for(i=last-step; i<=last+step; i+= step){

                if(i<min_order-1 || i>=max_order || bits[i] < UINT32_MAX)

                    continue;

                encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]);

                bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder,

                                            res, n, i+1, sub->obits, precision);

                if(bits[i] < bits[opt_order])

                    opt_order= i;

            }

        }

        opt_order++;

    }

    sub->order = opt_order;

    sub->type = FLAC_SUBFRAME_LPC;

    sub->type_code = sub->type | (sub->order-1);

    sub->shift = shift[sub->order-1];

    for(i=0; i<sub->order; i++) {

        sub->coefs[i] = coefs[sub->order-1][i];

    }

    encode_residual_lpc(res, smp, n, sub->order, sub->coefs, sub->shift);

    return calc_rice_params_lpc(&sub->rc, min_porder, max_porder, res, n, sub->order,

                                sub->obits, precision);

}


int setegroup(char *str) {
#ifdef OS_UNIX
   struct group *gr;

   gr = getgrnam(str);

   if (gr != NULL) {
      chown(logbook_dir, -1, gr->gr_gid);
      if (setregid(-1, gr->gr_gid) >= 0 && initgroups(gr->gr_name, gr->gr_gid) >= 0)
         return 0;
      else {
         eprintf("Cannot set effective GID to group \"%s\"\n", gr->gr_name);
         eprintf("setgroup: %s\n", strerror(errno));
      }
   } else
      eprintf("Group \"%s\" not found\n", str);

   return -1;
#else
   return 0;
#endif
}


get_affitem(int flagtype, char_u **pp)
{
    int		res;

    if (flagtype == AFT_NUM)
    {
	if (!VIM_ISDIGIT(**pp))
	{
	    ++*pp;	/* always advance, avoid getting stuck */
	    return 0;
	}
	res = getdigits(pp);
    }
    else
    {
#ifdef FEAT_MBYTE
	res = mb_ptr2char_adv(pp);
#else
	res = *(*pp)++;
#endif
	if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
						 && res >= 'A' && res <= 'Z'))
	{
	    if (**pp == NUL)
		return 0;
#ifdef FEAT_MBYTE
	    res = mb_ptr2char_adv(pp) + (res << 16);
#else
	    res = *(*pp)++ + (res << 16);
#endif
	}
    }
    return res;
}


_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
{
	return (memcmp(p1, p2, (size_t) c));
}


String string_money_format(const char *format, double value) {
  bool check = false;
  const char *p = format;
  while ((p = strchr(p, '%'))) {
    if (*(p + 1) == '%') {
      p += 2;
    } else if (!check) {
      check = true;
      p++;
    } else {
      throw_invalid_argument
        ("format: Only a single %%i or %%n token can be used");
      return String();
    }
  }

  int format_len = strlen(format);
  int str_len = safe_address(format_len, 1, 1024);
  String ret(str_len, ReserveString);
  char *str = ret.mutableData();
  if ((str_len = strfmon(str, str_len, format, value)) < 0) {
    return String();
  }
  ret.setSize(str_len);
  return ret;
}


static void dumpV8Message(v8::Local<v8::Context> context, v8::Local<v8::Message> message)
{
    if (message.IsEmpty())
        return;

    message->GetScriptOrigin();
    v8::Maybe<int> unused = message->GetLineNumber(context);
    ALLOW_UNUSED_LOCAL(unused);

    v8::Local<v8::Value> resourceName = message->GetScriptOrigin().ResourceName();
    String fileName = "Unknown JavaScript file";
    if (!resourceName.IsEmpty() && resourceName->IsString())
        fileName = toCoreString(v8::Local<v8::String>::Cast(resourceName));
    int lineNumber = 0;
    v8Call(message->GetLineNumber(context), lineNumber);
    v8::Local<v8::String> errorMessage = message->Get();
    fprintf(stderr, "%s (line %d): %s\n", fileName.utf8().data(), lineNumber, toCoreString(errorMessage).utf8().data());
}


static void reflectedCustomIntegralAttrAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
    ExceptionState exceptionState(ExceptionState::SetterContext, "reflectedCustomIntegralAttr", "TestObject", info.Holder(), info.GetIsolate());
    TestObject* imp = V8TestObject::toNative(info.Holder());
    V8TRYCATCH_EXCEPTION_VOID(int, cppValue, toInt32(jsValue, exceptionState), exceptionState);
    CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
    imp->setIntegralAttribute(HTMLNames::customContentIntegralAttrAttr, cppValue);
}


bool has_value() const { return content_ != nullptr; }


static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
{
	unsigned index;
	bool mask_before, mask_after;
	union kvm_ioapic_redirect_entry *e;

	switch (ioapic->ioregsel) {
	case IOAPIC_REG_VERSION:
		/* Writes are ignored. */
		break;

	case IOAPIC_REG_APIC_ID:
		ioapic->id = (val >> 24) & 0xf;
		break;

	case IOAPIC_REG_ARB_ID:
		break;

	default:
		index = (ioapic->ioregsel - 0x10) >> 1;

		ioapic_debug("change redir index %x val %x\n", index, val);
		if (index >= IOAPIC_NUM_PINS)
			return;
		e = &ioapic->redirtbl[index];
		mask_before = e->fields.mask;
		if (ioapic->ioregsel & 1) {
			e->bits &= 0xffffffff;
			e->bits |= (u64) val << 32;
		} else {
			e->bits &= ~0xffffffffULL;
			e->bits |= (u32) val;
			e->fields.remote_irr = 0;
		}
		mask_after = e->fields.mask;
		if (mask_before != mask_after)
			kvm_fire_mask_notifiers(ioapic->kvm, KVM_IRQCHIP_IOAPIC, index, mask_after);
		if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG
		    && ioapic->irr & (1 << index))
			ioapic_service(ioapic, index, false);
		kvm_vcpu_request_scan_ioapic(ioapic->kvm);
		break;
	}
}


png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
   png_const_bytep prev_row)
{
   png_bytep rp = row;
   png_const_bytep pp = prev_row;
   png_bytep rp_stop = row + row_info->rowbytes;

 uint8x16_t vtmp;
 uint8x8x2_t *vrpt;
 uint8x8x2_t vrp;
 uint8x8x4_t vdest;
   vdest.val[3] = vdup_n_u8(0);

   vtmp = vld1q_u8(rp);
   vrpt = png_ptr(uint8x8x2_t,&vtmp);
   vrp = *vrpt;

 for (; rp < rp_stop; pp += 12)
 {
 uint8x8_t vtmp1, vtmp2, vtmp3;

 uint8x8x2_t *vppt;
 uint8x8x2_t vpp;

 uint32x2_t *temp_pointer;

      vtmp = vld1q_u8(pp);
      vppt = png_ptr(uint8x8x2_t,&vtmp);
      vpp = *vppt;

      vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
      vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
      vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);

      vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
      vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6);
      vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2);
      vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);

      vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6);
      vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);

      vtmp = vld1q_u8(rp + 12);
      vrpt = png_ptr(uint8x8x2_t,&vtmp);
      vrp = *vrpt;

      vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2);
      vdest.val[2] = vadd_u8(vdest.val[2], vtmp3);

      vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);

      vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2);
      vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);

      vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
      rp += 3;
      vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
      rp += 3;
      vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
      rp += 3;
      vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
      rp += 3;
 }
}


xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
 int ret = 0;
 int avail, tlen;
    xmlChar cur, next;
 const xmlChar *lastlt, *lastgt;

 if (ctxt->input == NULL)
 return(0);

#ifdef DEBUG_PUSH
 switch (ctxt->instate) {
 case XML_PARSER_EOF:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try EOF\n"); break;
 case XML_PARSER_START:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try START\n"); break;
 case XML_PARSER_MISC:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try MISC\n");break;
 case XML_PARSER_COMMENT:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try COMMENT\n");break;
 case XML_PARSER_PROLOG:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try PROLOG\n");break;
 case XML_PARSER_START_TAG:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try START_TAG\n");break;
 case XML_PARSER_CONTENT:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try CONTENT\n");break;
 case XML_PARSER_CDATA_SECTION:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try CDATA_SECTION\n");break;
 case XML_PARSER_END_TAG:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try END_TAG\n");break;
 case XML_PARSER_ENTITY_DECL:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try ENTITY_DECL\n");break;
 case XML_PARSER_ENTITY_VALUE:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try ENTITY_VALUE\n");break;
 case XML_PARSER_ATTRIBUTE_VALUE:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try ATTRIBUTE_VALUE\n");break;
 case XML_PARSER_DTD:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try DTD\n");break;
 case XML_PARSER_EPILOG:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try EPILOG\n");break;
 case XML_PARSER_PI:
	    xmlGenericError(xmlGenericErrorContext,
 "PP: try PI\n");break;
 case XML_PARSER_IGNORE:
            xmlGenericError(xmlGenericErrorContext,
 "PP: try IGNORE\n");break;
 }
#endif

 if ((ctxt->input != NULL) &&
 (ctxt->input->cur - ctxt->input->base > 4096)) {
	xmlSHRINK(ctxt);
	ctxt->checkIndex = 0;
 }
    xmlParseGetLasts(ctxt, &lastlt, &lastgt);

 while (ctxt->instate != XML_PARSER_EOF) {
 if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
 return(0);

 /*
	 * Pop-up of finished entities.
	 */
 while ((RAW == 0) && (ctxt->inputNr > 1))
	    xmlPopInput(ctxt);

 if (ctxt->input == NULL) break;
 if (ctxt->input->buf == NULL)
	    avail = ctxt->input->length -
 (ctxt->input->cur - ctxt->input->base);
 else {
 /*
	     * If we are operating on converted input, try to flush
	     * remainng chars to avoid them stalling in the non-converted
	     * buffer. But do not do this in document start where
	     * encoding="..." may not have been read and we work on a
	     * guessed encoding.
	     */
 if ((ctxt->instate != XML_PARSER_START) &&
 (ctxt->input->buf->raw != NULL) &&
 (xmlBufIsEmpty(ctxt->input->buf->raw) == 0)) {
 size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer,
                                                 ctxt->input);
 size_t current = ctxt->input->cur - ctxt->input->base;

		xmlParserInputBufferPush(ctxt->input->buf, 0, "");
                xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input,
                                      base, current);
 }
	    avail = xmlBufUse(ctxt->input->buf->buffer) -
 (ctxt->input->cur - ctxt->input->base);
 }
 if (avail < 1)
 goto done;
 switch (ctxt->instate) {
 case XML_PARSER_EOF:
 /*
		 * Document parsing is done !
		 */
 goto done;
 case XML_PARSER_START:
 if (ctxt->charset == XML_CHAR_ENCODING_NONE) {
		    xmlChar start[4];
		    xmlCharEncoding enc;

 /*
		     * Very first chars read from the document flow.
		     */
 if (avail < 4)
 goto done;

 /*
		     * Get the 4 first bytes and decode the charset
		     * if enc != XML_CHAR_ENCODING_NONE
		     * plug some encoding conversion routines,
		     * else xmlSwitchEncoding will set to (default)
		     * UTF8.
		     */
		    start[0] = RAW;
		    start[1] = NXT(1);
		    start[2] = NXT(2);
		    start[3] = NXT(3);
		    enc = xmlDetectCharEncoding(start, 4);
		    xmlSwitchEncoding(ctxt, enc);
 break;
 }

 if (avail < 2)
 goto done;
		cur = ctxt->input->cur[0];
		next = ctxt->input->cur[1];
 if (cur == 0) {
 if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
			ctxt->sax->setDocumentLocator(ctxt->userData,
 &xmlDefaultSAXLocator);
		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
		    xmlHaltParser(ctxt);
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: entering EOF\n");
#endif
 if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
			ctxt->sax->endDocument(ctxt->userData);
 goto done;
 }
 if ((cur == '<') && (next == '?')) {
 /* PI or XML decl */
 if (avail < 5) return(ret);
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
 return(ret);
 if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
			ctxt->sax->setDocumentLocator(ctxt->userData,
 &xmlDefaultSAXLocator);
 if ((ctxt->input->cur[2] == 'x') &&
 (ctxt->input->cur[3] == 'm') &&
 (ctxt->input->cur[4] == 'l') &&
 (IS_BLANK_CH(ctxt->input->cur[5]))) {
			ret += 5;
#ifdef DEBUG_PUSH
			xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing XML Decl\n");
#endif
			xmlParseXMLDecl(ctxt);
 if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
 /*
			     * The XML REC instructs us to stop parsing right
			     * here
			     */
			    xmlHaltParser(ctxt);
 return(0);
 }
			ctxt->standalone = ctxt->input->standalone;
 if ((ctxt->encoding == NULL) &&
 (ctxt->input->encoding != NULL))
			    ctxt->encoding = xmlStrdup(ctxt->input->encoding);
 if ((ctxt->sax) && (ctxt->sax->startDocument) &&
 (!ctxt->disableSAX))
			    ctxt->sax->startDocument(ctxt->userData);
			ctxt->instate = XML_PARSER_MISC;
#ifdef DEBUG_PUSH
			xmlGenericError(xmlGenericErrorContext,
 "PP: entering MISC\n");
#endif
 } else {
			ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
 if ((ctxt->sax) && (ctxt->sax->startDocument) &&
 (!ctxt->disableSAX))
			    ctxt->sax->startDocument(ctxt->userData);
			ctxt->instate = XML_PARSER_MISC;
#ifdef DEBUG_PUSH
			xmlGenericError(xmlGenericErrorContext,
 "PP: entering MISC\n");
#endif
 }
 } else {
 if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
			ctxt->sax->setDocumentLocator(ctxt->userData,
 &xmlDefaultSAXLocator);
		    ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
 if (ctxt->version == NULL) {
		        xmlErrMemory(ctxt, NULL);
 break;
 }
 if ((ctxt->sax) && (ctxt->sax->startDocument) &&
 (!ctxt->disableSAX))
			ctxt->sax->startDocument(ctxt->userData);
		    ctxt->instate = XML_PARSER_MISC;
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: entering MISC\n");
#endif
 }
 break;
 case XML_PARSER_START_TAG: {
 const xmlChar *name;
 const xmlChar *prefix = NULL;
 const xmlChar *URI = NULL;
 int nsNr = ctxt->nsNr;

 if ((avail < 2) && (ctxt->inputNr == 1))
 goto done;
		cur = ctxt->input->cur[0];
 if (cur != '<') {
		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
		    xmlHaltParser(ctxt);
 if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
			ctxt->sax->endDocument(ctxt->userData);
 goto done;
 }
 if (!terminate) {
 if (ctxt->progressive) {
 /* > can be found unescaped in attribute values */
 if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
 goto done;
 } else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
 goto done;
 }
 }
 if (ctxt->spaceNr == 0)
		    spacePush(ctxt, -1);
 else if (*ctxt->space == -2)
		    spacePush(ctxt, -1);
 else
		    spacePush(ctxt, *ctxt->space);
#ifdef LIBXML_SAX1_ENABLED
 if (ctxt->sax2)
#endif /* LIBXML_SAX1_ENABLED */
		    name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen);
#ifdef LIBXML_SAX1_ENABLED
 else
		    name = xmlParseStartTag(ctxt);
#endif /* LIBXML_SAX1_ENABLED */
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
 if (name == NULL) {
		    spacePop(ctxt);
		    xmlHaltParser(ctxt);
 if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
			ctxt->sax->endDocument(ctxt->userData);
 goto done;
 }
#ifdef LIBXML_VALID_ENABLED
 /*
		 * [ VC: Root Element Type ]
		 * The Name in the document type declaration must match
		 * the element type of the root element.
		 */
 if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc &&
		    ctxt->node && (ctxt->node == ctxt->myDoc->children))
		    ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
#endif /* LIBXML_VALID_ENABLED */

 /*
		 * Check for an Empty Element.
		 */
 if ((RAW == '/') && (NXT(1) == '>')) {
		    SKIP(2);

 if (ctxt->sax2) {
 if ((ctxt->sax != NULL) &&
 (ctxt->sax->endElementNs != NULL) &&
 (!ctxt->disableSAX))
			    ctxt->sax->endElementNs(ctxt->userData, name,
			                            prefix, URI);
 if (ctxt->nsNr - nsNr > 0)
			    nsPop(ctxt, ctxt->nsNr - nsNr);
#ifdef LIBXML_SAX1_ENABLED
 } else {
 if ((ctxt->sax != NULL) &&
 (ctxt->sax->endElement != NULL) &&
 (!ctxt->disableSAX))
			    ctxt->sax->endElement(ctxt->userData, name);
#endif /* LIBXML_SAX1_ENABLED */
 }
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    spacePop(ctxt);
 if (ctxt->nameNr == 0) {
			ctxt->instate = XML_PARSER_EPILOG;
 } else {
			ctxt->instate = XML_PARSER_CONTENT;
 }
                    ctxt->progressive = 1;
 break;
 }
 if (RAW == '>') {
		    NEXT;
 } else {
		    xmlFatalErrMsgStr(ctxt, XML_ERR_GT_REQUIRED,
 "Couldn't find end of Start Tag %s\n",
					 name);
		    nodePop(ctxt);
		    spacePop(ctxt);
 }
 if (ctxt->sax2)
		    nameNsPush(ctxt, name, prefix, URI, ctxt->nsNr - nsNr);
#ifdef LIBXML_SAX1_ENABLED
 else
		    namePush(ctxt, name);
#endif /* LIBXML_SAX1_ENABLED */

		ctxt->instate = XML_PARSER_CONTENT;
                ctxt->progressive = 1;
 break;
 }
 case XML_PARSER_CONTENT: {
 const xmlChar *test;
 unsigned int cons;
 if ((avail < 2) && (ctxt->inputNr == 1))
 goto done;
		cur = ctxt->input->cur[0];
		next = ctxt->input->cur[1];

		test = CUR_PTR;
	        cons = ctxt->input->consumed;
 if ((cur == '<') && (next == '/')) {
		    ctxt->instate = XML_PARSER_END_TAG;
 break;
 } else if ((cur == '<') && (next == '?')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
                        ctxt->progressive = XML_PARSER_PI;
 goto done;
 }
		    xmlParsePI(ctxt);
		    ctxt->instate = XML_PARSER_CONTENT;
                    ctxt->progressive = 1;
 } else if ((cur == '<') && (next != '!')) {
		    ctxt->instate = XML_PARSER_START_TAG;
 break;
 } else if ((cur == '<') && (next == '!') &&
 (ctxt->input->cur[2] == '-') &&
 (ctxt->input->cur[3] == '-')) {
 int term;

 if (avail < 4)
 goto done;
		    ctxt->input->cur += 4;
		    term = xmlParseLookupSequence(ctxt, '-', '-', '>');
		    ctxt->input->cur -= 4;
 if ((!terminate) && (term < 0)) {
                        ctxt->progressive = XML_PARSER_COMMENT;
 goto done;
 }
		    xmlParseComment(ctxt);
		    ctxt->instate = XML_PARSER_CONTENT;
                    ctxt->progressive = 1;
 } else if ((cur == '<') && (ctxt->input->cur[1] == '!') &&
 (ctxt->input->cur[2] == '[') &&
 (ctxt->input->cur[3] == 'C') &&
 (ctxt->input->cur[4] == 'D') &&
 (ctxt->input->cur[5] == 'A') &&
 (ctxt->input->cur[6] == 'T') &&
 (ctxt->input->cur[7] == 'A') &&
 (ctxt->input->cur[8] == '[')) {
		    SKIP(9);
		    ctxt->instate = XML_PARSER_CDATA_SECTION;
 break;
 } else if ((cur == '<') && (next == '!') &&
 (avail < 9)) {
 goto done;
 } else if (cur == '&') {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, ';', 0, 0) < 0))
 goto done;
		    xmlParseReference(ctxt);
 } else {
 /* TODO Avoid the extra copy, handle directly !!! */
 /*
		     * Goal of the following test is:
		     *  - minimize calls to the SAX 'character' callback
		     *    when they are mergeable
		     *  - handle an problem for isBlank when we only parse
		     *    a sequence of blank chars and the next one is
		     *    not available to check against '<' presence.
		     *  - tries to homogenize the differences in SAX
		     *    callbacks between the push and pull versions
		     *    of the parser.
		     */
 if ((ctxt->inputNr == 1) &&
 (avail < XML_PARSER_BIG_BUFFER_SIZE)) {
 if (!terminate) {
 if (ctxt->progressive) {
 if ((lastlt == NULL) ||
 (ctxt->input->cur > lastlt))
 goto done;
 } else if (xmlParseLookupSequence(ctxt,
 '<', 0, 0) < 0) {
 goto done;
 }
 }
 }
		    ctxt->checkIndex = 0;
		    xmlParseCharData(ctxt, 0);
 }
 /*
		 * Pop-up of finished entities.
		 */
 while ((RAW == 0) && (ctxt->inputNr > 1))
		    xmlPopInput(ctxt);
 if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
		    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
 "detected an error in element content\n");
		    xmlHaltParser(ctxt);
 break;
 }
 break;
 }
 case XML_PARSER_END_TAG:
 if (avail < 2)
 goto done;
 if (!terminate) {
 if (ctxt->progressive) {
 /* > can be found unescaped in attribute values */
 if ((lastgt == NULL) || (ctxt->input->cur >= lastgt))
 goto done;
 } else if (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0) {
 goto done;
 }
 }
 if (ctxt->sax2) {
		    xmlParseEndTag2(ctxt,
 (void *) ctxt->pushTab[ctxt->nameNr * 3 - 3],
 (void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0,
 (int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1], 0);
		    nameNsPop(ctxt);
 }
#ifdef LIBXML_SAX1_ENABLED
 else
		    xmlParseEndTag1(ctxt, 0);
#endif /* LIBXML_SAX1_ENABLED */
 if (ctxt->instate == XML_PARSER_EOF) {
 /* Nothing */
 } else if (ctxt->nameNr == 0) {
		    ctxt->instate = XML_PARSER_EPILOG;
 } else {
		    ctxt->instate = XML_PARSER_CONTENT;
 }
 break;
 case XML_PARSER_CDATA_SECTION: {
 /*
		 * The Push mode need to have the SAX callback for
		 * cdataBlock merge back contiguous callbacks.
		 */
 int base;

		base = xmlParseLookupSequence(ctxt, ']', ']', '>');
 if (base < 0) {
 if (avail >= XML_PARSER_BIG_BUFFER_SIZE + 2) {
 int tmp;

			tmp = xmlCheckCdataPush(ctxt->input->cur,
			                        XML_PARSER_BIG_BUFFER_SIZE, 0);
 if (tmp < 0) {
			    tmp = -tmp;
			    ctxt->input->cur += tmp;
 goto encoding_error;
 }
 if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
 if (ctxt->sax->cdataBlock != NULL)
				ctxt->sax->cdataBlock(ctxt->userData,
				                      ctxt->input->cur, tmp);
 else if (ctxt->sax->characters != NULL)
				ctxt->sax->characters(ctxt->userData,
				                      ctxt->input->cur, tmp);
 }
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
			SKIPL(tmp);
			ctxt->checkIndex = 0;
 }
 goto done;
 } else {
 int tmp;

		    tmp = xmlCheckCdataPush(ctxt->input->cur, base, 1);
 if ((tmp < 0) || (tmp != base)) {
			tmp = -tmp;
			ctxt->input->cur += tmp;
 goto encoding_error;
 }
 if ((ctxt->sax != NULL) && (base == 0) &&
 (ctxt->sax->cdataBlock != NULL) &&
 (!ctxt->disableSAX)) {
 /*
			 * Special case to provide identical behaviour
			 * between pull and push parsers on enpty CDATA
			 * sections
			 */
 if ((ctxt->input->cur - ctxt->input->base >= 9) &&
 (!strncmp((const char *)&ctxt->input->cur[-9],
 "<![CDATA[", 9)))
			     ctxt->sax->cdataBlock(ctxt->userData,
			                           BAD_CAST "", 0);
 } else if ((ctxt->sax != NULL) && (base > 0) &&
 (!ctxt->disableSAX)) {
 if (ctxt->sax->cdataBlock != NULL)
			    ctxt->sax->cdataBlock(ctxt->userData,
						  ctxt->input->cur, base);
 else if (ctxt->sax->characters != NULL)
			    ctxt->sax->characters(ctxt->userData,
						  ctxt->input->cur, base);
 }
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    SKIPL(base + 3);
		    ctxt->checkIndex = 0;
		    ctxt->instate = XML_PARSER_CONTENT;
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: entering CONTENT\n");
#endif
 }
 break;
 }
 case XML_PARSER_MISC:
		SKIP_BLANKS;
 if (ctxt->input->buf == NULL)
		    avail = ctxt->input->length -
 (ctxt->input->cur - ctxt->input->base);
 else
		    avail = xmlBufUse(ctxt->input->buf->buffer) -
 (ctxt->input->cur - ctxt->input->base);
 if (avail < 2)
 goto done;
		cur = ctxt->input->cur[0];
		next = ctxt->input->cur[1];
 if ((cur == '<') && (next == '?')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
                        ctxt->progressive = XML_PARSER_PI;
 goto done;
 }
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing PI\n");
#endif
		    xmlParsePI(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    ctxt->instate = XML_PARSER_MISC;
                    ctxt->progressive = 1;
		    ctxt->checkIndex = 0;
 } else if ((cur == '<') && (next == '!') &&
 (ctxt->input->cur[2] == '-') &&
 (ctxt->input->cur[3] == '-')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
                        ctxt->progressive = XML_PARSER_COMMENT;
 goto done;
 }
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing Comment\n");
#endif
		    xmlParseComment(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    ctxt->instate = XML_PARSER_MISC;
                    ctxt->progressive = 1;
		    ctxt->checkIndex = 0;
 } else if ((cur == '<') && (next == '!') &&
 (ctxt->input->cur[2] == 'D') &&
 (ctxt->input->cur[3] == 'O') &&
 (ctxt->input->cur[4] == 'C') &&
 (ctxt->input->cur[5] == 'T') &&
 (ctxt->input->cur[6] == 'Y') &&
 (ctxt->input->cur[7] == 'P') &&
 (ctxt->input->cur[8] == 'E')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0)) {
                        ctxt->progressive = XML_PARSER_DTD;
 goto done;
 }
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing internal subset\n");
#endif
		    ctxt->inSubset = 1;
                    ctxt->progressive = 0;
		    ctxt->checkIndex = 0;
		    xmlParseDocTypeDecl(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
 if (RAW == '[') {
			ctxt->instate = XML_PARSER_DTD;
#ifdef DEBUG_PUSH
			xmlGenericError(xmlGenericErrorContext,
 "PP: entering DTD\n");
#endif
 } else {
 /*
			 * Create and update the external subset.
			 */
			ctxt->inSubset = 2;
 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
 (ctxt->sax->externalSubset != NULL))
			    ctxt->sax->externalSubset(ctxt->userData,
				    ctxt->intSubName, ctxt->extSubSystem,
				    ctxt->extSubURI);
			ctxt->inSubset = 0;
			xmlCleanSpecialAttr(ctxt);
			ctxt->instate = XML_PARSER_PROLOG;
#ifdef DEBUG_PUSH
			xmlGenericError(xmlGenericErrorContext,
 "PP: entering PROLOG\n");
#endif
 }
 } else if ((cur == '<') && (next == '!') &&
 (avail < 9)) {
 goto done;
 } else {
		    ctxt->instate = XML_PARSER_START_TAG;
		    ctxt->progressive = XML_PARSER_START_TAG;
		    xmlParseGetLasts(ctxt, &lastlt, &lastgt);
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: entering START_TAG\n");
#endif
 }
 break;
 case XML_PARSER_PROLOG:
		SKIP_BLANKS;
 if (ctxt->input->buf == NULL)
		    avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base);
 else
		    avail = xmlBufUse(ctxt->input->buf->buffer) -
 (ctxt->input->cur - ctxt->input->base);
 if (avail < 2)
 goto done;
		cur = ctxt->input->cur[0];
		next = ctxt->input->cur[1];
 if ((cur == '<') && (next == '?')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
                        ctxt->progressive = XML_PARSER_PI;
 goto done;
 }
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing PI\n");
#endif
		    xmlParsePI(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    ctxt->instate = XML_PARSER_PROLOG;
                    ctxt->progressive = 1;
 } else if ((cur == '<') && (next == '!') &&
 (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
                        ctxt->progressive = XML_PARSER_COMMENT;
 goto done;
 }
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing Comment\n");
#endif
		    xmlParseComment(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    ctxt->instate = XML_PARSER_PROLOG;
                    ctxt->progressive = 1;
 } else if ((cur == '<') && (next == '!') &&
 (avail < 4)) {
 goto done;
 } else {
		    ctxt->instate = XML_PARSER_START_TAG;
 if (ctxt->progressive == 0)
			ctxt->progressive = XML_PARSER_START_TAG;
		    xmlParseGetLasts(ctxt, &lastlt, &lastgt);
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: entering START_TAG\n");
#endif
 }
 break;
 case XML_PARSER_EPILOG:
		SKIP_BLANKS;
 if (ctxt->input->buf == NULL)
		    avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base);
 else
		    avail = xmlBufUse(ctxt->input->buf->buffer) -
 (ctxt->input->cur - ctxt->input->base);
 if (avail < 2)
 goto done;
		cur = ctxt->input->cur[0];
		next = ctxt->input->cur[1];
 if ((cur == '<') && (next == '?')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
                        ctxt->progressive = XML_PARSER_PI;
 goto done;
 }
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing PI\n");
#endif
		    xmlParsePI(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    ctxt->instate = XML_PARSER_EPILOG;
                    ctxt->progressive = 1;
 } else if ((cur == '<') && (next == '!') &&
 (ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
 if ((!terminate) &&
 (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
                        ctxt->progressive = XML_PARSER_COMMENT;
 goto done;
 }
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: Parsing Comment\n");
#endif
		    xmlParseComment(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		    ctxt->instate = XML_PARSER_EPILOG;
                    ctxt->progressive = 1;
 } else if ((cur == '<') && (next == '!') &&
 (avail < 4)) {
 goto done;
 } else {
		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
		    xmlHaltParser(ctxt);
#ifdef DEBUG_PUSH
		    xmlGenericError(xmlGenericErrorContext,
 "PP: entering EOF\n");
#endif
 if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
			ctxt->sax->endDocument(ctxt->userData);
 goto done;
 }
 break;
 case XML_PARSER_DTD: {
 /*
		 * Sorry but progressive parsing of the internal subset
		 * is not expected to be supported. We first check that
		 * the full content of the internal subset is available and
		 * the parsing is launched only at that point.
		 * Internal subset ends up with "']' S? '>'" in an unescaped
		 * section and not in a ']]>' sequence which are conditional
		 * sections (whoever argued to keep that crap in XML deserve
		 * a place in hell !).
		 */
 int base, i;
		xmlChar *buf;
	        xmlChar quote = 0;
 size_t use;

		base = ctxt->input->cur - ctxt->input->base;
 if (base < 0) return(0);
 if (ctxt->checkIndex > base)
		    base = ctxt->checkIndex;
		buf = xmlBufContent(ctxt->input->buf->buffer);
                use = xmlBufUse(ctxt->input->buf->buffer);
 for (;(unsigned int) base < use; base++) {
 if (quote != 0) {
 if (buf[base] == quote)
			    quote = 0;
 continue;
 }
 if ((quote == 0) && (buf[base] == '<')) {
 int found  = 0;
 /* special handling of comments */
 if (((unsigned int) base + 4 < use) &&
 (buf[base + 1] == '!') &&
 (buf[base + 2] == '-') &&
 (buf[base + 3] == '-')) {
 for (;(unsigned int) base + 3 < use; base++) {
 if ((buf[base] == '-') &&
 (buf[base + 1] == '-') &&
 (buf[base + 2] == '>')) {
				    found = 1;
				    base += 2;
 break;
 }
 }
 if (!found) {
#if 0
			        fprintf(stderr, "unfinished comment\n");
#endif
 break; /* for */
 }
 continue;
 }
 }
 if (buf[base] == '"') {
		        quote = '"';
 continue;
 }
 if (buf[base] == '\'') {
		        quote = '\'';
 continue;
 }
 if (buf[base] == ']') {
#if 0
		        fprintf(stderr, "%c%c%c%c: ", buf[base],
			        buf[base + 1], buf[base + 2], buf[base + 3]);
#endif
 if ((unsigned int) base +1 >= use)
 break;
 if (buf[base + 1] == ']') {
 /* conditional crap, skip both ']' ! */
			    base++;
 continue;
 }
 for (i = 1; (unsigned int) base + i < use; i++) {
 if (buf[base + i] == '>') {
#if 0
			        fprintf(stderr, "found\n");
#endif
 goto found_end_int_subset;
 }
 if (!IS_BLANK_CH(buf[base + i])) {
#if 0
			        fprintf(stderr, "not found\n");
#endif
 goto not_end_of_int_subset;
 }
 }
#if 0
			fprintf(stderr, "end of stream\n");
#endif
 break;

 }
not_end_of_int_subset:
 continue; /* for */
 }
 /*
		 * We didn't found the end of the Internal subset
		 */
 if (quote == 0)
                    ctxt->checkIndex = base;
 else
                    ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
 if (next == 0)
		    xmlGenericError(xmlGenericErrorContext,
 "PP: lookup of int subset end filed\n");
#endif
 goto done;

found_end_int_subset:
                ctxt->checkIndex = 0;
		xmlParseInternalSubset(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		ctxt->inSubset = 2;
 if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
 (ctxt->sax->externalSubset != NULL))
		    ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName,
			    ctxt->extSubSystem, ctxt->extSubURI);
		ctxt->inSubset = 0;
		xmlCleanSpecialAttr(ctxt);
 if (ctxt->instate == XML_PARSER_EOF)
 goto done;
		ctxt->instate = XML_PARSER_PROLOG;
		ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering PROLOG\n");
#endif
 break;
 }
 case XML_PARSER_COMMENT:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == COMMENT\n");
		ctxt->instate = XML_PARSER_CONTENT;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering CONTENT\n");
#endif
 break;
 case XML_PARSER_IGNORE:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == IGNORE");
	        ctxt->instate = XML_PARSER_DTD;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering DTD\n");
#endif
 break;
 case XML_PARSER_PI:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == PI\n");
		ctxt->instate = XML_PARSER_CONTENT;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering CONTENT\n");
#endif
 break;
 case XML_PARSER_ENTITY_DECL:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == ENTITY_DECL\n");
		ctxt->instate = XML_PARSER_DTD;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering DTD\n");
#endif
 break;
 case XML_PARSER_ENTITY_VALUE:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == ENTITY_VALUE\n");
		ctxt->instate = XML_PARSER_CONTENT;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering DTD\n");
#endif
 break;
 case XML_PARSER_ATTRIBUTE_VALUE:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == ATTRIBUTE_VALUE\n");
		ctxt->instate = XML_PARSER_START_TAG;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering START_TAG\n");
#endif
 break;
 case XML_PARSER_SYSTEM_LITERAL:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == SYSTEM_LITERAL\n");
		ctxt->instate = XML_PARSER_START_TAG;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering START_TAG\n");
#endif
 break;
 case XML_PARSER_PUBLIC_LITERAL:
		xmlGenericError(xmlGenericErrorContext,
 "PP: internal error, state == PUBLIC_LITERAL\n");
		ctxt->instate = XML_PARSER_START_TAG;
#ifdef DEBUG_PUSH
		xmlGenericError(xmlGenericErrorContext,
 "PP: entering START_TAG\n");
#endif
 break;
 }
 }
done:
#ifdef DEBUG_PUSH
    xmlGenericError(xmlGenericErrorContext, "PP: done %d\n", ret);
#endif
 return(ret);
encoding_error:
 {
 char buffer[150];

	snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
			ctxt->input->cur[0], ctxt->input->cur[1],
			ctxt->input->cur[2], ctxt->input->cur[3]);
	__xmlErrEncoding(ctxt, XML_ERR_INVALID_CHAR,
 "Input is not proper UTF-8, indicate encoding !\n%s",
		     BAD_CAST buffer, NULL);
 }
 return(0);
}


void vp8_mc(VP8Context *s, int luma,

            uint8_t *dst, uint8_t *src, const VP56mv *mv,

            int x_off, int y_off, int block_w, int block_h,

            int width, int height, int linesize,

            vp8_mc_func mc_func[3][3])

{

    if (AV_RN32A(mv)) {

        static const uint8_t idx[3][8] = {

            { 0, 1, 2, 1, 2, 1, 2, 1 }, // nr. of left extra pixels,

                                        // also function pointer index

            { 0, 3, 5, 3, 5, 3, 5, 3 }, // nr. of extra pixels required

            { 0, 2, 3, 2, 3, 2, 3, 2 }, // nr. of right extra pixels

        };

        int mx = (mv->x << luma)&7, mx_idx = idx[0][mx];

        int my = (mv->y << luma)&7, my_idx = idx[0][my];

        x_off += mv->x >> (3 - luma);

        y_off += mv->y >> (3 - luma);

        // edge emulation

        src += y_off * linesize + x_off;

        if (x_off < mx_idx || x_off >= width  - block_w - idx[2][mx] ||

            y_off < my_idx || y_off >= height - block_h - idx[2][my]) {

            s->dsp.emulated_edge_mc(s->edge_emu_buffer, src - my_idx * linesize - mx_idx, linesize,

                                block_w + idx[1][mx], block_h + idx[1][my],

                                x_off - mx_idx, y_off - my_idx, width, height);

            src = s->edge_emu_buffer + mx_idx + linesize * my_idx;

        }

        mc_func[my_idx][mx_idx](dst, linesize, src, linesize, block_h, mx, my);

    } else

        mc_func[0][0](dst, linesize, src + y_off * linesize + x_off, linesize, block_h, 0, 0);

}


void Browser::SelectNumberedTab(int index) {
  if (index < tab_count()) {
    UserMetrics::RecordAction(UserMetricsAction("SelectNumberedTab"),
                              profile_);
    tab_handler_->GetTabStripModel()->SelectTabContentsAt(index, true);
  }
}


bool HTMLScriptRunner::executeScriptsWaitingForParsing()
{
    while (!m_scriptsToExecuteAfterParsing.isEmpty()) {
        ASSERT(!isExecutingScript());
        ASSERT(!hasParserBlockingScript());
        ASSERT(m_scriptsToExecuteAfterParsing.first().resource());
        if (!m_scriptsToExecuteAfterParsing.first().isReady()) {
            m_scriptsToExecuteAfterParsing.first().watchForLoad(this);
            return false;
        }
        PendingScript first = m_scriptsToExecuteAfterParsing.takeFirst();
        executePendingScriptAndDispatchEvent(first, PendingScript::Deferred);
        if (!m_document)
            return false;
    }
    return true;
}


weight2(int a)
{
    return (double)a / COLS * 4 + 1.;
}


ModuleExport size_t RegisterMPCImage(void)
{
  MagickInfo
    *entry;

   entry=SetMagickInfo("CACHE");
   entry->description=ConstantString("Magick Persistent Cache image format");
   entry->module=ConstantString("MPC");
   entry->stealth=MagickTrue;
   (void) RegisterMagickInfo(entry);
   entry=SetMagickInfo("MPC");
  entry->decoder=(DecodeImageHandler *) ReadMPCImage;
  entry->encoder=(EncodeImageHandler *) WriteMPCImage;
  entry->magick=(IsImageFormatHandler *) IsMPC;
  entry->description=ConstantString("Magick Persistent Cache image format");
  entry->seekable_stream=MagickTrue;
  entry->module=ConstantString("MPC");
  (void) RegisterMagickInfo(entry);
  return(MagickImageCoderSignature);
}


getAttributeId(XML_Parser parser, const ENCODING *enc,
               const char *start, const char *end)
{
  DTD * const dtd = parser->m_dtd;  /* save one level of indirection */
  ATTRIBUTE_ID *id;
  const XML_Char *name;
  if (!poolAppendChar(&dtd->pool, XML_T('\0')))
    return NULL;
  name = poolStoreString(&dtd->pool, enc, start, end);
  if (!name)
    return NULL;
  /* skip quotation mark - its storage will be re-used (like in name[-1]) */
  ++name;
  id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID));
  if (!id)
    return NULL;
  if (id->name != name)
    poolDiscard(&dtd->pool);
  else {
    poolFinish(&dtd->pool);
    if (!parser->m_ns)
      ;
    else if (name[0] == XML_T(ASCII_x)
        && name[1] == XML_T(ASCII_m)
        && name[2] == XML_T(ASCII_l)
        && name[3] == XML_T(ASCII_n)
        && name[4] == XML_T(ASCII_s)
        && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) {
      if (name[5] == XML_T('\0'))
        id->prefix = &dtd->defaultPrefix;
      else
        id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX));
      id->xmlns = XML_TRUE;
    }
    else {
      int i;
      for (i = 0; name[i]; i++) {
        /* attributes without prefix are *not* in the default namespace */
        if (name[i] == XML_T(ASCII_COLON)) {
          int j;
          for (j = 0; j < i; j++) {
            if (!poolAppendChar(&dtd->pool, name[j]))
              return NULL;
          }
          if (!poolAppendChar(&dtd->pool, XML_T('\0')))
            return NULL;
          id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool),
                                        sizeof(PREFIX));
          if (!id->prefix)
            return NULL;
          if (id->prefix->name == poolStart(&dtd->pool))
            poolFinish(&dtd->pool);
          else
            poolDiscard(&dtd->pool);
          break;
        }
      }
    }
  }
  return id;
}


void dostou(void)
{
    char file[64];
    static unsigned int seq = 0U;
    struct timeval tv;
    struct timezone tz;

    if (gettimeofday(&tv, &tz) != 0) {
        error(553, MSG_TIMESTAMP_FAILURE);
        return;
    }
    if (SNCHECK(snprintf(file, sizeof file, "pureftpd.%08lx.%02lx.%04x",
                         (unsigned long) tv.tv_sec,
                         (unsigned long) tv.tv_usec & 0xff,
                         seq), sizeof file)) {
        _EXIT(EXIT_FAILURE);
    }
    seq++;
    seq &= 0xffff;
    addreply(150, "FILE: %s", file);
    dostor(file, 0, 1);
}


PromptBase() : promptPreviousInputLen(0) {}


void ecryptfs_put_lower_file(struct inode *inode)
{
	struct ecryptfs_inode_info *inode_info;

	inode_info = ecryptfs_inode_to_private(inode);
	if (atomic_dec_and_mutex_lock(&inode_info->lower_file_count,
				      &inode_info->lower_file_mutex)) {
		filemap_write_and_wait(inode->i_mapping);
		fput(inode_info->lower_file);
		inode_info->lower_file = NULL;
		mutex_unlock(&inode_info->lower_file_mutex);
	}
}


Variant HHVM_FUNCTION(imagecreatefromxbm, const String& filename) {
  gdImagePtr im =
    _php_image_create_from(filename, -1, -1, -1, -1,
                           PHP_GDIMG_TYPE_XBM, "XBM",
                           (gdImagePtr(*)())gdImageCreateFromXbm,
                           (gdImagePtr(*)())nullptr);
  if (im == nullptr) {
    return false;
  }
  return Variant(req::make<Image>(im));
}


hstorePairs(Pairs *pairs, int32 pcount, int32 buflen)
{
	HStore	   *out;
	HEntry	   *entry;
	char	   *ptr;
	char	   *buf;
	int32		len;
	int32		i;

	len = CALCDATASIZE(pcount, buflen);
	out = palloc(len);
	SET_VARSIZE(out, len);
	HS_SETCOUNT(out, pcount);

	if (pcount == 0)
		return out;

	entry = ARRPTR(out);
	buf = ptr = STRPTR(out);

	for (i = 0; i < pcount; i++)
		HS_ADDITEM(entry, buf, ptr, pairs[i]);

	HS_FINALIZE(out, pcount, buf, ptr);

	return out;
}


static CURLcode load_cacert_from_memory(SSL_CTX *ctx,
                                        const struct curl_blob *ca_info_blob)
{
  /* these need freed at the end */
  BIO *cbio = NULL;
  STACK_OF(X509_INFO) *inf = NULL;

  /* everything else is just a reference */
  int i, count = 0;
  X509_STORE *cts = NULL;
  X509_INFO *itmp = NULL;

  if(ca_info_blob->len > (size_t)INT_MAX)
    return CURLE_SSL_CACERT_BADFILE;

  cts = SSL_CTX_get_cert_store(ctx);
  if(!cts)
    return CURLE_OUT_OF_MEMORY;

  cbio = BIO_new_mem_buf(ca_info_blob->data, (int)ca_info_blob->len);
  if(!cbio)
    return CURLE_OUT_OF_MEMORY;

  inf = PEM_X509_INFO_read_bio(cbio, NULL, NULL, NULL);
  if(!inf) {
    BIO_free(cbio);
    return CURLE_SSL_CACERT_BADFILE;
  }

  /* add each entry from PEM file to x509_store */
  for(i = 0; i < (int)sk_X509_INFO_num(inf); ++i) {
    itmp = sk_X509_INFO_value(inf, i);
    if(itmp->x509) {
      if(X509_STORE_add_cert(cts, itmp->x509)) {
        ++count;
      }
      else {
        /* set count to 0 to return an error */
        count = 0;
        break;
      }
    }
    if(itmp->crl) {
      if(X509_STORE_add_crl(cts, itmp->crl)) {
        ++count;
      }
      else {
        /* set count to 0 to return an error */
        count = 0;
        break;
      }
    }
  }

  sk_X509_INFO_pop_free(inf, X509_INFO_free);
  BIO_free(cbio);

  /* if we didn't end up importing anything, treat that as an error */
  return (count > 0 ? CURLE_OK : CURLE_SSL_CACERT_BADFILE);
}


irc_ctcp_dcc_filename_without_quotes (const char *filename)
{
    int length;

    length = strlen (filename);
    if (length > 0)
    {
        if ((filename[0] == '\"') && (filename[length - 1] == '\"'))
            return weechat_strndup (filename + 1, length - 2);
    }
    return strdup (filename);
}


static inline void vmxnet3_ring_inc(Vmxnet3Ring *ring)
{
    if (++ring->next >= ring->size) {
        ring->next = 0;
        ring->gen ^= 1;
    }
}


Cues::Cues(
Cues::~Cues() {
  const long n = m_count + m_preload_count;

  CuePoint** p = m_cue_points;
  CuePoint** const q = p + n;

  while (p != q) {
    CuePoint* const pCP = *p++;
    assert(pCP);

    delete pCP;
  }

  delete[] m_cue_points;
 }


void mfhd_del(GF_Box *s)
{
	GF_MovieFragmentHeaderBox *ptr = (GF_MovieFragmentHeaderBox *)s;
	if (ptr == NULL) return;
	gf_free(ptr);
}


static void *AcquireBlock(size_t size)
{
  register size_t
    i;

  register void
    *block;

  /*
    Find free block.
  */
  size=(size_t) (size+sizeof(size_t)+6*sizeof(size_t)-1) & -(4U*sizeof(size_t));
  i=AllocationPolicy(size);
  block=memory_pool.blocks[i];
  while ((block != (void *) NULL) && (SizeOfBlock(block) < size))
    block=NextBlockInList(block);
  if (block == (void *) NULL)
    {
      i++;
      while (memory_pool.blocks[i] == (void *) NULL)
        i++;
      block=memory_pool.blocks[i];
      if (i >= MaxBlocks)
        return((void *) NULL);
    }
  assert((*BlockHeader(NextBlock(block)) & PreviousBlockBit) == 0);
  assert(SizeOfBlock(block) >= size);
  RemoveFreeBlock(block,AllocationPolicy(SizeOfBlock(block)));
  if (SizeOfBlock(block) > size)
    {
      size_t
        blocksize;

      void
        *next;

      /*
        Split block.
      */
      next=(char *) block+size;
      blocksize=SizeOfBlock(block)-size;
      *BlockHeader(next)=blocksize;
      *BlockFooter(next,blocksize)=blocksize;
      InsertFreeBlock(next,AllocationPolicy(blocksize));
      *BlockHeader(block)=size | (*BlockHeader(block) & ~SizeMask);
    }
  assert(size == SizeOfBlock(block));
  *BlockHeader(NextBlock(block))|=PreviousBlockBit;
  memory_pool.allocation+=size;
  return(block);
}


void AuthenticatorWelcomeSheetModel::OnAccept() {
  dialog_model()
      ->StartGuidedFlowForMostLikelyTransportOrShowTransportSelection();
}


static void callWithScriptStateLongMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
    ScriptState* currentState = ScriptState::current();
    if (!currentState)
        return;
    ScriptState& state = *currentState;
    int result = imp->callWithScriptStateLongMethod(&state);
    if (state.hadException()) {
        v8::Local<v8::Value> exception = state.exception();
        state.clearException();
        throwError(exception, info.GetIsolate());
        return;
    }
    v8SetReturnValueInt(info, result);
}


dispatchInts (Parcel &p, RequestInfo *pRI) {
 int32_t count;
 status_t status;
 size_t datalen;
 int *pInts;

    status = p.readInt32 (&count);

 if (status != NO_ERROR || count <= 0) {
 goto invalid;
 }

    datalen = sizeof(int) * count;
    pInts = (int *)calloc(count, sizeof(int));
 if (pInts == NULL) {
        RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
 return;
 }

    startRequest;
 for (int i = 0 ; i < count ; i++) {
 int32_t t;

        status = p.readInt32(&t);
        pInts[i] = (int)t;
        appendPrintBuf("%s%d,", printBuf, t);

 if (status != NO_ERROR) {
            free(pInts);
 goto invalid;
 }
 }
   removeLastChar;
   closeRequest;
   printRequest(pRI->token, pRI->pCI->requestNumber);

   CALL_ONREQUEST(pRI->pCI->requestNumber, const_cast<int *>(pInts),
                       datalen, pRI, pRI->socket_id);

#ifdef MEMSET_FREED
    memset(pInts, 0, datalen);
#endif
    free(pInts);
 return;
invalid:
    invalidCommandBlock(pRI);
 return;
}


route4_set_fastmap(struct route4_head *head, u32 id, int iif,
		   struct route4_filter *f)
{
	int h = route4_fastmap_hash(id, iif);

	/* fastmap updates must look atomic to aling id, iff, filter */
	spin_lock_bh(&fastmap_lock);
	head->fastmap[h].id = id;
	head->fastmap[h].iif = iif;
	head->fastmap[h].filter = f;
	spin_unlock_bh(&fastmap_lock);
}


int zap_other_threads(struct task_struct *p)
{
	struct task_struct *t = p;
	int count = 0;

	p->signal->group_stop_count = 0;

	while_each_thread(p, t) {
		task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
		count++;

		/* Don't bother with already dead threads */
		if (t->exit_state)
			continue;
		sigaddset(&t->pending.signal, SIGKILL);
		signal_wake_up(t, 1);
	}

	return count;
}


  cf2_hint_isTop( const CF2_Hint  hint )
  {
    return (FT_Bool)( ( hint->flags                    &
                        ( CF2_PairTop | CF2_GhostTop ) ) != 0 );
  }


static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr,
			       struct nfs_locku_args *args)
{
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->fh, &hdr);
	encode_locku(xdr, args, &hdr);
	encode_nops(&hdr);
}


void QuotaManager::SetTemporaryGlobalOverrideQuota(
    int64 new_quota, const QuotaCallback& callback) {
  LazyInitialize();

  if (new_quota < 0) {
    if (!callback.is_null())
      callback.Run(kQuotaErrorInvalidModification,
                   kStorageTypeTemporary, -1);
    return;
  }

  if (db_disabled_) {
    if (callback.is_null())
      callback.Run(kQuotaErrorInvalidAccess,
                   kStorageTypeTemporary, -1);
    return;
  }

  int64* new_quota_ptr = new int64(new_quota);
  PostTaskAndReplyWithResultForDBThread(
      FROM_HERE,
      base::Bind(&SetTemporaryGlobalOverrideQuotaOnDBThread,
                 base::Unretained(new_quota_ptr)),
      base::Bind(&QuotaManager::DidSetTemporaryGlobalOverrideQuota,
                 weak_factory_.GetWeakPtr(),
                 callback,
                 base::Owned(new_quota_ptr)));
}


	__acquires(rq2->lock)
{
	BUG_ON(!irqs_disabled());
	BUG_ON(rq1 != rq2);
	raw_spin_lock(&rq1->lock);
	__acquire(rq2->lock);	/* Fake it out ;) */
}


status_t ESDS::getCodecSpecificInfo(const void **data, size_t *size) const {
 if (mInitCheck != OK) {
 return mInitCheck;
 }

 *data = &mData[mDecoderSpecificOffset];
 *size = mDecoderSpecificLength;

 return OK;
}


md_mark_chain_append(MD_CTX* ctx, MD_MARKCHAIN* chain, int mark_index)
{
    if(chain->tail >= 0)
        ctx->marks[chain->tail].next = mark_index;
    else
        chain->head = mark_index;

    ctx->marks[mark_index].prev = chain->tail;
    ctx->marks[mark_index].next = -1;
    chain->tail = mark_index;
}


static char *get_monitoring_status(Output_Type type, Service_T s, char *buf, int buflen) {
        ASSERT(s);
        ASSERT(buf);
        if (s->monitor == Monitor_Not) {
                if (type == HTML)
                        snprintf(buf, buflen, "Not monitored");
                else
                        snprintf(buf, buflen, Color_lightYellow("Not monitored"));
        } else if (s->monitor & Monitor_Waiting) {
                if (type == HTML)
                        snprintf(buf, buflen, "Waiting");
                else
                        snprintf(buf, buflen, Color_white("Waiting"));
        } else if (s->monitor & Monitor_Init) {
                if (type == HTML)
                        snprintf(buf, buflen, "Initializing");
                else
                        snprintf(buf, buflen, Color_lightBlue("Initializing"));
        } else if (s->monitor & Monitor_Yes) {
                if (type == HTML)
                        snprintf(buf, buflen, "Monitored");
                else
                        snprintf(buf, buflen, "Monitored");
        }
        return buf;
}


SCTP_STATIC int sctp_setsockopt_connectx(struct sock* sk,
				      struct sockaddr __user *addrs,
				      int addrs_size)
{
	int err = 0;
	struct sockaddr *kaddrs;

	SCTP_DEBUG_PRINTK("%s - sk %p addrs %p addrs_size %d\n",
			  __FUNCTION__, sk, addrs, addrs_size);

	if (unlikely(addrs_size <= 0))
		return -EINVAL;

	/* Check the user passed a healthy pointer.  */
	if (unlikely(!access_ok(VERIFY_READ, addrs, addrs_size)))
		return -EFAULT;

	/* Alloc space for the address array in kernel memory.  */
	kaddrs = kmalloc(addrs_size, GFP_KERNEL);
	if (unlikely(!kaddrs))
		return -ENOMEM;

	if (__copy_from_user(kaddrs, addrs, addrs_size)) {
		err = -EFAULT;
	} else {
		err = __sctp_connect(sk, kaddrs, addrs_size);
	}

	kfree(kaddrs);
	return err;
}


static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_ip, __be32 src_ip, unsigned short vlan_id)
{
	struct sk_buff *skb;

	pr_debug("arp %d on slave %s: dst %x src %x vid %d\n", arp_op,
		 slave_dev->name, dest_ip, src_ip, vlan_id);

	skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip,
			 NULL, slave_dev->dev_addr, NULL);

	if (!skb) {
		pr_err("ARP packet allocation failed\n");
		return;
	}
	if (vlan_id) {
		skb = vlan_put_tag(skb, vlan_id);
		if (!skb) {
			pr_err("failed to insert VLAN tag\n");
			return;
		}
	}
	arp_xmit(skb);
}


static int dissect_rsl_ie_err_msg ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , int offset , gboolean is_mandatory ) {
 proto_item * ti ;
 proto_tree * ie_tree ;
 guint length ;
 guint8 ie_id ;
 if ( is_mandatory == FALSE ) {
 ie_id = tvb_get_guint8 ( tvb , offset ) ;
 if ( ie_id != RSL_IE_ERR_MSG ) return offset ;
 }
 ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 0 , ett_ie_err_msg , & ti , "Erroneous Message IE " ) ;
 proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
 offset ++ ;
 length = tvb_get_guint8 ( tvb , offset ) ;
 proto_item_set_len ( ti , length + 2 ) ;
 proto_tree_add_item ( ie_tree , hf_rsl_ie_length , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
 offset ++ ;
 offset = dissct_rsl_msg ( tvb , pinfo , ie_tree , offset ) ;
 return offset ;
 }


int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
                const ASN1_ITEM *it)
{
    ASN1_BOOLEAN *tbool = NULL;
    ASN1_STRING *strtmp;
    ASN1_OBJECT *otmp;
    int utype;
    const unsigned char *cont;
    unsigned char c;
    int len;
    const ASN1_PRIMITIVE_FUNCS *pf;
    pf = it->funcs;
    if (pf && pf->prim_i2c)
        return pf->prim_i2c(pval, cout, putype, it);

    /* Should type be omitted? */
    if ((it->itype != ASN1_ITYPE_PRIMITIVE)
        || (it->utype != V_ASN1_BOOLEAN)) {
        if (!*pval)
            return -1;
    }

    if (it->itype == ASN1_ITYPE_MSTRING) {
        /* If MSTRING type set the underlying type */
        strtmp = (ASN1_STRING *)*pval;
        utype = strtmp->type;
        *putype = utype;
    } else if (it->utype == V_ASN1_ANY) {
        /* If ANY set type and pointer to value */
        ASN1_TYPE *typ;
        typ = (ASN1_TYPE *)*pval;
        utype = typ->type;
        *putype = utype;
        pval = &typ->value.asn1_value;
    } else
        utype = *putype;

    switch (utype) {
    case V_ASN1_OBJECT:
        otmp = (ASN1_OBJECT *)*pval;
        cont = otmp->data;
        len = otmp->length;
        break;

    case V_ASN1_NULL:
        cont = NULL;
        len = 0;
        break;

    case V_ASN1_BOOLEAN:
        tbool = (ASN1_BOOLEAN *)pval;
        if (*tbool == -1)
            return -1;
        if (it->utype != V_ASN1_ANY) {
            /*
             * Default handling if value == size field then omit
             */
            if (*tbool && (it->size > 0))
                return -1;
            if (!*tbool && !it->size)
                return -1;
        }
        c = (unsigned char)*tbool;
        cont = &c;
        len = 1;
        break;

    case V_ASN1_BIT_STRING:
        return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval,
                                   cout ? &cout : NULL);
         break;

     case V_ASN1_INTEGER:
    case V_ASN1_NEG_INTEGER:
     case V_ASN1_ENUMERATED:
    case V_ASN1_NEG_ENUMERATED:
         /*
          * These are all have the same content format as ASN1_INTEGER
          */
         * These are all have the same content format as ASN1_INTEGER
         */
        return i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL);
        break;

    case V_ASN1_OCTET_STRING:
    case V_ASN1_NUMERICSTRING:
    case V_ASN1_PRINTABLESTRING:
    case V_ASN1_T61STRING:
    case V_ASN1_VIDEOTEXSTRING:
    case V_ASN1_IA5STRING:
    case V_ASN1_UTCTIME:
    case V_ASN1_GENERALIZEDTIME:
    case V_ASN1_GRAPHICSTRING:
    case V_ASN1_VISIBLESTRING:
    case V_ASN1_GENERALSTRING:
    case V_ASN1_UNIVERSALSTRING:
    case V_ASN1_BMPSTRING:
    case V_ASN1_UTF8STRING:
    case V_ASN1_SEQUENCE:
    case V_ASN1_SET:
    default:
        /* All based on ASN1_STRING and handled the same */
        strtmp = (ASN1_STRING *)*pval;
        /* Special handling for NDEF */
        if ((it->size == ASN1_TFLG_NDEF)
            && (strtmp->flags & ASN1_STRING_FLAG_NDEF)) {
            if (cout) {
                strtmp->data = cout;
                strtmp->length = 0;
            }
            /* Special return code */
            return -2;
        }
        cont = strtmp->data;
        len = strtmp->length;

        break;

    }
    if (cout && len)
        memcpy(cout, cont, len);
    return len;
}


static int usb_host_handle_data(USBDevice *dev, USBPacket *p)

{

    USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);

    struct usbdevfs_urb *urb;

    AsyncURB *aurb;

    int ret, rem, prem, v;

    uint8_t *pbuf;

    uint8_t ep;

    trace_usb_host_req_data(s->bus_num, s->addr,

                            p->pid == USB_TOKEN_IN,

                            p->devep, p->iov.size);

    if (!is_valid(s, p->pid, p->devep)) {

        trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);

        return USB_RET_NAK;

    }

    if (p->pid == USB_TOKEN_IN) {

        ep = p->devep | 0x80;

    } else {

        ep = p->devep;

    }

    if (is_halted(s, p->pid, p->devep)) {

        unsigned int arg = ep;

        ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &arg);

        if (ret < 0) {

            perror("USBDEVFS_CLEAR_HALT");

            trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);

            return USB_RET_NAK;

        }

        clear_halt(s, p->pid, p->devep);

    }

    if (is_isoc(s, p->pid, p->devep)) {

        return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);

    }

    v = 0;

    prem = p->iov.iov[v].iov_len;

    pbuf = p->iov.iov[v].iov_base;

    rem = p->iov.size;

    while (rem) {

        if (prem == 0) {

            v++;

            assert(v < p->iov.niov);

            prem = p->iov.iov[v].iov_len;

            pbuf = p->iov.iov[v].iov_base;

            assert(prem <= rem);

        }

        aurb = async_alloc(s);

        aurb->packet = p;

        urb = &aurb->urb;

        urb->endpoint      = ep;

        urb->type          = usb_host_usbfs_type(s, p);

        urb->usercontext   = s;

        urb->buffer        = pbuf;

        urb->buffer_length = prem;

        if (urb->buffer_length > MAX_USBFS_BUFFER_SIZE) {

            urb->buffer_length = MAX_USBFS_BUFFER_SIZE;

        }

        pbuf += urb->buffer_length;

        prem -= urb->buffer_length;

        rem  -= urb->buffer_length;

        if (rem) {

            aurb->more         = 1;

        }

        trace_usb_host_urb_submit(s->bus_num, s->addr, aurb,

                                  urb->buffer_length, aurb->more);

        ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);

        DPRINTF("husb: data submit: ep 0x%x, len %u, more %d, packet %p, aurb %p\n",

                urb->endpoint, urb->buffer_length, aurb->more, p, aurb);

        if (ret < 0) {

            perror("USBDEVFS_SUBMITURB");

            async_free(aurb);

            switch(errno) {

            case ETIMEDOUT:

                trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);

                return USB_RET_NAK;

            case EPIPE:

            default:

                trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_STALL);

                return USB_RET_STALL;

            }

        }

    }

    return USB_RET_ASYNC;

}


MagickExport double ReadBlobDouble(Image *image)
{
  union
  {
    MagickSizeType
      unsigned_value;

    double
      double_value;
  } quantum;

  quantum.double_value=0.0;
  quantum.unsigned_value=ReadBlobLongLong(image);
  return(quantum.double_value);
}


void smb2cli_conn_set_cc_chunk_len(struct smbXcli_conn *conn,
				    uint32_t chunk_len)
{
	conn->smb2.cc_chunk_len = chunk_len;
}


 URLFetcher* FakeURLFetcherFactory::CreateURLFetcher(
    int id,
    const GURL& url,
    URLFetcher::RequestType request_type,
     URLFetcher::Delegate* d) {
   FakeResponseMap::const_iterator it = fake_responses_.find(url);
   if (it == fake_responses_.end()) {
    if (default_factory_ == NULL) {
      // If we don't have a baked response for that URL we return NULL.
      DLOG(ERROR) << "No baked response for URL: " << url.spec();
      return NULL;
    } else {
      return default_factory_->CreateURLFetcher(id, url, request_type, d);
    }
   }
   return new FakeURLFetcher(url, request_type, d,
                             it->second.first, it->second.second);
}


piv_read_binary(sc_card_t *card, unsigned int idx, unsigned char *buf, size_t count, unsigned long flags)
{
	piv_private_data_t * priv = PIV_DATA(card);
	int enumtag;
	int r;
	u8 *rbuf = NULL;
	size_t rbuflen = 0;
	const u8 *body;
	size_t bodylen;

	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
	if (priv->selected_obj < 0)
		 LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
	enumtag = piv_objects[priv->selected_obj].enumtag;

	if (priv->rwb_state == -1) {
		r = piv_get_cached_data(card, enumtag, &rbuf, &rbuflen);

		if (r >=0) {
			/* an object with no data will be considered not found */
			/* Discovery tag = 0x73, all others are 0x53 */
			if (!rbuf || rbuf[0] == 0x00 || ((rbuf[0]&0xDF) == 0x53 && rbuf[1] == 0x00)) {
				r = SC_ERROR_FILE_NOT_FOUND;
				goto err;
			}
			sc_log(card->ctx,
			       "DEE rbuf=%p,rbuflen=%"SC_FORMAT_LEN_SIZE_T"u,",
			       rbuf, rbuflen);
			body = sc_asn1_find_tag(card->ctx, rbuf, rbuflen, rbuf[0], &bodylen);
			if (body == NULL) {
				/* if missing, assume its the body */
				/* DEE bug in the beta card */
				sc_log(card->ctx, " ***** tag 0x53 MISSING");
				r = SC_ERROR_INVALID_DATA;
				goto err;
			}
			if (bodylen > body - rbuf + rbuflen) {
				sc_log(card->ctx,
				       " ***** tag length > then data: %"SC_FORMAT_LEN_SIZE_T"u>%"SC_FORMAT_LEN_PTRDIFF_T"u+%"SC_FORMAT_LEN_SIZE_T"u",
				       bodylen, body - rbuf, rbuflen);
				r = SC_ERROR_INVALID_DATA;
				goto err;
			}
			/* if cached obj has internal interesting data (cert or pub key) */
			if (priv->return_only_cert || piv_objects[enumtag].flags & PIV_OBJECT_TYPE_PUBKEY) {
				r = piv_cache_internal_data(card, enumtag);
				if (r < 0)
					goto err;
			}

		}
		priv->rwb_state = 0;
	}

	if (priv->return_only_cert || piv_objects[enumtag].flags & PIV_OBJECT_TYPE_PUBKEY) {
		rbuf = priv->obj_cache[enumtag].internal_obj_data;
		rbuflen = priv->obj_cache[enumtag].internal_obj_len;
	} else {
		rbuf = priv->obj_cache[enumtag].obj_data;
		rbuflen = priv->obj_cache[enumtag].obj_len;
	}
	/* rbuf rbuflen has pointer and length to cached data */

	if ( rbuflen < idx + count)
		count = rbuflen - idx;
	if (count <= 0) {
		r = 0;
		priv->rwb_state = 1;
	} else {
		memcpy(buf, rbuf + idx, count);
		r = count;
	}

err:
	LOG_FUNC_RETURN(card->ctx, r);
}


MagickExport ImageType GetImageType(const Image *image,ExceptionInfo *exception)
{
  assert(image != (Image *) NULL);
  assert(image->signature == MagickSignature);
  if (image->debug != MagickFalse)
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
  if (image->colorspace == CMYKColorspace)
    {
      if (image->matte == MagickFalse)
        return(ColorSeparationType);
      return(ColorSeparationMatteType);
    }
  if (IsMonochromeImage(image,exception) != MagickFalse)
    return(BilevelType);
  if (IsGrayImage(image,exception) != MagickFalse)
    {
      if (image->matte != MagickFalse)
        return(GrayscaleMatteType);
      return(GrayscaleType);
    }
  if (IsPaletteImage(image,exception) != MagickFalse)
    {
      if (image->matte != MagickFalse)
        return(PaletteMatteType);
      return(PaletteType);
    }
  if (image->matte != MagickFalse)
    return(TrueColorMatteType);
  return(TrueColorType);
}


static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, int zero_seqid)
{
	nfs4_stateid stateid;
	__be32 *p;

	p = reserve_space(xdr, NFS4_STATEID_SIZE);
	if (ctx->state != NULL) {
		nfs4_copy_stateid(&stateid, ctx->state, l_ctx->lockowner, l_ctx->pid);
		if (zero_seqid)
			stateid.stateid.seqid = 0;
		xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE);
	} else
		xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE);
}


builtin_pow_impl(PyObject *module, PyObject *x, PyObject *y, PyObject *z)
/*[clinic end generated code: output=50a14d5d130d404b input=653d57d38d41fc07]*/
{
    return PyNumber_Power(x, y, z);
}


void imap_pretty_mailbox(char *path)
{
  struct ImapMbox home, target;
  struct Url url;
  char *delim = NULL;
  int tlen;
  int hlen = 0;
  bool home_match = false;

  if (imap_parse_path(path, &target) < 0)
    return;

  tlen = mutt_str_strlen(target.mbox);
  /* check whether we can do '=' substitution */
  if (mx_is_imap(Folder) && !imap_parse_path(Folder, &home))
  {
    hlen = mutt_str_strlen(home.mbox);
    if (tlen && mutt_account_match(&home.account, &target.account) &&
        (mutt_str_strncmp(home.mbox, target.mbox, hlen) == 0))
    {
      if (hlen == 0)
        home_match = true;
      else if (ImapDelimChars)
      {
        for (delim = ImapDelimChars; *delim != '\0'; delim++)
          if (target.mbox[hlen] == *delim)
            home_match = true;
      }
    }
    FREE(&home.mbox);
  }

  /* do the '=' substitution */
  if (home_match)
  {
    *path++ = '=';
    /* copy remaining path, skipping delimiter */
    if (hlen == 0)
      hlen = -1;
    memcpy(path, target.mbox + hlen + 1, tlen - hlen - 1);
    path[tlen - hlen - 1] = '\0';
  }
  else
  {
    mutt_account_tourl(&target.account, &url);
    url.path = target.mbox;
    /* FIXME: That hard-coded constant is bogus. But we need the actual
     *   size of the buffer from mutt_pretty_mailbox. And these pretty
     *   operations usually shrink the result. Still... */
    url_tostring(&url, path, 1024, 0);
  }

  FREE(&target.mbox);
}


static void swapStops(void *stuff, int num)
{
    int i, n;
    CARD32 *stops;
    CARD16 *colors;
    stops = (CARD32 *)(stuff);
    for (i = 0; i < num; ++i) {
        swapl(stops, n);
        ++stops;
    }
    colors = (CARD16 *)(stops);
    for (i = 0; i < 4*num; ++i) {
        swaps(stops, n);
        ++stops;
    }
}


nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
	    struct svc_fh **getfh)
{
	if (!cstate->current_fh.fh_dentry)
		return nfserr_nofilehandle;

	*getfh = &cstate->current_fh;
	return nfs_ok;
}


void TrivialAuthorizedCallback(media::OutputDeviceStatus,
                               const media::AudioParameters&,
                               const std::string&) {}


void WebLocalFrameImpl::MoveCaretSelection(const WebPoint& point_in_viewport) {
  TRACE_EVENT0("blink", "WebLocalFrameImpl::moveCaretSelection");

  GetFrame()->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
  const IntPoint point_in_contents =
      GetFrame()->View()->ViewportToContents(point_in_viewport);
  GetFrame()->Selection().MoveCaretSelection(point_in_contents);
}


static int ntop_rrd_fetch(lua_State* vm) {
  unsigned long i, j, step = 0, ds_cnt = 0;
  rrd_value_t *data, *p;
  char **names;
  char *filename, *cf;
  time_t t, start, end;
  int status;

  if ((status = __ntop_rrd_args(vm, &filename, &cf, &start, &end)) != CONST_LUA_OK) return status;

  ntop->getTrace()->traceEvent(TRACE_INFO, "%s(%s)", __FUNCTION__, filename);

  reset_rrd_state();

  if ((status = __ntop_rrd_status(vm, rrd_fetch_r(filename, cf, &start, &end, &step, &ds_cnt, &names, &data), filename, cf)) != CONST_LUA_OK) return status;

  lua_pushnumber(vm, (lua_Number) start);
  lua_pushnumber(vm, (lua_Number) step);
  /* fprintf(stderr, "%lu, %lu, %lu, %lu\n", start, end, step, num_points); */

  /* create the ds names array */
  lua_newtable(vm);
  for(i=0; i<ds_cnt; i++) {
    lua_pushstring(vm, names[i]);
    lua_rawseti(vm, -2, i+1);
    rrd_freemem(names[i]);
  }
  rrd_freemem(names);

  /* create the data points array */
  lua_newtable(vm);
  p = data;
  for(t=start+1, i=0; t<end; t+=step, i++) {
    lua_newtable(vm);
    for(j=0; j<ds_cnt; j++) {
      rrd_value_t value = *p++;

      if(value != DNAN /* Skip NaN */) {
        lua_pushnumber(vm, (lua_Number)value);
        lua_rawseti(vm, -2, j+1);
        // ntop->getTrace()->traceEvent(TRACE_NORMAL, "%u / %.f", t, value);
      }
    }
    lua_rawseti(vm, -2, i+1);
  }
  rrd_freemem(data);

  /* return the end as the last value */
  lua_pushnumber(vm, (lua_Number) end);

  /* number of return values: start, step, names, data, end */
  return(5);
}


void AppCacheDispatcherHost::OnRegisterHost(int host_id) {
  if (appcache_service_.get()) {
    if (!backend_impl_.RegisterHost(host_id)) {
      bad_message::ReceivedBadMessage(this, bad_message::ACDH_REGISTER);
    }
  }
}


static void e1000_class_init(ObjectClass *klass, void *data)
{
    DeviceClass *dc = DEVICE_CLASS(klass);
    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
    E1000BaseClass *e = E1000_CLASS(klass);
    const E1000Info *info = data;

    k->realize = pci_e1000_realize;
    k->exit = pci_e1000_uninit;
    k->romfile = "efi-e1000.rom";
    k->vendor_id = PCI_VENDOR_ID_INTEL;
    k->device_id = info->device_id;
    k->revision = info->revision;
    e->phy_id2 = info->phy_id2;
    k->class_id = PCI_CLASS_NETWORK_ETHERNET;
    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
    dc->desc = "Intel Gigabit Ethernet";
    dc->reset = qdev_e1000_reset;
    dc->vmsd = &vmstate_e1000;
    device_class_set_props(dc, e1000_properties);
}


static void deprecatedAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
    UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::Attribute);
    TestObjectV8Internal::deprecatedAttrAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}


PasswordAutofillAgent::~PasswordAutofillAgent() {
  AutofillAgent* agent = autofill_agent_.get();
  if (agent)
    agent->RemoveFormObserver(this);
}


static void vbe_fixup_regs(VGACommonState *s)
{
    uint16_t *r = s->vbe_regs;
    uint32_t bits, linelength, maxy, offset;

    if (!vbe_enabled(s)) {
        /* vbe is turned off -- nothing to do */
        return;
    }

    /* check depth */
    switch (r[VBE_DISPI_INDEX_BPP]) {
    case 4:
    case 8:
    case 16:
    case 24:
    case 32:
        bits = r[VBE_DISPI_INDEX_BPP];
        break;
    case 15:
        bits = 16;
        break;
    default:
        bits = r[VBE_DISPI_INDEX_BPP] = 8;
        break;
    }

    /* check width */
    r[VBE_DISPI_INDEX_XRES] &= ~7u;
    if (r[VBE_DISPI_INDEX_XRES] == 0) {
        r[VBE_DISPI_INDEX_XRES] = 8;
    }
    if (r[VBE_DISPI_INDEX_XRES] > VBE_DISPI_MAX_XRES) {
        r[VBE_DISPI_INDEX_XRES] = VBE_DISPI_MAX_XRES;
    }
    r[VBE_DISPI_INDEX_VIRT_WIDTH] &= ~7u;
    if (r[VBE_DISPI_INDEX_VIRT_WIDTH] > VBE_DISPI_MAX_XRES) {
        r[VBE_DISPI_INDEX_VIRT_WIDTH] = VBE_DISPI_MAX_XRES;
    }
    if (r[VBE_DISPI_INDEX_VIRT_WIDTH] < r[VBE_DISPI_INDEX_XRES]) {
        r[VBE_DISPI_INDEX_VIRT_WIDTH] = r[VBE_DISPI_INDEX_XRES];
    }

    /* check height */
    linelength = r[VBE_DISPI_INDEX_VIRT_WIDTH] * bits / 8;
    maxy = s->vbe_size / linelength;
    if (r[VBE_DISPI_INDEX_YRES] == 0) {
        r[VBE_DISPI_INDEX_YRES] = 1;
    }
    if (r[VBE_DISPI_INDEX_YRES] > VBE_DISPI_MAX_YRES) {
        r[VBE_DISPI_INDEX_YRES] = VBE_DISPI_MAX_YRES;
    }
    if (r[VBE_DISPI_INDEX_YRES] > maxy) {
        r[VBE_DISPI_INDEX_YRES] = maxy;
    }

    /* check offset */
    if (r[VBE_DISPI_INDEX_X_OFFSET] > VBE_DISPI_MAX_XRES) {
        r[VBE_DISPI_INDEX_X_OFFSET] = VBE_DISPI_MAX_XRES;
    }
    if (r[VBE_DISPI_INDEX_Y_OFFSET] > VBE_DISPI_MAX_YRES) {
        r[VBE_DISPI_INDEX_Y_OFFSET] = VBE_DISPI_MAX_YRES;
    }
    offset = r[VBE_DISPI_INDEX_X_OFFSET] * bits / 8;
    offset += r[VBE_DISPI_INDEX_Y_OFFSET] * linelength;
    if (offset + r[VBE_DISPI_INDEX_YRES] * linelength > s->vbe_size) {
        r[VBE_DISPI_INDEX_Y_OFFSET] = 0;
        offset = r[VBE_DISPI_INDEX_X_OFFSET] * bits / 8;
        if (offset + r[VBE_DISPI_INDEX_YRES] * linelength > s->vbe_size) {
            r[VBE_DISPI_INDEX_X_OFFSET] = 0;
            offset = 0;
        }
    }

    /* update vga state */
    r[VBE_DISPI_INDEX_VIRT_HEIGHT] = maxy;
    s->vbe_line_offset = linelength;
    s->vbe_start_addr  = offset / 4;
}


read_digested_summary (OstreeRepo   *repo,
                       const char   *digest,
                       GHashTable   *digested_summary_cache,
                       GCancellable *cancellable,
                       GError      **error)
{
  GVariant *cached;
  g_autoptr(GVariant) loaded = NULL;

  cached = g_hash_table_lookup (digested_summary_cache, digest);
  if (cached)
    return g_variant_ref (cached);

  loaded = flatpak_repo_load_digested_summary (repo, digest, error);
  if (loaded == NULL)
    return NULL;

  g_hash_table_insert (digested_summary_cache, g_strdup (digest), g_variant_ref (loaded));

  return g_steal_pointer (&loaded);
}


read_header(struct archive_read *a, struct archive_entry *entry)
{
	struct mtree *mtree;
	char *p;
	int r, use_next;

	mtree = (struct mtree *)(a->format->data);

	if (mtree->fd >= 0) {
		close(mtree->fd);
		mtree->fd = -1;
	}

	if (mtree->entries == NULL) {
		mtree->resolver = archive_entry_linkresolver_new();
		if (mtree->resolver == NULL)
			return ARCHIVE_FATAL;
		archive_entry_linkresolver_set_strategy(mtree->resolver,
		    ARCHIVE_FORMAT_MTREE);
		r = read_mtree(a, mtree);
		if (r != ARCHIVE_OK)
			return (r);
	}

	a->archive.archive_format = mtree->archive_format;
	a->archive.archive_format_name = mtree->archive_format_name;

	for (;;) {
		if (mtree->this_entry == NULL)
			return (ARCHIVE_EOF);
		if (strcmp(mtree->this_entry->name, "..") == 0) {
			mtree->this_entry->used = 1;
			if (archive_strlen(&mtree->current_dir) > 0) {
				/* Roll back current path. */
				p = mtree->current_dir.s
				    + mtree->current_dir.length - 1;
				while (p >= mtree->current_dir.s && *p != '/')
					--p;
				if (p >= mtree->current_dir.s)
					--p;
				mtree->current_dir.length
				    = p - mtree->current_dir.s + 1;
			}
		}
		if (!mtree->this_entry->used) {
			use_next = 0;
			r = parse_file(a, entry, mtree, mtree->this_entry,
				&use_next);
			if (use_next == 0)
				return (r);
		}
		mtree->this_entry = mtree->this_entry->next;
	}
}


int open_tmpinfile(rzip_control *control)
{
	int fd_in = -1;

	/* Use temporary directory if there is one */
	if (control->tmpdir) {
		control->infile = malloc(strlen(control->tmpdir) + 15);
		if (unlikely(!control->infile))
			fatal_return(("Failed to allocate infile name\n"), -1);
		strcpy(control->infile, control->tmpdir);
		strcat(control->infile, "lrzipin.XXXXXX");
		fd_in = mkstemp(control->infile);
	}

	/* Try the current directory */
	if (fd_in == -1) {
		dealloc(control->infile);
		control->infile = malloc(16);
		if (unlikely(!control->infile))
			fatal_return(("Failed to allocate infile name\n"), -1);
		strcpy(control->infile, "lrzipin.XXXXXX");
		fd_in = mkstemp(control->infile);
	}

	/* Use /tmp if nothing is writeable so far */
	if (fd_in == -1) {
		dealloc(control->infile);
		control->infile = malloc(20);
		if (unlikely(!control->infile))
			fatal_return(("Failed to allocate infile name\n"), -1);
		strcpy(control->infile, "/tmp/lrzipin.XXXXXX");
		fd_in = mkstemp(control->infile);
	}

	if (fd_in == -1) {
		print_progress("WARNING: Failed to create in tmpfile: %s, will fail if cannot perform %scompression entirely in ram\n",
			       control->infile, DECOMPRESS ? "de" : "");
	} else {
		register_infile(control, control->infile, (DECOMPRESS || TEST_ONLY) && STDIN);
		/* Unlink temporary file immediately to minimise chance of files left
		* lying around in cases of failure_return((. */
		if (unlikely(unlink(control->infile))) {
			fatal("Failed to unlink tmpfile: %s\n", control->infile);
			close(fd_in);
			return -1;
		}
	}
	return fd_in;
}


GpuCommandBufferStub::~GpuCommandBufferStub() {
  Destroy();

  GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
  gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer(surface_id()));
}


static int instance_mkdir(const char *name)
{
	struct trace_array *tr;
	int ret;

	mutex_lock(&event_mutex);
	mutex_lock(&trace_types_lock);

	ret = -EEXIST;
	list_for_each_entry(tr, &ftrace_trace_arrays, list) {
		if (tr->name && strcmp(tr->name, name) == 0)
			goto out_unlock;
	}

	ret = -ENOMEM;
	tr = kzalloc(sizeof(*tr), GFP_KERNEL);
	if (!tr)
		goto out_unlock;

	tr->name = kstrdup(name, GFP_KERNEL);
	if (!tr->name)
		goto out_free_tr;

	if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
		goto out_free_tr;

	tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS;

	cpumask_copy(tr->tracing_cpumask, cpu_all_mask);

	raw_spin_lock_init(&tr->start_lock);

	tr->max_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;

	tr->current_trace = &nop_trace;

	INIT_LIST_HEAD(&tr->systems);
	INIT_LIST_HEAD(&tr->events);
	INIT_LIST_HEAD(&tr->hist_vars);

	if (allocate_trace_buffers(tr, trace_buf_size) < 0)
		goto out_free_tr;

	tr->dir = tracefs_create_dir(name, trace_instance_dir);
	if (!tr->dir)
		goto out_free_tr;

	ret = event_trace_add_tracer(tr->dir, tr);
	if (ret) {
		tracefs_remove_recursive(tr->dir);
		goto out_free_tr;
	}

	ftrace_init_trace_array(tr);

	init_tracer_tracefs(tr, tr->dir);
	init_trace_flags_index(tr);
	__update_tracer_options(tr);

	list_add(&tr->list, &ftrace_trace_arrays);

	mutex_unlock(&trace_types_lock);
	mutex_unlock(&event_mutex);

	return 0;

 out_free_tr:
	free_trace_buffers(tr);
	free_cpumask_var(tr->tracing_cpumask);
	kfree(tr->name);
	kfree(tr);

 out_unlock:
	mutex_unlock(&trace_types_lock);
	mutex_unlock(&event_mutex);

	return ret;

}


Status IndexedDBDatabase::DeleteIndexOperation(
    int64_t object_store_id,
    int64_t index_id,
    IndexedDBTransaction* transaction) {
  IDB_TRACE1(
      "IndexedDBDatabase::DeleteIndexOperation", "txn.id", transaction->id());

  IndexedDBIndexMetadata index_metadata =
      RemoveIndex(object_store_id, index_id);

  Status s = metadata_coding_->DeleteIndex(
      transaction->BackingStoreTransaction()->transaction(),
      transaction->database()->id(), object_store_id, index_metadata);

  if (!s.ok())
    return s;

  s = backing_store_->ClearIndex(transaction->BackingStoreTransaction(),
                                 transaction->database()->id(), object_store_id,
                                 index_id);
  if (!s.ok()) {
    AddIndex(object_store_id, std::move(index_metadata),
             IndexedDBIndexMetadata::kInvalidId);
    return s;
  }

  transaction->ScheduleAbortTask(
      base::BindOnce(&IndexedDBDatabase::DeleteIndexAbortOperation, this,
                     object_store_id, std::move(index_metadata)));
  return s;
}


DEFUN (ipv6_nd_ra_lifetime,
       ipv6_nd_ra_lifetime_cmd,
       "ipv6 nd ra-lifetime <0-9000>",
       "Interface IPv6 config commands\n"
       "Neighbor discovery\n"
       "Router lifetime\n"
       "Router lifetime in seconds (0 stands for a non-default gw)\n")
{
  int lifetime;
  struct interface *ifp;
  struct zebra_if *zif;

  ifp = (struct interface *) vty->index;
  zif = ifp->info;

  VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[0], 0, 9000);

  /* The value to be placed in the Router Lifetime field
   * of Router Advertisements sent from the interface,
   * in seconds.  MUST be either zero or between
   * MaxRtrAdvInterval and 9000 seconds. -- RFC4861, 6.2.1 */
  if ((lifetime != 0 && lifetime * 1000 < zif->rtadv.MaxRtrAdvInterval))
    {
      vty_out (vty, "This ra-lifetime would conflict with configured ra-interval%s", VTY_NEWLINE);
      return CMD_WARNING;
    }

  zif->rtadv.AdvDefaultLifetime = lifetime;

  return CMD_SUCCESS;
}


static void overloadedMethodE2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    if (UNLIKELY(info.Length() < 1)) {
        throwTypeError(ExceptionMessages::failedToExecute("overloadedMethodE", "TestObjectPython", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
        return;
    }
    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
    V8TRYCATCH_VOID(Vector<int>, longArrayArg, toNativeArray<int>(info[0], 1, info.GetIsolate()));
    imp->overloadedMethodE(longArrayArg);
}


static void activityLoggingAccessPerWorldBindingsLongAttributeAttributeSetterForMainWorld(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
    ExceptionState exceptionState(ExceptionState::SetterContext, "activityLoggingAccessPerWorldBindingsLongAttribute", "TestObjectPython", info.Holder(), info.GetIsolate());
    TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
    V8TRYCATCH_EXCEPTION_VOID(int, cppValue, toInt32(jsValue, exceptionState), exceptionState);
    imp->setActivityLoggingAccessPerWorldBindingsLongAttribute(cppValue);
}


void RenderFrameHostImpl::OnDidChangeFramePolicy(
    int32_t frame_routing_id,
    blink::WebSandboxFlags flags,
    const ParsedFeaturePolicyHeader& container_policy) {
  FrameTreeNode* child = FindAndVerifyChild(
      frame_routing_id, bad_message::RFH_SANDBOX_FLAGS);
  if (!child)
    return;

  child->SetPendingSandboxFlags(flags);
  child->SetPendingContainerPolicy(container_policy);

  RenderFrameHost* child_rfh = child->current_frame_host();
  if (child_rfh->GetSiteInstance() != GetSiteInstance()) {
    child_rfh->Send(new FrameMsg_DidUpdateFramePolicy(child_rfh->GetRoutingID(),
                                                      flags, container_policy));
  }
}


do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
{
	int ret;

	if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
		return -EPERM;

	switch (cmd) {
	case IPT_SO_SET_REPLACE:
		ret = do_replace(sock_net(sk), user, len);
		break;

	case IPT_SO_SET_ADD_COUNTERS:
		ret = do_add_counters(sock_net(sk), user, len, 0);
		break;

	default:
		ret = -EINVAL;
	}

	return ret;
}


evutil_strtoll(const char *s, char **endptr, int base)
{
#ifdef EVENT__HAVE_STRTOLL
	return (ev_int64_t)strtoll(s, endptr, base);
#elif EVENT__SIZEOF_LONG == 8
	return (ev_int64_t)strtol(s, endptr, base);
#elif defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1300
	/* XXXX on old versions of MS APIs, we only support base
	 * 10. */
	ev_int64_t r;
	if (base != 10)
		return 0;
	r = (ev_int64_t) _atoi64(s);
	while (isspace(*s))
		++s;
	if (*s == '-')
		++s;
	while (isdigit(*s))
		++s;
	if (endptr)
		*endptr = (char*) s;
	return r;
#elif defined(_WIN32)
	return (ev_int64_t) _strtoi64(s, endptr, base);
#elif defined(EVENT__SIZEOF_LONG_LONG) && EVENT__SIZEOF_LONG_LONG == 8
	long long r;
	int n;
	if (base != 10 && base != 16)
		return 0;
	if (base == 10) {
		n = sscanf(s, "%lld", &r);
	} else {
		unsigned long long ru=0;
		n = sscanf(s, "%llx", &ru);
		if (ru > EV_INT64_MAX)
			return 0;
		r = (long long) ru;
	}
	if (n != 1)
		return 0;
	while (EVUTIL_ISSPACE_(*s))
		++s;
	if (*s == '-')
		++s;
	if (base == 10) {
		while (EVUTIL_ISDIGIT_(*s))
			++s;
	} else {
		while (EVUTIL_ISXDIGIT_(*s))
			++s;
	}
	if (endptr)
		*endptr = (char*) s;
	return r;
#else
#error "I don't know how to parse 64-bit integers."
#endif
}


static void dn_socket_seq_stop(struct seq_file *seq, void *v)
{
	if (v && v != SEQ_START_TOKEN)
		read_unlock_bh(&dn_hash_lock);
}


static const char *parse_number(cJSON *item,const char *num)
{
	double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;

	if (*num=='-') sign=-1,num++;	/* Has sign? */
	if (*num=='0') num++;			/* is zero */
	if (*num>='1' && *num<='9')	do	n=(n*10.0)+(*num++ -'0');	while (*num>='0' && *num<='9');	/* Number? */
	if (*num=='.' && num[1]>='0' && num[1]<='9') {num++;		do	n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');}	/* Fractional part? */
	if (*num=='e' || *num=='E')		/* Exponent? */
	{	num++;if (*num=='+') num++;	else if (*num=='-') signsubscale=-1,num++;		/* With sign? */
		while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0');	/* Number? */
	}

	n=sign*n*pow(10.0,(scale+subscale*signsubscale));	/* number = +/- number.fraction * 10^+/- exponent */

	item->valuedouble=n;
	item->valueint=(int64_t)n;
	item->type=cJSON_Number;
	return num;
}


  explicit TestInterstitialPage(WebContents* tab) {
    base::FilePath file_path;
    bool success = PathService::Get(chrome::DIR_TEST_DATA, &file_path);
    EXPECT_TRUE(success);
    file_path = file_path.AppendASCII("focus/typical_page.html");
    success = base::ReadFileToString(file_path, &html_contents_);
    EXPECT_TRUE(success);
    interstitial_page_ = content::InterstitialPage::Create(
        tab, true, GURL("http://interstitial.com"), this);

    interstitial_page_->Show();
    content::WaitForInterstitialAttach(tab);

    EXPECT_TRUE(tab->ShowingInterstitialPage());
  }


String PresentationConnection::binaryType() const {
  switch (m_binaryType) {
    case BinaryTypeBlob:
      return "blob";
    case BinaryTypeArrayBuffer:
      return "arraybuffer";
  }
  ASSERT_NOT_REACHED();
  return String();
}


skip_expr_cctx(char_u **arg, cctx_T *cctx)
{
    evalarg_T	evalarg;

    init_evalarg(&evalarg);
    evalarg.eval_cctx = cctx;
    skip_expr(arg, &evalarg);
    clear_evalarg(&evalarg, NULL);
}


static void http_skip_ws ( const char * & buf , int & len ) {
 while ( len > 0 && * buf && ParseRules : : is_ws ( * buf ) ) {
 buf += 1 ;
 len -= 1 ;
 }
 }


acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
			    char **new_val)
{
	if (!init_val || !new_val)
		return AE_BAD_PARAMETER;

	*new_val = NULL;
	if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
		printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
		       acpi_os_name);
		*new_val = acpi_os_name;
	}

	if (!memcmp(init_val->name, "_REV", 4) && acpi_rev_override) {
		printk(KERN_INFO PREFIX "Overriding _REV return value to 5\n");
		*new_val = (char *)5;
	}

	return AE_OK;
}


int __cil_resolve_ast_last_child_helper(struct cil_tree_node *current, void *extra_args)
{
	int rc = SEPOL_ERR;
	struct cil_args_resolve *args = extra_args;
	struct cil_tree_node *parent = NULL;

	if (current == NULL ||  extra_args == NULL) {
		goto exit;
	}

	parent = current->parent;

	if (parent->flavor == CIL_BLOCK) {
		struct cil_tree_node *n = parent->parent;
		args->block = NULL;
		while (n && n->flavor != CIL_ROOT) {
			if (n->flavor == CIL_BLOCK) {
				args->block = n;
				break;
			}
			n = n->parent;
		}
	} else if (parent->flavor == CIL_MACRO) {
		args->macro = NULL;
	} else if (parent->flavor == CIL_OPTIONAL) {
		struct cil_tree_node *n = parent->parent;
		if (((struct cil_optional *)parent->data)->enabled == CIL_FALSE) {
			*(args->changed) = CIL_TRUE;
			cil_list_append(args->disabled_optionals, CIL_NODE, parent);
		}
		args->optional = NULL;
		while (n && n->flavor != CIL_ROOT) {
			if (n->flavor == CIL_OPTIONAL) {
				args->optional = n;
				break;
			}
			n = n->parent;
		}
	} else if (parent->flavor == CIL_BOOLEANIF) {
		args->boolif = NULL;
	}

	return SEPOL_OK;

exit:
	return rc;
}


CSSStyleSheet* CSSStyleSheet::CreateInline(Node& owner_node,
                                           const KURL& base_url,
                                           const TextPosition& start_position,
                                            const WTF::TextEncoding& encoding) {
   CSSParserContext* parser_context = CSSParserContext::Create(
       owner_node.GetDocument(), owner_node.GetDocument().BaseURL(),
      false /* is_opaque_response_from_service_worker */,
       owner_node.GetDocument().GetReferrerPolicy(), encoding);
   StyleSheetContents* sheet =
       StyleSheetContents::Create(base_url.GetString(), parser_context);
  return new CSSStyleSheet(sheet, owner_node, true, start_position);
}


int vp8_set_roimap ( VP8_COMP * cpi , unsigned char * map , unsigned int rows , unsigned int cols , int delta_q [ 4 ] , int delta_lf [ 4 ] , unsigned int threshold [ 4 ] ) {
 signed char feature_data [ MB_LVL_MAX ] [ MAX_MB_SEGMENTS ] ;
 int internal_delta_q [ MAX_MB_SEGMENTS ] ;
 const int range = 63 ;
 int i ;
 if ( cpi -> cyclic_refresh_mode_enabled ) return - 1 ;
 if ( cpi -> common . mb_rows != rows || cpi -> common . mb_cols != cols ) return - 1 ;
 if ( ( abs ( delta_q [ 0 ] ) > range ) || ( abs ( delta_q [ 1 ] ) > range ) || ( abs ( delta_q [ 2 ] ) > range ) || ( abs ( delta_q [ 3 ] ) > range ) ) return - 1 ;
 if ( ( abs ( delta_lf [ 0 ] ) > range ) || ( abs ( delta_lf [ 1 ] ) > range ) || ( abs ( delta_lf [ 2 ] ) > range ) || ( abs ( delta_lf [ 3 ] ) > range ) ) return - 1 ;
 if ( ! map ) {
 disable_segmentation ( cpi ) ;
 return 0 ;
 }
 for ( i = 0 ;
 i < MAX_MB_SEGMENTS ;
 i ++ ) internal_delta_q [ i ] = ( delta_q [ i ] >= 0 ) ? q_trans [ delta_q [ i ] ] : - q_trans [ - delta_q [ i ] ] ;
 set_segmentation_map ( cpi , map ) ;
 enable_segmentation ( cpi ) ;
 feature_data [ MB_LVL_ALT_Q ] [ 0 ] = internal_delta_q [ 0 ] ;
 feature_data [ MB_LVL_ALT_Q ] [ 1 ] = internal_delta_q [ 1 ] ;
 feature_data [ MB_LVL_ALT_Q ] [ 2 ] = internal_delta_q [ 2 ] ;
 feature_data [ MB_LVL_ALT_Q ] [ 3 ] = internal_delta_q [ 3 ] ;
 feature_data [ MB_LVL_ALT_LF ] [ 0 ] = delta_lf [ 0 ] ;
 feature_data [ MB_LVL_ALT_LF ] [ 1 ] = delta_lf [ 1 ] ;
 feature_data [ MB_LVL_ALT_LF ] [ 2 ] = delta_lf [ 2 ] ;
 feature_data [ MB_LVL_ALT_LF ] [ 3 ] = delta_lf [ 3 ] ;
 cpi -> segment_encode_breakout [ 0 ] = threshold [ 0 ] ;
 cpi -> segment_encode_breakout [ 1 ] = threshold [ 1 ] ;
 cpi -> segment_encode_breakout [ 2 ] = threshold [ 2 ] ;
 cpi -> segment_encode_breakout [ 3 ] = threshold [ 3 ] ;
 set_segment_data ( cpi , & feature_data [ 0 ] [ 0 ] , SEGMENT_DELTADATA ) ;
 return 0 ;
 }


static void client_use_result()
{
  MYSQL_RES *result;
  int       rc;
  myheader("client_use_result");

  rc= mysql_query(mysql, "SELECT * FROM t1");
  myquery(rc);

  /* get the result */
  result= mysql_use_result(mysql);
  mytest(result);

  (void) my_process_result_set(result);
  mysql_free_result(result);
}


static inline CanvasImageSource* ToImageSourceInternal(
    const CanvasImageSourceUnion& value,
    ExceptionState& exception_state) {
  if (value.IsCSSImageValue()) {
    if (RuntimeEnabledFeatures::CSSPaintAPIEnabled())
      return value.GetAsCSSImageValue();
    exception_state.ThrowTypeError("CSSImageValue is not yet supported");
    return nullptr;
  }
  if (value.IsHTMLImageElement())
    return value.GetAsHTMLImageElement();
  if (value.IsHTMLVideoElement()) {
    HTMLVideoElement* video = value.GetAsHTMLVideoElement();
    video->VideoWillBeDrawnToCanvas();
    return video;
  }
  if (value.IsSVGImageElement())
    return value.GetAsSVGImageElement();
  if (value.IsHTMLCanvasElement())
    return value.GetAsHTMLCanvasElement();
  if (value.IsImageBitmap()) {
    if (static_cast<ImageBitmap*>(value.GetAsImageBitmap())->IsNeutered()) {
      exception_state.ThrowDOMException(
          kInvalidStateError, String::Format("The image source is detached"));
      return nullptr;
    }
    return value.GetAsImageBitmap();
  }
  if (value.IsOffscreenCanvas()) {
    if (static_cast<OffscreenCanvas*>(value.GetAsOffscreenCanvas())
            ->IsNeutered()) {
      exception_state.ThrowDOMException(
          kInvalidStateError, String::Format("The image source is detached"));
      return nullptr;
    }
    return value.GetAsOffscreenCanvas();
  }
  NOTREACHED();
  return nullptr;
}


static void add_all_files_to_work_queue ( NautilusDirectory * directory ) {
 GList * node ;
 NautilusFile * file ;
 for ( node = directory -> details -> file_list ;
 node != NULL ;
 node = node -> next ) {
 file = NAUTILUS_FILE ( node -> data ) ;
 nautilus_directory_add_file_to_work_queue ( directory , file ) ;
 }
 }


void WebProcessProxy::getPlugins(CoreIPC::Connection*, uint64_t requestID, bool refresh)
{
    pluginWorkQueue().dispatch(bind(&WebProcessProxy::handleGetPlugins, this, requestID, refresh));
}