// File: auton1[P]viterbi/entry.cpp
// Function: entry::get_type(unsigned int*, std::vector<char, std::allocator<char>> const&, unsigned int&, unsigned int&)
void entry::get_type(unsigned int * line_position, const vector<char>& line, unsigned int &type, unsigned int &size)
{
	uint8_t byte = *reinterpret_cast<const uint8_t*>(&line[*line_position]);
	*line_position += sizeof(byte);
	size = byte >> 4;
	type = (byte & (uint8_t)15);

	if (size == 15)
	{
		int type2;
		byte = *reinterpret_cast<const uint8_t*>(&line[*line_position]);
		*line_position += sizeof(byte);

		type2 = (byte & (uint8_t)15);
		if (type2 == 1)
		{
			int8_t tmp;
			tmp = *reinterpret_cast<const int8_t*>(&line[*line_position]);
			*line_position += sizeof(tmp);
			size = (unsigned int)tmp;
		}
		else if (type2 == 2)
		{
			int16_t tmp;
			tmp = *reinterpret_cast<const int16_t*>(&line[*line_position]);
			*line_position += sizeof(tmp);

			size = (int)tmp;
		}
		else if (type2 == 3)
		{
			int32_t tmp;
			tmp = *reinterpret_cast<const int32_t*>(&line[*line_position]);
			*line_position += sizeof(tmp);
			size = (unsigned int)tmp;
		}
		else
		{
			LOG.printLOG("Error: Invalid type for integer size.\n");
			exit(0);
		}
	}
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0x49920
movb (%rax), %al
movb %al, 0x4f(%rsp)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
addq $0x1, %rcx
movl %ecx, (%rax)
movzbl 0x4f(%rsp), %ecx
sarl $0x4, %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
movzbl 0x4f(%rsp), %ecx
andl $0xf, %ecx
movq 0x58(%rsp), %rax
movl %ecx, (%rax)
movq 0x50(%rsp), %rax
cmpl $0xf, (%rax)
jne 0x48bd9
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0x49920
movb (%rax), %al
movb %al, 0x4f(%rsp)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
addq $0x1, %rcx
movl %ecx, (%rax)
movzbl 0x4f(%rsp), %eax
andl $0xf, %eax
movl %eax, 0x48(%rsp)
cmpl $0x1, 0x48(%rsp)
jne 0x48acf
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0x49920
movb (%rax), %al
movb %al, 0x47(%rsp)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
addq $0x1, %rcx
movl %ecx, (%rax)
movsbl 0x47(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
jmp 0x48bd7
cmpl $0x2, 0x48(%rsp)
jne 0x48b0f
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0x49920
movw (%rax), %ax
movw %ax, 0x44(%rsp)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
addq $0x2, %rcx
movl %ecx, (%rax)
movswl 0x44(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
jmp 0x48bd5
cmpl $0x3, 0x48(%rsp)
jne 0x48b4c
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rax
movl (%rax), %eax
movl %eax, %esi
callq 0x49920
movl (%rax), %eax
movl %eax, 0x40(%rsp)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
addq $0x4, %rcx
movl %ecx, (%rax)
movl 0x40(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
jmp 0x48bd3
leaq 0x1f(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x69f0
movq (%rsp), %rdx
leaq 0x2c711(%rip), %rsi     # 0x75276
leaq 0x20(%rsp), %rdi
callq 0x67c0
jmp 0x48b71
leaq 0x4aa88(%rip), %rdi     # 0x93600
leaq 0x20(%rsp), %rsi
callq 0x71280
jmp 0x48b84
leaq 0x20(%rsp), %rdi
callq 0x6b50
leaq 0x1f(%rsp), %rdi
callq 0x65f0
xorl %edi, %edi
callq 0x66b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x10(%rsp)
movl %eax, 0xc(%rsp)
jmp 0x48bc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x10(%rsp)
movl %eax, 0xc(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x6b50
leaq 0x1f(%rsp), %rdi
callq 0x65f0
jmp 0x48bde
jmp 0x48bd5
jmp 0x48bd7
jmp 0x48bd9
addq $0x78, %rsp
retq
movq 0x10(%rsp), %rdi
callq 0x69e0
nopl (%rax,%rax)