// File: /workspace/github_cpp_makefile_star2_O3/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 0x5f2c
xorl %eax, %eax
movb %al, 0x60(%r14)
movl $0x1, (%rbx)
movw $0xf, 0x17(%rbx)
movb %al, 0x8(%rbx)
movb $0xf, 0x27(%rbx)
jmp 0x627e
movzbl 0x5f(%r14), %eax
testb %al, %al
jns 0x5f3b
movl 0x58(%r14), %eax
jmp 0x5f3e
xorl $0xf, %eax
leaq 0x50(%r14), %r12
testl %eax, %eax
je 0x5fdd
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 0x64ce
testb %al, %al
je 0x5fa1
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 0x627e
movzbl 0x57(%rsp), %eax
testb %al, %al
jns 0x5fb0
movl 0x50(%rsp), %eax
jmp 0x5fb3
xorl $0xf, %eax
testl %eax, %eax
je 0x5fdd
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c4a4(%rip), %rsi     # 0x3246c
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
movups (%r15), %xmm0
jmp 0x627a
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x5fec
movl 0x28(%r14), %eax
jmp 0x5fef
xorl $0xf, %eax
testl %eax, %eax
je 0x609a
leaq 0x30(%r14), %r15
movq 0x38(%r14), %rax
leaq 0x40(%r14), %r13
movzbl 0x4f(%r14), %esi
movl %esi, %edx
xorl $0xf, %edx
testb %sil, %sil
movl 0x48(%r14), %ebp
movl %ebp, %edi
cmovnsl %edx, %edi
cmpq %rdi, %rax
jbe 0x608b
movq %r15, %rcx
cmpq $0x41, %rax
jb 0x602a
movq (%r15), %rcx
movl %edi, %r8d
shrl $0x3, %r8d
movzbl (%rcx,%r8), %r8d
andl $0x7, %edi
btl %edi, %r8d
jae 0x61aa
addl $-0x2, %eax
js 0x6069
movl %eax, %edx
shrl $0x3, %edx
movzbl (%rcx,%rdx), %edx
movl %eax, %esi
andl $0x7, %esi
btl %esi, %edx
jb 0x6069
leal -0x1(%rax), %edx
testl %eax, %eax
movl %edx, %eax
jg 0x6048
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
incl %eax
movslq %eax, %rsi
movq %r15, %rdi
callq 0x5afc
movl $0x1, (%rbx)
movw $0xf, 0x17(%rbx)
movb $0x0, 0x8(%rbx)
jmp 0x5f23
movzbl 0x2f(%r14), %ecx
testb %cl, %cl
jns 0x60b0
movl 0x28(%r14), %ecx
jmp 0x60b3
movzbl 0x1f(%r14), %eax
testb %al, %al
jns 0x6155
movl 0x18(%r14), %eax
jmp 0x6158
xorl $0xf, %ecx
testl %ecx, %ecx
je 0x61d8
leaq 0x20(%r14), %r13
movups (%r13), %xmm0
movups %xmm0, (%r12)
leaq 0x2c39c(%rip), %rsi     # 0x3246c
xorl %ebp, %ebp
movq %r13, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
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 0x64ce
testb %al, %al
je 0x6258
movzbl 0x4f(%r14), %eax
movl %eax, %r12d
xorl $0xf, %r12d
testb %al, %al
cmovsl 0x48(%r14), %r12d
cmpb $0x0, 0x7(%rsp)
je 0x6290
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x6c8e
movl $0x0, (%rbx)
movups 0x30(%rsp), %xmm0
movups %xmm0, 0x8(%rbx)
movaps 0x10(%rsp), %xmm0
jmp 0x627a
xorl $0xf, %eax
testl %eax, %eax
je 0x5ff7
movq %r14, %rdi
movl $0x1, %esi
callq 0x698a
testb %al, %al
jne 0x5ff7
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c2e6(%rip), %rsi     # 0x3246c
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x290a0(%rip), %rsi     # 0x2f240
movl $0x15, %edx
jmp 0x624c
testb %sil, %sil
movq 0x40(%r14), %rax
cmovnsq %r13, %rax
movb (%rax), %r15b
cmovnsl %edx, %ebp
leal 0x1(%rbp), %esi
movq %r13, %rdi
callq 0x193c4
cmpb $0x0, 0x4f(%r14)
jns 0x61d1
movq 0x40(%r14), %r13
movb %r15b, (%r13,%rbp)
jmp 0x621c
testq %rax, %rax
je 0x62b1
movq %r13, %rdi
xorl %esi, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x6b28
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %rdx, %rcx
shrq $0x38, %rcx
xorq $0xf, %rcx
testq %rdx, %rdx
movl %edx, %edx
cmovnsq %rcx, %rdx
cmovsq %rax, %rsi
movq %r13, %rdi
callq 0x195fc
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c23f(%rip), %rsi     # 0x3246c
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x2900f(%rip), %rsi     # 0x2f256
movl $0x19, %edx
movl $0x1, %ecx
callq 0x5990
jmp 0x627e
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c203(%rip), %rsi     # 0x3246c
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
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 0x698a
testb %al, %al
je 0x63c6
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x62bc
movl 0x28(%r14), %ecx
jmp 0x62c1
movl $0x3, (%rbx)
jmp 0x607c
movl %eax, %ecx
xorl $0xf, %ecx
testl %ecx, %ecx
je 0x612c
movq %r13, %rcx
testb %al, %al
jns 0x62d4
movq (%r13), %rcx
cmpb $0x3a, (%rcx)
jne 0x612c
movzbl 0x4f(%r14), %ebp
testb %bpl, %bpl
jns 0x62ed
movl 0x48(%r14), %ebp
jmp 0x62f0
xorl $0xf, %ebp
movq %r13, %rdi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6b28
leaq 0x68(%r14), %rdi
movq %rdi, 0x8(%rsp)
movq %rax, %rsi
callq 0x6ce8
movq %r14, %rdi
xorl %esi, %esi
callq 0x698a
testb %al, %al
je 0x63c6
movzbl 0x2f(%r14), %eax
testb %al, %al
jns 0x6334
movl 0x28(%r14), %ecx
jmp 0x6339
movl %eax, %ecx
xorl $0xf, %ecx
testl %ecx, %ecx
je 0x63f4
movq %r13, %rcx
testb %al, %al
jns 0x634c
movq (%r13), %rcx
cmpb $0x3a, (%rcx)
jne 0x63f4
movzbl 0x4f(%r14), %eax
testb %al, %al
jns 0x6364
movl 0x48(%r14), %eax
jmp 0x6367
xorl $0xf, %eax
cmpl %eax, %ebp
jne 0x640d
movq %r13, %rdi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6b28
movq %rdx, %rcx
leaq 0x20(%rsp), %rdi
leaq 0x2c51c(%rip), %rsi     # 0x328ac
movq %rax, %rdx
callq 0x6bea
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x6c56
cmpb $0x0, 0x2f(%rsp)
jns 0x6313
movq 0x20(%rsp), %rdi
callq 0x3430
jmp 0x6313
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c095(%rip), %rsi     # 0x3246c
callq 0x695e
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x28e56(%rip), %rsi     # 0x2f240
callq 0x695e
jmp 0x627e
movzbl 0x4f(%r14), %eax
testb %al, %al
js 0x6433
xorl $0xf, %eax
cmpl %eax, %ebp
je 0x643b
jb 0x644f
cmpl %eax, %r12d
jae 0x643b
jmp 0x647d
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c04e(%rip), %rsi     # 0x3246c
callq 0x695e
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x28e3f(%rip), %rsi     # 0x2f270
jmp 0x63ea
movl 0x48(%r14), %eax
cmpl %ebp, %eax
jne 0x644d
movq 0x8(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
jmp 0x612c
jbe 0x6478
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2c00c(%rip), %rsi     # 0x3246c
callq 0x695e
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x28e2e(%rip), %rsi     # 0x2f2a1
jmp 0x63ea
cmpl %r12d, %eax
jbe 0x643b
movl %eax, %eax
movq 0x38(%r14), %rdx
cmpq %rax, %rdx
jbe 0x64a5
movq %r15, %rcx
cmpq $0x41, %rdx
jb 0x6494
movq (%r15), %rcx
movl %eax, %edx
shrl $0x3, %edx
movzbl (%rcx,%rdx), %ecx
andl $0x7, %eax
btl %eax, %ecx
jb 0x643b
movl $0x2, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x2bfb6(%rip), %rsi     # 0x3246c
callq 0x695e
movq %rbx, %rdi
addq $0x18, %rdi
leaq 0x28d8d(%rip), %rsi     # 0x2f256
jmp 0x63ea