// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movl $0x20, %edi
callq 0x21d0
movq %rax, %r14
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rax)
movslq 0x8(%rbx), %rbp
movl %ebp, 0x10(%rax)
movl %ebp, 0x14(%rax)
movw $0x0, 0x1c(%rax)
addq (%rbx), %rbp
movq %rbp, %r12
movq (%rbx), %r13
movq %r12, %r15
subq %r13, %r15
movl 0xc(%rbx), %edx
movl %edx, 0x18(%r14)
movzbl (%r12), %eax
cmpl $0x39, %eax
jg 0x2f3b
leal -0x9(%rax), %ecx
cmpl $0x26, %ecx
ja 0x2fdb
leaq 0xa3fe(%rip), %rsi      # 0xd314
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
movb $0x1, 0x1c(%r14)
incq %r12
movzbl (%r12), %eax
cmpl $0x20, %eax
je 0x2f24
cmpl $0x9, %eax
je 0x2f24
jmp 0x33ec
cmpl $0x5b, %eax
jg 0x2f86
leal -0x3a(%rax), %ecx
cmpl $0x4, %ecx
ja 0x2feb
leaq 0xa45d(%rip), %rdx      # 0xd3b0
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
incq %r12
movl $0x2, (%r14)
jmp 0x33fa
movzbl 0x1(%r12), %eax
incq %r12
testl %eax, %eax
je 0x33ec
cmpl $0xa, %eax
jne 0x2f6b
jmp 0x33ec
cmpl $0x7a, %eax
jle 0x2fb1
cmpl $0x7b, %eax
je 0x319d
cmpl $0x7c, %eax
je 0x3181
cmpl $0x7d, %eax
jne 0x2feb
incq %r12
movl $0x5, (%r14)
jmp 0x33fa
cmpl $0x5c, %eax
je 0x31ac
cmpl $0x5e, %eax
jne 0x2feb
cmpb $0x3d, 0x1(%r12)
jne 0x3322
addq $0x2, %r12
movl $0x22, (%r14)
jmp 0x33fa
testl %eax, %eax
jne 0x2feb
movl $0x0, (%r14)
jmp 0x33fa
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x321c
cmpb $0x30, %al
jne 0x336d
incq %r12
jmp 0x337e
movzbl 0x1(%r12), %eax
cmpl $0x2a, %eax
je 0x33b2
cmpl $0x3d, %eax
je 0x33a5
cmpl $0x2f, %eax
jne 0x33f0
addq $0x2, %r12
movzbl (%r12), %eax
testl %eax, %eax
je 0x33ec
cmpl $0xa, %eax
je 0x33ec
incq %r12
jmp 0x302c
incq %r12
movl $0x6, (%r14)
jmp 0x33fa
incq %r12
movl $0x8, (%r14)
jmp 0x33fa
incq %r12
incl %edx
movl %edx, 0xc(%rbx)
movq %r12, 0x10(%rbx)
movl $0x1, (%r14)
jmp 0x33fa
incq %r12
movq %r12, %r13
movzbl (%r13), %eax
cmpl $0x22, %eax
je 0x315d
testl %eax, %eax
je 0x347a
cmpb $0x5c, (%r13)
jne 0x30aa
cmpb $0x22, 0x1(%r13)
jne 0x30aa
incq %r13
incq %r13
jmp 0x3083
incq %r12
movl $0x3, (%r14)
jmp 0x33fa
incq %r12
movl $0x7, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x32d7
addq $0x2, %r12
movl $0x1c, (%r14)
jmp 0x33fa
leaq 0x2(%r12), %rax
cmpb $0x3d, 0x1(%r12)
leaq 0x1(%r12), %r12
cmoveq %rax, %r12
movl $0x10, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x32e6
addq $0x2, %r12
movl $0x21, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x32f5
addq $0x2, %r12
movl $0x1b, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x3304
addq $0x2, %r12
movl $0x1d, (%r14)
jmp 0x33fa
movq %r13, %rsi
subq %r12, %rsi
movq %r12, %rdi
callq 0x354b
movq %rax, 0x8(%r14)
movl $0xb, (%r14)
incq %r13
movq %r13, %r12
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x3313
addq $0x2, %r12
movl $0x20, (%r14)
jmp 0x33fa
incq %r12
movl $0x4, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x3331
addq $0x2, %r12
movl $0x1f, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x3340
addq $0x2, %r12
movl $0x12, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x334f
addq $0x2, %r12
movl $0x14, (%r14)
jmp 0x33fa
cmpb $0x3d, 0x1(%r12)
jne 0x335e
addq $0x2, %r12
movl $0xf, (%r14)
jmp 0x33fa
movq %rbp, (%rsp)
movl %eax, %ecx
andb $-0x21, %cl
addb $-0x41, %cl
cmpb $0x19, %cl
ja 0x3497
movl $0x1, %ebp
movb (%r12,%rbp), %al
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
jb 0x324e
cmpb $0x5f, %al
je 0x324e
andb $-0x21, %al
addb $-0x41, %al
cmpb $0x19, %al
ja 0x3253
incq %rbp
jmp 0x3236
movl $0x23, (%r14)
movslq %r15d, %rax
addq %rax, %r13
leaq 0xa902(%rip), %rdi      # 0xdb69
movq %r13, %rsi
movl %ebp, %edx
callq 0x2da2
movl $0x10, %ecx
testb %al, %al
jne 0x32c3
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
xorl %ebx, %ebx
movq %rbx, %r14
addq $0x10, %rbx
cmpq $0x40, %rbx
je 0x32ad
leaq 0x136b6(%rip), %rax     # 0x16950
movq 0x18(%r14,%rax), %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x2da2
testb %al, %al
je 0x3286
leaq 0x1369c(%rip), %rax     # 0x16950
movl 0x10(%r14,%rax), %ecx
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r14
addq %rbp, %r12
cmpl $-0x1, %ecx
je 0x32ce
movl %ecx, (%r14)
movq (%rsp), %rbp
jmp 0x33fa
incq %r12
movl $0x16, (%r14)
jmp 0x33fa
incq %r12
movl $0xd, (%r14)
jmp 0x33fa
incq %r12
movl $0x15, (%r14)
jmp 0x33fa
incq %r12
movl $0x17, (%r14)
jmp 0x33fa
incq %r12
movl $0xc, (%r14)
jmp 0x33fa
incq %r12
movl $0xe, (%r14)
jmp 0x33fa
incq %r12
movl $0x19, (%r14)
jmp 0x33fa
incq %r12
movl $0x11, (%r14)
jmp 0x33fa
incq %r12
movl $0x13, (%r14)
jmp 0x33fa
incq %r12
movl $0x1a, (%r14)
jmp 0x33fa
decq %r12
movb 0x1(%r12), %al
incq %r12
addb $-0x30, %al
cmpb $0xa, %al
jb 0x3370
cmpb $0x2e, (%r12)
jne 0x339c
movb 0x1(%r12), %al
incq %r12
addb $-0x30, %al
cmpb $0xa, %al
jb 0x3385
movl $0xa, (%r14)
jmp 0x33fa
movl $0x9, (%r14)
jmp 0x33fa
addq $0x2, %r12
movl $0x1e, (%r14)
jmp 0x33fa
addq $0x2, %r12
movl 0xc(%rbx), %eax
incq %r12
movzbl -0x1(%r12), %ecx
cmpl $0x2a, %ecx
je 0x33d5
cmpl $0xa, %ecx
je 0x33de
testl %ecx, %ecx
jne 0x33b9
jmp 0x3486
cmpb $0x2f, (%r12)
jne 0x33b9
jmp 0x33e9
incl %eax
movl %eax, 0xc(%rbx)
movq %r12, 0x10(%rbx)
jmp 0x33b9
incq %r12
movb $0x1, %al
jmp 0x3460
incq %r12
movl $0x18, (%r14)
movzbl (%r12), %eax
cmpl $0x20, %eax
je 0x3409
cmpl $0x9, %eax
jne 0x340e
movb $0x1, 0x1d(%r14)
movl %r12d, %eax
subl %ebp, %eax
addl 0x8(%rbx), %eax
movl %eax, 0x8(%rbx)
movl %r15d, 0x10(%r14)
movl %eax, 0x14(%r14)
cmpq $0x0, 0x8(%r14)
jne 0x345e
subl %r15d, %eax
movslq %eax, %r13
leaq 0x1(%r13), %rdi
callq 0x21d0
movq %r15, %rcx
movq %rbp, %r15
movq %rax, %rbp
movq %rax, 0x8(%r14)
movslq %ecx, %rsi
addq (%rbx), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x2120
movb $0x0, (%rbp,%r13)
movq %r15, %rbp
xorl %eax, %eax
testb %al, %al
jne 0x2ee9
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0xc(%rbx), %esi
leaq 0xa742(%rip), %rdi      # 0xdbc6
jmp 0x3490
movl 0xc(%rbx), %esi
leaq 0xa6e5(%rip), %rdi      # 0xdb75
xorl %eax, %eax
callq 0x34a8
movsbl %al, %esi
leaq 0xa76a(%rip), %rdi      # 0xdc0b
xorl %eax, %eax
callq 0x34a8