// File: /workspace/github_cpp_makefile_star2_O3/exrd[P]neteruhsp/neteruhsp/neteruhsp.cc
// Function: neteruhsp::get_token(neteruhsp::tokenize_context_t&)
token_t* get_token( tokenize_context_t& c )
{
	token_t* res = reinterpret_cast<token_t*>( xmalloc( sizeof( token_t ) ) );
	res->tag_ = TOKEN_UNKNOWN;
	res->content_ = nullptr;
	res->cursor_begin_ = c.cursor_;
	res->cursor_end_ = c.cursor_;
	res->left_space_ =false;
	res->right_space_ =false;

	const auto is_space = []( char c ) { return ( c==' ' || c=='\t' ); };
	const auto is_number = []( char c ) { return ( c>='0' && c<='9' ); };
	const auto is_alpha = []( char c ) { return ( ( c>='a' && c<='z' ) || ( c>='A' && c<='Z' ) ); };
	const auto is_rest_ident = [&]( char c ) { return ( is_number(c) || is_alpha(c) || c=='_' ); };

	const auto pp = c.script_ +c.cursor_;
	const char* p = c.script_ +c.cursor_;

restart:
	const auto prev_p = p;
	const auto prev_cursor = static_cast<int>( p - c.script_ );
	res->appear_line_ = c.line_;
	switch( p[0] )
	{
			// EOF
		case '\0':	res->tag_ = TOKEN_EOF; break;

			// 行終わり
		case '\r':
		case '\f':
			++p;
			goto restart;

		case '\n':
			// この位置はマーキング
			++p;
			++c.line_;
			c.line_head_ = p;
			res->tag_ = TOKEN_EOL;
			break;

			// ステートメント終わり
		case ':':
			++p;
			res->tag_ = TOKEN_EOS;
			break;

			// プリプロセッサで使う
		case '%':	++p; res->tag_ = TOKEN_PP_ARG_INDICATOR; break;

			// 微妙な文字
		case '{':	++p; res->tag_ = TOKEN_LBRACE; break;
		case '}':	++p; res->tag_ = TOKEN_RBRACE; break;
		case '(':	++p; res->tag_ = TOKEN_LPARENTHESIS; break;
		case ')':	++p; res->tag_ = TOKEN_RPARENTHESIS; break;
		case ',':	++p; res->tag_ = TOKEN_COMMA; break;

			// 演算子
		case '|':	++p; if ( p[0] == '=' ) { ++p; res->tag_ = TOKEN_BOR_ASSIGN; } else { res->tag_ = TOKEN_OP_BOR; } break;
		case '&':	++p; if ( p[0] == '=' ) { ++p; res->tag_ = TOKEN_BAND_ASSIGN; } else { res->tag_ = TOKEN_OP_BAND; } break;
		case '^':	++p; if ( p[0] == '=' ) { ++p; res->tag_ = TOKEN_BXOR_ASSIGN; } else { res->tag_ = TOKEN_OP_BXOR; } break;
		case '!':	++p; if ( p[0]=='=' ) { ++p; } res->tag_ = TOKEN_OP_NEQ; break;
		case '>':
			++p;
			if ( p[0] == '=' )
			{ ++p; res->tag_ = TOKEN_OP_GTOE; }
			else
			{ res->tag_ = TOKEN_OP_GT; }
			break;
		case '<':
			++p;
			if ( p[0] == '=' )
			{ ++p; res->tag_ = TOKEN_OP_LTOE; }
			else
			{ res->tag_ = TOKEN_OP_LT; }
			break;
		case '+':	++p; if ( p[0] == '=' ) { ++p; res->tag_ = TOKEN_ADD_ASSIGN; } else { res->tag_ = TOKEN_OP_ADD; } break;
		case '-':	++p; if ( p[0] == '=' ) { ++p; res->tag_ = TOKEN_SUB_ASSIGN; } else { res->tag_ = TOKEN_OP_SUB; } break;
		case '*':	++p; if ( p[0] == '=' ) { ++p; res->tag_ = TOKEN_MUL_ASSIGN; } else { res->tag_ = TOKEN_OP_MUL; } break;
		case '/':
			++p;
			if ( p[0] == '/' )// 一行コメント
			{
				++p;
				while( p[0]!='\n' && p[0]!='\0' )
				{ ++p; }
				goto restart;
			}
			if ( p[0] == '*' )// 複数行コメント
			{
				++p;
				for( ; ; )
				{
					if ( p[0] == '\0' )
					{
						raise_error( "複数行コメントの読み取り中にEOFが検出されました@@ %d行目", c.line_ );
						break;
					}
					if ( p[0] == '\n' )
					{
						++p;
						++c.line_;
						c.line_head_ = p;
						continue;
					}
					if ( p[0]=='*' && p[1]=='/' )
					{
						p += 2;
						break;
					}
					++p;
				}
				goto restart;
			}
			if ( p[0] == '=' )
			{
				++p;
				res->tag_ = TOKEN_DIV_ASSIGN;
			}
			else
			{ 
				res->tag_ = TOKEN_OP_DIV;
			}
			break;
		case '\\':	++p; if ( p[0] == '=' ) { ++p; res->tag_ = TOKEN_MOD_ASSIGN; } else { res->tag_ = TOKEN_OP_MOD; } break;

			// 代入
		case '=':
			++p;
			if ( p[0] == '=' )
			{
				++p;
				res->tag_ = TOKEN_OP_EQ;
			}
			else
			{
				res->tag_ = TOKEN_ASSIGN;
			}
			break;

			// 文字列
		case '\"':
		{
			++p;
			const auto s = p;
			while( p[0]!='\"' )
			{
				if ( p[0] == '\0' )
				{
					raise_error( "文字列の読み取り中にEOFが検出されました@@ %d行目", c.line_ );
				}
				if ( p[0]=='\\' && p[1]=='\"' )
				{
					++p;
				}
				++p;
			}
			const auto e = p;
			res->content_ = create_token_string( s, e -s );
			res->tag_ = TOKEN_STRING;
			++p;
			break;
		}

			// コメント
		case ';':
			++p;
			while( p[0]!='\n' && p[0]!='\0' )
			{
				++p;
			}
			goto restart;

		default:
			if ( is_space( p[0] ) )
			{
				// スペース
				++p;
				res->left_space_ =true;
				while( is_space(p[0]) )
				{
					++p;
				}
				goto restart;
			}
			else if ( is_number( p[0] ) )
			{
				// 数値
				if ( p[0] == '0' )
				{
					++p;
				}
				else
				{
					while( is_number(p[0]) )
					{
						++p;
					}
				}
				if ( p[0] == '.' )
				{
					++p;
					while( is_number(p[0]) )
					{
						++p;
					}
					res->tag_ = TOKEN_REAL;
				}
				else
				{
					res->tag_ = TOKEN_INTEGER;
				}
			}
			else if ( is_alpha( p[0] ) )
			{
				// 何らかの識別子
				++p;
				while( is_rest_ident( p[0] ) )
				{
					++p;
				}
				res->tag_ = TOKEN_IDENTIFIER;
				const auto shadow =query_token_shadow( c.script_ +prev_cursor, p -prev_p );
				if ( shadow != -1 )
				{
					res->tag_ = static_cast<token_tag>( shadow );
				}
			}
			else
			{
				// もう読めない
				raise_error( "読み取れない文字[%c]@@ %d行目", p[0], c.line_ );
			}
			break;
	}

	if ( is_space( p[0] ) )
	{
		res->right_space_ = true;
	}

	c.cursor_ += static_cast<int>( p - pp );
	res->cursor_begin_ = prev_cursor;
	res->cursor_end_ = c.cursor_;

	// contentが埋まってないなら埋める
	if ( res->content_ == nullptr )
	{
		const auto len = res->cursor_end_ -res->cursor_begin_;
		res->content_ = create_string( len );
		memcpy( res->content_, c.script_ +res->cursor_begin_, len );
		res->content_[len] = '\0';
	}

	return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movl $0x20, %edi
callq 0x21d0
movq %rax, %rbx
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rax)
movslq 0x8(%r14), %rbp
movl %ebp, 0x10(%rax)
movl %ebp, 0x14(%rax)
movw $0x0, 0x1c(%rax)
movq (%r14), %r12
addq %r12, %rbp
movl 0xc(%r14), %edx
leaq 0x9462(%rip), %rax      # 0xc2d4
leaq 0x94f7(%rip), %rcx      # 0xc370
movq %rbp, %r15
movl %edx, 0x18(%rbx)
movzbl (%r15), %esi
cmpl $0x39, %esi
jg 0x2eb4
leal -0x9(%rsi), %edi
cmpl $0x26, %edi
ja 0x2fc9
movslq (%rax,%rdi,4), %rdi
addq %rax, %rdi
jmpq *%rdi
movb $0x1, 0x1c(%rbx)
incq %r15
movzbl (%r15), %esi
cmpl $0x20, %esi
je 0x2ea1
cmpl $0x9, %esi
je 0x2ea1
jmp 0x2e7c
cmpl $0x5b, %esi
jg 0x2f4d
leal -0x3a(%rsi), %edi
cmpl $0x4, %edi
ja 0x2fde
movslq (%rcx,%rdi,4), %rsi
addq %rcx, %rsi
jmpq *%rsi
movzbl 0x1(%r15), %esi
incq %r15
testl %esi, %esi
je 0x2e7c
cmpl $0xa, %esi
jne 0x2ed2
jmp 0x2e7c
movzbl 0x1(%r15), %esi
cmpl $0x2f, %esi
jne 0x2f09
addq $0x2, %r15
movzbl (%r15), %esi
testl %esi, %esi
je 0x2e7c
cmpl $0xa, %esi
je 0x2e7c
incq %r15
jmp 0x2ef3
cmpl $0x2a, %esi
jne 0x2fab
addq $0x2, %r15
incq %r15
movzbl -0x1(%r15), %esi
cmpl $0x2a, %esi
je 0x2f31
cmpl $0xa, %esi
je 0x2f39
testl %esi, %esi
jne 0x2f16
jmp 0x342b
cmpb $0x2f, (%r15)
jne 0x2f16
jmp 0x2f45
incl %edx
movl %edx, 0xc(%r14)
movq %r15, 0x10(%r14)
jmp 0x2f16
incq %r15
jmp 0x2e7c
cmpl $0x7a, %esi
jle 0x2f7d
cmpl $0x7b, %esi
je 0x320a
cmpl $0x7c, %esi
je 0x31ea
cmpl $0x7d, %esi
jne 0x2fde
movq %r15, %r13
subq %r12, %r13
incq %r15
movl $0x5, (%rbx)
jmp 0x33b9
cmpl $0x5c, %esi
je 0x31b6
cmpl $0x5e, %esi
jne 0x2fde
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x3367
addq $0x2, %r15
movl $0x22, (%rbx)
jmp 0x33b9
cmpl $0x3d, %esi
jne 0x323e
movq %r15, %r13
subq %r12, %r13
addq $0x2, %r15
movl $0x1e, (%rbx)
jmp 0x33b9
testl %esi, %esi
jne 0x2fde
movq %r15, %r13
subq %r12, %r13
movl $0x0, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
leal -0x30(%rsi), %eax
cmpb $0x9, %al
ja 0x3258
cmpb $0x30, %sil
jne 0x3388
movb 0x1(%r15), %al
incq %r15
jmp 0x339a
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x3314
addq $0x2, %r15
movl $0x1b, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
movq %r15, %r12
movzbl (%r12), %eax
cmpl $0x5c, %eax
je 0x304d
cmpl $0x22, %eax
je 0x314d
testl %eax, %eax
jne 0x3058
jmp 0x3422
cmpb $0x22, 0x1(%r12)
jne 0x3058
incq %r12
incq %r12
jmp 0x3031
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
leaq 0x2(%r15), %rax
leaq 0x1(%r15), %r15
cmoveq %rax, %r15
movl $0x10, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x3322
addq $0x2, %r15
movl $0x1d, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
movl $0x6, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x3330
addq $0x2, %r15
movl $0x21, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
movl $0x7, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
movl $0x8, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
incl %edx
movl %edx, 0xc(%r14)
movq %r15, 0x10(%r14)
movl $0x1, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x333b
addq $0x2, %r15
movl $0x1c, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
movl $0x3, (%rbx)
jmp 0x33b9
movq %r12, %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x34f0
movq %rax, 0x8(%rbx)
movl $0xb, (%rbx)
incq %r12
testq %rax, %rax
sete %al
movq %r12, %r15
jmp 0x33bb
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x3346
addq $0x2, %r15
movl $0x14, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x3351
addq $0x2, %r15
movl $0x12, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x335c
addq $0x2, %r15
movl $0x1f, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
movl $0x2, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x3372
addq $0x2, %r15
movl $0x20, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
incq %r15
movl $0x4, (%rbx)
jmp 0x33b9
movq %r15, %r13
subq %r12, %r13
cmpb $0x3d, 0x1(%r15)
jne 0x337d
addq $0x2, %r15
movl $0xf, (%rbx)
jmp 0x33b9
leaq 0x1(%r15), %rcx
subq %r12, %r15
movl $0x18, (%rbx)
movb $0x1, %al
movq %r15, %r13
movq %rcx, %r15
jmp 0x33bb
movq %r13, (%rsp)
movl %esi, %eax
andb $-0x21, %al
addb $-0x41, %al
cmpb $0x19, %al
ja 0x343b
movl $0x1, %r13d
movb (%r15,%r13), %al
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
jb 0x3288
cmpb $0x5f, %al
je 0x3288
andb $-0x21, %al
addb $-0x41, %al
cmpb $0x19, %al
ja 0x328d
incq %r13
jmp 0x3270
movl $0x23, (%rbx)
movslq (%rsp), %rax
addq %rax, %r12
leaq 0x9888(%rip), %rdi      # 0xcb29
movq %r12, %rsi
movl %r13d, %edx
callq 0x2d26
addq %r13, %r15
movl $0x10, %ecx
testb %al, %al
jne 0x3307
movq %rbp, 0x8(%rsp)
movq %r14, 0x10(%rsp)
xorl %ebp, %ebp
movq %rbp, %r14
addq $0x10, %rbp
cmpq $0x40, %rbp
je 0x32ec
leaq 0x12678(%rip), %rax     # 0x15950
movq 0x18(%r14,%rax), %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x2d26
testb %al, %al
je 0x32c4
leaq 0x1265d(%rip), %rax     # 0x15950
movl 0x10(%r14,%rax), %ecx
cmpl $-0x1, %ecx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rbp
je 0x3309
movl %ecx, (%rbx)
movb $0x1, %al
movq (%rsp), %r13
jmp 0x33bb
incq %r15
movl $0x15, (%rbx)
jmp 0x33b9
incq %r15
movl $0x17, (%rbx)
jmp 0x33b9
incq %r15
movl $0xd, (%rbx)
jmp 0x33b9
incq %r15
movl $0x16, (%rbx)
jmp 0x33b9
incq %r15
movl $0x13, (%rbx)
jmp 0x33b9
incq %r15
movl $0x11, (%rbx)
jmp 0x33b9
incq %r15
movl $0x19, (%rbx)
jmp 0x33b9
incq %r15
movl $0xe, (%rbx)
jmp 0x33b9
incq %r15
movl $0xc, (%rbx)
jmp 0x33b9
incq %r15
movl $0x1a, (%rbx)
jmp 0x33b9
decq %r15
movb 0x1(%r15), %al
incq %r15
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
jb 0x338b
cmpb $0x2e, %al
jne 0x33b3
movb 0x1(%r15), %al
incq %r15
addb $-0x30, %al
cmpb $0xa, %al
jb 0x339e
movl $0xa, (%rbx)
jmp 0x33b9
movl $0x9, (%rbx)
movb $0x1, %al
movzbl (%r15), %ecx
cmpl $0x20, %ecx
je 0x33c9
cmpl $0x9, %ecx
jne 0x33cd
movb $0x1, 0x1d(%rbx)
subl %ebp, %r15d
addl 0x8(%r14), %r15d
movl %r15d, 0x8(%r14)
movl %r13d, 0x10(%rbx)
movl %r15d, 0x14(%rbx)
testb %al, %al
je 0x3410
subl %r13d, %r15d
movslq %r15d, %r15
leaq 0x1(%r15), %rdi
callq 0x21d0
movq %rax, %r12
movq %rax, 0x8(%rbx)
movslq %r13d, %rsi
addq (%r14), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2120
movb $0x0, (%r12,%r15)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x975d(%rip), %rdi      # 0xcb86
jmp 0x3432
leaq 0x9703(%rip), %rdi      # 0xcb35
movl %edx, %esi
xorl %eax, %eax
callq 0x344d
movsbl %sil, %esi
leaq 0x9785(%rip), %rdi      # 0xcbcb
xorl %eax, %eax
callq 0x344d