// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pict.c
// Function: do_handle_item
static void do_handle_item(struct item_handler_data *h)
{
	const char *opcode_name;
	const struct opcode_info *opi;
	i64 n;
	struct pict_rect tmprect;
	deark *c = h->c;

	opi = find_opcode_info(h->opcode);
	if(opi && opi->name) opcode_name = opi->name;
	else opcode_name = "?";

	if(h->d->version==2)
		de_dbg(c, "opcode 0x%04x (%s) at %"I64_FMT, h->opcode, opcode_name, h->opcode_pos);
	else
		de_dbg(c, "opcode 0x%02x (%s) at %"I64_FMT, h->opcode, opcode_name, h->opcode_pos);

	if(opi) {
		h->data_len = (i64)opi->size; // Default to the size in the table.
	}

	if(opi && opi->fn) {
		de_dbg_indent(c, 1);
		opi->fn(h);
		de_dbg_indent(c, -1);
	}
	else if(opi && opi->size_code==SZCODE_EXACT) {
		;
	}
	else if(opi && opi->size_code==SZCODE_REGION) {
		n = dbuf_getu16be(h->inf, h->data_pos);
		de_dbg_indent(c, 1);
		de_dbg(c, "region size: %d", (int)n);
		if(n>=10) {
			pict_read_rect(h->inf, h->data_pos+2, &tmprect, "rect");
		}
		de_dbg_indent(c, -1);
		h->data_len = n;
	}
	else if(opi && opi->size_code==SZCODE_POLYGON) {
		n = dbuf_getu16be(h->inf, h->data_pos);
		de_dbg_indent(c, 1);
		de_dbg(c, "polygon size: %d", (int)n);
		de_dbg_indent(c, -1);
		h->data_len = n;
	}
	else if(h->opcode>=0x2c && h->opcode<=0x2f) {
		// Starts with 2-byte size, size does not include the "size" field.
		n = dbuf_getu16be(h->inf, h->data_pos);
		h->data_len = 2+n;
	}
	else if(h->opcode>=0x8100 && h->opcode<=0xffff) {
		// Starts with 4-byte size, size does not include the "size" field.
		n = dbuf_getu32be(h->inf, h->data_pos);
		h->data_len = 4+n;
	}
	else {
		de_err(c, "Unsupported opcode: 0x%04x", h->opcode);
		h->fatal_errflag = 1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movl 0x18(%rax), %edi
callq 0x106f60
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x106cb7
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x106cb7
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x106cc2
leaq 0xb0f6f(%rip), %rax     # 0x1b7c2d
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x2, 0xc(%rax)
jne 0x106cf7
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x20(%rax), %r8
leaq 0xbb528(%rip), %rsi     # 0x1c2216
movb $0x0, %al
callq 0x15b0d0
jmp 0x106d1c
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x20(%rax), %r8
leaq 0xbb51b(%rip), %rsi     # 0x1c2230
movb $0x0, %al
callq 0x15b0d0
cmpq $0x0, -0x18(%rbp)
je 0x106d34
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x106d75
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x106d75
movq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
movq -0x48(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
jmp 0x106f54
cmpq $0x0, -0x18(%rbp)
je 0x106d8e
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %eax
cmpl $0x1, %eax
jne 0x106d8e
jmp 0x106f52
cmpq $0x0, -0x18(%rbp)
je 0x106e33
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %eax
cmpl $0x2, %eax
jne 0x106e33
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x1651d0
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0xbb468(%rip), %rsi     # 0x1c224a
movb $0x0, %al
callq 0x15b0d0
cmpq $0xa, -0x20(%rbp)
jl 0x106e14
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
addq $0x2, %rsi
leaq -0x40(%rbp), %rdx
leaq 0xad83f(%rip), %rcx     # 0x1b464e
callq 0x106a40
movq -0x48(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x106f50
cmpq $0x0, -0x18(%rbp)
je 0x106ea5
movq -0x18(%rbp), %rax
movzwl 0x2(%rax), %eax
cmpl $0x3, %eax
jne 0x106ea5
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x1651d0
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0xbb3db(%rip), %rsi     # 0x1c225a
movb $0x0, %al
callq 0x15b0d0
movq -0x48(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x106f4e
movq -0x8(%rbp), %rax
cmpl $0x2c, 0x18(%rax)
jb 0x106ee4
movq -0x8(%rbp), %rax
cmpl $0x2f, 0x18(%rax)
ja 0x106ee4
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x1651d0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
addq $0x2, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x106f4c
movq -0x8(%rbp), %rax
cmpl $0x8100, 0x18(%rax)     # imm = 0x8100
jb 0x106f29
movq -0x8(%rbp), %rax
cmpl $0xffff, 0x18(%rax)     # imm = 0xFFFF
ja 0x106f29
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x165470
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
addq $0x4, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x106f4a
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %edx
leaq 0xbb330(%rip), %rsi     # 0x1c226b
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rax
movb $0x1, 0x38(%rax)
jmp 0x106f4c
jmp 0x106f4e
jmp 0x106f50
jmp 0x106f52
jmp 0x106f54
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)