// File: /workspace/github_c_makefile_star2_O3/craigbarnes[P]lua-gumbo/lib/parser.c
// Function: handle_in_template
static bool handle_in_template(GumboParser* parser, GumboToken* token) {
  GumboParserState* state = parser->_parser_state;
  switch (token->type) {
    case GUMBO_TOKEN_WHITESPACE:
    case GUMBO_TOKEN_CHARACTER:
    case GUMBO_TOKEN_COMMENT:
    case GUMBO_TOKEN_NULL:
    case GUMBO_TOKEN_DOCTYPE:
      return handle_in_body(parser, token);
    default:
      break;
  }
  if (
    tag_in(token, kStartTag, &(const TagSet) {
      TAG(BASE), TAG(BASEFONT), TAG(BGSOUND), TAG(LINK), TAG(META),
      TAG(NOFRAMES), TAG(SCRIPT), TAG(STYLE), TAG(TEMPLATE), TAG(TITLE)
    })
    || tag_is(token, kEndTag, GUMBO_TAG_TEMPLATE)
  ) {
    return handle_in_head(parser, token);
  } else if (
    tag_in(token, kStartTag, &(const TagSet) {
      TAG(CAPTION), TAG(COLGROUP), TAG(TBODY), TAG(TFOOT), TAG(THEAD)
    })
  ) {
    pop_template_insertion_mode(parser);
    push_template_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_TABLE);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_TABLE);
    state->_reprocess_current_token = true;
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_COL)) {
    pop_template_insertion_mode(parser);
    push_template_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_COLUMN_GROUP);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_COLUMN_GROUP);
    state->_reprocess_current_token = true;
    return true;
  } else if (tag_is(token, kStartTag, GUMBO_TAG_TR)) {
    pop_template_insertion_mode(parser);
    push_template_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_TABLE_BODY);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_TABLE_BODY);
    state->_reprocess_current_token = true;
    return true;
  } else if (tag_in(token, kStartTag, &td_th_tags)) {
    pop_template_insertion_mode(parser);
    push_template_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_ROW);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_ROW);
    state->_reprocess_current_token = true;
    return true;
  } else if (token->type == GUMBO_TOKEN_START_TAG) {
    pop_template_insertion_mode(parser);
    push_template_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_BODY);
    set_insertion_mode(parser, GUMBO_INSERTION_MODE_IN_BODY);
    state->_reprocess_current_token = true;
    return true;
  } else if (token->type == GUMBO_TOKEN_END_TAG) {
    parser_add_parse_error(parser, token);
    ignore_token(parser);
    return false;
  } else if (token->type == GUMBO_TOKEN_EOF) {
    if (!has_open_element(parser, GUMBO_TAG_TEMPLATE)) {
      // Stop parsing.
      return true;
    }
    parser_add_parse_error(parser, token);
    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);
    state->_reprocess_current_token = true;
    return false;
  } else {
    assert(0);
    return false;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl (%rsi), %eax
cmpq $0x8, %rax
ja 0xa702
movq %rsi, %r15
movq %rdi, %rbx
movq 0x18(%rdi), %r14
leaq 0xf1a0(%rip), %rcx      # 0x19694
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x4ece
movl 0x30(%r15), %r12d
leaq 0x111ca(%rip), %rax     # 0x1b6e8
cmpb $0x0, (%r12,%rax)
jne 0xa603
leaq 0x11250(%rip), %rax     # 0x1b780
cmpb $0x0, (%r12,%rax)
je 0xa651
leaq 0x28(%r14), %rdi
callq 0x7bd3
movq 0x18(%rbx), %rsi
addq $0x28, %rsi
movl $0x8, %edi
callq 0x7b25
movq 0x18(%rbx), %rax
movl $0x8, (%rax)
movb $0x1, 0x50(%r14)
movb $0x1, %al
jmp 0xa645
leaq 0x4(%rsp), %rdx
movl $0x9, (%rdx)
leaq 0xf642(%rip), %r8       # 0x19bc0
movq %r14, %rdi
movl $0x1, %esi
xorl %ecx, %ecx
callq 0xb40a
movl %eax, %ecx
movb $0x1, %al
testb %cl, %cl
je 0xa645
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7d9d
movq %rbx, %rdi
callq 0xaffb
movq %rax, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0x8739
testb %al, %al
je 0xa5a4
movq 0x18(%rbx), %r15
addq $0x18, %r15
leaq 0xf55a(%rip), %r12      # 0x19b28
movq %r15, %rdi
callq 0x7bd3
testq %rax, %rax
je 0xa5e0
cmpq %r12, %rax
jne 0xa5ce
movq 0x18(%rbx), %rdi
addq $0x28, %rdi
callq 0x7bd3
movq %rbx, %rdi
callq 0x8104
movb $0x1, 0x50(%r14)
jmp 0xa643
cmpl $0x9, 0x30(%r15)
jne 0xa619
movq %rbx, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x8de1
movq %rbx, %rdi
movq %r15, %rsi
callq 0x7d9d
movq 0x18(%rbx), %rax
movq 0x98(%rax), %rbx
movq %rbx, %rdi
callq 0xc990
cmpl $0x1, (%rbx)
jne 0xa643
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpq $0x66, %r12
je 0xa687
cmpl $0x62, %r12d
jne 0xa6b1
leaq 0x28(%r14), %rdi
callq 0x7bd3
movq 0x18(%rbx), %rsi
addq $0x28, %rsi
movl $0xb, %edi
callq 0x7b25
movq 0x18(%rbx), %rax
movl $0xb, (%rax)
jmp 0xa560
leaq 0x28(%r14), %rdi
callq 0x7bd3
movq 0x18(%rbx), %rsi
addq $0x28, %rsi
movl $0xc, %edi
callq 0x7b25
movq 0x18(%rbx), %rax
movl $0xc, (%rax)
jmp 0xa560
leaq 0x10a38(%rip), %r15     # 0x1b0f0
leaq 0x28(%r14), %rdi
callq 0x7bd3
movq 0x18(%rbx), %rsi
addq $0x28, %rsi
cmpb $0x0, (%r12,%r15)
je 0xa6e9
movl $0xd, %edi
callq 0x7b25
movq 0x18(%rbx), %rax
movl $0xd, (%rax)
jmp 0xa560
movl $0x6, %edi
callq 0x7b25
movq 0x18(%rbx), %rax
movl $0x6, (%rax)
jmp 0xa560
leaq 0x12d3c(%rip), %rdi     # 0x1d445
leaq 0x11220(%rip), %rsi     # 0x1b930
leaq 0x12dd4(%rip), %rcx     # 0x1d4eb
movl $0xf6d, %edx            # imm = 0xF6D
callq 0x4100