// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/pict.c
// Function: handler_98_9a
static void handler_98_9a(struct item_handler_data *h)
{
	struct fmtutil_macbitmap_info *bi = NULL;
	i64 pixdata_size = 0;
	i64 colortable_size = 0;
	int retval = 0;
	i64 pos;
	deark *c = h->c;

	bi = de_malloc(c, sizeof(struct fmtutil_macbitmap_info));
	pos = h->data_pos;

	if(h->opcode==0x9a || h->opcode==0x9b) {
		fmtutil_macbitmap_read_baseaddr(c, h->inf, bi, pos);
		pos += 4;
	}

	fmtutil_macbitmap_read_rowbytes_and_bounds(c, h->inf, bi, pos);
	pos += 10;

	if(bi->pixmap_flag) {
		fmtutil_macbitmap_read_pixmap_only_fields(c, h->inf, bi, pos);
		pos += 36;
	}

	if((h->opcode==0x90 || h->opcode==0x91 || h->opcode==0x98 || h->opcode==0x99) && bi->pixmap_flag) {
		// Prepare to read the palette
		bi->uses_pal = 1;
		bi->has_colortable = 1;
	}
	else if((h->opcode==0x90 || h->opcode==0x91 || h->opcode==0x98 || h->opcode==0x99) && !bi->pixmap_flag) {
		// Settings implied by the lack of a PixMap header
		bi->pixelsize = 1;
		bi->cmpcount = 1;
		bi->cmpsize = 1;
		bi->uses_pal = 1;
		bi->num_pal_entries = 2;
		bi->pal[0] = DE_STOCKCOLOR_WHITE;
		bi->pal[1] = DE_STOCKCOLOR_BLACK;
	}
	else if((h->opcode==0x9a || h->opcode==0x9b) && !bi->pixmap_flag) {
		de_err(c, "DirectBitsRect image without PixMap flag is not supported");
		goto done;
	}

	if(bi->has_colortable) {
		if(!fmtutil_macbitmap_read_colortable(c, h->inf, bi, pos, &colortable_size)) goto done;
		pos += colortable_size;
	}

	read_src_dst_mode(c, h->d, bi, pos);
	pos += 18;

	if(h->opcode==0x91 || h->opcode==0x99 || h->opcode==0x9b) {
		i64 rgnsize;

		de_dbg(c, "region at %"I64_FMT, pos);
		de_dbg_indent(c, 1);
		rgnsize = de_getu16be(pos);
		de_dbg(c, "region size: %d", (int)rgnsize);
		de_dbg_indent(c, -1);
		if(rgnsize<2) goto done;
		pos += rgnsize;
		if(!c->padpix) {
			de_info(c, "Note: Ignoring clipping region. Output image might have "
				"extraneous pixels.");
		}
	}

	if(!get_pixdata_size(c, h->d, bi, pos, &pixdata_size)) {
		goto done;
	}
	decode_pixdata(c, h->d, bi, pos);
	pos += pixdata_size;

	h->data_len = pos - h->data_pos;

	retval = 1;

done:
	if(!retval) {
		h->fatal_errflag = 1;
	}
	de_free(c, bi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %rbp
andq $0x0, 0x40(%rsp)
andq $0x0, 0x38(%rsp)
movq (%rdi), %rbx
movl $0x480, %esi            # imm = 0x480
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r15
movq 0x28(%rbp), %r12
movl 0x18(%rbp), %eax
andl $-0x2, %eax
cmpl $0x9a, %eax
jne 0xabea1
movq 0x10(%rbp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0xedb42
addq $0x4, %r12
movq 0x10(%rbp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0xedb9a
leaq 0xa(%r12), %r13
cmpl $0x0, 0x6c(%r15)
je 0xabed8
movq 0x10(%rbp), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movq %r13, %rcx
callq 0xedcaf
addq $0x2e, %r12
movq %r12, %r13
movl 0x18(%rbp), %eax
leal -0x90(%rax), %ecx
pushq $0x1
popq %r14
cmpl $0x9, %ecx
ja 0xabf44
movl $0x303, %edx            # imm = 0x303
btl %ecx, %edx
jae 0xabf44
cmpl $0x0, 0x6c(%r15)
je 0xabf0b
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x70(%r15)
jmp 0xabf59
cmpl $0x9, %ecx
ja 0xabf44
btl %ecx, %edx
jae 0xabf44
movq %r14, 0x40(%r15)
movq %r14, 0x48(%r15)
movq %r14, 0x50(%r15)
movl $0x1, 0x74(%r15)
movq $0x2, 0x78(%r15)
movabsq $-0xffffff00000001, %rax # imm = 0xFF000000FFFFFFFF
movq %rax, 0x80(%r15)
jmp 0xabf59
andl $-0x2, %eax
cmpl $0x9a, %eax
jne 0xabf59
cmpl $0x0, 0x6c(%r15)
je 0xac162
cmpl $0x0, 0x70(%r15)
je 0xabf84
movq 0x10(%rbp), %rsi
leaq 0x38(%rsp), %r8
movq %rbx, %rdi
movq %r15, %rdx
movq %r13, %rcx
callq 0xedeaa
testl %eax, %eax
je 0xac173
addq 0x38(%rsp), %r13
leaq 0x7dca4(%rip), %rsi     # 0x129c2f
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
leaq 0x7dcac(%rip), %rcx     # 0x129c5a
leaq 0x98(%rsp), %r12
movq %r13, %rsi
movq %r12, %rdx
callq 0xab87e
leaq 0x8(%r13), %rsi
movq 0x18(%rbx), %rdi
leaq 0x7dc92(%rip), %rcx     # 0x129c62
movq %r12, %rdx
callq 0xab87e
leaq 0x10(%r13), %rax
leaq 0x60(%rsp), %rsi
movq %rax, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xe3f6e
leaq 0x7dc76(%rip), %rsi     # 0x129c6a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
addq $0x12, %r13
movl $0xffffff6f, %eax       # imm = 0xFFFFFF6F
addl 0x18(%rbp), %eax
cmpl $0xa, %eax
ja 0xac0a0
movl $0x501, %ecx            # imm = 0x501
btl %eax, %ecx
jae 0xac0a0
leaq 0x7dba5(%rip), %rsi     # 0x129bd6
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f46
movq %rax, %r12
leaq 0x7d5e9(%rip), %rsi     # 0x129648
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
cmpq $0x2, %r12
jl 0xac173
addq %r13, %r12
cmpb $0x0, 0xd6(%rbx)
jne 0xac0a3
leaq 0x7db50(%rip), %rsi     # 0x129be4
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf37f
jmp 0xac0a3
movq %r13, %r12
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xacba6
testl %eax, %eax
je 0xac173
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x10(%r15), %rdx
movq 0x20(%r15), %rcx
testq %rdx, %rdx
je 0xac137
testq %rcx, %rcx
je 0xac135
movq %rbx, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
callq 0xe6be1
testl %eax, %eax
je 0xac148
movq 0x40(%r15), %rdx
cmpq $0x20, %rdx
ja 0xac212
movabsq $0x101010116, %rax      # imm = 0x101010116
btq %rdx, %rax
jae 0xac212
movl 0x74(%r15), %esi
movq 0x38(%r15), %rax
testl %esi, %esi
je 0xac194
testq %rax, %rax
je 0xac19a
leaq 0x7db9f(%rip), %rsi     # 0x129cc6
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xdf2a5
jmp 0xac148
xorl %ecx, %ecx
leaq 0x7db3e(%rip), %rsi     # 0x129c7c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
addq 0x40(%rsp), %r12
subq 0x28(%rbp), %r12
movq %r12, 0x30(%rbp)
jmp 0xac177
leaq 0x7da33(%rip), %rsi     # 0x129b9c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movb $0x1, 0x38(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xded32
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x10, %rax
jne 0xac120
movq 0x48(%r15), %rax
cmpq $0x4, %rax
ja 0xac221
pushq $0x1a
popq %rcx
btq %rax, %rcx
jae 0xac221
movq 0x50(%r15), %rcx
cmpq $0x8, %rcx
ja 0xac419
movl $0x136, %edi            # imm = 0x136
btq %rcx, %rdi
jae 0xac419
movq 0x30(%r15), %r8
cmpq $0x4, %r8
ja 0xac42a
cmpq $0x2, %r8
je 0xac42a
testl %esi, %esi
je 0xac22d
cmpq $0x1, %r8
ja 0xac6de
cmpq $0x8, %rdx
ja 0xac6de
movl $0x116, %esi            # imm = 0x116
btq %rdx, %rsi
jae 0xac6de
xorq $0x1, %rax
xorq %rdx, %rcx
jmp 0xac256
leaq 0x7da86(%rip), %rsi     # 0x129c9f
movq %rbx, %rdi
jmp 0xac12c
leaq 0x7dabd(%rip), %rsi     # 0x129ce5
jmp 0xac127
cmpq $0x1, %r8
je 0xac247
cmpq $0x4, %r8
je 0xac471
cmpq $0x3, %r8
jne 0xac6de
xorq $0x10, %rdx
xorq $0x3, %rax
orq %rdx, %rax
xorq $0x5, %rcx
orq %rax, %rcx
jne 0xac6de
movq %r12, 0x18(%rsp)
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x98(%rsp), %rcx
movq %rbx, %rdi
callq 0xee7ee
movq (%r15), %rsi
movq 0x40(%r15), %rax
movq %rsi, 0x8(%r15)
cmpq $0x20, %rax
jne 0xac2b3
cmpq $0x3, 0x48(%r15)
jne 0xac2b3
cmpq $0x8, 0x50(%r15)
jne 0xac2b3
pushq $0x4
popq %rcx
movq %rsi, %rax
cqto
idivq %rcx
leaq (%rax,%rax,2), %rsi
movq %rsi, 0x8(%r15)
imulq 0x20(%r15), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xe59cd
movq %rbx, 0x20(%rsp)
movq %rax, %rbx
movq %rax, %rdi
callq 0xe589c
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rax
leaq 0x60(%rsp), %r13
movq %rax, (%r13)
leaq 0x80(%rsp), %rax
movq %rbx, 0x10(%rsp)
movq %rbx, (%rax)
movq 0x20(%rsp), %rbx
movq %rbp, 0x58(%rsp)
leaq -0x1(%r14), %rax
cmpq 0x20(%r15), %rax
jge 0xac43c
movq (%r15), %rbp
cmpq $0x1, 0x30(%r15)
sete %al
cmpq $0x8, %rbp
setl %cl
orb %al, %cl
jne 0xac357
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %rsi
cmpq $0xfb, %rbp
jb 0xac33f
callq 0xe3f6e
movq %rax, %rbp
jmp 0xac347
callq 0xe3f2a
movzbl %al, %ebp
movq 0x30(%r15), %rax
cmpq $0x1, %rax
je 0xac357
cmpq $0x7, (%r15)
jg 0xac3a1
movq 0x18(%rbx), %rdi
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0xe45f4
movq %rbx, %rdi
callq 0xe651f
movq 0x8(%r15), %rsi
imulq %r14, %rsi
cmpq %rsi, %rax
je 0xac38f
movq 0x10(%rsp), %rdi
callq 0xe5eb2
addq %rbp, 0x18(%rsp)
incq %r14
movq 0x20(%rsp), %rbx
jmp 0xac2ff
cmpq $0x3, %rax
jne 0xac3e2
cmpq $0x10, 0x40(%r15)
movq 0x18(%rsp), %rax
jne 0xac3e7
movl $0x2, 0x34(%rsp)
movq %rax, 0x68(%rsp)
movq %rbp, 0x70(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x80(%rsp), %rdx
leaq 0x98(%rsp), %rcx
leaq 0x34(%rsp), %r8
jmp 0xac40a
movq 0x18(%rsp), %rax
movq %rax, 0x68(%rsp)
movq %rbp, 0x70(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x80(%rsp), %rdx
leaq 0x98(%rsp), %rcx
xorl %r8d, %r8d
callq 0xeed4f
movq 0x10(%rsp), %rbx
jmp 0xac370
leaq 0x7d8e9(%rip), %rsi     # 0x129d09
movq %rbx, %rdi
movl %ecx, %edx
jmp 0xac12c
leaq 0x7d8fc(%rip), %rsi     # 0x129d2d
movq %rbx, %rdi
movl %r8d, %edx
jmp 0xac12c
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0xe58e8
cmpl $0x0, 0x74(%r15)
je 0xac49e
leaq 0x80(%r15), %rdi
movq 0x78(%r15), %rsi
callq 0xe6d06
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal 0x1(,%rcx,2), %r8d
jmp 0xac4a2
cmpq $0x20, %rdx
jne 0xac6de
cmpq $0x4, %rax
je 0xac6c2
cmpq $0x3, %rax
jne 0xac6de
cmpq $0x8, %rcx
je 0xac25f
jmp 0xac6de
pushq $0x3
popq %r8
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
movq 0x20(%r15), %rcx
movq %rbx, %rdi
callq 0xe746f
movq %rax, 0x28(%rsp)
movq %rbx, %rdi
callq 0xdfd1a
movsd 0x58(%r15), %xmm0
ucomisd 0x5be07(%rip), %xmm0    # 0x1082d8
jb 0xac4fa
movsd 0x60(%r15), %xmm1
ucomisd 0x5bdf7(%rip), %xmm1    # 0x1082d8
jb 0xac4fa
movl $0x2, 0x78(%rax)
movsd %xmm0, 0x80(%rax)
movsd %xmm1, 0x88(%rax)
movq %rax, 0x48(%rsp)
cmpl $0x0, 0x74(%r15)
movq 0x40(%r15), %rdx
movq %r12, 0x50(%rsp)
je 0xac571
movq 0x8(%r15), %rcx
movq %r15, %r8
subq $-0x80, %r8
andl $0x0, (%rsp)
movq %r14, %rdi
xorl %esi, %esi
movq 0x28(%rsp), %r9
callq 0xe7cbc
pushq $0x2
popq %rdx
movq 0x28(%rsp), %r14
movq %r14, %rdi
movq 0x48(%rsp), %r12
movq %r12, %rsi
callq 0xe70ab
movq %r14, %rdi
callq 0xe7084
movq %rbx, %rdi
movq %r12, %rsi
callq 0xdfd24
movq 0x10(%rsp), %rdi
callq 0xe5591
movq 0x58(%rsp), %rbp
movq 0x50(%rsp), %r12
jmp 0xac148
cmpq $0x10, %rdx
jne 0xac5f4
xorl %r12d, %r12d
cmpq 0x20(%r15), %r12
jge 0xac52d
pushq $0x1
popq %r14
xorl %ebp, %ebp
cmpq 0x18(%r15), %rbp
jge 0xac5ef
movq 0x8(%r15), %rax
imulq %r12, %rax
leaq (%r14,%rax), %rsi
decq %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xe3eb4
movl %eax, %r13d
movq 0x8(%r15), %rsi
imulq %r12, %rsi
addq %r14, %rsi
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0xe3eb4
movzbl %r13b, %ecx
shll $0x8, %ecx
movzbl %al, %edi
orl %ecx, %edi
callq 0xe1ea3
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movl %eax, %ecx
callq 0xe7287
incq %rbp
addq $0x2, %r14
jmp 0xac586
incq %r12
jmp 0xac57a
xorl %ebp, %ebp
cmpq 0x20(%r15), %rbp
jge 0xac52d
xorl %r12d, %r12d
movq 0x18(%r15), %rax
cmpq %rax, %r12
jge 0xac6ba
movq 0x48(%r15), %rcx
addq $-0x3, %rcx
imulq %rax, %rcx
movq 0x8(%r15), %rsi
imulq %rbp, %rsi
addq %r12, %rsi
addq %rcx, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0xe3eb4
movl %eax, %r13d
movq 0x48(%r15), %rax
addq $-0x2, %rax
imulq 0x18(%r15), %rax
movq 0x8(%r15), %rsi
imulq %rbp, %rsi
addq %r12, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0xe3eb4
movl %eax, %r14d
movq 0x48(%r15), %rax
decq %rax
imulq 0x18(%r15), %rax
movq 0x8(%r15), %rsi
imulq %rbp, %rsi
addq %r12, %rsi
addq %rax, %rsi
movq %rbx, %rdi
movq 0x20(%rsp), %rbx
callq 0xe3eb4
movzbl %r13b, %ecx
shll $0x10, %ecx
movzbl %r14b, %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl %al, %ecx
orl %edx, %ecx
orl $0xff000000, %ecx       # imm = 0xFF000000
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xe7287
incq %r12
jmp 0xac603
incq %rbp
jmp 0xac5f6
cmpq $0x8, %rcx
jne 0xac6de
leaq 0x7d67f(%rip), %rsi     # 0x129d4e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
jmp 0xac25f
leaq 0x7b84a(%rip), %rsi     # 0x127f2f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0xac148