void DevToolsUIBindings::LoadNetworkResource(const DispatchCallback& callback,
                                             const std::string& url,
                                             const std::string& headers,
                                             int stream_id) {
  GURL gurl(url);
  if (!gurl.is_valid()) {
    base::DictionaryValue response;
    response.SetInteger("statusCode", 404);
    callback.Run(&response);
    return;
  }
  net::NetworkTrafficAnnotationTag traffic_annotation =
      net::DefineNetworkTrafficAnnotation("devtools_network_resource", R"(
        semantics {
          sender: "Developer Tools"
          description:
            "When user opens Developer Tools, the browser may fetch additional "
            "resources from the network to enrich the debugging experience "
            "(e.g. source map resources)."
          trigger: "User opens Developer Tools to debug a web page."
          data: "Any resources requested by Developer Tools."
          destination: WEBSITE
        }
        policy {
          cookies_allowed: YES
          cookies_store: "user"
          setting:
            "It's not possible to disable this feature from settings."
          chrome_policy {
            DeveloperToolsDisabled {
              policy_options {mode: MANDATORY}
              DeveloperToolsDisabled: true
            }
          }
        })");

  net::URLFetcher* fetcher = net::URLFetcher::Create(gurl, net::URLFetcher::GET,
                                                     this, traffic_annotation)
                                 .release();
  pending_requests_[fetcher] = callback;
  fetcher->SetRequestContext(profile_->GetRequestContext());
  fetcher->SetExtraRequestHeaders(headers);
  fetcher->SaveResponseWithWriter(
      std::unique_ptr<net::URLFetcherResponseWriter>(
          new ResponseWriter(weak_factory_.GetWeakPtr(), stream_id)));
  fetcher->Start();
}


fcmp_eq(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
{
	if (CMP(CMP /*EQ*/) == 0)
		regs->sr |= 1;
	else
		regs->sr &= ~1;
	return 0;
}


GF_Err gf_isom_parse_movie_boxes(GF_ISOFile *mov, u32 *boxType, u64 *bytesMissing, Bool progressive_mode)
{
	GF_Err e;
	GF_Blob *blob = NULL;

	//if associated file is a blob, lock blob before parsing !
	if (mov->movieFileMap && ((mov->movieFileMap->type == GF_ISOM_DATA_MEM) || (mov->movieFileMap->type == GF_ISOM_DATA_FILE))) {
		blob = ((GF_FileDataMap *)mov->movieFileMap)->blob;
	}

	if (blob)
		gf_mx_p(blob->mx);

	unused_bytes = 0;
	e = gf_isom_parse_movie_boxes_internal(mov, boxType, bytesMissing, progressive_mode);

	if (blob)
		gf_mx_v(blob->mx);
	return e;

}


static struct io_kiocb *__io_prep_linked_timeout(struct io_kiocb *req)
{
	if (WARN_ON_ONCE(!req->link))
		return NULL;

	req->flags &= ~REQ_F_ARM_LTIMEOUT;
	req->flags |= REQ_F_LINK_TIMEOUT;

	/* linked timeouts should have two refs once prep'ed */
	io_req_set_refcount(req);
	__io_req_set_refcount(req->link, 2);
	return req->link;
}


u32 gf_hinter_track_get_bandwidth(GF_RTPHinter *tkHinter)
{
	return tkHinter->bandwidth;
}


void OpenSSL_add_all_ciphers(void)
	{

#ifndef OPENSSL_NO_DES
	EVP_add_cipher(EVP_des_cfb());
	EVP_add_cipher(EVP_des_cfb1());
	EVP_add_cipher(EVP_des_cfb8());
	EVP_add_cipher(EVP_des_ede_cfb());
	EVP_add_cipher(EVP_des_ede3_cfb());
	EVP_add_cipher(EVP_des_ede3_cfb1());
	EVP_add_cipher(EVP_des_ede3_cfb8());

	EVP_add_cipher(EVP_des_ofb());
	EVP_add_cipher(EVP_des_ede_ofb());
	EVP_add_cipher(EVP_des_ede3_ofb());

	EVP_add_cipher(EVP_desx_cbc());
	EVP_add_cipher_alias(SN_desx_cbc,"DESX");
	EVP_add_cipher_alias(SN_desx_cbc,"desx");

	EVP_add_cipher(EVP_des_cbc());
	EVP_add_cipher_alias(SN_des_cbc,"DES");
	EVP_add_cipher_alias(SN_des_cbc,"des");
	EVP_add_cipher(EVP_des_ede_cbc());
	EVP_add_cipher(EVP_des_ede3_cbc());
	EVP_add_cipher_alias(SN_des_ede3_cbc,"DES3");
	EVP_add_cipher_alias(SN_des_ede3_cbc,"des3");

	EVP_add_cipher(EVP_des_ecb());
	EVP_add_cipher(EVP_des_ede());
	EVP_add_cipher(EVP_des_ede3());
#endif

#ifndef OPENSSL_NO_RC4
	EVP_add_cipher(EVP_rc4());
	EVP_add_cipher(EVP_rc4_40());
#ifndef OPENSSL_NO_MD5
	EVP_add_cipher(EVP_rc4_hmac_md5());
#endif
#endif

#ifndef OPENSSL_NO_IDEA
	EVP_add_cipher(EVP_idea_ecb());
	EVP_add_cipher(EVP_idea_cfb());
	EVP_add_cipher(EVP_idea_ofb());
	EVP_add_cipher(EVP_idea_cbc());
	EVP_add_cipher_alias(SN_idea_cbc,"IDEA");
	EVP_add_cipher_alias(SN_idea_cbc,"idea");
#endif

#ifndef OPENSSL_NO_SEED
	EVP_add_cipher(EVP_seed_ecb());
	EVP_add_cipher(EVP_seed_cfb());
	EVP_add_cipher(EVP_seed_ofb());
	EVP_add_cipher(EVP_seed_cbc());
	EVP_add_cipher_alias(SN_seed_cbc,"SEED");
	EVP_add_cipher_alias(SN_seed_cbc,"seed");
#endif

#ifndef OPENSSL_NO_RC2
	EVP_add_cipher(EVP_rc2_ecb());
	EVP_add_cipher(EVP_rc2_cfb());
	EVP_add_cipher(EVP_rc2_ofb());
	EVP_add_cipher(EVP_rc2_cbc());
	EVP_add_cipher(EVP_rc2_40_cbc());
	EVP_add_cipher(EVP_rc2_64_cbc());
	EVP_add_cipher_alias(SN_rc2_cbc,"RC2");
	EVP_add_cipher_alias(SN_rc2_cbc,"rc2");
#endif

#ifndef OPENSSL_NO_BF
	EVP_add_cipher(EVP_bf_ecb());
	EVP_add_cipher(EVP_bf_cfb());
	EVP_add_cipher(EVP_bf_ofb());
	EVP_add_cipher(EVP_bf_cbc());
	EVP_add_cipher_alias(SN_bf_cbc,"BF");
	EVP_add_cipher_alias(SN_bf_cbc,"bf");
	EVP_add_cipher_alias(SN_bf_cbc,"blowfish");
#endif

#ifndef OPENSSL_NO_CAST
	EVP_add_cipher(EVP_cast5_ecb());
	EVP_add_cipher(EVP_cast5_cfb());
	EVP_add_cipher(EVP_cast5_ofb());
	EVP_add_cipher(EVP_cast5_cbc());
	EVP_add_cipher_alias(SN_cast5_cbc,"CAST");
	EVP_add_cipher_alias(SN_cast5_cbc,"cast");
	EVP_add_cipher_alias(SN_cast5_cbc,"CAST-cbc");
	EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc");
#endif

#ifndef OPENSSL_NO_RC5
	EVP_add_cipher(EVP_rc5_32_12_16_ecb());
	EVP_add_cipher(EVP_rc5_32_12_16_cfb());
	EVP_add_cipher(EVP_rc5_32_12_16_ofb());
	EVP_add_cipher(EVP_rc5_32_12_16_cbc());
	EVP_add_cipher_alias(SN_rc5_cbc,"rc5");
	EVP_add_cipher_alias(SN_rc5_cbc,"RC5");
#endif

#ifndef OPENSSL_NO_AES
	EVP_add_cipher(EVP_aes_128_ecb());
	EVP_add_cipher(EVP_aes_128_cbc());
	EVP_add_cipher(EVP_aes_128_cfb());
	EVP_add_cipher(EVP_aes_128_cfb1());
	EVP_add_cipher(EVP_aes_128_cfb8());
	EVP_add_cipher(EVP_aes_128_ofb());
	EVP_add_cipher(EVP_aes_128_ctr());
	EVP_add_cipher(EVP_aes_128_gcm());
	EVP_add_cipher(EVP_aes_128_xts());
	EVP_add_cipher_alias(SN_aes_128_cbc,"AES128");
	EVP_add_cipher_alias(SN_aes_128_cbc,"aes128");
	EVP_add_cipher(EVP_aes_192_ecb());
	EVP_add_cipher(EVP_aes_192_cbc());
	EVP_add_cipher(EVP_aes_192_cfb());
	EVP_add_cipher(EVP_aes_192_cfb1());
	EVP_add_cipher(EVP_aes_192_cfb8());
	EVP_add_cipher(EVP_aes_192_ofb());
	EVP_add_cipher(EVP_aes_192_ctr());
	EVP_add_cipher(EVP_aes_192_gcm());
	EVP_add_cipher_alias(SN_aes_192_cbc,"AES192");
	EVP_add_cipher_alias(SN_aes_192_cbc,"aes192");
	EVP_add_cipher(EVP_aes_256_ecb());
	EVP_add_cipher(EVP_aes_256_cbc());
	EVP_add_cipher(EVP_aes_256_cfb());
	EVP_add_cipher(EVP_aes_256_cfb1());
	EVP_add_cipher(EVP_aes_256_cfb8());
	EVP_add_cipher(EVP_aes_256_ofb());
	EVP_add_cipher(EVP_aes_256_ctr());
	EVP_add_cipher(EVP_aes_256_gcm());
        EVP_add_cipher(EVP_aes_256_xts());
        EVP_add_cipher_alias(SN_aes_256_cbc,"AES256");
        EVP_add_cipher_alias(SN_aes_256_cbc,"aes256");
 #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
        EVP_add_cipher(EVP_aes_128_cbc_hmac_sha1());
        EVP_add_cipher(EVP_aes_256_cbc_hmac_sha1());
 #endif
 #endif

 #ifndef OPENSSL_NO_CAMELLIA
        EVP_add_cipher(EVP_camellia_128_ecb());
#ifndef OPENSSL_NO_CAMELLIA
	EVP_add_cipher(EVP_camellia_128_ecb());
	EVP_add_cipher(EVP_camellia_128_cbc());
	EVP_add_cipher(EVP_camellia_128_cfb());
	EVP_add_cipher(EVP_camellia_128_cfb1());
	EVP_add_cipher(EVP_camellia_128_cfb8());
	EVP_add_cipher(EVP_camellia_128_ofb());
	EVP_add_cipher_alias(SN_camellia_128_cbc,"CAMELLIA128");
	EVP_add_cipher_alias(SN_camellia_128_cbc,"camellia128");
	EVP_add_cipher(EVP_camellia_192_ecb());
	EVP_add_cipher(EVP_camellia_192_cbc());
	EVP_add_cipher(EVP_camellia_192_cfb());
	EVP_add_cipher(EVP_camellia_192_cfb1());
	EVP_add_cipher(EVP_camellia_192_cfb8());
	EVP_add_cipher(EVP_camellia_192_ofb());
	EVP_add_cipher_alias(SN_camellia_192_cbc,"CAMELLIA192");
	EVP_add_cipher_alias(SN_camellia_192_cbc,"camellia192");
	EVP_add_cipher(EVP_camellia_256_ecb());
	EVP_add_cipher(EVP_camellia_256_cbc());
	EVP_add_cipher(EVP_camellia_256_cfb());
	EVP_add_cipher(EVP_camellia_256_cfb1());
	EVP_add_cipher(EVP_camellia_256_cfb8());
	EVP_add_cipher(EVP_camellia_256_ofb());
	EVP_add_cipher_alias(SN_camellia_256_cbc,"CAMELLIA256");
	EVP_add_cipher_alias(SN_camellia_256_cbc,"camellia256");
#endif
	}


static void initial_reordering_standalone_cluster ( const hb_ot_shape_plan_t * plan , hb_face_t * face , hb_buffer_t * buffer , unsigned int start , unsigned int end ) {
 if ( hb_options ( ) . uniscribe_bug_compatible ) {
 if ( buffer -> info [ end - 1 ] . indic_category ( ) == OT_DOTTEDCIRCLE ) return ;
 }
 initial_reordering_consonant_syllable ( plan , face , buffer , start , end ) ;
 }


void InspectorAccessibilityAgent::addAncestors(
    AXObject& firstAncestor,
    AXObject* inspectedAXObject,
    std::unique_ptr<protocol::Array<AXNode>>& nodes,
    AXObjectCacheImpl& cache) const {
  AXObject* ancestor = &firstAncestor;
  while (ancestor) {
    nodes->addItem(buildProtocolAXObject(*ancestor, inspectedAXObject, true,
                                         nodes, cache));
    ancestor = ancestor->parentObjectUnignored();
  }
}


static void ImportOpacityQuantum(const Image *image,QuantumInfo *quantum_info,
  const MagickSizeType number_pixels,const unsigned char *magick_restrict p,
  Quantum *magick_restrict q,ExceptionInfo *exception)
{
  QuantumAny
    range;

  register ssize_t
    x;

  unsigned int
    pixel;

  assert(image != (Image *) NULL);
  assert(image->signature == MagickCoreSignature);
  switch (quantum_info->depth)
  {
    case 8:
    {
      unsigned char
        pixel;

      for (x=0; x < (ssize_t) number_pixels; x++)
      {
        p=PushCharPixel(p,&pixel);
        SetPixelOpacity(image,ScaleCharToQuantum(pixel),q);
        p+=quantum_info->pad;
        q+=GetPixelChannels(image);
      }
      break;
    }
    case 16:
    {
      unsigned short
        pixel;

      if (quantum_info->format == FloatingPointQuantumFormat)
        {
          for (x=0; x < (ssize_t) number_pixels; x++)
          {
            p=PushShortPixel(quantum_info->endian,p,&pixel);
            SetPixelOpacity(image,ClampToQuantum(QuantumRange*
              HalfToSinglePrecision(pixel)),q);
            p+=quantum_info->pad;
            q+=GetPixelChannels(image);
          }
          break;
        }
      for (x=0; x < (ssize_t) number_pixels; x++)
      {
        p=PushShortPixel(quantum_info->endian,p,&pixel);
        SetPixelOpacity(image,ScaleShortToQuantum(pixel),q);
        p+=quantum_info->pad;
        q+=GetPixelChannels(image);
      }
      break;
    }
    case 32:
    {
      unsigned int
        pixel;

      if (quantum_info->format == FloatingPointQuantumFormat)
        {
          float
            pixel;

          for (x=0; x < (ssize_t) number_pixels; x++)
          {
            p=PushFloatPixel(quantum_info,p,&pixel);
            SetPixelOpacity(image,ClampToQuantum(pixel),q);
            p+=quantum_info->pad;
            q+=GetPixelChannels(image);
          }
          break;
        }
      for (x=0; x < (ssize_t) number_pixels; x++)
      {
        p=PushLongPixel(quantum_info->endian,p,&pixel);
        SetPixelOpacity(image,ScaleLongToQuantum(pixel),q);
        p+=quantum_info->pad;
        q+=GetPixelChannels(image);
      }
      break;
    }
    case 64:
    {
      if (quantum_info->format == FloatingPointQuantumFormat)
        {
          double
            pixel;

          for (x=0; x < (ssize_t) number_pixels; x++)
          {
            p=PushDoublePixel(quantum_info,p,&pixel);
            SetPixelOpacity(image,ClampToQuantum(pixel),q);
            p+=quantum_info->pad;
            q+=GetPixelChannels(image);
          }
          break;
        }
    }
    default:
    {
      range=GetQuantumRange(quantum_info->depth);
      for (x=0; x < (ssize_t) number_pixels; x++)
      {
        p=PushQuantumPixel(quantum_info,p,&pixel);
        SetPixelOpacity(image,ScaleAnyToQuantum(pixel,range),q);
        p+=quantum_info->pad;
        q+=GetPixelChannels(image);
      }
      break;
    }
  }
}


      static double mp_vector_map_sv(_cimg_math_parser& mp) { // Operator(scalar,vector)
        unsigned int
          siz = (unsigned int)mp.opcode[2],
          ptrs = (unsigned int)mp.opcode[5] + 1;
        double *ptrd = &_mp_arg(1) + 1;
        mp_func op = (mp_func)mp.opcode[3];
        CImg<ulongT> l_opcode(4);
        l_opcode[2] = mp.opcode[4]; // Scalar argument1
        l_opcode.swap(mp.opcode);
        ulongT &argument2 = mp.opcode[3];
        while (siz-->0) { argument2 = ptrs++; *(ptrd++) = (*op)(mp); }
        l_opcode.swap(mp.opcode);
        return cimg::type<double>::nan();


END_TEST START_TEST ( test_find_available_user_small_net ) {
 in_addr_t ip ;
 int i ;
 ip = inet_addr ( "127.0.0.1" ) ;
 init_users ( ip , 29 ) ;
 for ( i = 0 ;
 i < 5 ;
 i ++ ) {
 fail_unless ( find_available_user ( ) == i ) ;
 }
 for ( i = 0 ;
 i < USERS ;
 i ++ ) {
 fail_unless ( find_available_user ( ) == - 1 ) ;
 }
 users [ 3 ] . active = 0 ;
 fail_unless ( find_available_user ( ) == 3 ) ;
 fail_unless ( find_available_user ( ) == - 1 ) ;
 users [ 3 ] . last_pkt = 55 ;
 fail_unless ( find_available_user ( ) == 3 ) ;
 fail_unless ( find_available_user ( ) == - 1 ) ;
 }


AE_1_TransportConnect(PRIVATE_NETWORKKEY ** network,
         PRIVATE_ASSOCIATIONKEY ** association, int nextState, void *params)
{
    DUL_ASSOCIATESERVICEPARAMETERS
    * service;
    OFCondition cond = EC_Normal;

    service = (DUL_ASSOCIATESERVICEPARAMETERS *) params;
    clearPDUCache(association);
    cond = requestAssociationTCP(network, service, association);
    (*association)->protocolState = nextState;
    return cond;
}


void bdrv_parent_drained_begin(BlockDriverState *bs)

{

    BdrvChild *c;

    QLIST_FOREACH(c, &bs->parents, next_parent) {

        if (c->role->drained_begin) {

            c->role->drained_begin(c);

        }

    }

}


scoped_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const {
  return scoped_ptr<ui::EventTargetIterator>();
}


static char * CreateHtmlSubtitle ( int * pi_align , char * psz_subtitle ) {
 char * psz_tag = malloc ( 1 ) ;
 if ( psz_tag == NULL ) return NULL ;
 char * psz_html = malloc ( 1 ) ;
 if ( psz_html == NULL ) {
 free ( psz_tag ) ;
 return NULL ;
 }
 psz_tag [ 0 ] = '\0' ;
 psz_html [ 0 ] = '\0' ;
 bool b_has_align = false ;
 HtmlPut ( & psz_html , "<text>" ) ;
 while ( * psz_subtitle ) {
 if ( * psz_subtitle == '\n' ) {
 HtmlPut ( & psz_html , "
" ) ;
 psz_subtitle ++ ;
 }
 else if ( * psz_subtitle == '<' ) {
 if ( ! strncasecmp ( psz_subtitle , "
" , 5 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , "
" ) ;
 }
 else if ( ! strncasecmp ( psz_subtitle , "" , 3 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , "" ) ;
 HtmlPut ( & psz_tag , "b" ) ;
 }
 else if ( ! strncasecmp ( psz_subtitle , "" , 3 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , "" ) ;
 HtmlPut ( & psz_tag , "i" ) ;
 }
 else if ( ! strncasecmp ( psz_subtitle , "" , 3 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , "" ) ;
 HtmlPut ( & psz_tag , "u" ) ;
 }
 else if ( ! strncasecmp ( psz_subtitle , "<s>" , 3 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , "<s>" ) ;
 HtmlPut ( & psz_tag , "s" ) ;
 }
 else if ( ! strncasecmp ( psz_subtitle , "<font " , 6 ) ) {
 const char * psz_attribs [ ] = {
 "face=" , "family=" , "size=" , "color=" , "outline-color=" , "shadow-color=" , "outline-level=" , "shadow-level=" , "back-color=" , "alpha=" , NULL }
 ;
 HtmlCopy ( & psz_html , & psz_subtitle , "' ) {
 int k ;
 while ( * psz_subtitle == ' ' ) psz_subtitle ++ ;
 for ( k = 0 ;
 psz_attribs [ k ] ;
 k ++ ) {
 int i_len = strlen ( psz_attribs [ k ] ) ;
 if ( ! strncasecmp ( psz_subtitle , psz_attribs [ k ] , i_len ) ) {
 HtmlPut ( & psz_html , psz_attribs [ k ] ) ;
 psz_subtitle += i_len ;
 while ( * psz_subtitle == ' ' ) psz_subtitle ++ ;
 if ( * psz_subtitle == '"' ) {
 psz_subtitle ++ ;
 i_len = strcspn ( psz_subtitle , "\"" ) ;
 }
 else if ( * psz_subtitle == '\'' ) {
 psz_subtitle ++ ;
 i_len = strcspn ( psz_subtitle , "'" ) ;
 }
 else {
 i_len = strcspn ( psz_subtitle , " \t>" ) ;
 }
 HtmlPut ( & psz_html , "\"" ) ;
 HtmlNPut ( & psz_html , psz_subtitle , i_len ) ;
 HtmlPut ( & psz_html , "\"" ) ;
 psz_subtitle += i_len ;
 if ( * psz_subtitle == '\"' || * psz_subtitle == '\'' ) psz_subtitle ++ ;
 break ;
 }
 }
 if ( psz_attribs [ k ] == NULL ) {
 int i_len = strcspn ( psz_subtitle , "\"" ) ;
 if ( psz_subtitle [ i_len ] == '\"' ) {
 i_len += 1 + strcspn ( & psz_subtitle [ i_len + 1 ] , "\"" ) ;
 if ( psz_subtitle [ i_len ] == '\"' ) i_len ++ ;
 }
 if ( i_len == 0 ) psz_subtitle ++ ;
 psz_subtitle += i_len ;
 }
 HtmlNPut ( & psz_html , psz_subtitle , strspn ( psz_subtitle , " " ) ) ;
 }
 HtmlPut ( & psz_html , ">" ) ;
 psz_subtitle ++ ;
 }
 else if ( ! strncmp ( psz_subtitle , "</" , 2 ) ) {
 bool b_match = false ;
 bool b_ignore = false ;
 int i_len = ( psz_tag ? strlen ( psz_tag ) : 0 ) - 1 ;
 char * psz_lastTag = NULL ;
 if ( i_len >= 0 ) {
 psz_lastTag = psz_tag + i_len ;
 i_len = 0 ;
 switch ( * psz_lastTag ) {
 case 'b' : b_match = ! strncasecmp ( psz_subtitle , "" , 4 ) ;
 i_len = 4 ;
 break ;
 case 'i' : b_match = ! strncasecmp ( psz_subtitle , "" , 4 ) ;
 i_len = 4 ;
 break ;
 case 'u' : b_match = ! strncasecmp ( psz_subtitle , "" , 4 ) ;
 i_len = 4 ;
 break ;
 case 's' : b_match = ! strncasecmp ( psz_subtitle , "</s>" , 4 ) ;
 i_len = 4 ;
 break ;
 case 'f' : b_match = ! strncasecmp ( psz_subtitle , "" , 7 ) ;
 i_len = 7 ;
 break ;
 case 'I' : i_len = strcspn ( psz_subtitle , ">" ) ;
 b_match = psz_subtitle [ i_len ] == '>' ;
 b_ignore = true ;
 if ( b_match ) i_len ++ ;
 break ;
 }
 }
 if ( ! b_match ) {
 free ( psz_html ) ;
 psz_html = NULL ;
 break ;
 }
 * psz_lastTag = '\0' ;
 if ( ! b_ignore ) HtmlNPut ( & psz_html , psz_subtitle , i_len ) ;
 psz_subtitle += i_len ;
 }
 else if ( ( psz_subtitle [ 1 ] < 'a' || psz_subtitle [ 1 ] > 'z' ) && ( psz_subtitle [ 1 ] < 'A' || psz_subtitle [ 1 ] > 'Z' ) ) {
 HtmlPut ( & psz_html , "<
" ) ;
 psz_subtitle ++ ;
 }
 else {
 char * psz_stop = psz_subtitle + 1 + strcspn ( & psz_subtitle [ 1 ] , "<>" ) ;
 char * psz_closing = strstr ( psz_subtitle , "/>" ) ;
 if ( psz_closing && psz_closing < psz_stop ) {
 psz_subtitle = & psz_closing [ 2 ] ;
 }
 else if ( * psz_stop == '>' ) {
 char psz_match [ 256 ] ;
 snprintf ( psz_match , sizeof ( psz_match ) , "</%s" , & psz_subtitle [ 1 ] ) ;
 psz_match [ strcspn ( psz_match , " \t>" ) ] = '\0' ;
 if ( strstr ( psz_subtitle , psz_match ) ) {
 psz_subtitle = & psz_stop [ 1 ] ;
 HtmlPut ( & psz_tag , "I" ) ;
 }
 else {
 int i_len = psz_stop + 1 - psz_subtitle ;
 for ( ;
 i_len > 0 ;
 i_len -- , psz_subtitle ++ ) {
 if ( * psz_subtitle == '<' ) HtmlPut ( & psz_html , "<
" ) ;
 else if ( * psz_subtitle == '>' ) HtmlPut ( & psz_html , ">
" ) ;
 else HtmlNPut ( & psz_html , psz_subtitle , 1 ) ;
 }
 }
 }
 else {
 HtmlPut ( & psz_html , "<
" ) ;
 psz_subtitle ++ ;
 }
 }
 }
 else if ( * psz_subtitle == '&' ) {
 if ( ! strncasecmp ( psz_subtitle , "<
" , 4 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , "<
" ) ;
 }
 else if ( ! strncasecmp ( psz_subtitle , ">
" , 4 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , ">
" ) ;
 }
 else if ( ! strncasecmp ( psz_subtitle , "&
" , 5 ) ) {
 HtmlCopy ( & psz_html , & psz_subtitle , "&
" ) ;
 }
 else {
 HtmlPut ( & psz_html , "&
" ) ;
 psz_subtitle ++ ;
 }
 }
 else if ( * psz_subtitle == '>' ) {
 HtmlPut ( & psz_html , ">
" ) ;
 psz_subtitle ++ ;
 }
 else if ( psz_subtitle [ 0 ] == '{
' && psz_subtitle [ 1 ] == '\\' && strchr ( psz_subtitle , '}
' ) ) {
 if ( ! b_has_align && ! strncmp ( psz_subtitle , "{
\\an" , 4 ) && psz_subtitle [ 4 ] >= '1' && psz_subtitle [ 4 ] <= '9' && psz_subtitle [ 5 ] == '}
' ) {
 static const int pi_vertical [ 3 ] = {
 SUBPICTURE_ALIGN_BOTTOM , 0 , SUBPICTURE_ALIGN_TOP }
 ;
 static const int pi_horizontal [ 3 ] = {
 SUBPICTURE_ALIGN_LEFT , 0 , SUBPICTURE_ALIGN_RIGHT }
 ;
 const int i_id = psz_subtitle [ 4 ] - '1' ;
 b_has_align = true ;
 * pi_align = pi_vertical [ i_id / 3 ] | pi_horizontal [ i_id % 3 ] ;
 }
 psz_subtitle = strchr ( psz_subtitle , '}
' ) + 1 ;
 }
 else if ( psz_subtitle [ 0 ] == '{
' && ( psz_subtitle [ 1 ] == 'Y' || psz_subtitle [ 1 ] == 'y' ) && psz_subtitle [ 2 ] == ':' && strchr ( psz_subtitle , '}
' ) ) {
 if ( psz_subtitle [ 3 ] == 'i' ) {
 HtmlPut ( & psz_html , "" ) ;
 HtmlPut ( & psz_tag , "i" ) ;
 }
 if ( psz_subtitle [ 3 ] == 'b' ) {
 HtmlPut ( & psz_html , "" ) ;
 HtmlPut ( & psz_tag , "b" ) ;
 }
 if ( psz_subtitle [ 3 ] == 'u' ) {
 HtmlPut ( & psz_html , "" ) ;
 HtmlPut ( & psz_tag , "u" ) ;
 }
 psz_subtitle = strchr ( psz_subtitle , '}
' ) + 1 ;
 }
 else if ( psz_subtitle [ 0 ] == '{
' && psz_subtitle [ 2 ] == ':' && strchr ( psz_subtitle , '}
' ) ) {
 psz_subtitle = strchr ( psz_subtitle , '}
' ) + 1 ;
 }
 else if ( psz_subtitle [ 0 ] == '\\' && psz_subtitle [ 1 ] ) {
 if ( psz_subtitle [ 1 ] == 'N' || psz_subtitle [ 1 ] == 'n' ) {
 HtmlPut ( & psz_html , "
" ) ;
 psz_subtitle += 2 ;
 }
 else if ( psz_subtitle [ 1 ] == 'h' ) {
 HtmlPut ( & psz_html , NO_BREAKING_SPACE ) ;
 psz_subtitle += 2 ;
 }
 else {
 HtmlPut ( & psz_html , "\\" ) ;
 psz_subtitle ++ ;
 }
 }
 else {
 HtmlNPut ( & psz_html , psz_subtitle , 1 ) ;
 # if 0 if ( * psz_html ) {
 # error This test does not make sense . if ( ( * psz_html == ' ' || * psz_html == '\t' ) && ( * ( psz_html - 1 ) == ' ' || * ( psz_html - 1 ) == '\t' ) ) {
 HtmlPut ( & psz_html , NO_BREAKING_SPACE ) ;
 psz_html -- ;
 }
 }
 # endif psz_subtitle ++ ;
 }
 }
 while ( psz_tag && * psz_tag ) {
 char * psz_last = & psz_tag [ strlen ( psz_tag ) - 1 ] ;
 switch ( * psz_last ) {
 case 'b' : HtmlPut ( & psz_html , "" ) ;
 break ;
 case 'i' : HtmlPut ( & psz_html , "" ) ;
 break ;
 case 'u' : HtmlPut ( & psz_html , "" ) ;
 break ;
 case 's' : HtmlPut ( & psz_html , "</s>" ) ;
 break ;
 case 'f' : HtmlPut ( & psz_html , "" ) ;
 break ;
 case 'I' : break ;
 }
 * psz_last = '\0' ;
 }
 HtmlPut ( & psz_html , "</text>" ) ;
 free ( psz_tag ) ;
 return psz_html ;
 }


static int megasas_cluster_reset_ld(MegasasState *s, MegasasCmd *cmd)
{
    uint16_t target_id;
    int i;

    /* mbox0 contains the device index */
    target_id = le16_to_cpu(cmd->frame->dcmd.mbox[0]);
    trace_megasas_dcmd_reset_ld(cmd->index, target_id);
    for (i = 0; i < s->fw_cmds; i++) {
        MegasasCmd *tmp_cmd = &s->frames[i];
        if (tmp_cmd->req && tmp_cmd->req->dev->id == target_id) {
            SCSIDevice *d = tmp_cmd->req->dev;
            qdev_reset_all(&d->qdev);
        }
    }
    return MFI_STAT_OK;
}


gx_device_raster(const gx_device * dev, bool pad)
{
    ulong bits = (ulong) dev->width * dev->color_info.depth;
    ulong raster;
    int l2align;

    if (dev->is_planar)
        bits /= dev->color_info.num_components;

    raster = (uint)((bits + 7) >> 3);
    if (!pad)
        return raster;
    l2align = dev->log2_align_mod;
    if (l2align < log2_align_bitmap_mod)
        l2align = log2_align_bitmap_mod;
    return (uint)(((bits + (8 << l2align) - 1) >> (l2align + 3)) << l2align);
}


newSWFInput_buffer(unsigned char* buffer, int length)
{
	SWFInput input = (SWFInput) malloc(sizeof(struct SWFInput_s));

	/* If malloc failed, return NULL to signify this */
	if (NULL == input)
		return NULL;

	input->getChar = SWFInput_buffer_getChar;
	input->destroy = SWFInput_dtor;
	input->eof = SWFInput_buffer_eof;
	input->read = SWFInput_buffer_read;
	input->seek = SWFInput_buffer_seek;
	input->data = buffer;
	input->buffer = 0;
	input->bufbits = 0;
	input->offset = 0;
	input->length = length;

#if TRACK_ALLOCS
	input->gcnode = ming_gc_add_node(input, (dtorfunctype) destroySWFInput);
#endif

	return input;
}


void GDataCache::GetFileOnUIThread(const std::string& resource_id,
                                   const std::string& md5,
                                   const GetFileFromCacheCallback& callback) {
  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

  base::PlatformFileError* error =
      new base::PlatformFileError(base::PLATFORM_FILE_OK);
  FilePath* cache_file_path = new FilePath;
  pool_->GetSequencedTaskRunner(sequence_token_)->PostTaskAndReply(
      FROM_HERE,
      base::Bind(&GDataCache::GetFile,
                 base::Unretained(this),
                 resource_id,
                 md5,
                 error,
                 cache_file_path),
      base::Bind(&RunGetFileFromCacheCallback,
                 callback,
                 base::Owned(error),
                 resource_id,
                 md5,
                 base::Owned(cache_file_path)));
}


static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
{
	union {
		u64 v64;
		u32 v32[2];
	} d = { dividend };
	u32 upper;

	upper = d.v32[1];
	d.v32[1] = 0;
	if (upper >= divisor) {
		d.v32[1] = upper / divisor;
		upper %= divisor;
	}
	asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) :
		"rm" (divisor), "0" (d.v32[0]), "1" (upper));
	return d.v64;
}


static int pptp_create(struct net *net, struct socket *sock, int kern)
{
	int error = -ENOMEM;
	struct sock *sk;
	struct pppox_sock *po;
	struct pptp_opt *opt;

	sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pptp_sk_proto, kern);
	if (!sk)
		goto out;

	sock_init_data(sock, sk);

	sock->state = SS_UNCONNECTED;
	sock->ops   = &pptp_ops;

	sk->sk_backlog_rcv = pptp_rcv_core;
	sk->sk_state       = PPPOX_NONE;
	sk->sk_type        = SOCK_STREAM;
	sk->sk_family      = PF_PPPOX;
	sk->sk_protocol    = PX_PROTO_PPTP;
	sk->sk_destruct    = pptp_sock_destruct;

	po = pppox_sk(sk);
	opt = &po->proto.pptp;

	opt->seq_sent = 0; opt->seq_recv = 0xffffffff;
	opt->ack_recv = 0; opt->ack_sent = 0xffffffff;

	error = 0;
out:
	return error;
}


void ZydisFormatterBufferInit(ZydisFormatterBuffer* buffer, char* user_buffer,
    ZyanUSize length)
{
    ZYAN_ASSERT(buffer);
    ZYAN_ASSERT(user_buffer);
    ZYAN_ASSERT(length);

    buffer->is_token_list              = ZYAN_FALSE;
    buffer->string.flags               = ZYAN_STRING_HAS_FIXED_CAPACITY;
    buffer->string.vector.allocator    = ZYAN_NULL;
    buffer->string.vector.element_size = sizeof(char);
    buffer->string.vector.size         = 1;
    buffer->string.vector.capacity     = length;
    buffer->string.vector.data         = user_buffer;
    *user_buffer = '\0';
}


PJ_DEF(pj_status_t) pj_stun_msg_encode(pj_stun_msg *msg,
				       pj_uint8_t *buf, pj_size_t buf_size,
				       unsigned options,
				       const pj_str_t *key,
				       pj_size_t *p_msg_len)
{
    pj_uint8_t *start = buf;
    pj_stun_msgint_attr *amsgint = NULL;
    pj_stun_fingerprint_attr *afingerprint = NULL;
    unsigned printed = 0, body_len;
    pj_status_t status;
    unsigned i;

    PJ_ASSERT_RETURN(msg && buf && buf_size, PJ_EINVAL);

    PJ_UNUSED_ARG(options);
    PJ_ASSERT_RETURN(options == 0, PJ_EINVAL);

    /* Copy the message header part and convert the header fields to
     * network byte order
     */
    if (buf_size < sizeof(pj_stun_msg_hdr))
	return PJ_ETOOSMALL;

    PUTVAL16H(buf, 0, msg->hdr.type);
    PUTVAL16H(buf, 2, 0);   /* length will be calculated later */
    PUTVAL32H(buf, 4, msg->hdr.magic);
    pj_memcpy(buf+8, msg->hdr.tsx_id, sizeof(msg->hdr.tsx_id));

    buf += sizeof(pj_stun_msg_hdr);
    buf_size -= sizeof(pj_stun_msg_hdr);

    /* Encode each attribute to the message */
    for (i=0; i<msg->attr_count; ++i) {
	const struct attr_desc *adesc;
	const pj_stun_attr_hdr *attr_hdr = msg->attr[i];

	if (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) {
	    pj_assert(amsgint == NULL);
	    amsgint = (pj_stun_msgint_attr*) attr_hdr;

	    /* Stop when encountering MESSAGE-INTEGRITY */
	    break;

	} else if (attr_hdr->type == PJ_STUN_ATTR_FINGERPRINT) {
	    afingerprint = (pj_stun_fingerprint_attr*) attr_hdr;
	    break;
	}

	adesc = find_attr_desc(attr_hdr->type);
	if (adesc) {
	    status = adesc->encode_attr(attr_hdr, buf, (unsigned)buf_size,
					&msg->hdr, &printed);
	} else {
	    /* This may be a generic attribute */
	    const pj_stun_binary_attr *bin_attr = (const pj_stun_binary_attr*)
						   attr_hdr;
	    PJ_ASSERT_RETURN(bin_attr->magic == PJ_STUN_MAGIC, PJ_EBUG);
	    status = encode_binary_attr(bin_attr, buf, (unsigned)buf_size,
					&msg->hdr, &printed);
	}

	if (status != PJ_SUCCESS)
	    return status;

	buf += printed;
	buf_size -= printed;
    }

    /* We may have stopped printing attribute because we found
     * MESSAGE-INTEGRITY or FINGERPRINT. Scan the rest of the
     * attributes.
     */
    for ( ++i; i<msg->attr_count; ++i) {
	const pj_stun_attr_hdr *attr_hdr = msg->attr[i];

	/* There mustn't any attribute after FINGERPRINT */
	PJ_ASSERT_RETURN(afingerprint == NULL, PJNATH_ESTUNFINGERPOS);

	if (attr_hdr->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY) {
	    /* There mustn't be MESSAGE-INTEGRITY before */
	    PJ_ASSERT_RETURN(amsgint == NULL,
			     PJNATH_ESTUNMSGINTPOS);
	    amsgint = (pj_stun_msgint_attr*) attr_hdr;

	} else if (attr_hdr->type == PJ_STUN_ATTR_FINGERPRINT) {
	    afingerprint = (pj_stun_fingerprint_attr*) attr_hdr;
	}
    }

#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT
    /*
     * This is the old style MESSAGE-INTEGRITY and FINGERPRINT
     * calculation, used in rfc3489bis-06 and older.
     */
    /* We MUST update the message length in the header NOW before
     * calculating MESSAGE-INTEGRITY and FINGERPRINT.
     * Note that length is not including the 20 bytes header.
      */
    if (amsgint && afingerprint) {
	body_len = (pj_uint16_t)((buf - start) - 20 + 24 + 8);
    } else if (amsgint) {
	body_len = (pj_uint16_t)((buf - start) - 20 + 24);
    } else if (afingerprint) {
	body_len = (pj_uint16_t)((buf - start) - 20 + 8);
    } else {
	body_len = (pj_uint16_t)((buf - start) - 20);
    }
#else
    /* If MESSAGE-INTEGRITY is present, include the M-I attribute
     * in message length before calculating M-I
     */
    if (amsgint) {
	body_len = (pj_uint16_t)((buf - start) - 20 + 24);
    } else {
	body_len = (pj_uint16_t)((buf - start) - 20);
    }
#endif	/* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */

    /* hdr->length = pj_htons(length); */
    PUTVAL16H(start, 2, (pj_uint16_t)body_len);

    /* Calculate message integrity, if present */
    if (amsgint != NULL) {
	pj_hmac_sha1_context ctx;

	/* Key MUST be specified */
	PJ_ASSERT_RETURN(key, PJ_EINVALIDOP);

	/* MESSAGE-INTEGRITY must be the last attribute in the message, or
	 * the last attribute before FINGERPRINT.
	 */
	if (msg->attr_count>1 && i < msg->attr_count-2) {
	    /* Should not happen for message generated by us */
	    pj_assert(PJ_FALSE);
	    return PJNATH_ESTUNMSGINTPOS;

	} else if (i == msg->attr_count-2)  {
	    if (msg->attr[i+1]->type != PJ_STUN_ATTR_FINGERPRINT) {
		/* Should not happen for message generated by us */
		pj_assert(PJ_FALSE);
		return PJNATH_ESTUNMSGINTPOS;
	    } else {
		afingerprint = (pj_stun_fingerprint_attr*) msg->attr[i+1];
	    }
	}

	/* Calculate HMAC-SHA1 digest, add zero padding to input
	 * if necessary to make the input 64 bytes aligned.
	 */
	pj_hmac_sha1_init(&ctx, (const pj_uint8_t*)key->ptr,
			  (unsigned)key->slen);
	pj_hmac_sha1_update(&ctx, (const pj_uint8_t*)start,
			    (unsigned)(buf-start));
#if PJ_STUN_OLD_STYLE_MI_FINGERPRINT
	// These are obsoleted in rfc3489bis-08
	if ((buf-start) & 0x3F) {
	    pj_uint8_t zeroes[64];
	    pj_bzero(zeroes, sizeof(zeroes));
	    pj_hmac_sha1_update(&ctx, zeroes, 64-((buf-start) & 0x3F));
	}
#endif	/* PJ_STUN_OLD_STYLE_MI_FINGERPRINT */
	pj_hmac_sha1_final(&ctx, amsgint->hmac);

	/* Put this attribute in the message */
	status = encode_msgint_attr(amsgint, buf, (unsigned)buf_size,
			            &msg->hdr, &printed);
	if (status != PJ_SUCCESS)
	    return status;

	buf += printed;
	buf_size -= printed;
    }

    /* Calculate FINGERPRINT if present */
    if (afingerprint != NULL) {

#if !PJ_STUN_OLD_STYLE_MI_FINGERPRINT
	/* Update message length */
	PUTVAL16H(start, 2,
		 (pj_uint16_t)(GETVAL16H(start, 2)+8));
#endif

	afingerprint->value = pj_crc32_calc(start, buf-start);
	afingerprint->value ^= STUN_XOR_FINGERPRINT;

	/* Put this attribute in the message */
	status = encode_uint_attr(afingerprint, buf, (unsigned)buf_size,
				  &msg->hdr, &printed);
	if (status != PJ_SUCCESS)
	    return status;

	buf += printed;
	buf_size -= printed;
    }

    /* Update message length. */
    msg->hdr.length = (pj_uint16_t) ((buf - start) - 20);

    /* Return the length */
    if (p_msg_len)
	*p_msg_len = (buf - start);

    return PJ_SUCCESS;
}


static void *saved_tgids_next(struct seq_file *m, void *v, loff_t *pos)
{
	int *ptr = v;

	if (*pos || m->count)
		ptr++;

	(*pos)++;

	for (; ptr <= &tgid_map[PID_MAX_DEFAULT]; ptr++) {
		if (trace_find_tgid(*ptr))
			return ptr;
	}

	return NULL;
}


void FrameLoader::Load(const FrameLoadRequest& passed_request,
                       FrameLoadType frame_load_type,
                       HistoryItem* history_item,
                       HistoryLoadType history_load_type) {
  DCHECK(frame_->GetDocument());

  if (IsBackForwardLoadType(frame_load_type) && !frame_->IsNavigationAllowed())
    return;

  if (in_stop_all_loaders_)
    return;

  FrameLoadRequest request(passed_request);
  request.GetResourceRequest().SetHasUserGesture(
      Frame::HasTransientUserActivation(frame_));

  if (!PrepareRequestForThisFrame(request))
    return;

  Frame* target_frame = request.Form()
                            ? nullptr
                            : frame_->FindFrameForNavigation(
                                  AtomicString(request.FrameName()), *frame_,
                                  request.GetResourceRequest().Url());

  NavigationPolicy policy = NavigationPolicyForRequest(request);
  if (target_frame && target_frame != frame_ &&
      ShouldNavigateTargetFrame(policy)) {
    if (target_frame->IsLocalFrame() &&
        !ToLocalFrame(target_frame)->IsNavigationAllowed()) {
      return;
    }

    bool was_in_same_page = target_frame->GetPage() == frame_->GetPage();

    request.SetFrameName("_self");
    target_frame->Navigate(request);
    Page* page = target_frame->GetPage();
    if (!was_in_same_page && page)
      page->GetChromeClient().Focus();
    return;
  }

  SetReferrerForFrameRequest(request);

  if (!target_frame && !request.FrameName().IsEmpty()) {
    if (policy == kNavigationPolicyDownload) {
      Client()->DownloadURL(request.GetResourceRequest(), String());
      return;  // Navigation/download will be handled by the client.
    } else if (ShouldNavigateTargetFrame(policy)) {
      request.GetResourceRequest().SetFrameType(
          network::mojom::RequestContextFrameType::kAuxiliary);
      CreateWindowForRequest(request, *frame_, policy);
      return;  // Navigation will be handled by the new frame/window.
    }
  }

  if (!frame_->IsNavigationAllowed())
    return;

  const KURL& url = request.GetResourceRequest().Url();
  FrameLoadType new_load_type = (frame_load_type == kFrameLoadTypeStandard)
                                    ? DetermineFrameLoadType(request)
                                    : frame_load_type;
  bool same_document_history_navigation =
      IsBackForwardLoadType(new_load_type) &&
      history_load_type == kHistorySameDocumentLoad;
  bool same_document_navigation =
      policy == kNavigationPolicyCurrentTab &&
      ShouldPerformFragmentNavigation(request.Form(),
                                      request.GetResourceRequest().HttpMethod(),
                                      new_load_type, url);

  if (same_document_history_navigation || same_document_navigation) {
    DCHECK(history_item || !same_document_history_navigation);
    scoped_refptr<SerializedScriptValue> state_object =
        same_document_history_navigation ? history_item->StateObject()
                                         : nullptr;

    if (!same_document_history_navigation) {
      document_loader_->SetNavigationType(DetermineNavigationType(
          new_load_type, false, request.TriggeringEvent()));
      if (ShouldTreatURLAsSameAsCurrent(url))
        new_load_type = kFrameLoadTypeReplaceCurrentItem;
    }

    LoadInSameDocument(url, state_object, new_load_type, history_item,
                       request.ClientRedirect(), request.OriginDocument());
    return;
  }

  if (request.GetResourceRequest().IsSameDocumentNavigation())
    return;

  StartLoad(request, new_load_type, policy, history_item);
}


struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
				       struct ieee80211_vif *vif,
				       const u8 *ssid, size_t ssid_len,
				       size_t tailroom)
{
	struct ieee80211_sub_if_data *sdata;
	struct ieee80211_local *local;
	struct ieee80211_hdr_3addr *hdr;
	struct sk_buff *skb;
	size_t ie_ssid_len;
	u8 *pos;

	sdata = vif_to_sdata(vif);
	local = sdata->local;
	ie_ssid_len = 2 + ssid_len;

	skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*hdr) +
			    ie_ssid_len + tailroom);
	if (!skb)
		return NULL;

	skb_reserve(skb, local->hw.extra_tx_headroom);

	hdr = (struct ieee80211_hdr_3addr *) skb_put(skb, sizeof(*hdr));
	memset(hdr, 0, sizeof(*hdr));
	hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
					 IEEE80211_STYPE_PROBE_REQ);
	eth_broadcast_addr(hdr->addr1);
	memcpy(hdr->addr2, vif->addr, ETH_ALEN);
	eth_broadcast_addr(hdr->addr3);

	pos = skb_put(skb, ie_ssid_len);
	*pos++ = WLAN_EID_SSID;
	*pos++ = ssid_len;
	if (ssid_len)
		memcpy(pos, ssid, ssid_len);
	pos += ssid_len;

	return skb;
}


SYSCALL_DEFINE4(recv, int, fd, void __user *, ubuf, size_t, size,
		unsigned int, flags)
{
	return __sys_recvfrom(fd, ubuf, size, flags, NULL, NULL);
}


    //! Construct list as a copy of an existing list and force shared state of elements \inplace \specialization.
    CImgList<T>& assign(const CImgList<T>& list, const bool is_shared=false) {
      if (this==&list) return *this;
      CImgList<T> res(list._width);
      cimglist_for(res,l) res[l].assign(list[l],is_shared);
      return res.move_to(*this);


Ta27AST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename,
               PyArena *arena)
{
    int i, j, k, num;
    asdl_seq *stmts = NULL;
    asdl_seq *type_ignores = NULL;
    stmt_ty s;
    node *ch;
    struct compiling c;
    asdl_seq *argtypes = NULL;
    expr_ty ret, arg;

    if (flags && flags->cf_flags & PyCF_SOURCE_IS_UTF8) {
        c.c_encoding = "utf-8";
        if (TYPE(n) == encoding_decl) {
            ast_error(n, "encoding declaration in Unicode string");
            goto error;
        }
    } else if (TYPE(n) == encoding_decl) {
        c.c_encoding = STR(n);
        n = CHILD(n, 0);
    } else {
        c.c_encoding = NULL;
    }
    c.c_future_unicode = flags && flags->cf_flags & CO_FUTURE_UNICODE_LITERALS;
    c.c_arena = arena;
    c.c_filename = filename;

    k = 0;
    switch (TYPE(n)) {
        case file_input:
            stmts = asdl_seq_new(num_stmts(n), arena);
            if (!stmts)
                return NULL;
            for (i = 0; i < NCH(n) - 1; i++) {
                ch = CHILD(n, i);
                if (TYPE(ch) == NEWLINE)
                    continue;
                REQ(ch, stmt);
                num = num_stmts(ch);
                if (num == 1) {
                    s = ast_for_stmt(&c, ch);
                    if (!s)
                        goto error;
                    asdl_seq_SET(stmts, k++, s);
                }
                else {
                    ch = CHILD(ch, 0);
                    REQ(ch, simple_stmt);
                    for (j = 0; j < num; j++) {
                        s = ast_for_stmt(&c, CHILD(ch, j * 2));
                        if (!s)
                            goto error;
                        asdl_seq_SET(stmts, k++, s);
                    }
                }
            }
            /* Type ignores are stored under the ENDMARKER in file_input. */
            ch = CHILD(n, NCH(n) - 1);
            REQ(ch, ENDMARKER);
            num = NCH(ch);
            type_ignores = _Py_asdl_seq_new(num, arena);
            if (!type_ignores)
                goto error;

            for (i = 0; i < num; i++) {
                type_ignore_ty ti = TypeIgnore(LINENO(CHILD(ch, i)), arena);
                if (!ti)
                    goto error;
                asdl_seq_SET(type_ignores, i, ti);
            }

            return Module(stmts, type_ignores, arena);
        case eval_input: {
            expr_ty testlist_ast;

            /* XXX Why not comp_for here? */
            testlist_ast = ast_for_testlist(&c, CHILD(n, 0));
            if (!testlist_ast)
                goto error;
            return Expression(testlist_ast, arena);
        }
        case single_input:
            if (TYPE(CHILD(n, 0)) == NEWLINE) {
                stmts = asdl_seq_new(1, arena);
                if (!stmts)
                    goto error;
                asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset,
                                            arena));
                if (!asdl_seq_GET(stmts, 0))
                    goto error;
                return Interactive(stmts, arena);
            }
            else {
                n = CHILD(n, 0);
                num = num_stmts(n);
                stmts = asdl_seq_new(num, arena);
                if (!stmts)
                    goto error;
                if (num == 1) {
                    s = ast_for_stmt(&c, n);
                    if (!s)
                        goto error;
                    asdl_seq_SET(stmts, 0, s);
                }
                else {
                    /* Only a simple_stmt can contain multiple statements. */
                    REQ(n, simple_stmt);
                    for (i = 0; i < NCH(n); i += 2) {
                        if (TYPE(CHILD(n, i)) == NEWLINE)
                            break;
                        s = ast_for_stmt(&c, CHILD(n, i));
                        if (!s)
                            goto error;
                        asdl_seq_SET(stmts, i / 2, s);
                    }
                }

                return Interactive(stmts, arena);
            }
        case func_type_input:
            n = CHILD(n, 0);
            REQ(n, func_type);

            if (TYPE(CHILD(n, 1)) == typelist) {
                ch = CHILD(n, 1);
                /* this is overly permissive -- we don't pay any attention to
                 * stars on the args -- just parse them into an ordered list */
                num = 0;
                for (i = 0; i < NCH(ch); i++) {
                    if (TYPE(CHILD(ch, i)) == test)
                        num++;
                }

                argtypes = _Py_asdl_seq_new(num, arena);

                j = 0;
                for (i = 0; i < NCH(ch); i++) {
                    if (TYPE(CHILD(ch, i)) == test) {
                        arg = ast_for_expr(&c, CHILD(ch, i));
                        if (!arg)
                            goto error;
                        asdl_seq_SET(argtypes, j++, arg);
                    }
                }
            }
            else
                argtypes = _Py_asdl_seq_new(0, arena);

            ret = ast_for_expr(&c, CHILD(n, NCH(n) - 1));
            if (!ret)
                goto error;
            return FunctionType(argtypes, ret, arena);
        default:
            PyErr_Format(PyExc_SystemError,
                         "invalid node %d for Ta27AST_FromNode", TYPE(n));
            goto error;
    }
 error:
    ast_error_finish(filename);
    return NULL;
}


onig_print_statistics(FILE* f)
{
  int r;
  int i;

  r = fprintf(f, "   count      prev        time\n");
  if (r < 0) return -1;

  for (i = 0; OnigOpInfo[i].opcode >= 0; i++) {
    r = fprintf(f, "%8d: %8d: %10ld: %s\n",
                OpCounter[i], OpPrevCounter[i], OpTime[i], OnigOpInfo[i].name);
    if (r < 0) return -1;
  }
  r = fprintf(f, "\nmax stack depth: %d\n", MaxStackDepth);
  if (r < 0) return -1;

  return 0;
}


static void dumpdbl ( FILE * cfff , double d ) {
 if ( d - rint ( d ) > - .00001 && d - rint ( d ) < .00001 ) dumpint ( cfff , ( int ) d ) ;
 else {
 char buffer [ 20 ] , * pt ;
 int sofar , n , odd ;
 sprintf ( buffer , "%g" , d ) ;
 sofar = 0 ;
 odd = true ;
 putc ( 30 , cfff ) ;
 for ( pt = buffer ;
 * pt ;
 ++ pt ) {
 if ( isdigit ( * pt ) ) n = * pt - '0' ;
 else if ( * pt == '.' ) n = 0xa ;
 else if ( * pt == '-' ) n = 0xe ;
 else if ( ( * pt == 'E' || * pt == 'e' ) && pt [ 1 ] == '-' ) {
 n = 0xc ;
 ++ pt ;
 }
 else if ( * pt == 'E' || * pt == 'e' ) n = 0xb ;
 else n = 0 ;
 if ( odd ) {
 sofar = n << 4 ;
 odd = false ;
 }
 else {
 putc ( sofar | n , cfff ) ;
 sofar = 0 ;
 odd = true ;
 }
 }
 if ( sofar == 0 ) putc ( 0xff , cfff ) ;
 else putc ( sofar | 0xf , cfff ) ;
 }
 }


void GLES2DecoderImpl::DoGetSamplerParameterfv(GLuint client_id,
                                               GLenum pname,
                                               GLfloat* params,
                                               GLsizei params_size) {
  Sampler* sampler = GetSampler(client_id);
  if (!sampler) {
    LOCAL_SET_GL_ERROR(
        GL_INVALID_OPERATION, "glGetSamplerParamterfv", "unknown sampler");
    return;
  }
  api()->glGetSamplerParameterfvFn(sampler->service_id(), pname, params);
}


v8::Handle<v8::Value> V8ThrowException::createSyntaxError(v8::Isolate* isolate, const String& message)
{
    return v8::Exception::SyntaxError(v8String(isolate, message.isNull() ? "Syntax error" : message));
}


static int netlink_dump(struct sock *sk)
{
	struct netlink_sock *nlk = nlk_sk(sk);
	struct netlink_callback *cb;
	struct sk_buff *skb = NULL;
	struct nlmsghdr *nlh;
	int len, err = -ENOBUFS;
	int alloc_min_size;
	int alloc_size;

	mutex_lock(nlk->cb_mutex);
	if (!nlk->cb_running) {
		err = -EINVAL;
		goto errout_skb;
	}

	if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
		goto errout_skb;

	/* NLMSG_GOODSIZE is small to avoid high order allocations being
	 * required, but it makes sense to _attempt_ a 16K bytes allocation
	 * to reduce number of system calls on dump operations, if user
	 * ever provided a big enough buffer.
	 */
	cb = &nlk->cb;
	alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);

	if (alloc_min_size < nlk->max_recvmsg_len) {
		alloc_size = nlk->max_recvmsg_len;
		skb = alloc_skb(alloc_size, GFP_KERNEL |
					    __GFP_NOWARN | __GFP_NORETRY);
	}
	if (!skb) {
		alloc_size = alloc_min_size;
		skb = alloc_skb(alloc_size, GFP_KERNEL);
	}
	if (!skb)
		goto errout_skb;

	/* Trim skb to allocated size. User is expected to provide buffer as
	 * large as max(min_dump_alloc, 16KiB (mac_recvmsg_len capped at
	 * netlink_recvmsg())). dump will pack as many smaller messages as
	 * could fit within the allocated skb. skb is typically allocated
	 * with larger space than required (could be as much as near 2x the
	 * requested size with align to next power of 2 approach). Allowing
	 * dump to use the excess space makes it difficult for a user to have a
	 * reasonable static buffer based on the expected largest dump of a
	 * single netdev. The outcome is MSG_TRUNC error.
	 */
	skb_reserve(skb, skb_tailroom(skb) - alloc_size);
	netlink_skb_set_owner_r(skb, sk);

	len = cb->dump(skb, cb);

	if (len > 0) {
		mutex_unlock(nlk->cb_mutex);

		if (sk_filter(sk, skb))
			kfree_skb(skb);
		else
			__netlink_sendskb(sk, skb);
		return 0;
	}

	nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(len), NLM_F_MULTI);
	if (!nlh)
		goto errout_skb;

	nl_dump_check_consistent(cb, nlh);

	memcpy(nlmsg_data(nlh), &len, sizeof(len));

	if (sk_filter(sk, skb))
		kfree_skb(skb);
	else
		__netlink_sendskb(sk, skb);

	if (cb->done)
		cb->done(cb);

	nlk->cb_running = false;
	mutex_unlock(nlk->cb_mutex);
	module_put(cb->module);
	consume_skb(cb->skb);
	return 0;

errout_skb:
	mutex_unlock(nlk->cb_mutex);
	kfree_skb(skb);
	return err;
}


bool skipFilter() const { return filter_match_state_ && filter_match_state_->skipFilter(); }


long FS_ReadFileDir(const char *qpath, void *searchPath, qboolean unpure, void **buffer)
{
	fileHandle_t	h;
	searchpath_t	*search;
	byte*			buf;
	qboolean		isConfig;
	long				len;

	if ( !fs_searchpaths ) {
		Com_Error( ERR_FATAL, "Filesystem call made without initialization" );
	}

	if ( !qpath || !qpath[0] ) {
		Com_Error( ERR_FATAL, "FS_ReadFile with empty name" );
	}

	buf = NULL;	// quiet compiler warning

	// if this is a .cfg file and we are playing back a journal, read
	// it from the journal file
	if ( strstr( qpath, ".cfg" ) ) {
		isConfig = qtrue;
		if ( com_journal && com_journal->integer == 2 ) {
			int		r;

			Com_DPrintf( "Loading %s from journal file.\n", qpath );
			r = FS_Read( &len, sizeof( len ), com_journalDataFile );
			if ( r != sizeof( len ) ) {
				if (buffer != NULL) *buffer = NULL;
				return -1;
			}
			// if the file didn't exist when the journal was created
			if (!len) {
				if (buffer == NULL) {
					return 1;			// hack for old journal files
				}
				*buffer = NULL;
				return -1;
			}
			if (buffer == NULL) {
				return len;
			}

			buf = Hunk_AllocateTempMemory(len+1);
			*buffer = buf;

			r = FS_Read( buf, len, com_journalDataFile );
			if ( r != len ) {
				Com_Error( ERR_FATAL, "Read from journalDataFile failed" );
			}

			fs_loadCount++;
			fs_loadStack++;

			// guarantee that it will have a trailing 0 for string operations
			buf[len] = 0;

			return len;
		}
	} else {
		isConfig = qfalse;
	}

	search = searchPath;

	if(search == NULL)
	{
		// look for it in the filesystem or pack files
		len = FS_FOpenFileRead(qpath, &h, qfalse);
	}
	else
	{
		// look for it in a specific search path only
		len = FS_FOpenFileReadDir(qpath, search, &h, qfalse, unpure);
	}

	if ( h == 0 ) {
		if ( buffer ) {
			*buffer = NULL;
		}
		// if we are journalling and it is a config file, write a zero to the journal file
		if ( isConfig && com_journal && com_journal->integer == 1 ) {
			Com_DPrintf( "Writing zero for %s to journal file.\n", qpath );
			len = 0;
			FS_Write( &len, sizeof( len ), com_journalDataFile );
			FS_Flush( com_journalDataFile );
		}
		return -1;
	}

	if ( !buffer ) {
		if ( isConfig && com_journal && com_journal->integer == 1 ) {
			Com_DPrintf( "Writing len for %s to journal file.\n", qpath );
			FS_Write( &len, sizeof( len ), com_journalDataFile );
			FS_Flush( com_journalDataFile );
		}
		FS_FCloseFile( h);
		return len;
	}

	fs_loadCount++;
	fs_loadStack++;

	buf = Hunk_AllocateTempMemory(len+1);
	*buffer = buf;

	FS_Read (buf, len, h);

	// guarantee that it will have a trailing 0 for string operations
	buf[len] = 0;
	FS_FCloseFile( h );

	// if we are journalling and it is a config file, write it to the journal file
	if ( isConfig && com_journal && com_journal->integer == 1 ) {
		Com_DPrintf( "Writing %s to journal file.\n", qpath );
		FS_Write( &len, sizeof( len ), com_journalDataFile );
		FS_Write( buf, len, com_journalDataFile );
		FS_Flush( com_journalDataFile );
	}
	return len;
}


static gboolean ng_file_seek_rand ( wtap * wth , gint64 offset , int * err , gchar * * err_info ) {
 ngsniffer_t * ngsniffer ;
 gint64 delta ;
 GList * new_list , * next_list ;
 blob_info_t * next_blob , * new_blob ;
 ngsniffer = ( ngsniffer_t * ) wth -> priv ;
 if ( wth -> file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED ) {
 if ( file_seek ( wth -> random_fh , offset , SEEK_SET , err ) == - 1 ) return FALSE ;
 return TRUE ;
 }
 delta = offset - ngsniffer -> rand . uncomp_offset ;
 new_list = NULL ;
 if ( delta > 0 ) {
 if ( ( size_t ) ( ngsniffer -> rand . nextout + delta ) >= ngsniffer -> rand . nbytes ) {
 if ( ngsniffer -> current_blob == NULL ) {
 new_list = ngsniffer -> first_blob ;
 }
 else {
 new_list = g_list_next ( ngsniffer -> current_blob ) ;
 }
 while ( new_list ) {
 next_list = g_list_next ( new_list ) ;
 if ( next_list == NULL ) {
 break ;
 }
 next_blob = ( blob_info_t * ) next_list -> data ;
 if ( next_blob -> blob_uncomp_offset > offset ) break ;
 new_list = next_list ;
 }
 if ( new_list == NULL ) {
 * err = WTAP_ERR_CANT_SEEK ;
 return FALSE ;
 }
 }
 }
 else if ( delta < 0 ) {
 if ( ngsniffer -> rand . nextout + delta < 0 ) {
 if ( ngsniffer -> current_blob == NULL ) {
 new_list = ngsniffer -> last_blob ;
 }
 else {
 new_list = g_list_previous ( ngsniffer -> current_blob ) ;
 }
 while ( new_list ) {
 new_blob = ( blob_info_t * ) new_list -> data ;
 if ( new_blob -> blob_uncomp_offset <= offset ) break ;
 new_list = g_list_previous ( new_list ) ;
 }
 if ( new_list == NULL ) {
 * err = WTAP_ERR_CANT_SEEK ;
 return FALSE ;
 }
 }
 }
 if ( new_list != NULL ) {
 new_blob = ( blob_info_t * ) new_list -> data ;
 if ( file_seek ( wth -> random_fh , new_blob -> blob_comp_offset , SEEK_SET , err ) == - 1 ) return FALSE ;
 if ( ngsniffer -> rand . buf == NULL ) {
 ngsniffer -> rand . buf = ( unsigned char * ) g_malloc ( OUTBUF_SIZE ) ;
 }
 ngsniffer -> current_blob = new_list ;
 ngsniffer -> rand . uncomp_offset = new_blob -> blob_uncomp_offset ;
 ngsniffer -> rand . comp_offset = new_blob -> blob_comp_offset ;
 if ( ! read_blob ( wth -> random_fh , & ngsniffer -> rand , err , err_info ) ) return FALSE ;
 delta = offset - ngsniffer -> rand . uncomp_offset ;
 g_assert ( delta >= 0 && ( unsigned long ) delta < ngsniffer -> rand . nbytes ) ;
 }
 ngsniffer -> rand . nextout += ( int ) delta ;
 ngsniffer -> rand . uncomp_offset += delta ;
 return TRUE ;
 }


  void ProcessRequest() {
    DCHECK_CURRENTLY_ON(BrowserThread::UI);

    timer.Stop();  // Erase reference to self.

    WallpaperManager* manager = WallpaperManager::Get();
    if (manager->pending_inactive_ == this)
      manager->pending_inactive_ = NULL;

     started_load_at_ = base::Time::Now();

     if (default_) {
      manager->DoSetDefaultWallpaper(account_id_, std::move(on_finish_));
     } else if (!user_wallpaper_.isNull()) {
       SetWallpaper(user_wallpaper_, info_);
     } else if (!wallpaper_path_.empty()) {
      manager->task_runner_->PostTask(
          FROM_HERE,
          base::BindOnce(&WallpaperManager::GetCustomWallpaperInternal,
                         account_id_, info_, wallpaper_path_,
                         true /* update wallpaper */,
                         base::ThreadTaskRunnerHandle::Get(),
                          base::Passed(std::move(on_finish_)),
                          manager->weak_factory_.GetWeakPtr()));
     } else if (!info_.location.empty()) {
      manager->LoadWallpaper(account_id_, info_, true, std::move(on_finish_));
     } else {
       NOTREACHED();
      started_load_at_ = base::Time();
    }
    on_finish_.reset();
  }


int mp_sub_d(fp_int *a, fp_digit b, fp_int *c)
{
    return fp_sub_d(a, b, c);
}


static int x509_crt_check_parent( const mbedtls_x509_crt *child,
                                  const mbedtls_x509_crt *parent,
                                  int top, int bottom )
{
    int need_ca_bit;

    /* Parent must be the issuer */
    if( x509_name_cmp( &child->issuer, &parent->subject ) != 0 )
        return( -1 );

    /* Parent must have the basicConstraints CA bit set as a general rule */
    need_ca_bit = 1;

    /* Exception: v1/v2 certificates that are locally trusted. */
    if( top && parent->version < 3 )
        need_ca_bit = 0;

    /* Exception: self-signed end-entity certs that are locally trusted. */
    if( top && bottom &&
        child->raw.len == parent->raw.len &&
        memcmp( child->raw.p, parent->raw.p, child->raw.len ) == 0 )
    {
        need_ca_bit = 0;
    }

    if( need_ca_bit && ! parent->ca_istrue )
        return( -1 );

#if defined(MBEDTLS_X509_CHECK_KEY_USAGE)
    if( need_ca_bit &&
        mbedtls_x509_crt_check_key_usage( parent, MBEDTLS_X509_KU_KEY_CERT_SIGN ) != 0 )
    {
        return( -1 );
    }
#endif

    return( 0 );
}


static void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)

{

    const char *logfile = qemu_opt_get(opts, "logfile");

    backend->has_logfile = logfile != NULL;

    backend->logfile = logfile ? g_strdup(logfile) : NULL;

    backend->has_logappend = true;

    backend->logappend = qemu_opt_get_bool(opts, "logappend", false);

}


int disrsi_(

  int       stream,
  int      *negate,
  unsigned *value,
  unsigned  count)

  {
  int  c;
  unsigned locval;
  unsigned ndigs;
  char  *cp;
  char  scratch[DIS_BUFSIZ+1];

  assert(negate != NULL);
  assert(value != NULL);
  assert(count);
  assert(stream >= 0);
  assert(dis_getc != NULL);
  assert(dis_gets != NULL);

  memset(scratch, 0, DIS_BUFSIZ+1);
  if (dis_umaxd == 0)
    disiui_();

  switch (c = (*dis_getc)(stream))
    {

    case '-':

    case '+':

      *negate = c == '-';

      if ((*dis_gets)(stream, scratch, count) != (int)count)
        {
        return(DIS_EOD);
        }

      if (count >= dis_umaxd)
        {
        if (count > dis_umaxd)
          goto overflow;

        if (memcmp(scratch, dis_umax, dis_umaxd) > 0)
          goto overflow;
        }

      cp = scratch;

      locval = 0;

      do
        {
        if (((c = *cp++) < '0') || (c > '9'))
          {
          return(DIS_NONDIGIT);
          }

        locval = 10 * locval + c - '0';
        }
      while (--count);

      *value = locval;

      return (DIS_SUCCESS);

      break;

    case '0':

      return (DIS_LEADZRO);

      break;

    case '1':

    case '2':

    case '3':

    case '4':

    case '5':

    case '6':

    case '7':

    case '8':

    case '9':

      ndigs = c - '0';

      if (count > 1)
        {
        if ((*dis_gets)(stream, scratch + 1, count - 1) != (int)count - 1)
          {
          return(DIS_EOD);
          }

        cp = scratch;

        if (count >= dis_umaxd)
          {
          if (count > dis_umaxd)
            break;

          *cp = c;

          if (memcmp(scratch, dis_umax, dis_umaxd) > 0)
            break;
          }

        while (--count)
          {
          if (((c = *++cp) < '0') || (c > '9'))
            {
            return(DIS_NONDIGIT);
            }

          ndigs = 10 * ndigs + c - '0';
          }
        }    /* END if (count > 1) */

      return(disrsi_(stream, negate, value, ndigs));

      /*NOTREACHED*/

      break;

    case - 1:

      return(DIS_EOD);

      /*NOTREACHED*/

      break;

    case -2:

      return(DIS_EOF);

      /*NOTREACHED*/

      break;

    default:

      return(DIS_NONDIGIT);

      /*NOTREACHED*/

      break;
    }

  *negate = FALSE;

overflow:

  *value = UINT_MAX;

  return(DIS_OVERFLOW);
  }  /* END disrsi_() */


bool PopupContainer::handleWheelEvent(const PlatformWheelEvent& event)
{
    UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
    return m_listBox->handleWheelEvent(
        constructRelativeWheelEvent(event, this, m_listBox.get()));
}


bool Document::IsFrameSet() const {
  if (!IsHTMLDocument())
    return false;
  return IsHTMLFrameSetElement(body());
}


bool FilterManager::handleDataIfStopAll(ActiveStreamFilterBase& filter, Buffer::Instance& data,
                                        bool& filter_streaming) {
  if (filter.stoppedAll()) {
    ASSERT(!filter.canIterate());
    filter_streaming =
        filter.iteration_state_ == ActiveStreamFilterBase::IterationState::StopAllWatermark;
    filter.commonHandleBufferData(data);
    return true;
  }
  return false;
}


static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,

                       AVPacket *avpkt)

{

    CFHDContext *s = avctx->priv_data;

    GetByteContext gb;

    ThreadFrame frame = { .f = data };

    AVFrame *pic = data;

    int ret = 0, i, j, planes, plane, got_buffer = 0;

    int16_t *coeff_data;

    s->coded_format = AV_PIX_FMT_YUV422P10;

    init_frame_defaults(s);

    planes = av_pix_fmt_count_planes(s->coded_format);

    bytestream2_init(&gb, avpkt->data, avpkt->size);

    while (bytestream2_get_bytes_left(&gb) > 4) {

        /* Bit weird but implement the tag parsing as the spec says */

        uint16_t tagu   = bytestream2_get_be16(&gb);

        int16_t tag     = (int16_t)tagu;

        int8_t tag8     = (int8_t)(tagu >> 8);

        uint16_t abstag = abs(tag);

        int8_t abs_tag8 = abs(tag8);

        uint16_t data   = bytestream2_get_be16(&gb);

        if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {

            av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | data);

        } else if (tag == 20) {

            av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);

            s->coded_width = data;

        } else if (tag == 21) {

            av_log(avctx, AV_LOG_DEBUG, "Height %"PRIu16"\n", data);

            s->coded_height = data;

        } else if (tag == 101) {

            av_log(avctx, AV_LOG_DEBUG, "Bits per component: %"PRIu16"\n", data);

            if (data < 1 || data > 31) {

                av_log(avctx, AV_LOG_ERROR, "Bits per component %d is invalid\n", data);

                ret = AVERROR(EINVAL);

                break;

            }

            s->bpc = data;

        } else if (tag == 12) {

            av_log(avctx, AV_LOG_DEBUG, "Channel Count: %"PRIu16"\n", data);

            s->channel_cnt = data;

            if (data > 4) {

                av_log(avctx, AV_LOG_ERROR, "Channel Count of %"PRIu16" is unsupported\n", data);

                ret = AVERROR_PATCHWELCOME;

                break;

            }

        } else if (tag == 14) {

            av_log(avctx, AV_LOG_DEBUG, "Subband Count: %"PRIu16"\n", data);

            if (data != SUBBAND_COUNT) {

                av_log(avctx, AV_LOG_ERROR, "Subband Count of %"PRIu16" is unsupported\n", data);

                ret = AVERROR_PATCHWELCOME;

                break;

            }

        } else if (tag == 62) {

            s->channel_num = data;

            av_log(avctx, AV_LOG_DEBUG, "Channel number %"PRIu16"\n", data);

            if (s->channel_num >= planes) {

                av_log(avctx, AV_LOG_ERROR, "Invalid channel number\n");

                ret = AVERROR(EINVAL);

                break;

            }

            init_plane_defaults(s);

        } else if (tag == 48) {

            if (s->subband_num != 0 && data == 1)  // hack

                s->level++;

            av_log(avctx, AV_LOG_DEBUG, "Subband number %"PRIu16"\n", data);

            s->subband_num = data;

            if (s->level >= DWT_LEVELS) {

                av_log(avctx, AV_LOG_ERROR, "Invalid level\n");

                ret = AVERROR(EINVAL);

                break;

            }

            if (s->subband_num > 3) {

                av_log(avctx, AV_LOG_ERROR, "Invalid subband number\n");

                ret = AVERROR(EINVAL);

                break;

            }

        } else if (tag == 51) {

            av_log(avctx, AV_LOG_DEBUG, "Subband number actual %"PRIu16"\n", data);

            s->subband_num_actual = data;

            if (s->subband_num_actual >= 10) {

                av_log(avctx, AV_LOG_ERROR, "Invalid subband number actual\n");

                ret = AVERROR(EINVAL);

                break;

            }

        } else if (tag == 35)

            av_log(avctx, AV_LOG_DEBUG, "Lowpass precision bits: %"PRIu16"\n", data);

        else if (tag == 53) {

            s->quantisation = data;

            av_log(avctx, AV_LOG_DEBUG, "Quantisation: %"PRIu16"\n", data);

        } else if (tag == 109) {

            s->prescale_shift[0] = (data >> 0) & 0x7;

            s->prescale_shift[1] = (data >> 3) & 0x7;

            s->prescale_shift[2] = (data >> 6) & 0x7;

            av_log(avctx, AV_LOG_DEBUG, "Prescale shift (VC-5): %x\n", data);

        } else if (tag == 27) {

            av_log(avctx, AV_LOG_DEBUG, "Lowpass width %"PRIu16"\n", data);

            if (data < 3 || data > s->plane[s->channel_num].band[0][0].a_width) {

                av_log(avctx, AV_LOG_ERROR, "Invalid lowpass width\n");

                ret = AVERROR(EINVAL);

                break;

            }

            s->plane[s->channel_num].band[0][0].width  = data;

            s->plane[s->channel_num].band[0][0].stride = data;

        } else if (tag == 28) {

            av_log(avctx, AV_LOG_DEBUG, "Lowpass height %"PRIu16"\n", data);

            if (data < 3 || data > s->plane[s->channel_num].band[0][0].height) {

                av_log(avctx, AV_LOG_ERROR, "Invalid lowpass height\n");

                ret = AVERROR(EINVAL);

                break;

            }

            s->plane[s->channel_num].band[0][0].height = data;

        } else if (tag == 1)

            av_log(avctx, AV_LOG_DEBUG, "Sample type? %"PRIu16"\n", data);

        else if (tag == 10) {

            if (data != 0) {

                avpriv_report_missing_feature(avctx, "Transform type of %"PRIu16, data);

                ret = AVERROR_PATCHWELCOME;

                break;

            }

            av_log(avctx, AV_LOG_DEBUG, "Transform-type? %"PRIu16"\n", data);

        } else if (abstag >= 0x4000 && abstag <= 0x40ff) {

            av_log(avctx, AV_LOG_DEBUG, "Small chunk length %d %s\n", data * 4, tag < 0 ? "optional" : "required");

            bytestream2_skipu(&gb, data * 4);

        } else if (tag == 23) {

            av_log(avctx, AV_LOG_DEBUG, "Skip frame\n");

            avpriv_report_missing_feature(avctx, "Skip frame");

            ret = AVERROR_PATCHWELCOME;

            break;

        } else if (tag == 2) {

            av_log(avctx, AV_LOG_DEBUG, "tag=2 header - skipping %i tag/value pairs\n", data);

            if (data > bytestream2_get_bytes_left(&gb) / 4) {

                av_log(avctx, AV_LOG_ERROR, "too many tag/value pairs (%d)\n", data);

                ret = AVERROR_INVALIDDATA;

                break;

            }

            for (i = 0; i < data; i++) {

                uint16_t tag2 = bytestream2_get_be16(&gb);

                uint16_t val2 = bytestream2_get_be16(&gb);

                av_log(avctx, AV_LOG_DEBUG, "Tag/Value = %x %x\n", tag2, val2);

            }

        } else if (tag == 41) {

            av_log(avctx, AV_LOG_DEBUG, "Highpass width %i channel %i level %i subband %i\n", data, s->channel_num, s->level, s->subband_num);

            if (data < 3) {

                av_log(avctx, AV_LOG_ERROR, "Invalid highpass width\n");

                ret = AVERROR(EINVAL);

                break;

            }

            s->plane[s->channel_num].band[s->level][s->subband_num].width  = data;

            s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8);

        } else if (tag == 42) {

            av_log(avctx, AV_LOG_DEBUG, "Highpass height %i\n", data);

            if (data < 3) {

                av_log(avctx, AV_LOG_ERROR, "Invalid highpass height\n");

                ret = AVERROR(EINVAL);

                break;

            }

            s->plane[s->channel_num].band[s->level][s->subband_num].height = data;

        } else if (tag == 49) {

            av_log(avctx, AV_LOG_DEBUG, "Highpass width2 %i\n", data);

            if (data < 3) {

                av_log(avctx, AV_LOG_ERROR, "Invalid highpass width2\n");

                ret = AVERROR(EINVAL);

                break;

            }

            s->plane[s->channel_num].band[s->level][s->subband_num].width  = data;

            s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8);

        } else if (tag == 50) {

            av_log(avctx, AV_LOG_DEBUG, "Highpass height2 %i\n", data);

            if (data < 3) {

                av_log(avctx, AV_LOG_ERROR, "Invalid highpass height2\n");

                ret = AVERROR(EINVAL);

                break;

            }

            s->plane[s->channel_num].band[s->level][s->subband_num].height = data;

        } else if (tag == 71) {

            s->codebook = data;

            av_log(avctx, AV_LOG_DEBUG, "Codebook %i\n", s->codebook);

        } else if (tag == 72) {

            s->codebook = data;

            av_log(avctx, AV_LOG_DEBUG, "Other codebook? %i\n", s->codebook);

        } else if (tag == 70) {

            av_log(avctx, AV_LOG_DEBUG, "Subsampling or bit-depth flag? %i\n", data);

            if (!(data == 10 || data == 12)) {

                av_log(avctx, AV_LOG_ERROR, "Invalid bits per channel\n");

                ret = AVERROR(EINVAL);

                break;

            }

            s->bpc = data;

        } else if (tag == 84) {

            av_log(avctx, AV_LOG_DEBUG, "Sample format? %i\n", data);

            if (data == 1)

                s->coded_format = AV_PIX_FMT_YUV422P10;

            else if (data == 3)

                s->coded_format = AV_PIX_FMT_GBRP12;

            else if (data == 4)

                s->coded_format = AV_PIX_FMT_GBRAP12;

            else {

                avpriv_report_missing_feature(avctx, "Sample format of %"PRIu16, data);

                ret = AVERROR_PATCHWELCOME;

                break;

            }

            planes = av_pix_fmt_count_planes(s->coded_format);

        } else

            av_log(avctx, AV_LOG_DEBUG,  "Unknown tag %i data %x\n", tag, data);

        /* Some kind of end of header tag */

        if (tag == 4 && data == 0x1a4a && s->coded_width && s->coded_height &&

            s->coded_format != AV_PIX_FMT_NONE) {

            if (s->a_width != s->coded_width || s->a_height != s->coded_height ||

                s->a_format != s->coded_format) {

                free_buffers(avctx);

                if ((ret = alloc_buffers(avctx)) < 0) {

                    free_buffers(avctx);

                    return ret;

                }

            }

            ret = ff_set_dimensions(avctx, s->coded_width, s->coded_height);

            if (ret < 0)

                return ret;

            frame.f->width =

            frame.f->height = 0;

            if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)

                return ret;

            s->coded_width = 0;

            s->coded_height = 0;

            s->coded_format = AV_PIX_FMT_NONE;

            got_buffer = 1;

        }

        coeff_data = s->plane[s->channel_num].subband[s->subband_num_actual];

        /* Lowpass coefficients */

        if (tag == 4 && data == 0xf0f && s->a_width && s->a_height) {

            int lowpass_height = s->plane[s->channel_num].band[0][0].height;

            int lowpass_width  = s->plane[s->channel_num].band[0][0].width;

            int lowpass_a_height = s->plane[s->channel_num].band[0][0].a_height;

            int lowpass_a_width  = s->plane[s->channel_num].band[0][0].a_width;

            if (!got_buffer) {

                av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");

                ret = AVERROR(EINVAL);

                goto end;

            }

            if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width ||

                lowpass_a_width * lowpass_a_height * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) {

                av_log(avctx, AV_LOG_ERROR, "Too many lowpass coefficients\n");

                ret = AVERROR(EINVAL);

                goto end;

            }

            av_log(avctx, AV_LOG_DEBUG, "Start of lowpass coeffs component %d height:%d, width:%d\n", s->channel_num, lowpass_height, lowpass_width);

            for (i = 0; i < lowpass_height; i++) {

                for (j = 0; j < lowpass_width; j++)

                    coeff_data[j] = bytestream2_get_be16u(&gb);

                coeff_data += lowpass_width;

            }

            /* Align to mod-4 position to continue reading tags */

            bytestream2_seek(&gb, bytestream2_tell(&gb) & 3, SEEK_CUR);

            /* Copy last line of coefficients if odd height */

            if (lowpass_height & 1) {

                memcpy(&coeff_data[lowpass_height * lowpass_width],

                       &coeff_data[(lowpass_height - 1) * lowpass_width],

                       lowpass_width * sizeof(*coeff_data));

            }

            av_log(avctx, AV_LOG_DEBUG, "Lowpass coefficients %d\n", lowpass_width * lowpass_height);

        }

        if (tag == 55 && s->subband_num_actual != 255 && s->a_width && s->a_height) {

            int highpass_height = s->plane[s->channel_num].band[s->level][s->subband_num].height;

            int highpass_width  = s->plane[s->channel_num].band[s->level][s->subband_num].width;

            int highpass_a_width = s->plane[s->channel_num].band[s->level][s->subband_num].a_width;

            int highpass_a_height = s->plane[s->channel_num].band[s->level][s->subband_num].a_height;

            int highpass_stride = s->plane[s->channel_num].band[s->level][s->subband_num].stride;

            int expected;

            int a_expected = highpass_a_height * highpass_a_width;

            int level, run, coeff;

            int count = 0, bytes;

            if (!got_buffer) {

                av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");

                ret = AVERROR(EINVAL);

                goto end;

            }

            if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) {

                av_log(avctx, AV_LOG_ERROR, "Too many highpass coefficients\n");

                ret = AVERROR(EINVAL);

                goto end;

            }

            expected = highpass_height * highpass_stride;

            av_log(avctx, AV_LOG_DEBUG, "Start subband coeffs plane %i level %i codebook %i expected %i\n", s->channel_num, s->level, s->codebook, expected);

            init_get_bits(&s->gb, gb.buffer, bytestream2_get_bytes_left(&gb) * 8);

            {

                OPEN_READER(re, &s->gb);

                if (!s->codebook) {

                    while (1) {

                        UPDATE_CACHE(re, &s->gb);

                        GET_RL_VLC(level, run, re, &s->gb, s->table_9_rl_vlc,

                                   VLC_BITS, 3, 1);

                        /* escape */

                        if (level == 64)

                            break;

                        count += run;

                        if (count > expected)

                            break;

                        coeff = dequant_and_decompand(level, s->quantisation);

                        for (i = 0; i < run; i++)

                            *coeff_data++ = coeff;

                    }

                } else {

                    while (1) {

                        UPDATE_CACHE(re, &s->gb);

                        GET_RL_VLC(level, run, re, &s->gb, s->table_18_rl_vlc,

                                   VLC_BITS, 3, 1);

                        /* escape */

                        if (level == 255 && run == 2)

                            break;

                        count += run;

                        if (count > expected)

                            break;

                        coeff = dequant_and_decompand(level, s->quantisation);

                        for (i = 0; i < run; i++)

                            *coeff_data++ = coeff;

                    }

                }

                CLOSE_READER(re, &s->gb);

            }

            if (count > expected) {

                av_log(avctx, AV_LOG_ERROR, "Escape codeword not found, probably corrupt data\n");

                ret = AVERROR(EINVAL);

                goto end;

            }

            bytes = FFALIGN(FF_CEIL_RSHIFT(get_bits_count(&s->gb), 3), 4);

            if (bytes > bytestream2_get_bytes_left(&gb)) {

                av_log(avctx, AV_LOG_ERROR, "Bitstream overread error\n");

                ret = AVERROR(EINVAL);

                goto end;

            } else

                bytestream2_seek(&gb, bytes, SEEK_CUR);

            av_log(avctx, AV_LOG_DEBUG, "End subband coeffs %i extra %i\n", count, count - expected);

            s->codebook = 0;

            /* Copy last line of coefficients if odd height */

            if (highpass_height & 1) {

                memcpy(&coeff_data[highpass_height * highpass_stride],

                       &coeff_data[(highpass_height - 1) * highpass_stride],

                       highpass_stride * sizeof(*coeff_data));

            }

        }

    }

    if (!s->a_width || !s->a_height || s->a_format == AV_PIX_FMT_NONE ||

        s->coded_width || s->coded_height || s->coded_format != AV_PIX_FMT_NONE) {

        av_log(avctx, AV_LOG_ERROR, "Invalid dimensions\n");

        ret = AVERROR(EINVAL);

        goto end;

    }

    if (!got_buffer) {

        av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n");

        ret = AVERROR(EINVAL);

        goto end;

    }

    planes = av_pix_fmt_count_planes(avctx->pix_fmt);

    for (plane = 0; plane < planes && !ret; plane++) {

        /* level 1 */

        int lowpass_height  = s->plane[plane].band[0][0].height;

        int lowpass_width   = s->plane[plane].band[0][0].width;

        int highpass_stride = s->plane[plane].band[0][1].stride;

        int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;

        int16_t *low, *high, *output, *dst;

        if (lowpass_height > s->plane[plane].band[0][0].a_height || lowpass_width > s->plane[plane].band[0][0].a_width ||

            !highpass_stride || s->plane[plane].band[0][1].width > s->plane[plane].band[0][1].a_width) {

            av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");

            ret = AVERROR(EINVAL);

            goto end;

        }

        av_log(avctx, AV_LOG_DEBUG, "Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);

        low    = s->plane[plane].subband[0];

        high   = s->plane[plane].subband[2];

        output = s->plane[plane].l_h[0];

        for (i = 0; i < lowpass_width; i++) {

            vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);

            low++;

            high++;

            output++;

        }

        low    = s->plane[plane].subband[1];

        high   = s->plane[plane].subband[3];

        output = s->plane[plane].l_h[1];

        for (i = 0; i < lowpass_width; i++) {

            // note the stride of "low" is highpass_stride

            vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);

            low++;

            high++;

            output++;

        }

        low    = s->plane[plane].l_h[0];

        high   = s->plane[plane].l_h[1];

        output = s->plane[plane].subband[0];

        for (i = 0; i < lowpass_height * 2; i++) {

            horiz_filter(output, low, high, lowpass_width);

            low    += lowpass_width;

            high   += lowpass_width;

            output += lowpass_width * 2;

        }

        if (s->bpc == 12) {

            output = s->plane[plane].subband[0];

            for (i = 0; i < lowpass_height * 2; i++) {

                for (j = 0; j < lowpass_width * 2; j++)

                    output[j] *= 4;

                output += lowpass_width * 2;

            }

        }

        /* level 2 */

        lowpass_height  = s->plane[plane].band[1][1].height;

        lowpass_width   = s->plane[plane].band[1][1].width;

        highpass_stride = s->plane[plane].band[1][1].stride;

        if (lowpass_height > s->plane[plane].band[1][1].a_height || lowpass_width > s->plane[plane].band[1][1].a_width ||

            !highpass_stride || s->plane[plane].band[1][1].width > s->plane[plane].band[1][1].a_width) {

            av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");

            ret = AVERROR(EINVAL);

            goto end;

        }

        av_log(avctx, AV_LOG_DEBUG, "Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);

        low    = s->plane[plane].subband[0];

        high   = s->plane[plane].subband[5];

        output = s->plane[plane].l_h[3];

        for (i = 0; i < lowpass_width; i++) {

            vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);

            low++;

            high++;

            output++;

        }

        low    = s->plane[plane].subband[4];

        high   = s->plane[plane].subband[6];

        output = s->plane[plane].l_h[4];

        for (i = 0; i < lowpass_width; i++) {

            vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);

            low++;

            high++;

            output++;

        }

        low    = s->plane[plane].l_h[3];

        high   = s->plane[plane].l_h[4];

        output = s->plane[plane].subband[0];

        for (i = 0; i < lowpass_height * 2; i++) {

            horiz_filter(output, low, high, lowpass_width);

            low    += lowpass_width;

            high   += lowpass_width;

            output += lowpass_width * 2;

        }

        output = s->plane[plane].subband[0];

        for (i = 0; i < lowpass_height * 2; i++) {

            for (j = 0; j < lowpass_width * 2; j++)

                output[j] *= 4;

            output += lowpass_width * 2;

        }

        /* level 3 */

        lowpass_height  = s->plane[plane].band[2][1].height;

        lowpass_width   = s->plane[plane].band[2][1].width;

        highpass_stride = s->plane[plane].band[2][1].stride;

        if (lowpass_height > s->plane[plane].band[2][1].a_height || lowpass_width > s->plane[plane].band[2][1].a_width ||

            !highpass_stride || s->plane[plane].band[2][1].width > s->plane[plane].band[2][1].a_width) {

            av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n");

            ret = AVERROR(EINVAL);

            goto end;

        }

        av_log(avctx, AV_LOG_DEBUG, "Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride);

        low    = s->plane[plane].subband[0];

        high   = s->plane[plane].subband[8];

        output = s->plane[plane].l_h[6];

        for (i = 0; i < lowpass_width; i++) {

            vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height);

            low++;

            high++;

            output++;

        }

        low    = s->plane[plane].subband[7];

        high   = s->plane[plane].subband[9];

        output = s->plane[plane].l_h[7];

        for (i = 0; i < lowpass_width; i++) {

            vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height);

            low++;

            high++;

            output++;

        }

        dst = (int16_t *)pic->data[act_plane];

        low  = s->plane[plane].l_h[6];

        high = s->plane[plane].l_h[7];

        for (i = 0; i < lowpass_height * 2; i++) {

            horiz_filter_clip(dst, low, high, lowpass_width, s->bpc);

            low  += lowpass_width;

            high += lowpass_width;

            dst  += pic->linesize[act_plane] / 2;

        }

    }

end:

    if (ret < 0)

        return ret;

    *got_frame = 1;

    return avpkt->size;

}


HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
{
    enum xkb_match_operation pred;
    xkb_mod_mask_t mods;
    SymInterpInfo si;

    if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) {
        log_err(info->ctx,
                "Couldn't determine matching modifiers; "
                "Symbol interpretation ignored\n");
        return false;
    }

    si = info->default_interp;
    si.merge = merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
    si.interp.sym = def->sym;
    si.interp.match = pred;
    si.interp.mods = mods;

    if (!HandleInterpBody(info, def->def, &si)) {
        info->errorCount++;
        return false;
    }

    if (!AddInterp(info, &si, true)) {
        info->errorCount++;
        return false;
    }

    return true;
}


Status EagerLocalExecute(EagerOperation* op, TensorHandle** retvals,
                         int* num_retvals) {
  profiler::ScopedMemoryDebugAnnotation op_annotation(
      op->op_name(), op->eager_func_params().has_value()
                         ? op->eager_func_params().value().step_id.value_or(0)
                         : 0);
  profiler::TraceMe activity(
      [&] { return absl::StrCat("EagerLocalExecute: ", op->Name()); },
      profiler::TraceMeLevel::kInfo);
  EagerContext& ctx = op->EagerContext();
  auto& executor = op->Executor();
  TF_RETURN_IF_ERROR(executor.status());

  core::RefCountPtr<KernelAndDevice> kernel;
  auto status = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);

#ifdef INTEL_MKL
  if (IsMKLEnabled() && kernel != nullptr &&
      op->Device() == kVariantDeviceNull) {
    // oneDNN optimization pass relies on the op's assigned device to determine
    // whether it can be rewritten.
    op->SetDevice(kernel->device());
  }
#endif  // INTEL_MKL

  // Run all the registered rewrite pass after the placement, regardless whether
  // the placement is successful or not. The passes can either create new ops
  // (without placement) or update some fields of the input op.
  std::unique_ptr<tensorflow::EagerOperation> out_op;
  TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite(
      EagerOpRewriteRegistry::POST_PLACEMENT, op, &out_op));
  if (out_op) {
    op = out_op.get();
    // If the out op doesn't have device, either because it is a new op or
    // the op wasn't placed successfully, then we do the placement again.
    if (op->Device() == kVariantDeviceNull) {
      status = GetOrCreateKernelAndDevice(op, retvals, num_retvals, &kernel);
    }
  }
  if (!status.ok()) return status;

  int num_outputs = kernel->num_outputs();
  TF_RETURN_IF_ERROR(ValidateInputTypeAndPlacement(&ctx, op, kernel));

  if (ctx.LogDevicePlacement() || VLOG_IS_ON(1)) {
    string msg = strings::StrCat("Executing op ", op->Name(), " in device ",
                                 kernel->device()->name());
    if (!logging::LogToListeners(msg)) {
      LOG(INFO) << msg;
    }
  }

  Status s = AddOrExecuteNode(std::move(kernel), op, retvals);
  // Since the operation failed, we need to Unref any outputs if they were
  // allocated.
  if (!s.ok()) {
    for (int i = 0, end = num_outputs; i < end; ++i) {
      if (retvals[i] != nullptr) {
        retvals[i]->Unref();
        retvals[i] = nullptr;
      }
    }
  }

  return s;
}


static void setterRaisesExceptionLongAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
    TestObjectPythonV8Internal::setterRaisesExceptionLongAttributeAttributeSetter(jsValue, info);
    TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}


qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
	      u32 level, const char *fmt, ...)
{
	va_list va;
	struct va_format vaf;
	char nfunc[32];

	memset(nfunc, 0, sizeof(nfunc));
	memcpy(nfunc, func, sizeof(nfunc) - 1);

	va_start(va, fmt);

	vaf.fmt = fmt;
	vaf.va = &va;

	if (!(qedi_dbg_log & level))
		goto ret;

	if (likely(qedi) && likely(qedi->pdev))
		pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
			nfunc, line, qedi->host_no, &vaf);
	else
		pr_info("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);

ret:
	va_end(va);
}


UWORD32 ihevcd_cabac_decode_bypass_bins_egk(cab_ctxt_t *ps_cabac,
 bitstrm_t *ps_bitstrm,
                                            WORD32 k)
{

    UWORD32 u4_sym;
    WORD32 numones;
    WORD32 bin;

 /* Sanity checks */
    ASSERT((k >= 0));

     numones = k;
     bin = 1;
     u4_sym = 0;
    while(bin && (numones <= 16))
     {
         IHEVCD_CABAC_DECODE_BYPASS_BIN(bin, ps_cabac, ps_bitstrm);
         u4_sym += bin << numones++;
     }

     numones -= 1;

     if(numones)
     {
        UWORD32 u4_suffix;

        IHEVCD_CABAC_DECODE_BYPASS_BINS(u4_suffix, ps_cabac, ps_bitstrm, numones);
        u4_sym += u4_suffix;
 }
 return (u4_sym);
}


R_API RBinJavaAttrInfo *r_bin_java_signature_attr_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {
	ut64 offset = 6;
	RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (buffer, sz, buf_offset);
	if (!attr) {
		return NULL;
	}
	attr->type = R_BIN_JAVA_ATTR_TYPE_SIGNATURE_ATTR;
	// attr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset);
	// offset += 2;
	attr->info.signature_attr.signature_idx = R_BIN_JAVA_USHORT (buffer, offset);
	offset += 2;
	attr->info.signature_attr.signature = r_bin_java_get_utf8_from_bin_cp_list (
		R_BIN_JAVA_GLOBAL_BIN, attr->info.signature_attr.signature_idx);
	if (!attr->info.signature_attr.signature) {
		eprintf ("r_bin_java_signature_attr_new: Unable to resolve the "
			"Signature UTF8 String Index: 0x%02x\n", attr->info.signature_attr.signature_idx);
	}
	attr->size = offset;
	// IFDBG r_bin_java_print_source_code_file_attr_summary(attr);
	return attr;
}


static int vol_prc_lib_get_descriptor(const effect_uuid_t *uuid,
 effect_descriptor_t *descriptor)
{
 int i = 0;
    ALOGV("%s Called ", __func__);
 if (lib_init() != 0) {
 return init_status;
 }

 if (descriptor == NULL || uuid == NULL) {
        ALOGE("%s: %s is NULL", __func__, (descriptor == NULL) ? "descriptor" : "uuid");
 return -EINVAL;
 }

 for (i = 0; descriptors[i] != NULL; i++) {
 if (memcmp(uuid, &descriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
 *descriptor = *descriptors[i];
 return 0;
 }
 }

    ALOGE("%s: couldnt found uuid passed, oops", __func__);
 return -EINVAL;
}


FakeDownloadItem* DownloadPathReservationTrackerTest::CreateDownloadItem(
    int32 id) {
  FakeDownloadItem* item = new ::testing::StrictMock<FakeDownloadItem>;
  DownloadId download_id(reinterpret_cast<void*>(this), id);
  EXPECT_CALL(*item, GetGlobalId())
      .WillRepeatedly(Return(download_id));
  EXPECT_CALL(*item, GetTargetFilePath())
      .WillRepeatedly(ReturnRefOfCopy(base::FilePath()));
  return item;
}


PJ_DEF(pj_status_t) pjsip_auth_create_aka_response(
					     pj_pool_t *pool,
					     const pjsip_digest_challenge *chal,
					     const pjsip_cred_info *cred,
					     const pj_str_t *method,
					     pjsip_digest_credential *auth)
{
    pj_str_t nonce_bin;
    int aka_version;
    const pj_str_t pjsip_AKAv1_MD5 = { "AKAv1-MD5", 9 };
    const pj_str_t pjsip_AKAv2_MD5 = { "AKAv2-MD5", 9 };
    pj_uint8_t *chal_rand, *chal_sqnxoraka, *chal_mac;
    pj_uint8_t k[PJSIP_AKA_KLEN];
    pj_uint8_t op[PJSIP_AKA_OPLEN];
    pj_uint8_t amf[PJSIP_AKA_AMFLEN];
    pj_uint8_t res[PJSIP_AKA_RESLEN];
    pj_uint8_t ck[PJSIP_AKA_CKLEN];
    pj_uint8_t ik[PJSIP_AKA_IKLEN];
    pj_uint8_t ak[PJSIP_AKA_AKLEN];
    pj_uint8_t sqn[PJSIP_AKA_SQNLEN];
    pj_uint8_t xmac[PJSIP_AKA_MACLEN];
    pjsip_cred_info aka_cred;
    int i, len;
    pj_status_t status;

    /* Check the algorithm is supported. */
    if (chal->algorithm.slen==0 || pj_stricmp2(&chal->algorithm, "md5") == 0) {
	/*
	 * A normal MD5 authentication is requested. Fallbackt to the usual
	 * MD5 digest creation.
	 */
	pjsip_auth_create_digest(&auth->response, &auth->nonce, &auth->nc,
				 &auth->cnonce, &auth->qop, &auth->uri,
				 &auth->realm, cred, method);
	return PJ_SUCCESS;

    } else if (pj_stricmp(&chal->algorithm, &pjsip_AKAv1_MD5) == 0) {
	/*
	 * AKA version 1 is requested.
	 */
	aka_version = 1;

    } else if (pj_stricmp(&chal->algorithm, &pjsip_AKAv2_MD5) == 0) {
	/*
	 * AKA version 2 is requested.
	 */
	aka_version = 2;

    } else {
	/* Unsupported algorithm */
	return PJSIP_EINVALIDALGORITHM;
    }

    /* Decode nonce */
    nonce_bin.slen = len = PJ_BASE64_TO_BASE256_LEN(chal->nonce.slen);
    nonce_bin.ptr = pj_pool_alloc(pool, nonce_bin.slen + 1);
    status = pj_base64_decode(&chal->nonce, (pj_uint8_t*)nonce_bin.ptr, &len);
    nonce_bin.slen = len;
    if (status != PJ_SUCCESS)
	return PJSIP_EAUTHINNONCE;

    if (nonce_bin.slen < PJSIP_AKA_RANDLEN + PJSIP_AKA_AUTNLEN)
	return PJSIP_EAUTHINNONCE;

    /* Get RAND, AUTN, and MAC */
    chal_rand = (pj_uint8_t*)(nonce_bin.ptr + 0);
    chal_sqnxoraka = (pj_uint8_t*) (nonce_bin.ptr + PJSIP_AKA_RANDLEN);
    chal_mac = (pj_uint8_t*) (nonce_bin.ptr + PJSIP_AKA_RANDLEN +
			      PJSIP_AKA_SQNLEN + PJSIP_AKA_AMFLEN);

    /* Copy k. op, and amf */
    pj_bzero(k, sizeof(k));
    pj_bzero(op, sizeof(op));
    pj_bzero(amf, sizeof(amf));

    if (cred->ext.aka.k.slen)
	pj_memcpy(k, cred->ext.aka.k.ptr, cred->ext.aka.k.slen);
    if (cred->ext.aka.op.slen)
	pj_memcpy(op, cred->ext.aka.op.ptr, cred->ext.aka.op.slen);
    if (cred->ext.aka.amf.slen)
	pj_memcpy(amf, cred->ext.aka.amf.ptr, cred->ext.aka.amf.slen);

    /* Given key K and random challenge RAND, compute response RES,
     * confidentiality key CK, integrity key IK and anonymity key AK.
     */
    f2345(k, chal_rand, res, ck, ik, ak, op);

    /* Compute sequence number SQN */
    for (i=0; i<PJSIP_AKA_SQNLEN; ++i)
	sqn[i] = (pj_uint8_t) (chal_sqnxoraka[i] ^ ak[i]);

    /* Verify MAC in the challenge */
    /* Compute XMAC */
    f1(k, chal_rand, sqn, amf, xmac, op);

    if (pj_memcmp(chal_mac, xmac, PJSIP_AKA_MACLEN) != 0) {
	return PJSIP_EAUTHINNONCE;
    }

    /* Build a temporary credential info to create MD5 digest, using
     * "res" as the password.
     */
    pj_memcpy(&aka_cred, cred, sizeof(aka_cred));
    aka_cred.data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;

    /* Create a response */
    if (aka_version == 1) {
	/*
	 * For AKAv1, the password is RES
	 */
	aka_cred.data.ptr = (char*)res;
	aka_cred.data.slen = PJSIP_AKA_RESLEN;

	pjsip_auth_create_digest(&auth->response, &chal->nonce,
				 &auth->nc, &auth->cnonce, &auth->qop,
				 &auth->uri, &chal->realm, &aka_cred, method);

    } else if (aka_version == 2) {

	/*
	 * For AKAv2, password is base64 encoded [1] parameters:
	 *    PRF(RES||IK||CK,"http-digest-akav2-password")
	 *
	 * The pseudo-random function (PRF) is HMAC-MD5 in this case.
	 */

	pj_str_t resikck;
	const pj_str_t AKAv2_Passwd = { "http-digest-akav2-password", 26 };
	pj_uint8_t hmac_digest[16];
	char tmp_buf[48];
	int hmac64_len;

	resikck.slen = PJSIP_AKA_RESLEN + PJSIP_AKA_IKLEN + PJSIP_AKA_CKLEN;
	pj_assert(resikck.slen <= PJ_ARRAY_SIZE(tmp_buf));
	resikck.ptr = tmp_buf;
	pj_memcpy(resikck.ptr + 0, res, PJSIP_AKA_RESLEN);
	pj_memcpy(resikck.ptr + PJSIP_AKA_RESLEN, ik, PJSIP_AKA_IKLEN);
	pj_memcpy(resikck.ptr + PJSIP_AKA_RESLEN + PJSIP_AKA_IKLEN,
	          ck, PJSIP_AKA_CKLEN);

	pj_hmac_md5((const pj_uint8_t*)AKAv2_Passwd.ptr, AKAv2_Passwd.slen,
	            (const pj_uint8_t*)resikck.ptr, resikck.slen,
	            hmac_digest);

	aka_cred.data.slen = hmac64_len =
		PJ_BASE256_TO_BASE64_LEN(PJ_ARRAY_SIZE(hmac_digest));
	pj_assert(aka_cred.data.slen+1 <= PJ_ARRAY_SIZE(tmp_buf));
	aka_cred.data.ptr = tmp_buf;
	pj_base64_encode(hmac_digest, PJ_ARRAY_SIZE(hmac_digest),
	                 aka_cred.data.ptr, &len);
	aka_cred.data.slen = hmac64_len;

	pjsip_auth_create_digest(&auth->response, &chal->nonce,
				 &auth->nc, &auth->cnonce, &auth->qop,
				 &auth->uri, &chal->realm, &aka_cred, method);

    } else {
	pj_assert(!"Bug!");
	return PJ_EBUG;
    }

    /* Done */
    return PJ_SUCCESS;
}


static int show_partition(struct seq_file *seqf, void *v)
{
	struct gendisk *sgp = v;
	struct disk_part_iter piter;
	struct hd_struct *part;
	char buf[BDEVNAME_SIZE];

	/* Don't show non-partitionable removeable devices or empty devices */
	if (!get_capacity(sgp) || (!disk_max_parts(sgp) &&
				   (sgp->flags & GENHD_FL_REMOVABLE)))
		return 0;
	if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)
		return 0;

	/* show the full disk and all non-0 size partitions of it */
	disk_part_iter_init(&piter, sgp, DISK_PITER_INCL_PART0);
	while ((part = disk_part_iter_next(&piter)))
		seq_printf(seqf, "%4d  %7d %10llu %s\n",
			   MAJOR(part_devt(part)), MINOR(part_devt(part)),
			   (unsigned long long)part_nr_sects_read(part) >> 1,
			   disk_name(sgp, part->partno, buf));
	disk_part_iter_exit(&piter);

	return 0;
}


void QSvgHandler::parse()
{
    xml->setNamespaceProcessing(false);
#ifndef QT_NO_CSSPARSER
    m_selector = new QSvgStyleSelector;
    m_inStyle = false;
#endif
    bool done = false;
    int remainingUnfinishedElements = unfinishedElementsLimit;
    while (!xml->atEnd() && !done) {
        switch (xml->readNext()) {
        case QXmlStreamReader::StartElement:
            // he we could/should verify the namespaces, and simply
            // call m_skipNodes(Unknown) if we don't know the
            // namespace.  We do support http://www.w3.org/2000/svg
            // but also http://www.w3.org/2000/svg-20000303-stylable
            // And if the document uses an external dtd, the reported
            // namespaceUri is empty. The only possible strategy at
            // this point is to do what everyone else seems to do and
            // ignore the reported namespaceUri completely.
            if (remainingUnfinishedElements
                    && startElement(xml->name().toString(), xml->attributes())) {
                --remainingUnfinishedElements;
            } else {
                delete m_doc;
                m_doc = 0;
                return;
            }
            break;
        case QXmlStreamReader::EndElement:
            endElement(xml->name());
            ++remainingUnfinishedElements;
            // if we are using somebody else's qxmlstreamreader
            // we should not read until the end of the stream
            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
            break;
        case QXmlStreamReader::Characters:
            characters(xml->text());
            break;
        case QXmlStreamReader::ProcessingInstruction:
            processingInstruction(xml->processingInstructionTarget().toString(), xml->processingInstructionData().toString());
            break;
        default:
            break;
        }
    }
    resolveGradients(m_doc);
    resolveNodes();
}


bool PrintRenderFrameHelper::FinalizePrintReadyDocument() {
  DCHECK(!is_print_ready_metafile_sent_);
  print_preview_context_.FinalizePrintReadyDocument();

  PdfMetafileSkia* metafile = print_preview_context_.metafile();
  PrintHostMsg_DidPreviewDocument_Params preview_params;

  if (!CopyMetafileDataToSharedMem(*metafile,
                                   &preview_params.metafile_data_handle)) {
    LOG(ERROR) << "CopyMetafileDataToSharedMem failed";
    print_preview_context_.set_error(PREVIEW_ERROR_METAFILE_COPY_FAILED);
    return false;
  }

  preview_params.data_size = metafile->GetDataSize();
  preview_params.document_cookie = print_pages_params_->params.document_cookie;
  preview_params.expected_pages_count =
      print_preview_context_.total_page_count();
  preview_params.modifiable = print_preview_context_.IsModifiable();
  preview_params.preview_request_id =
      print_pages_params_->params.preview_request_id;

  is_print_ready_metafile_sent_ = true;

  Send(new PrintHostMsg_MetafileReadyForPrinting(routing_id(), preview_params));
  return true;
}