// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/png.c
// Function: handler_fdAT
static void handler_fdAT(deark *c, lctx *d, struct handler_params *hp)
{
	i64 IDAT_dlen;

	if(hp->dlen<4) return;
	do_APNG_seqno(c, d, hp->dpos);

	if(!d->found_fcTL) return;
	if(d->curr_fcTL_width==0 || d->curr_fcTL_height==0) return;
	if(!d->extract_from_APNG_enabled) return;
	if(!d->APNG_prefix || d->APNG_prefix_IHDR_pos==0) {
		d->extract_from_APNG_enabled = 0;
		return;
	}

	// Convert the fdAT chunk to an IDAT chunk, and write it to d->curr_APNG_frame.

	if(!d->crco_for_write) {
		d->crco_for_write = de_crcobj_create(c, DE_CRCOBJ_CRC32_IEEE);
	}

	if(!d->curr_APNG_frame) {
		d->curr_APNG_frame = dbuf_create_output_file(c, "png", NULL, 0);

		// Update the width & height in the APNG_prefix membuf, in-place.

		writeu32be_at(d->APNG_prefix, d->APNG_prefix_IHDR_pos+8, d->curr_fcTL_width);
		writeu32be_at(d->APNG_prefix, d->APNG_prefix_IHDR_pos+8+4, d->curr_fcTL_height);

		de_crcobj_reset(d->crco_for_write);
		de_crcobj_addslice(d->crco_for_write, d->APNG_prefix, d->APNG_prefix_IHDR_pos+4, 4+13);
		writeu32be_at(d->APNG_prefix, d->APNG_prefix_IHDR_pos+8+13,
			(i64)de_crcobj_getval(d->crco_for_write));

		dbuf_copy(d->APNG_prefix, 0, d->APNG_prefix->len, d->curr_APNG_frame);
	}

	IDAT_dlen = hp->dlen-4;
	dbuf_writeu32be(d->curr_APNG_frame, IDAT_dlen);

	de_crcobj_reset(d->crco_for_write);
	dbuf_set_writelistener(d->curr_APNG_frame, de_writelistener_for_crc, (void*)d->crco_for_write);

	dbuf_writeu32be(d->curr_APNG_frame, (i64)CODE_IDAT);
	dbuf_copy(c->infile, hp->dpos+4, IDAT_dlen, d->curr_APNG_frame);
	dbuf_set_writelistener(d->curr_APNG_frame, NULL, NULL);
	dbuf_writeu32be(d->curr_APNG_frame, (i64)de_crcobj_getval(d->crco_for_write));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
cmpq $0x4, 0x8(%rdx)
jl 0xb661b
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq (%rdx), %rsi
movq 0x18(%rdi), %rdi
callq 0xef32a
leaq 0x811ea(%rip), %rsi     # 0x137676
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0xd(%rbx)
je 0xb661b
cmpq $0x0, 0x20(%rbx)
je 0xb661b
cmpq $0x0, 0x28(%rbx)
je 0xb661b
cmpb $0x0, 0xa(%rbx)
je 0xb661b
cmpq $0x0, 0x38(%rbx)
je 0xb6617
cmpq $0x0, 0x30(%rbx)
je 0xb6617
cmpq $0x0, 0x18(%rbx)
jne 0xb64f0
movq %r15, %rdi
movl $0x10, %esi
callq 0xeba56
movq %rax, 0x18(%rbx)
cmpq $0x0, 0x40(%rbx)
jne 0xb6594
leaq 0x71ffe(%rip), %rsi     # 0x128500
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, 0x40(%rbx)
movq 0x38(%rbx), %rdi
movq 0x20(%rbx), %rdx
movq 0x30(%rbx), %rsi
addq $0x8, %rsi
callq 0xb720e
movq 0x38(%rbx), %rdi
movq 0x28(%rbx), %rdx
movq 0x30(%rbx), %rsi
addq $0xc, %rsi
callq 0xb720e
movq 0x18(%rbx), %rdi
callq 0xebdc3
movq 0x38(%rbx), %rsi
movq 0x18(%rbx), %rdi
movq 0x30(%rbx), %rdx
addq $0x4, %rdx
movl $0x11, %ecx
callq 0xebf09
movq 0x38(%rbx), %r12
movq 0x18(%rbx), %rdi
movq 0x30(%rbx), %r13
addq $0x15, %r13
callq 0xebe2a
movl %eax, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0xb720e
movq 0x38(%rbx), %rdi
movq 0x40(%rbx), %rcx
movq 0x18(%rdi), %rdx
xorl %esi, %esi
callq 0xefabc
movq 0x8(%r14), %r12
addq $-0x4, %r12
movq 0x40(%rbx), %rdi
movq %r12, %rsi
callq 0xf1629
movq 0x18(%rbx), %rdi
callq 0xebdc3
movq 0x18(%rbx), %rdx
movq 0x40(%rbx), %rdi
leaq 0x3b491(%rip), %rsi     # 0xf1a51
callq 0xf1a12
movq 0x40(%rbx), %rdi
movl $0x49444154, %esi       # imm = 0x49444154
callq 0xf1629
movq 0x18(%r15), %rdi
movq (%r14), %rsi
addq $0x4, %rsi
movq 0x40(%rbx), %rcx
movq %r12, %rdx
callq 0xefabc
movq 0x40(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf1a12
movq 0x18(%rbx), %rdi
movq 0x40(%rbx), %rbx
callq 0xebe2a
movl %eax, %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xf1629
movb $0x0, 0xa(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq