// File: /workspace/github_cpp_makefile_star2_O1/Falldog[P]dcinja/src/include/inja/inja.hpp
// Function: inja::Lexer::scan()
Token scan() {
    tok_start = pos;

  again:
    if (tok_start >= m_in.size()) {
      return make_token(Token::Kind::Eof);
    }

    switch (state) {
    default:
    case State::Text: {
      // fast-scan to first open character
      size_t open_start = m_in.substr(pos).find_first_of(config.open_chars);
      if (open_start == nonstd::string_view::npos) {
        // didn't find open, return remaining text as text token
        pos = m_in.size();
        return make_token(Token::Kind::Text);
      }
      pos += open_start;

      // try to match one of the opening sequences, and get the close
      nonstd::string_view open_str = m_in.substr(pos);
      bool must_lstrip = false;
      if (inja::string_view::starts_with(open_str, config.expression_open)) {
        if (inja::string_view::starts_with(open_str, config.expression_open_force_lstrip)) {
          state = State::ExpressionStartForceLstrip;
          must_lstrip = true;
        } else {
          state = State::ExpressionStart;
        }
      } else if (inja::string_view::starts_with(open_str, config.statement_open)) {
        if (inja::string_view::starts_with(open_str, config.statement_open_no_lstrip)) {
          state = State::StatementStartNoLstrip;
        } else if (inja::string_view::starts_with(open_str, config.statement_open_force_lstrip )) {
          state = State::StatementStartForceLstrip;
          must_lstrip = true;
        } else {
          state = State::StatementStart;
          must_lstrip = config.lstrip_blocks;
        }
      } else if (inja::string_view::starts_with(open_str, config.comment_open)) {
        state = State::CommentStart;
        must_lstrip = config.lstrip_blocks;
      } else if ((pos == 0 || m_in[pos - 1] == '\n') && inja::string_view::starts_with(open_str, config.line_statement)) {
        state = State::LineStart;
      } else {
        pos += 1; // wasn't actually an opening sequence
        goto again;
      }

      nonstd::string_view text = string_view::slice(m_in, tok_start, pos);
      if (must_lstrip) {
        text = clear_final_line_if_whitespace(text);
      }

      if (text.empty()) {
        goto again; // don't generate empty token
      }
      return Token(Token::Kind::Text, text);
    }
    case State::ExpressionStart: {
      state = State::ExpressionBody;
      pos += config.expression_open.size();
      return make_token(Token::Kind::ExpressionOpen);
    }
    case State::ExpressionStartForceLstrip: {
      state = State::ExpressionBody;
      pos += config.expression_open_force_lstrip.size();
      return make_token(Token::Kind::ExpressionOpen);
    }
    case State::LineStart: {
      state = State::LineBody;
      pos += config.line_statement.size();
      return make_token(Token::Kind::LineStatementOpen);
    }
    case State::StatementStart: {
      state = State::StatementBody;
      pos += config.statement_open.size();
      return make_token(Token::Kind::StatementOpen);
    }
    case State::StatementStartNoLstrip: {
      state = State::StatementBody;
      pos += config.statement_open_no_lstrip.size();
      return make_token(Token::Kind::StatementOpen);
    }
    case State::StatementStartForceLstrip: {
      state = State::StatementBody;
      pos += config.statement_open_force_lstrip.size();
      return make_token(Token::Kind::StatementOpen);
    }
    case State::CommentStart: {
      state = State::CommentBody;
      pos += config.comment_open.size();
      return make_token(Token::Kind::CommentOpen);
    }
    case State::ExpressionBody:
      return scan_body(config.expression_close, Token::Kind::ExpressionClose, config.expression_close_force_rstrip);
    case State::LineBody:
      return scan_body("\n", Token::Kind::LineStatementClose);
    case State::StatementBody:
      return scan_body(config.statement_close, Token::Kind::StatementClose, config.statement_close_force_rstrip, config.trim_blocks);
    case State::CommentBody: {
      // fast-scan to comment close
      size_t end = m_in.substr(pos).find(config.comment_close);
      if (end == nonstd::string_view::npos) {
        pos = m_in.size();
        return make_token(Token::Kind::Eof);
      }
      // return the entire comment in the close token
      state = State::Text;
      pos += end + config.comment_close.size();
      Token tok = make_token(Token::Kind::CommentClose);
      if (config.trim_blocks) {
        skip_whitespaces_and_first_newline();
      }
      return tok;
    }
    }
  }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rsi), %rcx
movq 0x28(%rsi), %rax
movq %rax, 0x20(%rsi)
cmpq %rcx, %rax
jae 0x1ef96
leaq 0x10(%rsp), %r15
movl 0x8(%r14), %edx
decl %edx
cmpl $0xa, %edx
jbe 0x1efb1
movq 0x28(%r14), %rdx
movq %rcx, %rax
subq %rdx, %rax
jb 0x1f2ff
addq 0x18(%r14), %rdx
movq %rax, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
movq (%r14), %rax
movq 0x180(%rax), %rsi
movq 0x188(%rax), %rcx
movq %r15, %rdi
xorl %edx, %edx
callq 0x1fc4c
cmpq $-0x1, %rax
je 0x1f2a4
movq %rax, %r12
addq 0x28(%r14), %r12
movq %r12, 0x28(%r14)
movq 0x10(%r14), %rcx
movq %rcx, %r13
subq %r12, %r13
jb 0x1f30f
addq 0x18(%r14), %r12
movq (%r14), %rax
movq 0xc0(%rax), %r8
movq 0xc8(%rax), %rcx
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
cmpq %rcx, %r13
jb 0x1eda1
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x1ec56
testl %eax, %eax
je 0x1ee56
movq (%r14), %rax
movq (%rax), %r8
movq 0x8(%rax), %rcx
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
cmpq %rcx, %r13
jb 0x1edcf
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x1ec56
testl %eax, %eax
je 0x1ee98
movq (%r14), %rax
movq 0x140(%rax), %r8
movq 0x148(%rax), %rcx
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
cmpq %rcx, %r13
jb 0x1ee04
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x1ec56
testl %eax, %eax
je 0x1eefc
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x1ee18
movq 0x18(%r14), %rcx
cmpb $0xa, -0x1(%rcx,%rax)
jne 0x1ee4d
movq (%r14), %rax
movq 0xa0(%rax), %r8
movq 0xa8(%rax), %rcx
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
cmpq %rcx, %r13
jb 0x1ee4d
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x1ec56
testl %eax, %eax
je 0x1ef0f
incq 0x28(%r14)
jmp 0x1ef77
movq (%r14), %rax
movq 0xe0(%rax), %r8
movq 0xe8(%rax), %rcx
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
cmpq %rcx, %r13
jb 0x1ee8b
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x1ec56
testl %eax, %eax
je 0x1ef19
movl $0x1, 0x8(%r14)
jmp 0x1ef2b
movq (%r14), %rax
movq 0x20(%rax), %r8
movq 0x28(%rax), %rcx
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
cmpq %rcx, %r13
jb 0x1eec3
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x1ec56
testl %eax, %eax
je 0x1ef23
movq (%r14), %rax
movq 0x40(%rax), %r8
movq 0x48(%rax), %rcx
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
cmpq %rcx, %r13
jb 0x1eef2
movq %r15, %rdi
xorl %esi, %esi
movq %rcx, %rdx
callq 0x1ec56
testl %eax, %eax
je 0x1ef8a
movl $0x6, 0x8(%r14)
jmp 0x1ef04
movl $0xa, 0x8(%r14)
movq (%r14), %rax
movb 0x1a1(%rax), %cl
jmp 0x1ef2d
movl $0x4, 0x8(%r14)
jmp 0x1ef2b
movl $0x2, 0x8(%r14)
jmp 0x1ef92
movl $0x7, 0x8(%r14)
xorl %ecx, %ecx
movq 0x10(%r14), %rax
movq 0x20(%r14), %rdx
movq 0x28(%r14), %rsi
cmpq %rdx, %rax
cmovbq %rax, %rdx
cmpq %rsi, %rdx
cmovaq %rdx, %rsi
cmpq %rax, %rsi
cmovaeq %rax, %rsi
subq %rdx, %rsi
subq %rdx, %rax
cmpq %rsi, %rax
cmovaeq %rsi, %rax
addq 0x18(%r14), %rdx
testb %cl, %cl
je 0x1ef6e
movq %rax, %rdi
movq %rdx, %rsi
callq 0x1f328
testq %rax, %rax
jne 0x1f2c6
movq 0x10(%r14), %rcx
movq 0x20(%r14), %rax
cmpq %rcx, %rax
jb 0x1ecfb
jmp 0x1ef96
movl $0x8, 0x8(%r14)
movb $0x1, %cl
jmp 0x1ef2d
addq 0x18(%r14), %rcx
movl $0x22, (%rbx)
movq $0x0, 0x8(%rbx)
movq %rcx, 0x10(%rbx)
jmp 0x1f293
leaq 0x36298(%rip), %rsi     # 0x55250
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movl $0x3, 0x8(%r14)
movq (%r14), %rdx
movq 0x28(%r14), %rsi
addq 0xc8(%rdx), %rsi
jmp 0x1f10c
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movups %xmm0, (%rsp)
leaq 0x3798b(%rip), %rcx     # 0x5697a
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x4, %r8d
jmp 0x1f08e
movl $0xb, 0x8(%r14)
movq (%r14), %rdx
movq 0x28(%r14), %rsi
addq 0x148(%rdx), %rsi
movq %rsi, 0x28(%r14)
cmpq %rax, %rcx
cmovbq %rcx, %rax
cmpq %rsi, %rax
cmovaq %rax, %rsi
cmpq %rcx, %rsi
cmovaeq %rcx, %rsi
subq %rax, %rsi
subq %rax, %rcx
cmpq %rsi, %rcx
cmovaeq %rsi, %rcx
addq 0x18(%r14), %rax
movl $0x7, (%rbx)
jmp 0x1f196
movq (%r14), %rax
movq 0x100(%rax), %rcx
movq 0x108(%rax), %rdx
movq 0x120(%rax), %rsi
movq 0x128(%rax), %rax
movq %rax, 0x30(%rsp)
movq %rsi, 0x38(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %r8d
xorl %r9d, %r9d
jmp 0x1f28e
movl $0x5, 0x8(%r14)
movq (%r14), %rdx
movq 0x28(%r14), %rsi
addq 0xa8(%rdx), %rsi
movq %rsi, 0x28(%r14)
cmpq %rax, %rcx
cmovbq %rcx, %rax
cmpq %rsi, %rax
cmovaq %rax, %rsi
cmpq %rcx, %rsi
cmovaeq %rcx, %rsi
subq %rax, %rsi
subq %rax, %rcx
cmpq %rsi, %rcx
cmovaeq %rsi, %rcx
addq 0x18(%r14), %rax
movl $0x3, (%rbx)
jmp 0x1f196
movl $0x9, 0x8(%r14)
movq (%r14), %rdx
movq 0x28(%r14), %rsi
addq 0x48(%rdx), %rsi
jmp 0x1f166
movl $0x3, 0x8(%r14)
movq (%r14), %rdx
movq 0x28(%r14), %rsi
addq 0xe8(%rdx), %rsi
movq %rsi, 0x28(%r14)
cmpq %rax, %rcx
cmovbq %rcx, %rax
cmpq %rsi, %rax
cmovaq %rax, %rsi
cmpq %rcx, %rsi
cmovaeq %rcx, %rsi
subq %rax, %rsi
subq %rax, %rcx
cmpq %rsi, %rcx
cmovaeq %rsi, %rcx
addq 0x18(%r14), %rax
movl $0x1, (%rbx)
jmp 0x1f196
movl $0x9, 0x8(%r14)
movq (%r14), %rdx
movq 0x28(%r14), %rsi
addq 0x8(%rdx), %rsi
jmp 0x1f166
movl $0x9, 0x8(%r14)
movq (%r14), %rdx
movq 0x28(%r14), %rsi
addq 0x28(%rdx), %rsi
movq %rsi, 0x28(%r14)
cmpq %rax, %rcx
cmovbq %rcx, %rax
cmpq %rsi, %rax
cmovaq %rax, %rsi
cmpq %rcx, %rsi
cmovaeq %rcx, %rsi
subq %rax, %rsi
subq %rax, %rcx
cmpq %rsi, %rcx
cmovaeq %rsi, %rcx
addq 0x18(%r14), %rax
movl $0x5, (%rbx)
movq %rcx, 0x8(%rbx)
movq %rax, 0x10(%rbx)
jmp 0x1f293
movq 0x28(%r14), %rdx
movq %rcx, %rax
subq %rdx, %rax
jb 0x1f2ff
addq 0x18(%r14), %rdx
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
movq (%r14), %rax
movq 0x160(%rax), %rsi
movq 0x168(%rax), %rcx
xorl %edx, %edx
callq 0x1feac
cmpq $-0x1, %rax
je 0x1f2d6
movl $0x0, 0x8(%r14)
movq (%r14), %rcx
addq 0x168(%rcx), %rax
movq 0x10(%r14), %rdx
addq 0x28(%r14), %rax
movq %rax, 0x28(%r14)
movq 0x20(%r14), %rsi
cmpq %rsi, %rdx
cmovbq %rdx, %rsi
cmpq %rax, %rsi
cmovaq %rsi, %rax
cmpq %rdx, %rax
cmovaeq %rdx, %rax
subq %rsi, %rax
subq %rsi, %rdx
cmpq %rax, %rdx
cmovaeq %rax, %rdx
addq 0x18(%r14), %rsi
movl $0x8, (%rbx)
movq %rdx, 0x8(%rbx)
movq %rsi, 0x10(%rbx)
cmpb $0x1, 0x1a0(%rcx)
jne 0x1f293
movq %r14, %rdi
callq 0x1fbc4
jmp 0x1f293
movq (%r14), %rax
movq 0x60(%rax), %rcx
movq 0x68(%rax), %rdx
movq 0x80(%rax), %rsi
movq 0x88(%rax), %rdi
movq %rdi, 0x20(%rsp)
movq %rsi, 0x28(%rsp)
movzbl 0x1a0(%rax), %r9d
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movl $0x6, %r8d
callq 0x1f374
movq %rbx, %rax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x10(%r14), %rax
movq 0x20(%r14), %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rax, 0x28(%r14)
subq %rcx, %rax
addq 0x18(%r14), %rcx
movl $0x0, (%rbx)
jmp 0x1f2f6
movl $0x0, (%rbx)
movq %rax, 0x8(%rbx)
movq %rdx, 0x10(%rbx)
jmp 0x1f293
movq 0x10(%r14), %rax
movq 0x20(%r14), %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rax, 0x28(%r14)
subq %rcx, %rax
addq 0x18(%r14), %rcx
movl $0x22, (%rbx)
movq %rax, 0x8(%rbx)
jmp 0x1efa8
leaq 0x3786d(%rip), %rdi     # 0x56b73
leaq 0x3784c(%rip), %rsi     # 0x56b59
jmp 0x1f320
leaq 0x3785d(%rip), %rdi     # 0x56b73
leaq 0x3783c(%rip), %rsi     # 0x56b59
movq %r12, %rdx
xorl %eax, %eax
callq 0x9670
nop