// File: Nallantli[P]Rossa/main/rossa/instruction/instruction.cpp
// Function: LengthI::evaluate(object_t const*, std::vector<std::pair<token_t, function_t>, std::allocator<std::pair<token_t, function_t>>>&) const
const symbol_t LengthI::evaluate(const object_t *scope, trace_t &stack_trace) const
{
	const symbol_t evalA = a->evaluate(scope, stack_trace);
	switch (evalA.getValueType())
	{
	case value_type_enum::STRING:
	{
		std::string str = evalA.getString(&token, stack_trace);
		int c, i, ix, q;
		for (q = 0, i = 0, ix = str.size(); i < ix; i++, q++)
		{
			c = static_cast<unsigned char>(str[i]);
			if (c >= 0 && c <= 127)
				i += 0;
			else if ((c & 0xE0) == 0xC0)
				i += 1;
			else if ((c & 0xF0) == 0xE0)
				i += 2;
			else if ((c & 0xF8) == 0xF0)
				i += 3;
			else
				return symbol_t::Number(number_t::Long(evalA.getString(&token, stack_trace).size()));
		}
		return symbol_t::Number(number_t::Long(q));
	}
	case value_type_enum::DICTIONARY:
		return symbol_t::Number(number_t::Long(evalA.dictionarySize(&token, stack_trace)));
	case value_type_enum::ARRAY:
		return symbol_t::Number(number_t::Long(evalA.vectorSize()));
	case value_type_enum::OBJECT:
	{
		const auto &o = evalA.getObject(&token, stack_trace);
		if (o->hasValue(parser_t::HASH_LENGTH))
			return o->getVariable(parser_t::HASH_LENGTH, &token, stack_trace).call({}, &token, stack_trace);
	}
	default:
		throw rossa_error_t(_FAILURE_LENGTH_, token, stack_trace);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x1a8(%rbp)
movq %rdi, %rax
movq %rax, -0x1a0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x198(%rbp)
addq $0x90, %rdi
callq 0x2d300
movq %rax, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x30(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq *%rax
movq -0x190(%rbp), %rdi
callq 0x883e0
movl %eax, -0x188(%rbp)
jmp 0x12d475
movl -0x188(%rbp), %eax
addl $0x8, %eax
movl %eax, %ecx
movq %rcx, -0x1b0(%rbp)
subl $0x4, %eax
ja 0x12d906
movq -0x1b0(%rbp), %rax
leaq 0x2793a(%rip), %rcx     # 0x154dd8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12d9f8
movq -0x198(%rbp), %rdx
addq $0x8, %rdx
movq -0x20(%rbp), %rcx
leaq -0x60(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x880d0
jmp 0x12d4d6
movl $0x0, -0x70(%rbp)
movl $0x0, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x113e0
movl %eax, -0x6c(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jge 0x12d66b
movslq -0x68(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x11ac0
movq %rax, -0x1b8(%rbp)
jmp 0x12d512
movq -0x1b8(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jl 0x12d54a
cmpl $0x7f, -0x64(%rbp)
jg 0x12d54a
movl -0x68(%rbp), %eax
addl $0x0, %eax
movl %eax, -0x68(%rbp)
jmp 0x12d652
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12d6d6
movl -0x64(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0x12d567
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x12d650
movl -0x64(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0x12d584
movl -0x68(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x68(%rbp)
jmp 0x12d64e
movl -0x64(%rbp), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0x12d5a1
movl -0x68(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x68(%rbp)
jmp 0x12d64c
movq -0x198(%rbp), %rdx
addq $0x8, %rdx
movq -0x20(%rbp), %rcx
leaq -0xa8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x880d0
jmp 0x12d5c2
leaq -0xa8(%rbp), %rdi
callq 0x113e0
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x9c540
movq -0x1a8(%rbp), %rdi
movl %edx, -0xb0(%rbp)
movq %rax, -0xb8(%rbp)
movl -0xb0(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x80(%rbp), %rsi
callq 0x86bf0
jmp 0x12d614
leaq -0xa8(%rbp), %rdi
callq 0x11360
movl $0x1, -0xbc(%rbp)
jmp 0x12d6c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x11360
jmp 0x12d6d6
jmp 0x12d64e
jmp 0x12d650
jmp 0x12d652
jmp 0x12d654
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x12d4f0
movslq -0x70(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x9c540
movq -0x1a8(%rbp), %rdi
movl %edx, -0xe0(%rbp)
movq %rax, -0xe8(%rbp)
movl -0xe0(%rbp), %eax
movl %eax, -0xc8(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x86bf0
jmp 0x12d6be
movl $0x1, -0xbc(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x11360
jmp 0x12d9df
leaq -0x60(%rbp), %rdi
callq 0x11360
jmp 0x12d9f8
movq -0x198(%rbp), %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x88fa0
movq %rax, -0x1c0(%rbp)
jmp 0x12d705
movq -0x1c0(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x9c540
movq -0x1a8(%rbp), %rdi
movl %edx, -0x108(%rbp)
movq %rax, -0x110(%rbp)
movl -0x108(%rbp), %eax
movl %eax, -0xf0(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rsi
callq 0x86bf0
jmp 0x12d75b
movl $0x1, -0xbc(%rbp)
jmp 0x12d9df
leaq -0x30(%rbp), %rdi
callq 0x88f70
movq %rax, -0x1c8(%rbp)
jmp 0x12d77c
movq -0x1c8(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x9c540
movq -0x1a8(%rbp), %rdi
movl %edx, -0x130(%rbp)
movq %rax, -0x138(%rbp)
movl -0x130(%rbp), %eax
movl %eax, -0x118(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x120(%rbp), %rsi
callq 0x86bf0
jmp 0x12d7d2
movl $0x1, -0xbc(%rbp)
jmp 0x12d9df
movq -0x198(%rbp), %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x882f0
movq %rax, -0x1d0(%rbp)
jmp 0x12d802
movq -0x1d0(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x148(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq (%rax), %rdi
leaq 0xb8371(%rip), %rsi     # 0x1e5ba0
callq 0x7dd00
movb %al, -0x1d1(%rbp)
jmp 0x12d83c
movb -0x1d1(%rbp), %al
testb $0x1, %al
jne 0x12d84b
jmp 0x12d904
movq -0x198(%rbp), %rdx
movq -0x140(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdx
movq -0x20(%rbp), %rcx
leaq 0xb8335(%rip), %rsi     # 0x1e5ba0
callq 0x7ddd0
movq %rax, -0x1e0(%rbp)
jmp 0x12d879
xorps %xmm0, %xmm0
movaps %xmm0, -0x160(%rbp)
movq $0x0, -0x150(%rbp)
leaq -0x160(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x2cc30
movq -0x198(%rbp), %rcx
movq -0x1a8(%rbp), %rdi
movq -0x1e0(%rbp), %rsi
movq -0x1e8(%rbp), %rdx
addq $0x8, %rcx
movq -0x20(%rbp), %r8
callq 0x89e20
jmp 0x12d8cc
leaq -0x160(%rbp), %rdi
callq 0x2cf10
movl $0x1, -0xbc(%rbp)
jmp 0x12d9df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x2cf10
jmp 0x12d9f8
jmp 0x12d906
movb $0x1, -0x182(%rbp)
movl $0xa8, %edi
callq 0x112b0
movq %rax, -0x1f8(%rbp)
leaq -0x181(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x119d0
movq -0x1f0(%rbp), %rdx
leaq 0x27849(%rip), %rsi     # 0x155188
leaq -0x180(%rbp), %rdi
callq 0x24740
jmp 0x12d94d
movq -0x1f8(%rbp), %rdi
movq -0x198(%rbp), %rdx
addq $0x8, %rdx
movq -0x20(%rbp), %rcx
leaq -0x180(%rbp), %rsi
callq 0x9c360
jmp 0x12d971
movq -0x1f8(%rbp), %rdi
movb $0x0, -0x182(%rbp)
leaq 0xb32fa(%rip), %rsi     # 0x1e0c80
leaq -0xd2fed(%rip), %rdx    # 0x5a9a0
callq 0x11970
jmp 0x12da0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x12d9ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x11360
leaq -0x181(%rbp), %rdi
callq 0x11600
testb $0x1, -0x182(%rbp)
jne 0x12d9d1
jmp 0x12d9dd
movq -0x1f8(%rbp), %rdi
callq 0x11420
jmp 0x12d9f8
leaq -0x30(%rbp), %rdi
callq 0x86dc0
movq -0x1a0(%rbp), %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x86dc0
movq -0x38(%rbp), %rdi
callq 0x119c0
nopw (%rax,%rax)