// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x90(%rsi), %rsi
movq (%rsi), %rax
movq %rsp, %r12
movq %r12, %rdi
callq *(%rax)
movq %r12, %rdi
callq 0x39ca6
addl $0x8, %eax
cmpl $0x4, %eax
ja 0x678bf
leaq 0x12cae(%rip), %rcx     # 0x7a390
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8(%r15), %r12
movq %rsp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x39c02
movq %rax, %r13
leaq 0x4f309(%rip), %rsi     # 0xb6a10
movq %rax, %rdi
callq 0x366b2
testb %al, %al
je 0x678bf
leaq 0x4f2f2(%rip), %rsi     # 0xb6a10
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x366ec
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rcx
movq %r14, %r8
callq 0x3aa8c
leaq 0x10(%rsp), %rdi
callq 0x1f0b8
jmp 0x67861
movq %rsp, %rdi
callq 0x3a2fc
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
callq 0x3ecba
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x39080
jmp 0x67861
addq $0x8, %r15
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x39aa6
movl 0x18(%rsp), %ecx
xorl %eax, %eax
movq 0x10(%rsp), %rdx
xorl %esi, %esi
cmpl %ecx, %esi
jge 0x67837
movslq %esi, %rdi
movzbl (%rdx,%rdi), %edi
testb %dil, %dil
jns 0x677fc
movl %edi, %r8d
andl $-0x20, %r8d
cmpl $0xc0, %r8d
jne 0x677d5
incl %esi
jmp 0x677fc
movl %edi, %r8d
andl $-0x10, %r8d
cmpl $0xe0, %r8d
jne 0x677ea
addl $0x2, %esi
jmp 0x677fc
andl $-0x8, %edi
cmpl $0xf0, %edi
jne 0x6787b
addl $0x3, %esi
incl %esi
incq %rax
jmp 0x677ad
addq $0x8, %r15
movq %rsp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3a31a
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
callq 0x3ecba
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x39080
jmp 0x67861
leaq 0x58(%rsp), %rdi
movq %rax, (%rdi)
callq 0x3ecba
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x39080
leaq 0x10(%rsp), %rdi
callq 0x101d0
movq %rsp, %rdi
callq 0x39102
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x39aa6
movq 0x38(%rsp), %rax
leaq 0x50(%rsp), %rdi
movq %rax, (%rdi)
callq 0x3ecba
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x39080
leaq 0x30(%rsp), %rdi
callq 0x101d0
jmp 0x67857
movl $0xa8, %edi
callq 0x101f0
movq %rax, %r12
leaq 0x12e6d(%rip), %rsi     # 0x7a740
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x1c814
addq $0x8, %r15
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3ebb8
xorl %ebp, %ebp
leaq 0x4a39b(%rip), %rsi     # 0xb1ca0
leaq -0x3849a(%rip), %rdx    # 0x2f472
movq %r12, %rdi
callq 0x106c0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x101d0
jmp 0x67928
jmp 0x67925
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x67971
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1f0b8
jmp 0x67971
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
testb %bpl, %bpl
jne 0x6795a
jmp 0x67971
movq %rax, %rbx
movq %r12, %rdi
callq 0x102e0
jmp 0x67971
jmp 0x6796e
jmp 0x6796e
jmp 0x6796e
jmp 0x6796e
jmp 0x6796e
movq %rax, %rbx
movq %rsp, %rdi
callq 0x39102
movq %rbx, %rdi
callq 0x106f0
nop