// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/png.c
// Function: handler_IDAT
static void handler_IDAT(deark *c, lctx *d, struct handler_params *hp)
{
	if(!d->found_IDAT) {
		d->found_IDAT = 1;
		// In case format declaration was deferred, do it now.
		declare_png_fmt(c, d);

		prepare_PNG_extraction_from_APNG(c, d);

		if(d->fmt==DE_PNGFMT_PNG && !d->is_CgBI && !d->IDAT_prefix) {
			d->IDAT_prefix = dbuf_create_membuf(c, 8, 0x1);
		}

		if(d->opt_want_raw_zlib && d->fmt==DE_PNGFMT_PNG && !d->is_CgBI &&
			!d->raw_zlib)
		{
			d->raw_zlib = dbuf_create_output_file(c, "zlib", NULL, 0);
		}
	}

	// Collect at least the first 2 bytes of IDAT data for analysis.
	// We allow for the possibility that the bytes are not all in the same chunk.
	if(d->IDAT_prefix && d->IDAT_prefix->len<2) {
		i64 n;

		n = de_min_int(2, hp->dlen);
		dbuf_copy(c->infile, hp->dpos, n, d->IDAT_prefix);
		if(d->IDAT_prefix->len>=2) {
			decode_zlib_header(c, d);
		}
	}

	if(d->raw_zlib) {
		dbuf_copy(c->infile, hp->dpos, hp->dlen, d->raw_zlib);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpb $0x0, 0xc(%rsi)
pushq $0x1
popq %r13
je 0xae039
movq 0x48(%r15), %rax
testq %rax, %rax
je 0xae00e
cmpq $0x1, 0x18(%rax)
jg 0xae00e
movq 0x8(%rbx), %rsi
pushq $0x2
popq %rdi
callq 0xdfb45
movq 0x18(%r14), %rdi
movq (%rbx), %rsi
movq 0x48(%r15), %rcx
movq %rax, %rdx
callq 0xe45f4
movq 0x48(%r15), %rdi
cmpq $0x2, 0x18(%rdi)
jl 0xae00e
xorl %esi, %esi
callq 0xe3eb4
movl %eax, %ebp
movq 0x48(%r15), %rdi
pushq $0x1
popq %rsi
callq 0xe3eb4
movl %eax, %r12d
shrb $0x4, %bpl
addb $0x8, %bpl
movl %ebp, %ecx
shll %cl, %r13d
leaq 0x7c57f(%rip), %rsi     # 0x12a567
movq %r14, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
shrb $0x6, %r12b
movzbl %r12b, %edx
leaq 0x7c578(%rip), %rsi     # 0x12a57c
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x50(%r15), %rcx
testq %rcx, %rcx
je 0xae235
movq 0x18(%r14), %rdi
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe45f4
movb $0x1, 0xc(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0xadeb2
cmpb $0x0, 0x8(%r15)
je 0xae26e
cmpb $0x0, 0xa(%r15)
je 0xae26e
cmpb $0x0, 0xb(%r15)
jne 0xae26e
cmpq $0x0, 0x38(%r15)
jne 0xae26e
movq %rbx, 0x10(%rsp)
movb $0x1, 0xb(%r15)
movq $0x0, 0x8(%rsp)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, 0x38(%r15)
movl $0xfa1, %esi            # imm = 0xFA1
movq %rax, %rdi
callq 0xe5a74
movq 0x38(%r15), %rdi
leaq 0x7c17c(%rip), %r13     # 0x12a22c
pushq $0x8
popq %r12
movq %r13, %rsi
movq %r12, %rdx
callq 0xe46ba
leaq 0x7c473(%rip), %rsi     # 0x12a539
movq %r14, %rdi
xorl %eax, %eax
callq 0xde9f1
cmpb $0x0, 0xd(%r15)
leaq 0x7c47f(%rip), %rax     # 0x12a55b
leaq 0x6d40d(%rip), %rsi     # 0x11b4f0
cmoveq %rax, %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, (%rsp)
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xe46ba
leaq 0xc(%r12), %rax
movq 0x18(%r14), %rdi
cmpq 0x18(%rdi), %rax
jg 0xae244
movq %r12, %r13
movq %r12, %rsi
callq 0xe404f
movq %rax, %rbp
movq 0x18(%r14), %rdi
leaq 0x4(%r12), %rsi
callq 0xe404f
addq %rbp, %r12
addq $0xc, %r12
movq 0x18(%r14), %rdi
cmpq 0x18(%rdi), %r12
jg 0xae244
cmpl $0x49444154, %eax       # imm = 0x49444154
pushq $0x1
popq %rcx
movq 0x8(%rsp), %rdx
cmovel %ecx, %edx
movq %rdx, %rcx
leaq 0xc(%rbp), %rdx
cmpb $0x0, 0xa(%r15)
movb $0x1, %bl
movq %rcx, 0x8(%rsp)
je 0xae1b3
testl %ecx, %ecx
jne 0xae1b3
cmpl $0x49484452, %eax       # imm = 0x49484452
je 0xae1f7
cmpl $0x504c5445, %eax       # imm = 0x504C5445
je 0xae1b1
cmpl $0x624b4744, %eax       # imm = 0x624B4744
je 0xae1b1
cmpl $0x6348524d, %eax       # imm = 0x6348524D
je 0xae1b1
cmpl $0x67414d41, %eax       # imm = 0x67414D41
je 0xae1b1
cmpl $0x70485973, %eax       # imm = 0x70485973
je 0xae1b1
cmpl $0x73424954, %eax       # imm = 0x73424954
je 0xae1b1
cmpl $0x74524e53, %eax       # imm = 0x74524E53
je 0xae1b1
cmpl $0x73524742, %eax       # imm = 0x73524742
jne 0xae1b3
xorl %ebx, %ebx
cmpl $0x6163544c, %eax       # imm = 0x6163544C
je 0xae1da
cmpl $0x6663544c, %eax       # imm = 0x6663544C
je 0xae1da
cmpl $0x66644154, %eax       # imm = 0x66644154
je 0xae1da
movq %r13, %rsi
movq %rdx, %rbp
movq (%rsp), %rcx
callq 0xe45f4
movq %rbp, %rdx
testb %bl, %bl
jne 0xae105
movq 0x18(%r14), %rdi
movq 0x38(%r15), %rcx
movq %r13, %rsi
callq 0xe45f4
jmp 0xae105
cmpq $0xd, %rbp
jne 0xae204
cmpq $0x0, 0x30(%r15)
je 0xae215
movq %r13, %rsi
movq (%rsp), %rcx
callq 0xe45f4
jmp 0xae105
movq 0x38(%r15), %rax
movq 0x18(%rax), %rax
movq %rax, 0x30(%r15)
movq %r13, %rsi
movq %rdx, %rbx
movq (%rsp), %rcx
callq 0xe45f4
movq %rbx, %rdx
jmp 0xae1e2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x38(%r15), %rax
testq %rax, %rax
je 0xae25c
cmpq $0xfa1, 0x18(%rax)      # imm = 0xFA1
jl 0xae25c
movb $0x0, 0xa(%r15)
movq (%rsp), %rdi
callq 0xe5591
movq 0x10(%rsp), %rbx
pushq $0x1
popq %r13
cmpl $0x1, (%r15)
jne 0xae294
cmpb $0x0, 0x7(%r15)
jne 0xae294
cmpq $0x0, 0x48(%r15)
jne 0xae294
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0xe59cd
movq %rax, 0x48(%r15)
cmpb $0x0, 0x6(%r15)
je 0xadf7e
cmpl $0x1, (%r15)
jne 0xadf7e
cmpb $0x0, 0x7(%r15)
jne 0xadf7e
cmpq $0x0, 0x50(%r15)
jne 0xadf7e
leaq 0x7c00c(%rip), %rsi     # 0x12a2d2
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, 0x50(%r15)
jmp 0xadf7e