// File: /workspace/github_cpp_makefile_star2_O3/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
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq *(%rax)
movq %r12, %rdi
callq 0x40b5a
addl $0x8, %eax
cmpl $0x4, %eax
ja 0x711ea
leaq 0x163ba(%rip), %rcx     # 0x87398
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8(%r15), %r12
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x40a9e
movq %rax, %r13
leaq 0x449fb(%rip), %rsi     # 0xb5a00
movq %rax, %rdi
callq 0x3ce6c
testb %al, %al
je 0x711ea
leaq 0x449e4(%rip), %rsi     # 0xb5a00
movq %r13, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x3ced2
xorps %xmm0, %xmm0
movq %rsp, %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rcx
movq %r14, %r8
callq 0x41ffe
movq %rsp, %rdi
callq 0x20952
jmp 0x71174
leaq 0x20(%rsp), %rdi
callq 0x4130e
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
callq 0x47014
movq %rsp, %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x3fd84
jmp 0x71174
addq $0x8, %r15
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x40904
movl 0x8(%rsp), %eax
xorl %ecx, %ecx
testl %eax, %eax
jle 0x71137
movq (%rsp), %rsi
xorl %edx, %edx
movslq %ecx, %rdi
movzbl (%rsi,%rdi), %edi
testb %dil, %dil
jns 0x710f8
movl %edi, %r8d
andl $-0x20, %r8d
cmpl $0xc0, %r8d
jne 0x710d1
incl %ecx
jmp 0x710f8
movl %edi, %r8d
andl $-0x10, %r8d
cmpl $0xe0, %r8d
jne 0x710e6
addl $0x2, %ecx
jmp 0x710f8
andl $-0x8, %edi
cmpl $0xf0, %edi
jne 0x71190
addl $0x3, %ecx
incl %ecx
incq %rdx
cmpl %eax, %ecx
jl 0x710b1
jmp 0x71139
addq $0x8, %r15
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4132c
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
callq 0x47014
movq %rsp, %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x3fd84
jmp 0x71174
xorl %edx, %edx
leaq 0x58(%rsp), %rdi
movq %rdx, (%rdi)
callq 0x47014
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x3fd84
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71174
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x103d0
leaq 0x20(%rsp), %rdi
callq 0x3fe06
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x40904
movq 0x38(%rsp), %rax
leaq 0x50(%rsp), %rdi
movq %rax, (%rdi)
callq 0x47014
leaq 0x58(%rsp), %rsi
movq %rax, (%rsi)
movl %edx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x3fd84
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x71159
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x71159
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r12
leaq 0x10(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x16541(%rip), %rsi     # 0x87748
leaq 0x16554(%rip), %rdx     # 0x87762
movq %rsp, %rdi
callq 0x1e698
addq $0x8, %r15
movb $0x1, %bpl
movq %rsp, %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq 0x46e88
xorl %ebp, %ebp
leaq 0x3fae9(%rip), %rsi     # 0xb0d20
leaq -0x39f9a(%rip), %rdx    # 0x372a4
movq %r12, %rdi
callq 0x106d0
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7126b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x7126b
jmp 0x71268
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x712cf
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x712cf
movq %rax, %rbx
movq %rsp, %rdi
callq 0x20952
jmp 0x712cf
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x712ae
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x103d0
testb %bpl, %bpl
jne 0x712b8
jmp 0x712cf
movq %rax, %rbx
movq %r12, %rdi
callq 0x102d0
jmp 0x712cf
jmp 0x712cc
jmp 0x712cc
jmp 0x712cc
jmp 0x712cc
jmp 0x712cc
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3fe06
movq %rbx, %rdi
callq 0x106f0
nop