// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/vort.c
// Function: do_primitive_object
static int do_primitive_object(deark *c, lctx *d, i64 pos1,
	u8 obj_fulltype, i64 *bytes_consumed)
{
	u8 obj_type;
	i64 obj_dlen;
	i64 pos = pos1;
	const struct obj_type_info_struct *oti;
	const char *name;

	i64 value_as_vlq = 0;

	de_dbg(c, "primitive object at %"I64_FMT, pos1);
	de_dbg_indent(c, 1);
	obj_type = de_getbyte_p(&pos);
	oti = find_obj_type_info(obj_fulltype, obj_type);
	if(oti && oti->name) name = oti->name;
	else name = "?";
	de_dbg(c, "primitive type: %u (%s)", (UI)obj_type, name);

	// The data is usually a VLQ, but sometimes it's not. For convenience,
	// we'll read the length byte, then go back and read the whole thing as a VLQ.
	obj_dlen = (i64)de_getbyte(pos);

	if(obj_dlen>=1 && obj_dlen<=8) {
		i64 tmppos = pos;
		value_as_vlq = read_vlq(c, &tmppos);
	}
	pos++; // For the length byte

	if(oti && oti->flags&0x01 && (!oti->decoder_fn || (oti->flags&0x2))) {
		if(obj_dlen==0) {
			de_dbg(c, "%s: (field is present)", name);
		}
		else {
			de_dbg(c, "%s: %"I64_FMT, name, value_as_vlq);
		}
	}

	if(oti && oti->decoder_fn) {
		oti->decoder_fn(c, d, oti, pos, obj_dlen, value_as_vlq);
	}

	pos += obj_dlen;

	de_dbg_indent(c, -1);
	*bytes_consumed = pos-pos1;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x93fb2(%rip), %rsi     # 0x1cc1de
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x165170
movb %al, -0x29(%rbp)
movb -0x19(%rbp), %al
movzbl %al, %edi
movzbl -0x29(%rbp), %esi
callq 0x1383d0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x138288
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x138288
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x138293
leaq 0x7f99e(%rip), %rax     # 0x1b7c2d
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x29(%rbp), %edx
movq -0x50(%rbp), %rcx
leaq 0x93f50(%rip), %rsi     # 0x1cc1f6
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x165060
movzbl %al, %eax
movq %rax, -0x38(%rbp)
cmpq $0x1, -0x38(%rbp)
jl 0x1382ec
cmpq $0x8, -0x38(%rbp)
jg 0x1382ec
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x137910
movq %rax, -0x58(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x138361
movq -0x48(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x138361
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x138326
movq -0x48(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x138361
cmpq $0x0, -0x38(%rbp)
jne 0x138345
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rdx
leaq 0x93ed2(%rip), %rsi     # 0x1cc20e
movb $0x0, %al
callq 0x15b0d0
jmp 0x13835f
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
leaq 0x759c7(%rip), %rsi     # 0x1add1f
movb $0x0, %al
callq 0x15b0d0
jmp 0x138361
cmpq $0x0, -0x48(%rbp)
je 0x138395
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x138395
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x58(%rbp), %r9
callq *%rax
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x40(%rbp), %rcx
subq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)