// File: /workspace/github_c_makefile_star2_O3/almk277[P]ROSE/rasm/parser.cpp
// Function: parser::parse()
void parser::parse()
{
	parser_state state;
	string name;

	bool more_tok = true;
	while (more_tok) {
		switch (s.next()) {
		case tok::STRING:
		{
			state.ensure(parser_state::SUB);
			auto it = instr.find(s.str());
			if (it == instr.end())
				throw error(s.str() + ": no such instruction");
			instruction i = it->second;
			m.text.set_next_addr(i.len);
			m.text.put(i.opcode);
			parse_operands(i);
			s >> eol;
			break;
		}
		case tok::LABEL:
			s >> name >> eol;
			m.text.add_label(name);
			break;
		case tok::BYTE:
			state.ensure(parser_state::STR);
			m.str.put(s.num_byte());
			break;
		case tok::INT:
			state.ensure(parser_state::STR);
			m.str.put(s.num_int());
			break;
		case tok::FLOAT:
			state.ensure(parser_state::STR);
			m.str.put(s.num_flt());
			break;
		case tok::ARRAY:
			state.ensure(parser_state::STR);
			m.str.put(s.array());
			break;
		case tok::NEWLINE:
			break;
		case tok::END:
			more_tok = false;
			break;
		case tok::ARG:
		{
			state.ensure(parser_state::SUB);
			string type;
			s >> type >> name >> eol;
			m.text.add_arg(name, mangle(type));
			break;
		}
		case tok::DATA:
		{
			string type;
			s >> type >> name >> eol;
			m.data.add(name);
			break;
		}
		case tok::EXPORT:
		{
			s >> name >> eol;
			auto slot = m.ptbl[name];
			auto &exp = m.exp.add(name);
			exp.name = m.sym.add(name);
			exp.idx = slot;
			break;
		}
		case tok::EXTERN:
		{
			s >> name >> eol;
			auto ss = s.string_pair();
			auto &imp = m.imp.add(name);
			imp.name = m.sym.add(ss.first);
			imp.module = m.mtbl[ss.second];
			imp.type = m.sym.add(read_types());
			break;
		}
		case tok::IMPORT:
		{
			unsigned char maj, min;
			s >> name >> maj >> min >> eol;
			auto &mod = m.mtbl.add(name);
			mod.name = m.sym.add(name);
			mod.version = { maj, min };
			break;
		}
		case tok::MODULE:
		{
			unsigned char maj, min;
			s >> name >> maj >> min >> eol;
			m.header.name = m.sym.add(name);
			m.header.version = { maj, min };
			break;
		}
		case tok::STR:
			state.set(parser_state::STR, [this]{ m.str.finish(); });
			s >> name >> eol;
			m.str.start(name);
			break;
		case tok::SUB:
			state.set(parser_state::SUB, [this]{ m.text.finish(); });
			s >> name >> eol;
			m.text.start(&m.ptbl.add(name));
			break;
		case tok::VAR:
			state.ensure(parser_state::SUB);
			s >> name >> eol;
			m.text.add_var(name);
			break;
		default: throw std::logic_error("bad token type");
		}
	} //while (more_tok)

	state.set(parser_state::NONE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %r14
leaq 0xc0(%rsp), %rcx
movl $0x0, -0x8(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
leaq 0x186a(%rip), %rax      # 0xc58c
movq %rax, 0x18(%rcx)
leaq 0x1861(%rip), %rax      # 0xc58e
movq %rax, 0x10(%rcx)
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x3841(%rip), %rbp      # 0xe590
leaq 0xb8(%rsp), %r12
leaq 0x38f6(%rip), %rbx      # 0xe654
leaq 0xe0(%rsp), %r15
movq (%r14), %rdi
callq 0x5698
cmpl $0x10, %eax
ja 0xb470
movl %eax, %eax
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq %r12, %rdi
movl $0x1, %esi
callq 0xbe88
movq (%r14), %rsi
addq $0x10, %rsi
leaq 0x9602(%rip), %rdi      # 0x143a0
callq 0xccd0
testq %rax, %rax
je 0xb4a4
movups 0x28(%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x8(%r14), %rax
leaq 0x240(%rax), %rdi
movl 0x248(%rax), %ecx
subl 0x240(%rax), %ecx
addl 0x14(%rsp), %ecx
movl %ecx, 0x330(%rax)
movzbl 0x10(%rsp), %esi
callq 0xc0e2
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0xb6c0
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x61e9
jmp 0xad66
movq $0x0, 0x80(%rsp)
movq %r14, 0x78(%rsp)
leaq 0xd89(%rip), %rax       # 0xbb9e
movq %rax, 0x90(%rsp)
leaq 0xd8c(%rip), %rax       # 0xbbb0
movq %rax, 0x88(%rsp)
movq %r12, %rdi
movl $0x1, %esi
leaq 0x78(%rsp), %rdx
callq 0xc400
movq 0x88(%rsp), %rax
testq %rax, %rax
je 0xae5a
leaq 0x78(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %r13
leaq 0xa0(%r13), %rdi
movq %r15, %rsi
callq 0xc442
addq $0x240, %r13            # imm = 0x240
movq %r13, %rdi
movq %rax, %rsi
callq 0x81f0
jmp 0xad66
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
leaq 0x58(%rsp), %rsi
movq %rax, %rdi
callq 0x6224
movq %rax, %rdi
leaq 0xf(%rsp), %rsi
callq 0x6224
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %r12
leaq 0x110(%r12), %rdi
movq %r15, %rsi
callq 0x76b4
leaq 0x168(%r12), %rdi
movl $0x0, 0x10(%rsp)
leaq 0x10(%rsp), %rsi
callq 0xcfec
movq 0x170(%r12), %r12
movq 0x8(%r14), %rdi
movl $0x1f0, %eax            # imm = 0x1F0
addq %rax, %rdi
movq %r15, %rsi
callq 0x7884
movw %ax, -0x4(%r12)
movb 0x58(%rsp), %al
movb 0xf(%rsp), %cl
movb %al, -0x2(%r12)
movb %cl, -0x1(%r12)
leaq 0xb8(%rsp), %r12
jmp 0xad66
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq (%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x6298
movq %rbx, %rbp
movq 0x8(%r14), %rdi
movl $0x180, %eax            # imm = 0x180
addq %rax, %rdi
movq %r15, %rsi
callq 0xc36e
movq %rax, %r13
movq 0x8(%r14), %rdi
movl $0x1f0, %eax            # imm = 0x1F0
addq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x7884
movw %ax, (%r13)
movq 0x8(%r14), %rdi
movl $0x110, %eax            # imm = 0x110
addq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0xc182
movb %al, 0x5(%r13)
movq 0x8(%r14), %r12
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb934
addq $0x1f0, %r12            # imm = 0x1F0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7884
movw %ax, 0x2(%r13)
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
leaq 0xb8(%rsp), %r12
movq %rbp, %rbx
je 0xaffd
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
leaq 0x357f(%rip), %rbp      # 0xe590
je 0xb1e3
movq 0x40(%rsp), %rsi
jmp 0xb1db
movq %r12, %rdi
movl $0x2, %esi
callq 0xbe88
movq 0x8(%r14), %rdi
movl $0x338, %eax            # imm = 0x338
addq %rax, %rdi
movq (%r14), %rax
movss 0x38(%rax), %xmm0
callq 0xc13e
jmp 0xad66
movq %r12, %rdi
movl $0x2, %esi
callq 0xbe88
movq 0x8(%r14), %rdi
movl $0x338, %eax            # imm = 0x338
addq %rax, %rdi
movq (%r14), %rax
movzbl 0x34(%rax), %esi
callq 0xc0e2
jmp 0xad66
movq %r12, %rdi
movl $0x2, %esi
callq 0xbe88
movq 0x8(%r14), %rdi
movl $0x338, %eax            # imm = 0x338
addq %rax, %rdi
movq (%r14), %rax
movl 0x30(%rax), %esi
callq 0xc0fe
jmp 0xad66
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %rdi
movl $0x240, %eax            # imm = 0x240
addq %rax, %rdi
movq %r15, %rsi
callq 0x7a6a
jmp 0xad66
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq (%r14), %rdi
leaq 0x10(%rsp), %rsi
callq 0x61fc
movq %rax, %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %rdi
movl $0x390, %eax            # imm = 0x390
addq %rax, %rdi
movq %r15, %rsi
callq 0x76b4
jmp 0xb1e3
movq %r12, %rdi
movl $0x2, %esi
callq 0xbe88
movq 0x8(%r14), %rdi
movl $0x338, %eax            # imm = 0x338
addq %rax, %rdi
movq (%r14), %rsi
addq $0x40, %rsi
callq 0x7954
jmp 0xad66
movq %r12, %rdi
movl $0x1, %esi
callq 0xbe88
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq (%r14), %rdi
leaq 0x10(%rsp), %rsi
callq 0x61fc
movq %rax, %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %r12
leaq 0x58(%rsp), %r13
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0xaa87
addq $0x240, %r12            # imm = 0x240
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x7f60
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
leaq 0xb8(%rsp), %r12
je 0xb1e3
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xad66
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0xad66
movq $0x0, 0xa0(%rsp)
movq %r14, 0x98(%rsp)
leaq 0x943(%rip), %rax       # 0xbb66
movq %rax, 0xb0(%rsp)
leaq 0x946(%rip), %rax       # 0xbb78
movq %rax, 0xa8(%rsp)
movq %r12, %rdi
movl $0x2, %esi
leaq 0x98(%rsp), %rdx
callq 0xc400
movq 0xa8(%rsp), %rax
testq %rax, %rax
je 0xb26e
leaq 0x98(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %rdi
movl $0x338, %eax            # imm = 0x338
addq %rax, %rdi
movq %r15, %rsi
callq 0x797a
jmp 0xad66
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %rdi
movl $0xa0, %eax
addq %rax, %rdi
movq %r15, %rsi
callq 0xc182
movl %eax, %r13d
movq 0x8(%r14), %r12
leaq 0x30(%r12), %rdi
movq %r15, %rsi
callq 0x76b4
leaq 0x88(%r12), %rdi
movw $0x0, 0x10(%rsp)
movb $0x0, 0x12(%rsp)
leaq 0x10(%rsp), %rsi
callq 0xcd0a
movq 0x90(%r12), %r12
movq 0x8(%r14), %rdi
movl $0x1f0, %eax            # imm = 0x1F0
addq %rax, %rdi
movq %r15, %rsi
callq 0x7884
movw %ax, -0x4(%r12)
movb %r13b, -0x2(%r12)
leaq 0xb8(%rsp), %r12
jmp 0xad66
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x6224
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x6224
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %rdi
movl $0x1f0, %eax            # imm = 0x1F0
addq %rax, %rdi
movq %r15, %rsi
callq 0x7884
movq 0x8(%r14), %rcx
movw %ax, 0x6(%rcx)
movb 0x10(%rsp), %al
movb 0x58(%rsp), %dl
movb %al, 0x8(%rcx)
movb %dl, 0x9(%rcx)
jmp 0xad66
movq %r12, %rdi
movl $0x1, %esi
callq 0xbe88
movq (%r14), %rdi
movq %r15, %rsi
callq 0x61fc
movq %rax, %rdi
movq %rbx, %rsi
callq 0x61e9
movq 0x8(%r14), %rdi
movl $0x240, %eax            # imm = 0x240
addq %rax, %rdi
movq %r15, %rsi
callq 0x7f46
jmp 0xad66
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rdx
movaps %xmm0, (%rdx)
leaq 0x1ef7(%rip), %rax      # 0xd2d4
movq %rax, 0x18(%rdx)
leaq 0x1eee(%rip), %rax      # 0xd2d6
movq %rax, 0x10(%rdx)
leaq 0xb8(%rsp), %rdi
xorl %esi, %esi
callq 0xc400
movq 0x110(%rsp), %rax
testq %rax, %rax
je 0xb41a
leaq 0x100(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0xb43f
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0xd0(%rsp), %rax
testq %rax, %rax
je 0xb45e
leaq 0xc0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x3150
movq %rax, %r14
leaq 0x3232(%rip), %rsi      # 0xe6b6
movq %rax, %rdi
callq 0x33b0
movq 0x8b3d(%rip), %rsi      # 0x13fd0
movq 0x8b26(%rip), %rdx      # 0x13fc0
movq %r14, %rdi
callq 0x3480
jmp 0xb4f1
movl $0x10, %edi
callq 0x3150
movq %rax, %r15
movq (%r14), %rsi
addq $0x10, %rsi
leaq 0x31e1(%rip), %rdx      # 0xe6a0
leaq 0x10(%rsp), %rdi
callq 0x49df
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x3440
xorl %ebp, %ebp
movq 0x8b0e(%rip), %rsi      # 0x13ff0
movq 0x8ac7(%rip), %rdx      # 0x13fb0
movq %r15, %rdi
callq 0x3480
jmp 0xb6b8
jmp 0xb6b8
movq %rax, %rbx
movq 0x110(%rsp), %rax
testq %rax, %rax
je 0xb66c
leaq 0x100(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0xb66c
jmp 0xb6b8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xb54a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
testb %bpl, %bpl
jne 0xb557
jmp 0xb66c
movq %rax, %rbx
movq %r15, %rdi
jmp 0xb567
jmp 0xb669
movq %rax, %rbx
movq %r14, %rdi
callq 0x31f0
jmp 0xb66c
jmp 0xb6b8
jmp 0xb6b8
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xb632
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0xb632
jmp 0xb669
jmp 0xb669
jmp 0xb669
jmp 0xb644
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xb647
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0xb647
movq %rax, %rbx
movq 0xa8(%rsp), %rax
testq %rax, %rax
je 0xb66c
leaq 0x98(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0xb66c
jmp 0xb6b8
movq %rax, %rbx
movq 0x88(%rsp), %rax
testq %rax, %rax
je 0xb66c
leaq 0x78(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0xb66c
jmp 0xb6b8
jmp 0xb62f
jmp 0xb669
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xc3ca
jmp 0xb66c
jmp 0xb644
jmp 0xb669
jmp 0xb669
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xb66c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0xb66c
jmp 0xb669
jmp 0xb669
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rax
cmpq %rax, %rdi
je 0xb691
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0xd0(%rsp), %rax
testq %rax, %rax
je 0xb6b0
leaq 0xc0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq %rbx, %rdi
callq 0x34a0
movq %rax, %rdi
callq 0x4acf