// File: /workspace/github_c_makefile_star2_O3/craigbarnes[P]lua-gumbo/lib/parser.c
// Function: handle_in_head
static bool handle_in_head(GumboParser* parser, GumboToken* token) {
  if (token->type == GUMBO_TOKEN_WHITESPACE) {
    insert_text_token(parser, token);
    return true;
  } else if (token->type == GUMBO_TOKEN_DOCTYPE) {
    parser_add_parse_error(parser, token);
    ignore_token(parser);
    return false;
  } else if (token->type == GUMBO_TOKEN_COMMENT) {
    append_comment_node(parser, get_current_node(parser), token);
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_HTML)) {
    return handle_in_body(parser, token);
  } else if (
    tag_in(token, kStartTag, &(const TagSet) {
      TAG(BASE), TAG(BASEFONT), TAG(BGSOUND), TAG(LINK)
    })
  ) {
    insert_element_from_token(parser, token);
    pop_current_node(parser);
    acknowledge_self_closing_tag(parser);
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_META)) {
    insert_element_from_token(parser, token);
    pop_current_node(parser);
    acknowledge_self_closing_tag(parser);
    // NOTE(jdtang): Gumbo handles only UTF-8, so the encoding clause of the
    // spec doesn't apply. If clients want to handle meta-tag re-encoding, they
    // should specifically look for that string in the document and re-encode it
    // before passing to Gumbo.
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_TITLE)) {
    run_generic_parsing_algorithm(parser, token, GUMBO_LEX_RCDATA);
    return true;
  } else if (
    tag_in(token, kStartTag, &(const TagSet){TAG(NOFRAMES), TAG(STYLE)})
  ) {
    run_generic_parsing_algorithm(parser, token, GUMBO_LEX_RAWTEXT);
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_NOSCRIPT)) {
    insert_element_from_token(parser, token);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_HEAD_NOSCRIPT);
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_SCRIPT)) {
    run_generic_parsing_algorithm(parser, token, GUMBO_LEX_SCRIPT);
    return true;
  } else if (tag_is(token, kEndTag, GUMBO_TAG_HEAD)) {
    GumboNode* head = pop_current_node(parser);
    UNUSED_IF_NDEBUG(head);
    assert(node_html_tag_is(head, GUMBO_TAG_HEAD));
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_AFTER_HEAD);
    return true;
  } else if (
    tag_in(token, kEndTag, &(const TagSet){TAG(BODY), TAG(HTML), TAG(BR)})
  ) {
    pop_current_node(parser);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_AFTER_HEAD);
    parser->_parser_state->_reprocess_current_token = true;
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_TEMPLATE)) {
    insert_element_from_token(parser, token);
    add_formatting_element(parser, &kActiveFormattingScopeMarker);
    parser->_parser_state->_frameset_ok = false;
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_TEMPLATE);
    push_template_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_TEMPLATE);
    return true;
  } else if (tag_is(token, kEndTag, GUMBO_TAG_TEMPLATE)) {
    if (!has_open_element(parser, GUMBO_TAG_TEMPLATE)) {
      parser_add_parse_error(parser, token);
      ignore_token(parser);
      return false;
    }
    generate_all_implied_end_tags_thoroughly(parser);
    bool success = true;
    if (!node_html_tag_is(get_current_node(parser), GUMBO_TAG_TEMPLATE)) {
      parser_add_parse_error(parser, token);
      success = false;
    }
    while (!node_html_tag_is(pop_current_node(parser), GUMBO_TAG_TEMPLATE)) {
      ;
    }
    clear_active_formatting_elements(parser);
    pop_template_insertion_mode(parser);
    reset_insertion_mode_appropriately(parser);
    return success;
  } else if (
    tag_is(token, kStartTag, GUMBO_TAG_HEAD)
    || (token->type == GUMBO_TOKEN_END_TAG)
  ) {
    parser_add_parse_error(parser, token);
    ignore_token(parser);
    return false;
  } else {
    pop_current_node(parser);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_AFTER_HEAD);
    parser->_parser_state->_reprocess_current_token = true;
    return true;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rsi), %eax
cmpq $0x4, %rax
ja 0x8ed8
movq %rsi, %r14
leaq 0x107c7(%rip), %rcx     # 0x195c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7d9d
movq 0x18(%rbx), %rax
movq 0x98(%rax), %rbx
movq %rbx, %rdi
callq 0xc990
cmpl $0x1, (%rbx)
jne 0x8e34
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbx)
xorl %ebp, %ebp
jmp 0x8ef1
movq %rbx, %rdi
movq %r14, %rsi
callq 0xaf71
jmp 0x8eee
movl 0x30(%r14), %eax
cmpq $0x1, %rax
jne 0x8ecb
movq %rbx, %rdi
callq 0xaffb
movq %rax, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x8739
testb %al, %al
je 0x908e
movq 0x18(%rbx), %rax
movl $0x5, (%rax)
jmp 0x8eee
movq %rbx, %rdi
callq 0x7d33
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xac3d
jmp 0x8eee
movl 0x30(%r14), %eax
testq %rax, %rax
je 0x8efe
leaq 0x10b50(%rip), %rcx     # 0x199f8
cmpb $0x0, (%rax,%rcx)
je 0x8f13
movq %rbx, %rdi
movq %r14, %rsi
callq 0xade5
movq %rbx, %rdi
callq 0xaffb
movq 0x18(%rbx), %rax
movb $0x1, 0x51(%rax)
jmp 0x8eee
leaq 0x10ebe(%rip), %rcx     # 0x19d90
cmpb $0x0, (%rax,%rcx)
je 0x8f43
movq %rbx, %rdi
callq 0xaffb
movq 0x18(%rbx), %rax
movl $0x5, (%rax)
movb $0x1, 0x50(%rax)
movb $0x1, %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4ece
cmpq $0x2, %rax
je 0x8ffc
cmpl $0x5, %eax
je 0x8eae
leaq 0x10b67(%rip), %rcx     # 0x19a90
cmpb $0x0, (%rax,%rcx)
je 0x9011
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %edx
jmp 0x9007
cmpl $0x9, %eax
jne 0x8e0a
movq 0x18(%rbx), %rdi
leaq 0x4(%rsp), %rdx
movl $0x9, (%rdx)
leaq 0x10c5e(%rip), %r8      # 0x19bc0
movl $0x1, %esi
xorl %ecx, %ecx
callq 0xb40a
movq %rbx, %rdi
testb %al, %al
je 0x8e0d
callq 0xb277
movq %rbx, %rdi
callq 0x7d33
movq %rax, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0x8739
movl %eax, %ebp
testb %al, %al
jne 0x8fa6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7d9d
movq %rbx, %rdi
callq 0xaffb
movq %rax, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0x8739
testb %al, %al
je 0x8fa6
movq 0x18(%rbx), %r14
addq $0x18, %r14
leaq 0x10b58(%rip), %r15     # 0x19b28
movq %r14, %rdi
callq 0x7bd3
testq %rax, %rax
je 0x8fe2
cmpq %r15, %rax
jne 0x8fd0
movq 0x18(%rbx), %rdi
addq $0x28, %rdi
callq 0x7bd3
movq %rbx, %rdi
callq 0x8104
jmp 0x8ef1
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0xb1b5
jmp 0x8eee
decl %eax
cmpl $0x8, %eax
ja 0x8ed8
leaq 0x105b9(%rip), %rcx     # 0x195dc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r14, %rsi
movl $0x5, %edx
jmp 0x9007
movq %rbx, %rdi
movq %r14, %rsi
callq 0xade5
movq 0x18(%rbx), %rax
movl $0x4, (%rax)
jmp 0x8eee
movq %rbx, %rdi
movq %r14, %rsi
callq 0xade5
leaq 0x10ac3(%rip), %rsi     # 0x19b28
movq %rbx, %rdi
callq 0xb1e4
movq 0x18(%rbx), %rsi
movb $0x0, 0x52(%rsi)
movl $0x11, (%rsi)
addq $0x28, %rsi
movl $0x11, %edi
callq 0x7b25
jmp 0x8eee
leaq 0x1394b(%rip), %rdi     # 0x1c9e0
leaq 0x12894(%rip), %rsi     # 0x1b930
leaq 0x13964(%rip), %rcx     # 0x1ca07
movl $0x9b0, %edx            # imm = 0x9B0
callq 0x4100