// File: /workspace/github_c_makefile_star2_O3/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)
je 0xb5007
movq 0x48(%r15), %rax
testq %rax, %rax
je 0xb4fdc
cmpq $0x1, 0x18(%rax)
jg 0xb4fdc
movq 0x8(%rbx), %rsi
movl $0x2, %edi
callq 0xe9c3b
movq 0x18(%r14), %rdi
movq (%rbx), %rsi
movq 0x48(%r15), %rcx
movq %rax, %rdx
callq 0xef481
movq 0x48(%r15), %rdi
cmpq $0x2, 0x18(%rdi)
jl 0xb4fdc
xorl %esi, %esi
callq 0xeead3
movl %eax, %ebp
movq 0x48(%r15), %rdi
movl $0x1, %esi
callq 0xeead3
movl %eax, %r12d
shrb $0x4, %bpl
addb $0x8, %bpl
movl $0x1, %edx
movl %ebp, %ecx
shll %cl, %edx
leaq 0x8288e(%rip), %rsi     # 0x137847
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
shrb $0x6, %r12b
movzbl %r12b, %edx
leaq 0x8288a(%rip), %rsi     # 0x13785c
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x50(%r15), %rcx
testq %rcx, %rcx
je 0xb5174
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 0xef481
movb $0x1, 0xc(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0xb4e76
cmpb $0x0, 0x8(%r15)
je 0xb5103
cmpb $0x0, 0xa(%r15)
je 0xb5103
cmpb $0x0, 0xb(%r15)
jne 0xb5103
cmpq $0x0, 0x38(%r15)
jne 0xb5103
movb $0x1, 0xb(%r15)
movq $0x0, 0x8(%rsp)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
movq %rax, 0x38(%r15)
movl $0xfa1, %esi            # imm = 0xFA1
movq %rax, %rdi
callq 0xf0a7c
movq 0x38(%r15), %rdi
leaq 0x82493(%rip), %r12     # 0x13750c
movl $0x8, %ebp
movl $0x8, %edx
movq %r12, %rsi
callq 0xef547
leaq 0x82787(%rip), %rsi     # 0x137819
movq %r14, %rdi
xorl %eax, %eax
callq 0xe87e4
cmpb $0x0, 0xd(%r15)
leaq 0x82793(%rip), %rax     # 0x13783b
leaq 0x73681(%rip), %rsi     # 0x128730
cmoveq %rax, %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movl $0x8, %edx
movq %rax, (%rsp)
movq %rax, %rdi
movq %r12, %rsi
callq 0xef547
movq 0x18(%r14), %rdi
cmpq $0x14, 0x18(%rdi)
jge 0xb5183
movq 0x38(%r15), %rax
testq %rax, %rax
je 0xb50fa
cmpq $0xfa1, 0x18(%rax)      # imm = 0xFA1
jl 0xb50fa
movb $0x0, 0xa(%r15)
movq (%rsp), %rdi
callq 0xf052b
cmpl $0x1, (%r15)
jne 0xb512d
cmpb $0x0, 0x7(%r15)
jne 0xb512d
cmpq $0x0, 0x48(%r15)
jne 0xb512d
movl $0x8, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xf09c5
movq %rax, 0x48(%r15)
cmpb $0x0, 0x6(%r15)
je 0xb4f43
cmpl $0x1, (%r15)
jne 0xb4f43
cmpb $0x0, 0x7(%r15)
jne 0xb4f43
cmpq $0x0, 0x50(%r15)
jne 0xb4f43
leaq 0x82453(%rip), %rsi     # 0x1375b2
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, 0x50(%r15)
jmp 0xb4f43
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %r13
movq %rbp, %rsi
callq 0xeed0d
movq %rax, %r12
movq 0x18(%r14), %rdi
leaq 0x4(%rbp), %rsi
callq 0xeed0d
addq %r12, %rbp
addq $0xc, %rbp
movq 0x18(%r14), %rdi
cmpq 0x18(%rdi), %rbp
jg 0xb50e2
cmpl $0x49444154, %eax       # imm = 0x49444154
movq 0x8(%rsp), %rcx
movl $0x1, %edx
cmovel %edx, %ecx
leaq 0xc(%r12), %rdx
cmpb $0x0, 0xa(%r15)
movb $0x1, %sil
movq %rcx, 0x8(%rsp)
je 0xb523d
testl %ecx, %ecx
jne 0xb523d
cmpl $0x67414d40, %eax       # imm = 0x67414D40
jle 0xb5202
cmpl $0x73424953, %eax       # imm = 0x73424953
jle 0xb522d
cmpl $0x73424954, %eax       # imm = 0x73424954
je 0xb523b
cmpl $0x74524e53, %eax       # imm = 0x74524E53
je 0xb523b
cmpl $0x73524742, %eax       # imm = 0x73524742
je 0xb523b
jmp 0xb523d
cmpl $0x624b4743, %eax       # imm = 0x624B4743
jg 0xb521d
cmpl $0x49484452, %eax       # imm = 0x49484452
je 0xb529d
cmpl $0x504c5445, %eax       # imm = 0x504C5445
je 0xb523b
jmp 0xb523d
cmpl $0x624b4744, %eax       # imm = 0x624B4744
je 0xb523b
cmpl $0x6348524d, %eax       # imm = 0x6348524D
je 0xb523b
jmp 0xb523d
cmpl $0x67414d41, %eax       # imm = 0x67414D41
je 0xb523b
cmpl $0x70485973, %eax       # imm = 0x70485973
jne 0xb523d
xorl %esi, %esi
cmpl $0x6163544c, %eax       # imm = 0x6163544C
je 0xb5252
cmpl $0x6663544c, %eax       # imm = 0x6663544C
je 0xb5252
cmpl $0x66644154, %eax       # imm = 0x66644154
jne 0xb5259
testb %sil, %sil
je 0xb5276
jmp 0xb5286
movl %esi, 0x14(%rsp)
movq %r13, %rsi
movq %rdx, %r12
movq (%rsp), %rcx
callq 0xef481
movq %r12, %rdx
cmpb $0x0, 0x14(%rsp)
jne 0xb5286
movq 0x18(%r14), %rdi
movq 0x38(%r15), %rcx
movq %r13, %rsi
callq 0xef481
leaq 0xc(%rbp), %rax
movq 0x18(%r14), %rdi
cmpq 0x18(%rdi), %rax
jle 0xb5183
jmp 0xb50e2
cmpq $0xd, %r12
jne 0xb52aa
cmpq $0x0, 0x30(%r15)
je 0xb52c1
movq %r13, %rsi
movq (%rsp), %rcx
callq 0xef481
movq $0x0, 0x8(%rsp)
jmp 0xb5286
movq 0x38(%r15), %rax
movq 0x18(%rax), %rax
movq %rax, 0x30(%r15)
movq %r13, %rsi
movq %rdx, %r12
movq (%rsp), %rcx
callq 0xef481
movq %r12, %rdx
jmp 0xb5276