// File: /workspace/github_c_makefile_star2_O0/craigbarnes[P]lua-gumbo/lib/parser.c
// Function: handle_in_foreign_content
static bool handle_in_foreign_content(GumboParser* parser, GumboToken* token) {
  gumbo_debug("Handling foreign content");
  switch (token->type) {
    case GUMBO_TOKEN_NULL:
      parser_add_parse_error(parser, token);
      token->v.character = UNICODE_REPLACEMENT_CHAR;
      insert_text_token(parser, token);
      return false;
    case GUMBO_TOKEN_WHITESPACE:
      insert_text_token(parser, token);
      return true;
    case GUMBO_TOKEN_CDATA:
    case GUMBO_TOKEN_CHARACTER:
      insert_text_token(parser, token);
      set_frameset_not_ok(parser);
      return true;
    case GUMBO_TOKEN_COMMENT:
      append_comment_node(parser, get_current_node(parser), token);
      return true;
    case GUMBO_TOKEN_DOCTYPE:
      parser_add_parse_error(parser, token);
      ignore_token(parser);
      return false;
    default:
      // Fall through to the if-statements below.
      break;
  }
  // Order matters for these clauses.
  if (
    tag_in(token, kStartTag, &(const TagSet) {
      TAG(B), TAG(BIG), TAG(BLOCKQUOTE), TAG(BODY), TAG(BR), TAG(CENTER),
      TAG(CODE), TAG(DD), TAG(DIV), TAG(DL), TAG(DT), TAG(EM), TAG(EMBED),
      TAG(H1), TAG(H2), TAG(H3), TAG(H4), TAG(H5), TAG(H6), TAG(HEAD),
      TAG(HR), TAG(I), TAG(IMG), TAG(LI), TAG(LISTING), TAG(MENU), TAG(META),
      TAG(NOBR), TAG(OL), TAG(P), TAG(PRE), TAG(RUBY), TAG(S), TAG(SMALL),
      TAG(SPAN), TAG(STRONG), TAG(STRIKE), TAG(SUB), TAG(SUP), TAG(TABLE),
      TAG(TT), TAG(U), TAG(UL), TAG(VAR)
    })
    || (
      tag_is(token, kStartTag, GUMBO_TAG_FONT)
      && (
        token_has_attribute(token, "color")
        || token_has_attribute(token, "face")
        || token_has_attribute(token, "size")
      )
    )
  ) {
    /* Parse error */
    parser_add_parse_error(parser, token);

    /*
     * Fragment case: If the parser was originally created for the HTML
     * fragment parsing algorithm, then act as described in the "any other
     * start tag" entry below.
     */
    if (!is_fragment_parser(parser)) {
      do {
        pop_current_node(parser);
      } while (
        !(
          is_mathml_integration_point(get_current_node(parser))
          || is_html_integration_point(get_current_node(parser))
          || get_current_node(parser)->v.element.tag_namespace == GUMBO_NAMESPACE_HTML
        )
      );
      parser->_parser_state->_reprocess_current_token = true;
      return false;
    }

    assert(token->type == GUMBO_TOKEN_START_TAG);
  }

  if (token->type == GUMBO_TOKEN_START_TAG) {
    const GumboNamespaceEnum current_namespace =
        get_adjusted_current_node(parser)->v.element.tag_namespace;
    if (current_namespace == GUMBO_NAMESPACE_MATHML) {
      adjust_mathml_attributes(token);
    }
    if (current_namespace == GUMBO_NAMESPACE_SVG) {
      // Tag adjustment is left to the gumbo_normalize_svg_tagname helper
      // function.
      adjust_svg_attributes(token);
    }
    adjust_foreign_attributes(token);
    insert_foreign_element(parser, token, current_namespace);
    if (token->v.start_tag.is_self_closing) {
      pop_current_node(parser);
      acknowledge_self_closing_tag(parser);
    }
    return true;
    // </script> tags are handled like any other end tag, putting the script's
    // text into a text node child and closing the current node.
  } else {
    assert(token->type == GUMBO_TOKEN_END_TAG);
    GumboNode* node = get_current_node(parser);
    assert(node != NULL);
    GumboStringPiece token_tagname = token->original_text;
    GumboStringPiece node_tagname = node->v.element.original_tag;
    gumbo_tag_from_original_text(&token_tagname);
    gumbo_tag_from_original_text(&node_tagname);

    bool is_success = true;
    if (!string_piece_equal_icase(&node_tagname, &token_tagname)) {
      parser_add_parse_error(parser, token);
      is_success = false;
    }
    int i = parser->_parser_state->_open_elements.length;
    for (--i; i > 0;) {
      // Here we move up the stack until we find an HTML element (in which
      // case we do nothing) or we find the element that we're about to
      // close (in which case we pop everything we've seen until that
      // point.)
      gumbo_debug (
        "Foreign %.*s node at %d.\n",
        (int) node_tagname.length,
        node_tagname.data,
        i
      );
      if (string_piece_equal_icase(&node_tagname, &token_tagname)) {
        gumbo_debug("Matches.\n");
        while (pop_current_node(parser) != node) {
          // Pop all the nodes below the current one. Node is guaranteed to
          // be an element on the stack of open elements (set below), so
          // this loop is guaranteed to terminate.
        }
        return is_success;
      }
      --i;
      node = parser->_parser_state->_open_elements.data[i];
      if (node->v.element.tag_namespace == GUMBO_NAMESPACE_HTML) {
        // Must break before gumbo_tag_from_original_text to avoid passing
        // parser-inserted nodes through.
        break;
      }
      node_tagname = node->v.element.original_tag;
      gumbo_tag_from_original_text(&node_tagname);
    }
    assert(node->v.element.tag_namespace == GUMBO_NAMESPACE_HTML);
    // We can't call handle_token directly because the current node is still in
    // the SVG namespace, so it would re-enter this and result in infinite
    // recursion.
    return handle_html_content(parser, token) && is_success;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq 0x2c1f7(%rip), %rdi     # 0x350c1
xorl %eax, %eax
callq 0x7540
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xf0(%rbp)
subq $0x7, %rax
ja 0x8fb1
movq -0xf0(%rbp), %rax
leaq 0x27872(%rip), %rcx     # 0x30768
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x78a0
movq -0x18(%rbp), %rax
movl $0xfffd, 0x30(%rax)     # imm = 0xFFFD
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xef60
movb $0x0, -0x1(%rbp)
jmp 0x93ea
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xef60
movb $0x1, -0x1(%rbp)
jmp 0x93ea
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xef60
movq -0x10(%rbp), %rdi
callq 0xfaa0
movb $0x1, -0x1(%rbp)
jmp 0x93ea
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7550
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
movq -0x18(%rbp), %rdx
callq 0xe7b0
movb $0x1, -0x1(%rbp)
jmp 0x93ea
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x78a0
movq -0x10(%rbp), %rdi
callq 0x8bd0
movb $0x0, -0x1(%rbp)
jmp 0x93ea
jmp 0x8fb3
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0xb0(%rbp), %rdi
leaq 0x29d5c(%rip), %rsi     # 0x32d28
movl $0x98, %edx
callq 0x41a0
movq -0x100(%rbp), %rdi
movl $0x1, %esi
leaq -0xb0(%rbp), %rdx
callq 0x8d40
testb $0x1, %al
jne 0x904f
movq -0x18(%rbp), %rdi
movl $0x1, %esi
movl $0x8e, %edx
callq 0x8c40
testb $0x1, %al
jne 0x900e
jmp 0x911b
movq -0x18(%rbp), %rdi
leaq 0x64d4f(%rip), %rsi     # 0x6dd68
callq 0x11300
testb $0x1, %al
jne 0x904f
movq -0x18(%rbp), %rdi
leaq 0x2c0ad(%rip), %rsi     # 0x350da
callq 0x11300
testb $0x1, %al
jne 0x904f
movq -0x18(%rbp), %rdi
leaq 0x2c09e(%rip), %rsi     # 0x350df
callq 0x11300
testb $0x1, %al
jne 0x904f
jmp 0x911b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x78a0
movq -0x10(%rbp), %rdi
callq 0x8b60
testb $0x1, %al
jne 0x90ef
jmp 0x906f
movq -0x10(%rbp), %rdi
callq 0xf060
movq -0x10(%rbp), %rdi
callq 0x7550
movq %rax, %rdi
callq 0x8d10
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x101(%rbp)
jne 0x90ce
movq -0x10(%rbp), %rdi
callq 0x7550
movq %rax, %rdi
callq 0x8db0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x101(%rbp)
jne 0x90ce
movq -0x10(%rbp), %rdi
callq 0x7550
cmpl $0x0, 0x2c(%rax)
sete %al
movb %al, -0x101(%rbp)
movb -0x101(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x906f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movb $0x1, 0x50(%rax)
movb $0x0, -0x1(%rbp)
jmp 0x93ea
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x90fa
jmp 0x9119
leaq 0x2aeca(%rip), %rdi     # 0x33fcb
leaq 0x29d6c(%rip), %rsi     # 0x32e74
movl $0x1087, %edx           # imm = 0x1087
leaq 0x2bfd0(%rip), %rcx     # 0x350e4
callq 0x4100
jmp 0x911b
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x919b
movq -0x10(%rbp), %rdi
callq 0x8cb0
movl 0x2c(%rax), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x2, -0xb4(%rbp)
jne 0x9148
movq -0x18(%rbp), %rdi
callq 0x10c30
cmpl $0x1, -0xb4(%rbp)
jne 0x915a
movq -0x18(%rbp), %rdi
callq 0x10eb0
movq -0x18(%rbp), %rdi
callq 0x10cc0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0xb4(%rbp), %edx
callq 0x10db0
movq -0x18(%rbp), %rax
testb $0x1, 0x48(%rax)
je 0x9192
movq -0x10(%rbp), %rdi
callq 0xf060
movq -0x10(%rbp), %rdi
callq 0xf240
movb $0x1, -0x1(%rbp)
jmp 0x93ea
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x91a6
jmp 0x91c5
leaq 0x2b436(%rip), %rdi     # 0x345e3
leaq 0x29cc0(%rip), %rsi     # 0x32e74
movl $0x109f, %edx           # imm = 0x109F
leaq 0x2bf24(%rip), %rcx     # 0x350e4
callq 0x4100
movq -0x10(%rbp), %rdi
callq 0x7550
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0xc0(%rbp)
je 0x91e1
jmp 0x9200
leaq 0x2be37(%rip), %rdi     # 0x3501f
leaq 0x29c85(%rip), %rsi     # 0x32e74
movl $0x10a1, %edx           # imm = 0x10A1
leaq 0x2bee9(%rip), %rcx     # 0x350e4
callq 0x4100
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0xd0(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rax
movq 0x30(%rax), %rcx
movq %rcx, -0xe0(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x6000
leaq -0xe0(%rbp), %rdi
callq 0x6000
movb $0x1, -0xe1(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x11690
testb $0x1, %al
jne 0x9281
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x78a0
movb $0x0, -0xe1(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0xe8(%rbp)
movl -0xe8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xe8(%rbp)
cmpl $0x0, -0xe8(%rbp)
jle 0x9387
movq -0xd8(%rbp), %rax
movl %eax, %esi
movq -0xe0(%rbp), %rdx
movl -0xe8(%rbp), %ecx
leaq 0x2be56(%rip), %rdi     # 0x35121
movb $0x0, %al
callq 0x7540
leaq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x11690
testb $0x1, %al
jne 0x92eb
jmp 0x931d
leaq 0x2be49(%rip), %rdi     # 0x3513b
movb $0x0, %al
callq 0x7540
movq -0x10(%rbp), %rdi
callq 0xf060
cmpq -0xc0(%rbp), %rax
je 0x930d
jmp 0x92f9
movb -0xe1(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x93ea
movl -0xe8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xe8(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movslq -0xe8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jne 0x9359
jmp 0x9387
movq -0xc0(%rbp), %rax
movq 0x30(%rax), %rcx
movq %rcx, -0xe0(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0xd8(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x6000
jmp 0x92a1
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jne 0x9396
jmp 0x93b5
leaq 0x2bda8(%rip), %rdi     # 0x35145
leaq 0x29ad0(%rip), %rsi     # 0x32e74
movl $0x10cb, %edx           # imm = 0x10CB
leaq 0x2bd34(%rip), %rcx     # 0x350e4
callq 0x4100
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8e60
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x102(%rbp)
jne 0x93d3
jmp 0x93df
movb -0xe1(%rbp), %al
movb %al, -0x102(%rbp)
movb -0x102(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax,%rax)