// File: /workspace/github_cpp_makefile_star2_O2/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 0x4b68
xorl %eax, %eax
movb %al, 0x60(%r14)
movl $0x1, (%rbx)
movw $0xf, 0x17(%rbx)
movb %al, 0x8(%rbx)
movb $0xf, 0x27(%rbx)
jmp 0x4f81
movzbl 0x5f(%r14), %eax
testb %al, %al
jns 0x4b77
movl 0x58(%r14), %eax
jmp 0x4b7a
xorl $0xf, %eax
leaq 0x50(%r14), %r12
testl %eax, %eax
je 0x4c0f
leaq 0x28(%rsp), %rsi
andl $0x0, -0x8(%rsi)
movw $0xf, 0xf(%rsi)
movb $0x0, (%rsi)
leaq 0x38(%rsp), %r15
movb $0xf, 0xf(%r15)
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rcx
callq 0x5030
testb %al, %al
je 0x4bda
movb $0x1, 0x60(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rbx)
movups 0x20(%rsp), %xmm0
movups 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
jmp 0x4f81
movzbl 0x47(%rsp), %eax
testb %al, %al
jns 0x4be9
movl 0x40(%rsp), %eax
jmp 0x4bec
xorl $0xf, %eax
testl %eax, %eax
je 0x4c0f
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x267d8(%rip), %rsi     # 0x2b3d9
callq 0x42ce
movups (%r15), %xmm0
jmp 0x4de0
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x4c1e
movl 0x28(%r14), %eax
jmp 0x4c21
xorl $0xf, %eax
testl %eax, %eax
je 0x4c90
leaq 0x30(%r14), %r15
movq 0x38(%r14), %rax
movzbl 0x4f(%r14), %ecx
movl %ecx, %esi
xorl $0xf, %esi
testb %cl, %cl
cmovsl 0x48(%r14), %esi
cmpq %rsi, %rax
jbe 0x4c81
movq %r15, %rdi
xorl %edx, %edx
callq 0x559c
movq 0x38(%r14), %r12
testb %al, %al
je 0x4ca6
decl %r12d
leaq 0x20(%rsp), %r14
movl %r12d, %ebp
decl %ebp
js 0x4cde
movl %ebp, %eax
movq %r15, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movq %r14, %rdi
callq 0x5624
testb %al, %al
jne 0x4cde
movl %ebp, %r12d
jmp 0x4c60
movzbl 0x2f(%r14), %ecx
testb %cl, %cl
jns 0x4cfe
movl 0x28(%r14), %ecx
jmp 0x4d01
movzbl 0x1f(%r14), %eax
testb %al, %al
jns 0x4d8e
movl 0x18(%r14), %eax
jmp 0x4d91
leaq 0x40(%r14), %r15
movzbl 0x4f(%r14), %eax
movl %eax, %ecx
xorl $0xf, %ecx
testb %al, %al
cmovsl 0x48(%r14), %ecx
cmpq %rcx, %r12
jbe 0x4de9
movq %r15, %rcx
testb %al, %al
jns 0x4cce
movq (%r15), %rcx
movzbl (%rcx), %esi
movq %r15, %rdi
callq 0x4354
jmp 0x4e01
movslq %r12d, %rsi
movq %r15, %rdi
callq 0x4498
movl $0x1, (%rbx)
movw $0xf, 0x17(%rbx)
movb $0x0, 0x8(%rbx)
jmp 0x4b5f
xorl $0xf, %ecx
testl %ecx, %ecx
je 0x4db1
leaq 0x20(%r14), %r13
movups (%r13), %xmm0
movups %xmm0, (%r12)
leaq 0x266bb(%rip), %rsi     # 0x2b3d9
movq %r13, %rdi
callq 0x42ce
movb $0xf, %al
leaq 0x20(%rsp), %rsi
movb %al, 0xf(%rsi)
xorl %edx, %edx
movb %dl, (%rsi)
leaq 0x10(%rsp), %rcx
movb %al, 0xf(%rcx)
movb %dl, (%rcx)
leaq 0x3(%rsp), %rdx
movq %r12, %rdi
callq 0x5030
testb %al, %al
je 0x4dc5
movzbl 0x4f(%r14), %eax
movl %eax, %r12d
xorl $0xf, %r12d
testb %al, %al
cmovsl 0x48(%r14), %r12d
cmpb $0x0, 0x3(%rsp)
je 0x4e2a
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x5634
andl $0x0, (%rbx)
movups 0x20(%rsp), %xmm0
movups %xmm0, 0x8(%rbx)
movaps 0x10(%rsp), %xmm0
jmp 0x4de0
xorl $0xf, %eax
testl %eax, %eax
je 0x4c25
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x5436
testb %al, %al
jne 0x4c25
jmp 0x4f58
testq %rax, %rax
jne 0x4c43
movl $0x3, (%rbx)
jmp 0x4cef
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x26603(%rip), %rsi     # 0x2b3d9
callq 0x42ce
movups 0x10(%rsp), %xmm0
movups %xmm0, 0x18(%rbx)
jmp 0x4f81
pushq $-0x2
popq %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x55aa
movq %r15, %rdi
movq %rax, %rsi
callq 0x5682
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x265c7(%rip), %rsi     # 0x2b3d9
callq 0x42ce
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x23431(%rip), %rsi     # 0x28256
jmp 0x4f7c
movq %r14, %rdi
xorl %esi, %esi
callq 0x5436
testb %al, %al
je 0x4f58
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x4e4b
movl 0x28(%r14), %ecx
jmp 0x4e50
movl %eax, %ecx
xorl $0xf, %ecx
testl %ecx, %ecx
je 0x4d6d
movq %r13, %rcx
testb %al, %al
jns 0x4e63
movq (%r13), %rcx
cmpb $0x3a, (%rcx)
jne 0x4d6d
movzbl 0x4f(%r14), %ebp
testb %bpl, %bpl
jns 0x4e7c
movl 0x48(%r14), %ebp
jmp 0x4e7f
xorl $0xf, %ebp
pushq $0x1
popq %rsi
pushq $-0x1
popq %rdx
movq %r13, %rdi
callq 0x55aa
leaq 0x68(%r14), %rdi
movq %rdi, 0x8(%rsp)
movq %rax, %rsi
callq 0x5682
movq %r14, %rdi
xorl %esi, %esi
callq 0x5436
testb %al, %al
je 0x4f58
movl %ebp, 0x4(%rsp)
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x4ec3
movl 0x28(%r14), %ecx
jmp 0x4ec8
movl %eax, %ecx
xorl $0xf, %ecx
movl 0x4(%rsp), %edx
testl %ecx, %ecx
je 0x4f93
movq %r13, %rcx
testb %al, %al
jns 0x4edf
movq (%r13), %rcx
cmpb $0x3a, (%rcx)
jne 0x4f93
movzbl 0x4f(%r14), %eax
testb %al, %al
jns 0x4ef7
movl 0x48(%r14), %eax
jmp 0x4efa
xorl $0xf, %eax
cmpl %eax, %edx
jne 0x4fac
movq %r13, %rdi
pushq $0x1
popq %rsi
pushq $-0x1
popq %rdx
callq 0x55aa
movq %rdx, %rcx
leaq 0x48(%rsp), %rbp
movq %rbp, %rdi
leaq 0x239c5(%rip), %rsi     # 0x288e7
movq %rax, %rdx
callq 0x41b8
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x4296
movq %rbp, %rdi
callq 0x56b4
movq %r14, %rdi
xorl %esi, %esi
callq 0x5436
testb %al, %al
jne 0x4eb4
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x26470(%rip), %rsi     # 0x2b3d9
callq 0x42ce
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x232c4(%rip), %rsi     # 0x28240
callq 0x42ce
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl 0x4f(%r14), %eax
testb %al, %al
js 0x4fd2
xorl $0xf, %eax
cmpl %eax, %edx
je 0x501e
jb 0x4fdc
cmpl %eax, %r12d
jb 0x500a
jmp 0x501e
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2641c(%rip), %rsi     # 0x2b3d9
callq 0x42ce
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x232a0(%rip), %rsi     # 0x28270
jmp 0x4f7c
movl 0x48(%r14), %eax
cmpl %edx, %eax
je 0x501e
jbe 0x5005
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x263ec(%rip), %rsi     # 0x2b3d9
callq 0x42ce
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x232a1(%rip), %rsi     # 0x282a1
jmp 0x4f7c
cmpl %r12d, %eax
jbe 0x501e
movl %eax, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x559c
testb %al, %al
je 0x4e01
movq 0x8(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
jmp 0x4d6d