// File: /workspace/github_c_makefile_star2_O2/almk277[P]ROSE/rasm/scanner.cpp
// Function: scanner::next()
tok scanner::next()
{
	static const std::unordered_map<string, tok> dirs = {
		{ "arg",    tok::ARG },
		{ "data",   tok::DATA },
		{ "export", tok::EXPORT },
		{ "extern", tok::EXTERN },
		{ "import", tok::IMPORT },
		{ "module", tok::MODULE },
		{ "str",    tok::STR },
		{ "sub",    tok::SUB },
		{ "var",    tok::VAR },
	};

	char c = in.peek();

	while (c == ' ' or c == '\t')
		c = in.ignore().peek();

	if (in.eof())
		return tok::END;

	if (std::isalpha(c) or c == '_') {
		in >> s;
		if (s.back() == ':') {
			s.pop_back();
			return tok::LABEL;
		}
		return tok::STRING;
	}

	if (std::isdigit(c) or c == '-') {
		in >> s;
		if (s.find('.') != string::npos) {
			std::size_t pos;
			d = std::stof(s, &pos);
			if (pos < s.size())
				throw error("wrong float: " + s);
			return tok::FLOAT;
		}
		if (s.back() == INT_SUFFIX) {
			s.pop_back();
			convert(n, s);
			return tok::INT;
		}
		convert(b, s);
		return tok::BYTE;
	}

	in.ignore();
	switch (c) {
	case '.':
	{
		if (!std::isalpha(in.peek()))
			throw error("ill-formed directive");
		in >> s;
		auto it = dirs.find(s);
		if (it == dirs.end())
			throw error("unknown directive:" + s);
		return it->second;
	}
	case '\n':
		++lineno;
		return tok::NEWLINE;
	case COMMENT:
		in.ignore(numeric_limits<std::streamsize>::max(), '\n');
		if (in.eof())
			return tok::END;
		++lineno;
		return tok::NEWLINE;
	case '"':
		a.clear();
		while (in.get(c)) {
			switch (c) {
			case '"':
				return tok::ARRAY;
			case '\n':
				throw error("unexpected end of line");
			case '\\':
				c = unescape(in.get());
				// fallthrough
			default:
				a.push_back(c);
			}
		}
		throw error("unexpected end of file");
	}

	throw error("unexpected symbol: "
			+ (std::isprint(c) ?
				string("'") + c + "'"
				: string("#") + std::to_string(int(c))));
	return tok::END; // nonreachable
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
movb 0xffc8(%rip), %al       # 0x15398
testb %al, %al
je 0x5672
movq (%rbx), %rdi
callq 0x30f0
movl %eax, %r15d
movb %r15b, 0x8(%rsp)
cmpb $0x20, %r15b
je 0x53f8
movzbl %r15b, %r13d
cmpl $0x9, %r13d
jne 0x5405
movq (%rbx), %rdi
callq 0x34d0
movq %rax, %rdi
jmp 0x53db
movq (%rbx), %r12
movq (%r12), %rax
movq -0x18(%rax), %rax
pushq $0x7
popq %rbp
testb $0x2, 0x20(%r12,%rax)
jne 0x563f
movsbl %r15b, %r14d
movl %r14d, %edi
callq 0x3420
cmpb $0x5f, %r15b
je 0x549e
testl %eax, %eax
jne 0x549e
addl $-0x30, %r14d
cmpl $0xa, %r14d
setae %al
cmpb $0x2d, %r15b
setne %cl
testb %al, %cl
jne 0x54d1
leaq 0x10(%rbx), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x3300
pushq $0x2e
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3320
cmpq $-0x1, %rax
je 0x5547
leaq 0x40(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x605d
movss %xmm0, 0x38(%rbx)
movq (%r15), %rax
cmpq 0x18(%rbx), %rax
jb 0x5867
pushq $0x4
jmp 0x563e
leaq 0x10(%rbx), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x3300
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
xorl %ebp, %ebp
cmpb $0x3a, -0x1(%rax,%rcx)
jne 0x563f
movq %r14, %rdi
callq 0x32e0
pushq $0x1
jmp 0x563e
movq %r12, %rdi
callq 0x34d0
cmpb $0xa, %r15b
je 0x55a2
cmpl $0x22, %r13d
je 0x55ac
cmpl $0x3b, %r13d
je 0x5578
cmpl $0x2e, %r13d
jne 0x58b9
movq (%rbx), %rdi
callq 0x30f0
movl %eax, %edi
callq 0x3420
testl %eax, %eax
je 0x591a
movq (%rbx), %rdi
addq $0x10, %rbx
movq %rbx, %rsi
callq 0x3300
leaq 0xfe32(%rip), %rdi      # 0x15360
movq %rbx, %rsi
callq 0x6d5a
testq %rax, %rax
je 0x5939
movl 0x28(%rax), %ebp
jmp 0x563f
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
cmpb $0x4c, -0x1(%rax,%rcx)
jne 0x562d
movq %r14, %rdi
callq 0x32e0
addq $0x30, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x60ec
pushq $0x3
jmp 0x563e
movq (%rbx), %rdi
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
pushq $0xa
popq %rdx
callq 0x31d0
movq (%rbx), %rax
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x2, 0x20(%rax,%rcx)
jne 0x563f
incl 0x8(%rbx)
pushq $0x6
jmp 0x563e
movq 0x40(%rbx), %rax
cmpq %rax, 0x48(%rbx)
je 0x55ba
movq %rax, 0x48(%rbx)
leaq 0x40(%rbx), %r14
leaq 0x8(%rsp), %r15
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x3370
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5653
movzbl 0x8(%rsp), %eax
cmpl $0x5c, %eax
je 0x55f5
cmpl $0x22, %eax
je 0x5629
cmpl $0xa, %eax
jne 0x561c
jmp 0x5837
movq (%rbx), %rdi
callq 0x32c0
cmpb $0x30, %al
je 0x5616
movzbl %al, %ecx
cmpl $0x74, %ecx
je 0x5612
cmpl $0x6e, %ecx
jne 0x5618
movb $0xa, %al
jmp 0x5618
movb $0x9, %al
jmp 0x5618
xorl %eax, %eax
movb %al, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x62ce
jmp 0x55c3
pushq $0x5
jmp 0x563e
addq $0x34, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61dd
pushq $0x2
popq %rbp
movl %ebp, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x3170
movq %rax, %r14
leaq 0x7b35(%rip), %rsi      # 0xd19a
movq %rax, %rdi
callq 0x3100
jmp 0x5851
leaq 0xfd1f(%rip), %rdi      # 0x15398
callq 0x34c0
testl %eax, %eax
je 0x53d8
leaq 0x40(%rsp), %rdx
movl $0x8, (%rdx)
leaq 0x7a86(%rip), %rsi      # 0xd11e
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x5ff2
leaq 0xc8(%rsp), %r15
leaq 0x20(%rsp), %rdx
movl $0x9, (%rdx)
leaq 0x7a61(%rip), %rsi      # 0xd123
movq %r15, %rdi
callq 0x6014
leaq 0xf0(%rsp), %r15
leaq 0x60(%rsp), %rdx
movl $0xa, (%rdx)
leaq 0x7a45(%rip), %rsi      # 0xd129
movq %r15, %rdi
callq 0x6036
leaq 0x118(%rsp), %r15
leaq 0x80(%rsp), %rdx
movl $0xb, (%rdx)
leaq 0x7a28(%rip), %rsi      # 0xd131
movq %r15, %rdi
callq 0x6036
leaq 0x140(%rsp), %r15
leaq 0x8(%rsp), %rdx
movl $0xc, (%rdx)
leaq 0x7a0e(%rip), %rsi      # 0xd139
movq %r15, %rdi
callq 0x6036
leaq 0x168(%rsp), %r15
leaq 0x10(%rsp), %rdx
movl $0xd, (%rdx)
leaq 0x79f4(%rip), %rsi      # 0xd141
movq %r15, %rdi
callq 0x6036
leaq 0x190(%rsp), %r15
leaq 0x1c(%rsp), %rdx
movl $0xe, (%rdx)
leaq 0x7d2d(%rip), %rsi      # 0xd49c
movq %r15, %rdi
callq 0x5ff2
leaq 0x1b8(%rsp), %r15
leaq 0x18(%rsp), %rdx
movl $0xf, (%rdx)
leaq 0x7d75(%rip), %rsi      # 0xd506
movq %r15, %rdi
callq 0x5ff2
leaq 0x1e0(%rsp), %r15
leaq 0x14(%rsp), %rdx
movl $0x10, (%rdx)
leaq 0x7996(%rip), %rsi      # 0xd149
movq %r15, %rdi
callq 0x5ff2
leaq 0x208(%rsp), %rdx
leaq 0xd(%rsp), %rax
movq %rax, (%rsp)
leaq 0xfb8d(%rip), %rdi      # 0x15360
leaq 0xa0(%rsp), %rsi
leaq 0xf(%rsp), %r8
leaq 0xe(%rsp), %r9
xorl %ecx, %ecx
callq 0x676a
movl $0x140, %r14d           # imm = 0x140
leaq (%rsp,%r14), %rdi
addq $0xa0, %rdi
callq 0x3528
addq $-0x28, %r14
cmpq $-0x28, %r14
jne 0x57f2
leaq 0x845(%rip), %rdi       # 0x6058
leaq 0xfb46(%rip), %rsi      # 0x15360
leaq 0xfa77(%rip), %rdx      # 0x15298
callq 0x3240
leaq 0xfb6b(%rip), %rdi      # 0x15398
callq 0x31e0
jmp 0x53d8
pushq $0x10
popq %rdi
callq 0x3170
movq %rax, %r14
leaq 0x793a(%rip), %rsi      # 0xd183
movq %rax, %rdi
callq 0x3100
movq 0xf790(%rip), %rsi      # 0x14fe8
movq 0xf739(%rip), %rdx      # 0x14f98
movq %r14, %rdi
callq 0x3470
pushq $0x10
popq %rdi
callq 0x3170
movq %rax, %r15
leaq 0x78d4(%rip), %rsi      # 0xd14d
leaq 0xa0(%rsp), %rdi
movq %r14, %rdx
callq 0x6076
movb $0x1, %bpl
leaq 0xa0(%rsp), %rsi
movq %r15, %rdi
callq 0x3440
xorl %ebp, %ebp
movq 0xf743(%rip), %rsi      # 0x14fe8
movq 0xf6ec(%rip), %rdx      # 0x14f98
movq %r15, %rdi
callq 0x3470
jmp 0x5a0f
pushq $0x10
popq %rdi
callq 0x3170
movq %rax, %r14
movsbl %r15b, %ebx
movl %ebx, %edi
callq 0x34a0
movl %eax, %ebp
testl %eax, %eax
jne 0x598b
leaq 0x78e5(%rip), %rsi      # 0xd1c5
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x46b2
leaq 0x80(%rsp), %rdi
movl %ebx, %esi
callq 0x6395
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x632e
jmp 0x59ca
pushq $0x10
popq %rdi
callq 0x3170
movq %rax, %r14
leaq 0x782f(%rip), %rsi      # 0xd15b
movq %rax, %rdi
callq 0x3100
jmp 0x5851
pushq $0x10
popq %rdi
callq 0x3170
movq %rax, %r14
leaq 0x7825(%rip), %rsi      # 0xd170
leaq 0xa0(%rsp), %rdi
movq %rbx, %rdx
callq 0x6076
movb $0x1, %bpl
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq 0x3440
xorl %ebp, %ebp
movq 0xf671(%rip), %rsi      # 0x14fe8
movq 0xf61a(%rip), %rdx      # 0x14f98
movq %r14, %rdi
callq 0x3470
jmp 0x5a0f
leaq 0x7de0(%rip), %rsi      # 0xd772
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x46b2
movsbl %r15b, %edx
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x630c
leaq 0x7db7(%rip), %rdx      # 0xd772
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x46ed
leaq 0x77e0(%rip), %rsi      # 0xd1b1
leaq 0xa0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x62e8
movb $0x1, %r15b
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq 0x3440
xorl %r15d, %r15d
movq 0xf5e8(%rip), %rsi      # 0x14fe8
movq 0xf591(%rip), %rdx      # 0x14f98
movq %r14, %rdi
callq 0x3470
movq %rax, %rbx
movl $0x140, %r12d           # imm = 0x140
leaq (%rsp,%r12), %rdi
addq $0xa0, %rdi
callq 0x3528
addq $-0x28, %r12
cmpq $-0x28, %r12
jne 0x5a18
movb $0x1, %al
jmp 0x5a49
jmp 0x5a44
jmp 0x5a44
jmp 0x5a44
jmp 0x5a44
jmp 0x5a44
jmp 0x5a44
jmp 0x5a44
movq %rax, %rbx
xorl %eax, %eax
cmpq %r15, %r14
sete %cl
testb %al, %al
jne 0x5a68
testb %cl, %cl
jne 0x5a68
addq $-0x28, %r15
movq %r15, %rdi
callq 0x3528
cmpq %r14, %r15
jne 0x5a57
leaq 0xf929(%rip), %rdi      # 0x15398
callq 0x31c0
jmp 0x5b3c
movq %rax, %rbx
jmp 0x5a68
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x3528
jmp 0x5a96
movq %rax, %rbx
movb $0x1, %r15b
leaq 0x40(%rsp), %rdi
callq 0x3528
testl %ebp, %ebp
jne 0x5aac
jmp 0x5abe
movq %rax, %rbx
movb $0x1, %r15b
leaq 0x20(%rsp), %rdi
callq 0x3528
jmp 0x5ad3
movq %rax, %rbx
movb $0x1, %r15b
leaq 0x80(%rsp), %rdi
callq 0x3528
jmp 0x5ae0
movq %rax, %rbx
movb $0x1, %r15b
leaq 0x60(%rsp), %rdi
jmp 0x5ae5
movq %rax, %rbx
movb $0x1, %r15b
leaq 0x20(%rsp), %rdi
callq 0x3528
testb %r15b, %r15b
jne 0x5b34
jmp 0x5b3c
jmp 0x5b31
jmp 0x5b31
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x3528
testb %bpl, %bpl
jne 0x5b34
jmp 0x5b3c
jmp 0x5b31
jmp 0x5b31
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x3528
testb %bpl, %bpl
jne 0x5b2a
jmp 0x5b3c
movq %rax, %rbx
movq %r15, %rdi
jmp 0x5b37
jmp 0x5b31
movq %rax, %rbx
movq %r14, %rdi
callq 0x3210
movq %rbx, %rdi
callq 0x3490