// File: /workspace/github_cpp_makefile_star2_O1/Alcaro[P]bridges/arlib/bmlparse.cpp
// Function: bmlparser::next()
bmlparser::event bmlparser::next()
{
	if (m_exit)
	{
		m_exit = false;
		return { exit };
	}
	
	if (m_inlines)
	{
		event ev = { enter };
		bool dummy;
		if (bml_parse_inline_node(m_inlines, ev.name, dummy, ev.value))
		{
			m_exit = true;
			return ev;
		}
		else if (ev.value) return { error, "", ev.value };
		//else fall through
	}
	
	if (!m_thisline && m_data)
	{
		if (!getline(true)) return { error, "", "Mixed tabs and spaces" };
	}
	
	if (m_indent_step.size() > m_indent.length())
	{
	handle_indent:
		if (!m_indent_step.get_or(m_indent.length(), false))
		{
			//this may throw random mix-tab-space errors that weren't present in the original,
			// but only if the document contains mix-tab-space and this error already.
			if (m_indent_step.size() > m_indent.length()) m_indent += m_indent[0];
			else m_indent = m_indent.substr(0, ~1);
			return { error, "", "Invalid indentation depth" };
		}
		
		int lasttrue = m_indent_step.size()-2; // -1 for [size()] being OOB, -1 to skip the true at [size()-1] and discard it
		while (lasttrue>=0 && m_indent_step[lasttrue]==false) lasttrue--;
		
		m_indent_step.resize(lasttrue+1);
		return { exit };
	}
	
	if (!m_thisline)
	{
		if (m_indent_step.size()) goto handle_indent;
		return { finish };
	}
	
	m_inlines = m_thisline;
	m_thisline = "";
	
	cstring node;
	bool hasvalue;
	cstring value;
	if (!bml_parse_inline_node(m_inlines, node, hasvalue, value))
	{
		//m_inlines can't be empty here, we've called getline()
		return { error, "", value };
	}
	
	size_t indentlen = m_indent.length(); // changed by getline
	//multilines
	if (!hasvalue)
	{
		if (!getline(false)) return { error, "", "Mixed tabs and spaces" };
		if (m_thisline && m_thisline[0] == ':')
		{
			size_t inner_indent = m_indent.length();
			m_tmp_value = m_thisline.substr(1, ~0);
			if (!getline(false)) return { error, "", "Mixed tabs and spaces" };
			while (m_thisline && m_thisline[0] == ':')
			{
				if (inner_indent != m_indent.length()) return { error, "", "Multi-line values must have constant indentation" };
				m_tmp_value += "\n" + m_thisline.substr(1, ~0);
				if (!getline(false)) return { error, "", "Mixed tabs and spaces" };
			}
			
			if (m_indent.length() != inner_indent)
			{
				if (m_indent.length() > inner_indent)
				{
					return { error, "", "Can't change indentation after a multi-line value" };
				}
				if (m_indent.length() > indentlen && !m_indent_step.get_or(m_indent.length(), false))
				{
					return { error, "", "Invalid indentation depth" };
				}
			}
			
			value = m_tmp_value;
		}
	}
	
	m_indent_step.set_resize(indentlen, true);
	return { enter, node, value };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x1, 0x60(%rsi)
jne 0x588c
xorl %eax, %eax
movb %al, 0x60(%r14)
movl $0x1, (%rbx)
movw $0xf, 0x17(%rbx)
movb %al, 0x8(%rbx)
movb $0xf, 0x27(%rbx)
jmp 0x5c18
movzbl 0x5f(%r14), %eax
testb %al, %al
jns 0x589b
movl 0x58(%r14), %eax
jmp 0x589e
xorl $0xf, %eax
leaq 0x50(%r14), %r12
testl %eax, %eax
je 0x593d
leaq 0x38(%rsp), %rsi
movl $0x0, -0x8(%rsi)
movw $0xf, 0xf(%rsi)
movb $0x0, (%rsi)
leaq 0x48(%rsp), %r15
movb $0xf, 0xf(%r15)
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rcx
callq 0x5e86
testb %al, %al
je 0x5901
movb $0x1, 0x60(%r14)
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rbx)
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
jmp 0x5c18
movzbl 0x57(%rsp), %eax
testb %al, %al
jns 0x5910
movl 0x50(%rsp), %eax
jmp 0x5913
xorl $0xf, %eax
testl %eax, %eax
je 0x593d
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2caa4(%rip), %rsi     # 0x323cc
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movups (%r15), %xmm0
jmp 0x5c14
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x594c
movl 0x28(%r14), %eax
jmp 0x594f
xorl $0xf, %eax
testl %eax, %eax
je 0x5a05
leaq 0x30(%r14), %r15
movq 0x38(%r14), %rcx
movzbl 0x4f(%r14), %eax
movl %eax, %r13d
xorl $0xf, %r13d
testb %al, %al
movl 0x48(%r14), %edx
cmovnsl %r13d, %edx
cmpq %rdx, %rcx
jbe 0x59f6
testb %al, %al
movl 0x48(%r14), %edx
cmovnsl %r13d, %edx
cmpq %rdx, %rcx
jbe 0x5a1b
movq %r15, %rsi
cmpq $0x41, %rcx
jb 0x5999
movq (%r15), %rsi
movl %edx, %edi
shrl $0x3, %edi
movzbl (%rsi,%rdi), %esi
andl $0x7, %edx
btl %edx, %esi
jae 0x5a1b
movl %ecx, %eax
addl $-0x2, %eax
js 0x59de
movq %r15, %rdx
cmpq $0x41, %rcx
jb 0x59bd
movq (%r15), %rdx
movl %eax, %ecx
shrl $0x3, %ecx
movzbl (%rdx,%rcx), %ecx
movl %eax, %esi
andl $0x7, %esi
btl %esi, %ecx
jb 0x59de
leal -0x1(%rax), %ecx
testl %eax, %eax
movl %ecx, %eax
jg 0x59bd
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %eax
movslq %eax, %rsi
movq %r15, %rdi
callq 0x51ac
movl $0x1, (%rbx)
jmp 0x5be3
movzbl 0x2f(%r14), %edx
testb %dl, %dl
jns 0x5a67
movl 0x28(%r14), %edx
jmp 0x5a6a
movzbl 0x1f(%r14), %eax
testb %al, %al
jns 0x5b0c
movl 0x18(%r14), %eax
jmp 0x5b0f
leaq 0x40(%r14), %r15
testb %al, %al
movl 0x48(%r14), %edx
cmovnsl %r13d, %edx
cmpq %rdx, %rcx
jbe 0x5b5e
movq %r15, %rcx
testb %al, %al
jns 0x5a3d
movq 0x40(%r14), %rcx
movb (%rcx), %bpl
testb %al, %al
cmovsl 0x48(%r14), %r13d
leal 0x1(%r13), %esi
movq %r15, %rdi
callq 0x191a4
cmpb $0x0, 0x4f(%r14)
jns 0x5a5e
movq 0x40(%r14), %r15
movb %bpl, (%r15,%r13)
jmp 0x5b98
xorl $0xf, %edx
testl %edx, %edx
je 0x5bd4
leaq 0x20(%r14), %r13
movups (%r13), %xmm0
movups %xmm0, (%r12)
leaq 0x2c945(%rip), %rsi     # 0x323cc
xorl %ebp, %ebp
movq %r13, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movb $0xf, %al
leaq 0x30(%rsp), %rsi
movb %al, 0xf(%rsi)
movb %bpl, (%rsi)
leaq 0x10(%rsp), %rcx
movb %al, 0xf(%rcx)
movb %bpl, (%rcx)
leaq 0x7(%rsp), %rdx
movq %r12, %rdi
callq 0x5e86
testb %al, %al
je 0x5bf2
movzbl 0x4f(%r14), %eax
movl %eax, %r12d
xorl $0xf, %r12d
testb %al, %al
cmovsl 0x48(%r14), %r12d
cmpb $0x0, 0x7(%rsp)
je 0x5c2a
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x66f0
movl $0x0, (%rbx)
movups 0x30(%rsp), %xmm0
movups %xmm0, 0x8(%rbx)
movaps 0x10(%rsp), %xmm0
jmp 0x5c14
xorl $0xf, %eax
testl %eax, %eax
je 0x5957
movq %r14, %rdi
movl $0x1, %esi
callq 0x63b0
testb %al, %al
jne 0x5957
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c88f(%rip), %rsi     # 0x323cc
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x296e9(%rip), %rsi     # 0x2f240
movl $0x15, %edx
jmp 0x5bc8
movq %r15, %rdi
xorl %esi, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x658a
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movzbl 0xf(%rsi), %ecx
movq %rcx, %rdi
xorq $0xf, %rdi
testb %cl, %cl
movl %edx, %edx
cmovsq %rax, %rsi
cmovnsq %rdi, %rdx
movq %r15, %rdi
callq 0x193dc
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c823(%rip), %rsi     # 0x323cc
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x29693(%rip), %rsi     # 0x2f256
movl $0x19, %edx
movl $0x1, %ecx
callq 0x5040
jmp 0x5c18
testq %rcx, %rcx
jne 0x597a
movl $0x3, (%rbx)
movw $0xf, 0x17(%rbx)
movb $0x0, 0x8(%rbx)
jmp 0x5883
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c7c9(%rip), %rsi     # 0x323cc
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movups 0x10(%rsp), %xmm0
movups %xmm0, 0x18(%rbx)
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
xorl %esi, %esi
callq 0x63b0
testb %al, %al
je 0x5d55
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x5c4b
movl 0x28(%r14), %ecx
jmp 0x5c50
movl %eax, %ecx
xorl $0xf, %ecx
testl %ecx, %ecx
je 0x5ae3
movq %r13, %rcx
testb %al, %al
jns 0x5c63
movq (%r13), %rcx
cmpb $0x3a, (%rcx)
jne 0x5ae3
movzbl 0x4f(%r14), %ebp
testb %bpl, %bpl
jns 0x5c7c
movl 0x48(%r14), %ebp
jmp 0x5c7f
xorl $0xf, %ebp
movq %r13, %rdi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x658a
leaq 0x68(%r14), %rdi
movq %rdi, 0x8(%rsp)
movq %rax, %rsi
callq 0x6744
movq %r14, %rdi
xorl %esi, %esi
callq 0x63b0
testb %al, %al
je 0x5d55
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x5cc3
movl 0x28(%r14), %ecx
jmp 0x5cc8
movl %eax, %ecx
xorl $0xf, %ecx
testl %ecx, %ecx
je 0x5d83
movq %r13, %rcx
testb %al, %al
jns 0x5cdb
movq (%r13), %rcx
cmpb $0x3a, (%rcx)
jne 0x5d83
movzbl 0x4f(%r14), %eax
testb %al, %al
jns 0x5cf3
movl 0x48(%r14), %eax
jmp 0x5cf6
xorl $0xf, %eax
cmpl %eax, %ebp
jne 0x5db7
movq %r13, %rdi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x658a
movq %rdx, %rcx
leaq 0x20(%rsp), %rdi
leaq 0x2caad(%rip), %rsi     # 0x327cc
movq %rax, %rdx
callq 0x664a
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x66b6
cmpb $0x0, 0x2f(%rsp)
jns 0x5ca2
movq 0x20(%rsp), %rdi
callq 0x3430
jmp 0x5ca2
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c666(%rip), %rsi     # 0x323cc
callq 0x6384
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x294c7(%rip), %rsi     # 0x2f240
callq 0x6384
jmp 0x5c18
movzbl 0x4f(%r14), %eax
testb %al, %al
jns 0x5d92
movl 0x48(%r14), %ecx
jmp 0x5d97
movl %eax, %ecx
xorl $0xf, %ecx
cmpl %ebp, %ecx
jne 0x5dad
movq 0x8(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
jmp 0x5ae3
testb %al, %al
jns 0x5ddd
movl 0x48(%r14), %ecx
jmp 0x5de2
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c604(%rip), %rsi     # 0x323cc
callq 0x6384
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x29495(%rip), %rsi     # 0x2f270
jmp 0x5d79
movl %eax, %ecx
xorl $0xf, %ecx
cmpl %ebp, %ecx
jbe 0x5e0f
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c5d5(%rip), %rsi     # 0x323cc
callq 0x6384
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x29497(%rip), %rsi     # 0x2f2a1
jmp 0x5d79
testb %al, %al
jns 0x5e19
movl 0x48(%r14), %ecx
jmp 0x5e1e
movl %eax, %ecx
xorl $0xf, %ecx
cmpl %r12d, %ecx
jbe 0x5d9b
movl %eax, %ecx
xorl $0xf, %ecx
testb %al, %al
cmovsl 0x48(%r14), %ecx
movq 0x38(%r14), %rdx
cmpq %rcx, %rdx
jbe 0x5e5d
movq %r15, %rax
cmpq $0x41, %rdx
jb 0x5e48
movq (%r15), %rax
movl %ecx, %edx
shrl $0x3, %edx
movzbl (%rax,%rdx), %eax
andl $0x7, %ecx
btl %ecx, %eax
jb 0x5d9b
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c55e(%rip), %rsi     # 0x323cc
callq 0x6384
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x293d5(%rip), %rsi     # 0x2f256
jmp 0x5d79