// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/iptc.c
// Function: do_dataset
static int do_dataset(deark *c, lctx *d, i64 ds_idx, i64 pos1,
	i64 *bytes_consumed)
{
	u8 b;
	u8 recnum, dsnum;
	int retval = 0;
	i64 pos = pos1;
	i64 dflen;
	i64 dflen_bytes_consumed;
	struct ds_info dsi;
	int ds_known;

	*bytes_consumed = 0;

	b = de_getbyte(pos);
	if(b!=0x1c) {
		if(b==0x00 && ds_idx>0) {
			// Extraneous padding at the end of data?
			if(pos == c->infile->len-1) {
				de_dbg(c, "[ignoring extra byte at end of IPTC-IIM data]");
			}
			else {
				de_warn(c, "Expected %"I64_FMT" bytes of IPTC-IIM data, only found %"I64_FMT,
					c->infile->len, pos);
			}
		}
		else {
			de_err(c, "Bad IPTC tag marker (0x%02x) at %d", (int)b, (int)pos);
		}
		goto done;
	}
	pos++;

	recnum = de_getbyte(pos++);
	dsnum = de_getbyte(pos++);

	ds_known = lookup_ds_info(recnum, dsnum, &dsi);

	if(!read_dflen(c, c->infile, pos, &dflen, &dflen_bytes_consumed)) goto done;
	pos += dflen_bytes_consumed;

	de_dbg(c, "IPTC dataset %d:%02d (%s) dpos=%" I64_FMT " dlen=%" I64_FMT "",
		(int)recnum, (int)dsnum, dsi.dsname, pos, dflen);

	// Decode the value
	de_dbg_indent(c, 1);

	if(dsi.hfn) {
		dsi.hfn(c, d, &dsi, pos, dflen);
	}
	else if(dsi.flags&0x1) {
		handle_text(c, d, &dsi, pos, dflen);
	}
	else if(dsi.recnum==2 && !ds_known) {
		// Unknown record-2 datasets often contain readable text.
		handle_text(c, d, &dsi, pos, dflen);
	}
	pos += dflen;

	de_dbg_indent(c, -1);
	//

	*bytes_consumed = pos - pos1;
	retval = 1;
done:
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x165060
movb %al, -0x29(%rbp)
movzbl -0x29(%rbp), %eax
cmpl $0x1c, %eax
je 0xb9489
movzbl -0x29(%rbp), %eax
cmpl $0x0, %eax
jne 0xb9468
cmpq $0x0, -0x18(%rbp)
jle 0xb9468
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x18(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0xb9444
movq -0x8(%rbp), %rdi
leaq 0xfc224(%rip), %rsi     # 0x1b565f
movb $0x0, %al
callq 0x15b0d0
jmp 0xb9466
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rdx
movq -0x38(%rbp), %rcx
leaq 0xfc22e(%rip), %rsi     # 0x1b568d
movb $0x0, %al
callq 0x15bc10
jmp 0xb9484
movq -0x8(%rbp), %rdi
movzbl -0x29(%rbp), %edx
movq -0x38(%rbp), %rax
movl %eax, %ecx
leaq 0xfc244(%rip), %rsi     # 0x1b56c1
movb $0x0, %al
callq 0x15bfb0
jmp 0xb95f9
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
callq 0x165060
movb %al, -0x2a(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x38(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
callq 0x165060
movb %al, -0x2b(%rbp)
movb -0x2a(%rbp), %al
leaq -0x60(%rbp), %rdx
movzbl %al, %edi
movzbl -0x2b(%rbp), %esi
callq 0xb9610
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x38(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0xb96f0
cmpl $0x0, %eax
jne 0xb9510
jmp 0xb95f9
movq -0x48(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x2a(%rbp), %edx
movzbl -0x2b(%rbp), %ecx
movq -0x58(%rbp), %r8
movq -0x38(%rbp), %r9
movq -0x40(%rbp), %rax
leaq 0xfc1a9(%rip), %rsi     # 0x1b56e4
movq %rax, (%rsp)
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
cmpq $0x0, -0x50(%rbp)
je 0xb9577
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
leaq -0x60(%rbp), %rdx
callq *%rax
jmp 0xb95c9
movl -0x5c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb959d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
leaq -0x60(%rbp), %rdx
callq 0xb9810
jmp 0xb95c7
movzbl -0x60(%rbp), %eax
cmpl $0x2, %eax
jne 0xb95c5
cmpl $0x0, -0x64(%rbp)
jne 0xb95c5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
leaq -0x60(%rbp), %rdx
callq 0xb9810
jmp 0xb95c7
jmp 0xb95c9
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x38(%rbp), %rcx
subq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)