// File: /workspace/github_c_makefile_star2_O0/craigbarnes[P]lua-gumbo/lib/tokenizer.c
// Function: gumbo_lex
HOT bool gumbo_lex(GumboParser* parser, GumboToken* output) {
  // Because of the spec requirements that...
  //
  // 1. Tokens be handled immediately by the parser upon emission.
  // 2. Some states (eg. CDATA, or various error conditions) require the
  // emission of multiple tokens in the same states.
  // 3. The tokenizer often has to reconsume the same character in a different
  // state.
  //
  // ...all state must be held in the GumboTokenizer struct instead of in local
  // variables in this function. That allows us to return from this method with
  // a token, and then immediately jump back to the same state with the same
  // input if we need to return a different token. The various emit_* functions
  // are responsible for changing state (eg. flushing the chardata buffer,
  // reading the next input character) to avoid an infinite loop.
  GumboTokenizerState* tokenizer = parser->_tokenizer_state;

  if (tokenizer->_buffered_emit_char != kGumboNoChar) {
    tokenizer->_reconsume_current_input = true;
    emit_char(parser, tokenizer->_buffered_emit_char, output);
    // And now that we've avoided advancing the input, make sure we set
    // _reconsume_current_input back to false to make sure the *next* character
    // isn't consumed twice.
    tokenizer->_reconsume_current_input = false;
    tokenizer->_buffered_emit_char = kGumboNoChar;
    return true;
  }

  if (maybe_emit_from_temporary_buffer(parser, output)) {
    return true;
  }

  while (1) {
    assert(!tokenizer->_temporary_buffer_emit);
    assert(tokenizer->_buffered_emit_char == kGumboNoChar);
    int c = utf8iterator_current(&tokenizer->_input);
    GumboTokenizerEnum state = tokenizer->_state;
    gumbo_debug("Lexing character '%c' (%d) in state %u.\n", c, c, state);
    StateResult result = dispatch_table[state](parser, tokenizer, c, output);
    // We need to clear reconsume_current_input before returning to prevent
    // certain infinite loop states.
    bool should_advance = !tokenizer->_reconsume_current_input;
    tokenizer->_reconsume_current_input = false;

    if (result == RETURN_SUCCESS) {
      return true;
    } else if (result == RETURN_ERROR) {
      return false;
    }

    if (should_advance) {
      utf8iterator_next(&tokenizer->_input);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
leaq 0x279a6(%rip), %rcx     # 0x39620
cmpl (%rcx), %eax
je 0x11cbb
movq -0x20(%rbp), %rax
movb $0x1, 0x4(%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x18(%rbp), %rdx
callq 0x11df0
movq -0x20(%rbp), %rax
movb $0x0, 0x4(%rax)
leaq 0x27977(%rip), %rax     # 0x39620
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x11dda
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11e40
testb $0x1, %al
jne 0x11cce
jmp 0x11cd7
movb $0x1, -0x1(%rbp)
jmp 0x11dda
jmp 0x11cd9
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x11ce6
jmp 0x11d05
leaq 0x2481d(%rip), %rdi     # 0x3650a
leaq 0x2473c(%rip), %rsi     # 0x36430
movl $0xc89, %edx            # imm = 0xC89
leaq 0x2482d(%rip), %rcx     # 0x3652d
callq 0x4100
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
leaq 0x2790d(%rip), %rcx     # 0x39620
cmpl (%rcx), %eax
jne 0x11d19
jmp 0x11d38
leaq 0x2483a(%rip), %rdi     # 0x3655a
leaq 0x24709(%rip), %rsi     # 0x36430
movl $0xc8a, %edx            # imm = 0xC8A
leaq 0x247fa(%rip), %rcx     # 0x3652d
callq 0x4100
movq -0x20(%rbp), %rdi
addq $0xe8, %rdi
callq 0x11f40
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %esi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
leaq 0x24825(%rip), %rdi     # 0x36589
movb $0x0, %al
callq 0x11c40
movl -0x28(%rbp), %eax
movl %eax, %ecx
leaq 0x63429(%rip), %rax     # 0x751a0
movq (%rax,%rcx,8), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0x18(%rbp), %rcx
callq *%rax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movb 0x4(%rax), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x2d(%rbp)
movq -0x20(%rbp), %rax
movb $0x0, 0x4(%rax)
cmpl $0x1, -0x2c(%rbp)
jne 0x11db1
movb $0x1, -0x1(%rbp)
jmp 0x11dda
cmpl $0x0, -0x2c(%rbp)
jne 0x11dbd
movb $0x0, -0x1(%rbp)
jmp 0x11dda
jmp 0x11dbf
testb $0x1, -0x2d(%rbp)
je 0x11dd5
movq -0x20(%rbp), %rdi
addq $0xe8, %rdi
callq 0x6500
jmp 0x11cd9
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)