// File: /workspace/github_c_makefile_star2_O2/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
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %ebp
testl %ebp, %ebp
je 0x8ae1
cmpl $0x3, %ebp
je 0x88c7
cmpl $0x4, %ebp
jne 0x88e5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa59b
jmp 0x88dd
movq %rbx, %rdi
callq 0x7913
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xa2ca
movb $0x1, %bpl
jmp 0x8af6
cmpl $0x1, %ebp
jne 0x8925
movl 0x30(%r14), %eax
testq %rax, %rax
je 0x8979
leaq 0xf06a(%rip), %rcx      # 0x17968
cmpb $0x0, (%rax,%rcx)
je 0x8991
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa439
movq %rbx, %rdi
callq 0xa620
movq 0x18(%rbx), %rax
movb $0x1, 0x51(%rax)
jmp 0x88dd
leaq 0xf0d4(%rip), %rsi      # 0x17a00
movq %rsp, %rdi
movl $0x98, %edx
callq 0x4190
cmpl $0x2, %ebp
jne 0x8a02
movb $0x1, %al
cmpl $0x1, 0x30(%r14)
jne 0x8a04
movq %rbx, %rdi
callq 0xa620
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x82b7
testb %al, %al
je 0x8b63
movq 0x18(%rbx), %rax
movl $0x5, (%rax)
jmp 0x88dd
movq %rbx, %rdi
movq %r14, %rsi
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4d63
cmpq $0x2, %rax
je 0x89c7
cmpl $0x5, %eax
je 0x8908
leaq 0xf059(%rip), %rsi      # 0x17a00
movq %rsp, %rdi
movl $0x98, %edx
callq 0x4190
cmpl $0x1, %ebp
jne 0x8939
movl 0x30(%r14), %eax
cmpb $0x0, (%rsp,%rax)
je 0x89da
pushq $0x4
jmp 0x89c9
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa7b9
jmp 0x88dd
cmpl $0x7, %eax
je 0x8b5c
cmpl $0x8, %eax
jne 0x8a02
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa439
movq 0x18(%rbx), %rax
movl $0x4, (%rax)
jmp 0x88dd
xorl %eax, %eax
testb %al, %al
je 0x8a3b
movl 0x30(%r14), %ecx
leaq 0xf2ed(%rip), %rdx      # 0x17d00
cmpb $0x0, (%rcx,%rdx)
jne 0x8a8d
movl 0x30(%r14), %ecx
cmpl $0x1, %ebp
jne 0x8aa8
cmpl $0x9, %ecx
je 0x8a47
testb %al, %al
je 0x8a7f
cmpl $0x9, 0x30(%r14)
je 0x8aad
jmp 0x8ae1
cmpl $0x1, %ebp
jne 0x8a8d
cmpl $0x9, 0x30(%r14)
jne 0x8a7f
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa439
leaq 0xf03f(%rip), %rsi      # 0x17a98
movq %rbx, %rdi
callq 0xa7e8
movq 0x18(%rbx), %rax
movb $0x0, 0x52(%rax)
movl $0x11, (%rax)
pushq $0x11
popq %rsi
movq %rbx, %rdi
callq 0x7cd8
jmp 0x88dd
cmpl $0x1, 0x30(%r14)
setne %cl
notb %al
testb %cl, %al
je 0x8ae1
movq %rbx, %rdi
callq 0xa620
movq 0x18(%rbx), %rax
movl $0x5, (%rax)
movb $0x1, 0x50(%rax)
jmp 0x88dd
cmpl $0x9, %ecx
jne 0x8ae1
movq %rbx, %rdi
callq 0xa946
testb %al, %al
je 0x8ae1
leaq 0xf110(%rip), %r15      # 0x17bd0
movq %rbx, %rdi
callq 0x7913
movq %rax, %rdi
movq %r15, %rsi
callq 0x8272
movq %rbx, %rdi
testb %al, %al
je 0x8b06
callq 0xa620
jmp 0x8ac0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x797d
movq %rbx, %rdi
callq 0x83cf
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x7913
pushq $0x9
popq %rsi
movq %rax, %rdi
callq 0x82b7
movl %eax, %ebp
testb %al, %al
jne 0x8b27
movq %rbx, %rdi
movq %r14, %rsi
callq 0x797d
pushq $0x9
popq %r14
movq %rbx, %rdi
callq 0xa620
movq %rax, %rdi
movl %r14d, %esi
callq 0x82b7
testb %al, %al
je 0x8b2b
movq %rbx, %rdi
callq 0xa965
movq %rbx, %rdi
callq 0xa992
movq %rbx, %rdi
callq 0x7cea
jmp 0x8af6
pushq $0x5
jmp 0x89c9
leaq 0x11de6(%rip), %rdi     # 0x1a950
leaq 0x10d2f(%rip), %rsi     # 0x198a0
leaq 0x11dff(%rip), %rcx     # 0x1a977
movl $0x9b0, %edx            # imm = 0x9B0
callq 0x4100