// File: /workspace/github_c_makefile_star2_O2/craigbarnes[P]lua-gumbo/lib/parser.c
// Function: gumbo_parse_with_options
HOT GumboOutput* gumbo_parse_with_options (
  const GumboOptions* options,
  const char* buffer,
  size_t length
) {
  GumboParser parser;
  parser._options = options;
  output_init(&parser);
  gumbo_tokenizer_state_init(&parser, buffer, length);
  parser_state_init(&parser);

  if (options->fragment_context != GUMBO_TAG_LAST) {
    fragment_parser_init (
      &parser,
      options->fragment_context,
      options->fragment_namespace
    );
  }

  GumboParserState* state = parser._parser_state;
  gumbo_debug (
    "Parsing %.*s.\n",
    (int) length,
    buffer
  );

  // Sanity check so that infinite loops die with an assertion failure instead
  // of hanging the process before we ever get an error.
  uint_fast32_t loop_count = 0;

  const unsigned int max_tree_depth = options->max_tree_depth;
  GumboToken token;
  bool has_error = false;

  do {
    if (state->_reprocess_current_token) {
      state->_reprocess_current_token = false;
    } else {
      GumboNode* current_node = get_current_node(&parser);
      gumbo_tokenizer_set_is_current_node_foreign (
        &parser,
        current_node &&
          current_node->v.element.tag_namespace != GUMBO_NAMESPACE_HTML
      );
      has_error = !gumbo_lex(&parser, &token) || has_error;
    }

    const char* token_type = "text";
    switch (token.type) {
      case GUMBO_TOKEN_DOCTYPE:
        token_type = "doctype";
        break;
      case GUMBO_TOKEN_START_TAG:
        token_type = gumbo_normalized_tagname(token.v.start_tag.tag);
        break;
      case GUMBO_TOKEN_END_TAG:
        token_type = gumbo_normalized_tagname(token.v.end_tag);
        break;
      case GUMBO_TOKEN_COMMENT:
        token_type = "comment";
        break;
      default:
        break;
    }
    gumbo_debug (
      "Handling %s token @%zu:%zu in state %u.\n",
      (char*) token_type,
      token.position.line,
      token.position.column,
      state->_insertion_mode
    );

    state->_current_token = &token;
    state->_self_closing_flag_acknowledged =
      !(
        token.type == GUMBO_TOKEN_START_TAG
        && token.v.start_tag.is_self_closing
      );

    has_error = !handle_token(&parser, &token) || has_error;

    // Check for memory leaks when ownership is transferred from start tag
    // tokens to nodes.
    assert (
      state->_reprocess_current_token
      || token.type != GUMBO_TOKEN_START_TAG
      || token.v.start_tag.attributes.data == NULL
    );

    if (!state->_self_closing_flag_acknowledged) {
      GumboError* error = parser_add_parse_error(&parser, &token);
      if (error) {
        error->type = GUMBO_ERR_UNACKNOWLEDGED_SELF_CLOSING_TAG;
      }
    }

    if (unlikely(state->_open_elements.length > max_tree_depth)) {
      parser._output->status = GUMBO_STATUS_TREE_TOO_DEEP;
      gumbo_debug("Tree depth limit exceeded.\n");
      break;
    }

    ++loop_count;
    assert(loop_count < 1000000000UL);

  } while (
    (token.type != GUMBO_TOKEN_EOF || state->_reprocess_current_token)
    && !(options->stop_on_first_error && has_error)
  );

  finish_parsing(&parser);
  // For API uniformity reasons, if the doctype still has nulls, convert them to
  // empty strings.
  GumboDocument* doc_type = &parser._output->document->v.document;
  if (doc_type->name == NULL) {
    doc_type->name = gumbo_strdup("");
  }
  if (doc_type->public_identifier == NULL) {
    doc_type->public_identifier = gumbo_strdup("");
  }
  if (doc_type->system_identifier == NULL) {
    doc_type->system_identifier = gumbo_strdup("");
  }

  parser_state_destroy(&parser);
  gumbo_tokenizer_state_destroy(&parser);
  return parser._output;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
leaq 0x8(%rsp), %rax
movq %rdi, (%rax)
pushq $0x28
popq %rdi
callq 0xf6a4
movq %rax, %r13
andq $0x0, 0x8(%rax)
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x7bec
movq %rax, %rbp
movl $0x1, 0x14(%rax)
leaq 0x18(%rax), %rsi
pushq $0x1
popq %rdi
callq 0x76f4
movb %bl, 0x28(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbp)
andq $0x0, 0x40(%rbp)
movq %rbp, (%r13)
andl $0x0, 0x20(%r13)
leaq 0x8(%rsp), %rbp
movq %r13, 0x8(%rbp)
movq %rbp, %rdi
callq 0x702b
movq %rbp, %rdi
movq %rbp, %r13
movq %r12, %rsi
movq %r15, %r12
movq %r14, %rdx
callq 0xbbcc
movl $0xa8, %edi
callq 0xf6a4
movq %rax, %r14
andl $0x0, (%rax)
movb %bl, 0x50(%rax)
movw $0x1, 0x52(%rax)
movb %bl, 0x54(%rax)
leaq 0x58(%rax), %rdi
movl $0x5, 0x90(%rax)
callq 0x70f4
leaq 0x8(%r14), %rsi
pushq $0xa
popq %rdi
callq 0x76f4
leaq 0x18(%r14), %rsi
pushq $0x5
popq %rbp
movl %ebp, %edi
callq 0x76f4
leaq 0x28(%r14), %rsi
movl %ebp, %edi
callq 0x76f4
andq $0x0, 0x98(%r14)
andw $0x0, 0xa0(%r14)
andq $0x0, 0x48(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r14)
movq %r14, 0x18(%r13)
movl 0x10(%r15), %r15d
cmpl $0x97, %r15d
je 0x4556
movl 0x14(%r12), %ebx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl %r15d, %esi
callq 0x7c0b
movq 0x18(%r14), %rcx
movq %rax, 0x48(%rcx)
movl %ebx, 0x2c(%rax)
testl %ebx, %ebx
jne 0x4514
leal -0x82(%r15), %eax
cmpl $0x5, %eax
jbe 0x44f7
pushq $0x2
popq %rsi
cmpl $0x2, %r15d
je 0x450a
cmpl $0x6, %r15d
je 0x4507
cmpl $0x7, %r15d
je 0x4b50
cmpl $0x73, %r15d
je 0x450a
cmpl $0x48, %r15d
je 0x4507
jmp 0x4514
leaq 0x12fc2(%rip), %rcx     # 0x174c0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x4
popq %rsi
leaq 0x8(%rsp), %rdi
callq 0xbc80
leaq 0x8(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x7c99
movq 0x8(%r14), %rcx
movq %rax, 0x8(%rcx)
cmpl $0x9, %r15d
jne 0x4545
movq 0x20(%rsp), %rsi
addq $0x28, %rsi
pushq $0x11
popq %rdi
callq 0x7726
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x7cea
movq 0x18(%r14), %r14
movl 0x8(%r12), %eax
movl %eax, 0x2c(%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
pushq $0x1
popq %rbp
movq %r14, 0x88(%rsp)
cmpb $0x1, 0x50(%r14)
jne 0x4582
movb $0x0, 0x50(%r14)
leaq 0x30(%rsp), %r13
jmp 0x45de
movq %r15, %r14
movl %ebp, %r15d
leaq 0x8(%rsp), %rdi
callq 0x7913
movq %r12, %rbp
testq %rax, %rax
je 0x45a3
cmpl $0x0, 0x2c(%rax)
setne %al
jmp 0x45a5
xorl %eax, %eax
leaq 0x30(%rsp), %r13
movzbl %al, %esi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xbd22
movq %r12, %rdi
movq %r13, %rsi
callq 0x5f4a
xorb $0x1, %al
orb %al, %bl
movl 0x30(%rsp), %eax
movq %rbp, %r12
movl %r15d, %ebp
movq %r14, %r15
movq 0x88(%rsp), %r14
leal -0x1(%rax), %ecx
cmpl $0x1, %ecx
ja 0x45f3
movl 0x60(%rsp), %edi
callq 0x730c
movl 0x30(%rsp), %eax
movq %r13, 0x98(%r14)
movb 0x78(%rsp), %cl
xorb $0x1, %cl
cmpl $0x1, %eax
movzbl %cl, %ecx
cmovnel %ebp, %ecx
movb %cl, 0x51(%r14)
movq 0x20(%rsp), %rcx
cmpb $0x1, 0x53(%rcx)
jne 0x463b
cmpl $0x4, %eax
jne 0x463b
cmpl $0xa, 0x60(%rsp)
movb $0x0, 0x53(%rcx)
leaq 0x8(%rsp), %rdi
jne 0x4666
callq 0x83cf
movb $0x1, %r13b
jmp 0x4742
movb $0x0, 0x53(%rcx)
cmpl $0x2, %eax
leaq 0x8(%rsp), %rdi
jne 0x4666
movl 0x60(%rsp), %eax
testl %eax, %eax
je 0x465f
cmpl $0xa, %eax
jne 0x4666
movb $0x1, 0xa0(%rcx)
jmp 0x4666
movb $0x1, 0xa1(%rcx)
callq 0x83f1
testq %rax, %rax
je 0x4724
movq %rax, %r13
movl (%rax), %eax
cmpl $0x1, %eax
je 0x4687
cmpl $0x6, %eax
jne 0x4cc8
movl 0x28(%r13), %edi
callq 0x730c
cmpl $0x0, 0x2c(%r13)
je 0x4724
movq %r13, %rdi
callq 0x840d
testb %al, %al
je 0x46ce
movl 0x30(%rsp), %eax
leal -0x4(%rax), %ecx
cmpl $0x2, %ecx
jb 0x4724
cmpl $0x7, %eax
je 0x4724
cmpl $0x1, %eax
jne 0x46ce
movl 0x60(%rsp), %eax
leaq 0x13024(%rip), %rcx     # 0x176ec
cmpb $0x0, (%rax,%rcx)
je 0x4724
cmpl $0x2, 0x2c(%r13)
jne 0x46f5
movq %r13, %rdi
pushq $0x2
popq %rsi
pushq $0x5b
popq %rdx
callq 0x82bd
testb %al, %al
je 0x46f5
cmpl $0x1, 0x30(%rsp)
jne 0x46f5
cmpl $0x5c, 0x60(%rsp)
je 0x4724
movq %r13, %rdi
callq 0x8419
movl 0x30(%rsp), %ecx
movl %ecx, %edx
testb %al, %al
je 0x47cf
cmpl $0x8, %ecx
ja 0x4948
leaq 0x12de1(%rip), %rsi     # 0x174fc
movslq (%rsi,%rdx,4), %rax
addq %rsi, %rax
jmpq *%rax
movq 0x20(%rsp), %rax
movl (%rax), %eax
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x4d594(%rip), %rcx     # 0x51cd0
callq *(%rcx,%rax,8)
movl %eax, %r13d
cmpb $0x0, 0x50(%r14)
jne 0x475c
cmpl $0x1, 0x30(%rsp)
jne 0x475c
cmpq $0x0, 0x68(%rsp)
jne 0x4c8a
cmpb $0x0, 0x51(%r14)
jne 0x477d
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x797d
testq %rax, %rax
je 0x477d
movl $0x29, (%rax)
movl 0x2c(%rsp), %eax
cmpl %eax, 0x10(%r14)
ja 0x4b57
cmpq $0x3b9ac9ff, %r15       # imm = 0x3B9AC9FF
je 0x4ca9
movl 0x30(%rsp), %eax
cmpl $0x8, %eax
jne 0x47ac
cmpb $0x1, 0x50(%r14)
jne 0x4b63
xorb $0x1, %r13b
orb %bl, %r13b
incq %r15
movb 0x4(%r12), %cl
andb %r13b, %cl
movl %r13d, %ebx
cmpb $0x1, %cl
jne 0x456f
jmp 0x4b63
cmpl $0x8, %ecx
ja 0x4948
leaq 0x12cf9(%rip), %rsi     # 0x174d8
movslq (%rsi,%rdx,4), %rax
addq %rsi, %rax
jmpq *%rax
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa59b
movq 0x20(%rsp), %rax
movb $0x0, 0x52(%rax)
jmp 0x4633
movq %r12, %r13
leaq 0x8(%rsp), %r12
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
callq 0x797d
movq %r12, %rdi
movq %r13, %r12
callq 0x83cf
jmp 0x4b41
movq %r12, %r13
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x7913
movq %r12, %rdi
movq %r13, %r12
movq %rax, %rsi
leaq 0x30(%rsp), %rdx
callq 0xa2ca
jmp 0x4633
movl 0x60(%rsp), %eax
leaq 0x14f2b(%rip), %rcx     # 0x19788
cmpb $0x0, (%rax,%rcx)
leaq 0x30(%rsp), %r13
je 0x48f8
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x797d
movq 0x20(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0x4af5
cmpl $0x1, 0x30(%rsp)
je 0x495b
jmp 0x4d25
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa59b
jmp 0x4633
movq %r15, %r14
movq %rbx, %r15
movl %ebp, %ebx
movq %r12, %rbp
leaq 0x8(%rsp), %r12
movq %r12, %rdi
leaq 0x30(%rsp), %r13
movq %r13, %rsi
callq 0x797d
movl $0xfffd, 0x60(%rsp)     # imm = 0xFFFD
movq %r12, %rdi
movq %rbp, %r12
movl %ebx, %ebp
movq %r15, %rbx
movq %r14, %r15
movq 0x88(%rsp), %r14
movq %r13, %rsi
callq 0xa59b
jmp 0x4b41
cmpl $0x8e, %eax
jne 0x495b
movq %r13, %rdi
leaq 0x46e1f(%rip), %rsi     # 0x4b728
callq 0xb94c
testb %al, %al
jne 0x486c
movq %r13, %rdi
leaq 0x16c18(%rip), %rsi     # 0x1b538
callq 0xb94c
testb %al, %al
jne 0x486c
movq %r13, %rdi
leaq 0x16c06(%rip), %rsi     # 0x1b53d
callq 0xb94c
testb %al, %al
jne 0x486c
movl 0x30(%rsp), %ecx
cmpl $0x2, %ecx
je 0x4987
cmpl $0x1, %ecx
leaq 0x30(%rsp), %r13
jne 0x4ce7
leaq 0x8(%rsp), %rdi
callq 0x83f1
movl 0x2c(%rax), %ebp
cmpl $0x1, %ebp
je 0x4a66
cmpl $0x2, %ebp
jne 0x4a6e
movq %r13, %rdi
callq 0xb50b
jmp 0x4a6e
leaq 0x8(%rsp), %rdi
callq 0x7913
testq %rax, %rax
je 0x4d06
movq %rax, %rbp
movq %r12, 0x80(%rsp)
leaq 0x50(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0xa0(%rsp)
movups 0x30(%rbp), %xmm0
movaps %xmm0, 0x90(%rsp)
leaq 0xa0(%rsp), %r12
movq %r12, %rdi
callq 0x7345
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x7345
movq %r13, %rdi
movq %r12, %rsi
callq 0xbbb2
movl %eax, %r13d
testb %al, %al
jne 0x4a02
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x797d
movq 0x20(%rsp), %rax
movl 0x10(%rax), %r12d
decl %r12d
testl %r12d, %r12d
jle 0x4aa4
leaq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xbbb2
testb %al, %al
jne 0x4ad6
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rcx,%r12,8), %rbp
cmpl $0x0, 0x2c(%rbp)
je 0x4ab3
movups 0x30(%rbp), %xmm0
movaps %xmm0, 0x90(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x7345
decq %r12
jmp 0x4a0e
movq %r13, %rdi
callq 0xb6c0
movq %r13, %rdi
callq 0xb563
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0xb5f3
movb $0x1, %r13b
cmpb $0x1, 0x78(%rsp)
jne 0x4aed
leaq 0x8(%rsp), %rdi
callq 0xa620
movq 0x20(%rsp), %rax
movb $0x1, 0x51(%rax)
jmp 0x4aed
cmpl $0x0, 0x2c(%rbp)
jne 0x4d44
movq 0x20(%rsp), %rax
movl (%rax), %eax
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x4d20a(%rip), %rcx     # 0x51cd0
callq *(%rcx,%rax,8)
andb %al, %r13b
movq 0x80(%rsp), %r12
jmp 0x4aed
movq 0x80(%rsp), %r12
leaq 0x8(%rsp), %rdi
callq 0xa620
cmpq %rbp, %rax
jne 0x4ade
pushq $0x1
popq %rbp
jmp 0x4742
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0xa620
movq %r13, %rdi
callq 0x7913
movq %rax, %rdi
callq 0x840d
testb %al, %al
jne 0x4b38
movq %r13, %rdi
callq 0x7913
movq %rax, %rdi
callq 0x8419
testb %al, %al
jne 0x4b38
movq %r13, %rdi
callq 0x7913
cmpl $0x0, 0x2c(%rax)
jne 0x4afa
movq 0x20(%rsp), %rax
movb $0x1, 0x50(%rax)
xorl %r13d, %r13d
jmp 0x4742
pushq $0x6
jmp 0x4509
movl %ebp, %esi
jmp 0x450a
movq 0x10(%rsp), %rax
movl $0x1, 0x20(%rax)
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7ec1
movq 0x18(%rbx), %r15
movq %rbx, %rdi
callq 0xa620
movq %rax, %r14
pushq $0xa
popq %rbp
testq %r14, %r14
je 0x4bc9
movq %r14, %rdi
movl %ebp, %esi
callq 0x82b7
testb %al, %al
je 0x4b9f
cmpb $0x0, 0xa0(%r15)
jne 0x4bbc
movq %r14, %rdi
xorl %esi, %esi
callq 0x82b7
testb %al, %al
je 0x4bb7
cmpb $0x0, 0xa1(%r15)
jne 0x4bbc
orb $0x2, 0x14(%r14)
movq %rbx, %rdi
callq 0xa620
movq %rax, %r14
jmp 0x4b82
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa620
testq %rax, %rax
jne 0x4bce
movq 0x10(%rsp), %rax
movq (%rax), %rbx
cmpq $0x0, 0x30(%rbx)
jne 0x4bfa
leaq 0x11a67(%rip), %rdi     # 0x16658
callq 0xf6e5
movq %rax, 0x30(%rbx)
cmpq $0x0, 0x38(%rbx)
jne 0x4c11
leaq 0x11a50(%rip), %rdi     # 0x16658
callq 0xf6e5
movq %rax, 0x38(%rbx)
cmpq $0x0, 0x40(%rbx)
jne 0x4c28
leaq 0x11a39(%rip), %rdi     # 0x16658
callq 0xf6e5
movq %rax, 0x40(%rbx)
movq 0x20(%rsp), %rbx
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x4c3b
callq 0x7a76
leaq 0x18(%rbx), %rdi
callq 0x7717
leaq 0x8(%rbx), %rdi
callq 0x7717
leaq 0x28(%rbx), %rdi
callq 0x7717
leaq 0x58(%rbx), %rdi
callq 0x7301
movq %rbx, %rdi
callq 0xf6e0
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0xbc87
movq 0x8(%rbx), %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14b9b(%rip), %rdi     # 0x1982c
leaq 0x14c08(%rip), %rsi     # 0x198a0
leaq 0x14c0e(%rip), %rcx     # 0x198ad
movl $0x11a8, %edx           # imm = 0x11A8
callq 0x4100
leaq 0x14c4f(%rip), %rdi     # 0x198ff
leaq 0x14be9(%rip), %rsi     # 0x198a0
leaq 0x14bef(%rip), %rcx     # 0x198ad
movl $0x11b8, %edx           # imm = 0x11B8
callq 0x4100
leaq 0x15075(%rip), %rdi     # 0x19d44
leaq 0x14bca(%rip), %rsi     # 0x198a0
leaq 0x150ce(%rip), %rcx     # 0x19dab
movl $0x10ef, %edx           # imm = 0x10EF
callq 0x4100
leaq 0x16093(%rip), %rdi     # 0x1ad81
leaq 0x14bab(%rip), %rsi     # 0x198a0
leaq 0x16846(%rip), %rcx     # 0x1b542
movl $0x109f, %edx           # imm = 0x109F
callq 0x4100
leaq 0x16789(%rip), %rdi     # 0x1b496
leaq 0x14b8c(%rip), %rsi     # 0x198a0
leaq 0x16827(%rip), %rcx     # 0x1b542
movl $0x10a1, %edx           # imm = 0x10A1
callq 0x4100
leaq 0x15b31(%rip), %rdi     # 0x1a85d
leaq 0x14b6d(%rip), %rsi     # 0x198a0
leaq 0x16808(%rip), %rcx     # 0x1b542
movl $0x1087, %edx           # imm = 0x1087
callq 0x4100
leaq 0x16834(%rip), %rdi     # 0x1b57f
leaq 0x14b4e(%rip), %rsi     # 0x198a0
leaq 0x167e9(%rip), %rcx     # 0x1b542
movl $0x10cb, %edx           # imm = 0x10CB
callq 0x4100