// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/psd.c
// Function: do_bitmap_packbits
static void do_bitmap_packbits(deark *c, lctx *d, zztype *zz, const struct image_info *iinfo)
{
	dbuf *unc_pixels = NULL;
	i64 cmpr_data_size = 0;
	i64 k;

	// Data begins with a table of row byte counts.
	de_dbg(c, "row sizes table at %"I64_FMT", len=%d", zz->pos,
		(int)(iinfo->num_channels * iinfo->height * d->intsize_2or4));

	for(k=0; k < iinfo->num_channels * iinfo->height; k++) {
		if(d->intsize_2or4==4) {
			cmpr_data_size += psd_getu32zz(zz);
		}
		else {
			cmpr_data_size += psd_getu16zz(zz);
		}
	}

	de_dbg(c, "compressed data at %"I64_FMT", len=%"I64_FMT"", zz->pos, cmpr_data_size);
	if(zz->pos + cmpr_data_size>c->infile->len) {
		de_err(c, "Unexpected end of file");
		goto done;
	}

	unc_pixels = dbuf_create_membuf(c, 1024, 0);
	dbuf_enable_wbuffer(unc_pixels);
	fmtutil_decompress_packbits(c->infile, zz->pos, cmpr_data_size, unc_pixels, NULL);
	dbuf_flush(unc_pixels);
	zz->pos += cmpr_data_size;
	de_dbg_indent(c, 1);
	de_dbg(c, "decompressed %"I64_FMT" bytes to %"I64_FMT"", cmpr_data_size, unc_pixels->len);
	de_dbg_indent(c, -1);
	do_bitmap(c, d, iinfo, unc_pixels, 0, unc_pixels->len);

done:
	dbuf_close(unc_pixels);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
imulq 0x8(%rcx), %rax
movq -0x10(%rbp), %rcx
imulq 0x18(%rcx), %rax
movl %eax, %ecx
leaq 0xc4b76(%rip), %rsi     # 0x1c042c
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x20(%rbp), %rdx
imulq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jge 0xfb93c
movq -0x10(%rbp), %rax
cmpq $0x4, 0x18(%rax)
jne 0xfb90c
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3330
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0xfb92c
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
callq 0xf3de0
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0xfb92e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xfb8c5
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movq -0x30(%rbp), %rcx
leaq 0xb6116(%rip), %rsi     # 0x1b1a68
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq (%rax), %rax
addq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xfb989
movq -0x8(%rbp), %rdi
leaq 0xa3442(%rip), %rsi     # 0x19edbf
movb $0x0, %al
callq 0x15bfb0
jmp 0xfba3a
movq -0x8(%rbp), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x168020
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x167b90
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x177e60
movq -0x28(%rbp), %rdi
callq 0x167c30
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rcx
leaq 0xa3340(%rip), %rsi     # 0x19ed43
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x18(%rax), %r9
xorl %eax, %eax
movl %eax, %r8d
callq 0xfb430
movq -0x28(%rbp), %rdi
callq 0x1676a0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)