// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/ilbm.c
// Function: decompress_delta_op74
static void decompress_delta_op74(deark *c, lctx *d, struct imgbody_info *ibi,
	struct frame_ctx *frctx, i64 pos1, i64 len)
{
	struct d74state d74s;

	de_zeromem(&d74s, sizeof(struct d74state));
	d74s.ibi = ibi;
	d74s.frctx = frctx;
	d74s.pos = pos1;
	d74s.endpos = pos1+len;

	if(!d->delta_ops_used[74]) { // If this is the first DLTA#7 chunk...
		if(ibi->width < 320) {
			// The XAnim code says this is a special case, but I haven't found any
			// sample files. (TODO)
			de_warn(c, "ANIM-J with width < 320 might not be supported correctly");
		}
	}

	while(1) {
		UI code;

		if(d74s.pos+2 >= d74s.endpos) goto done;
		code = (UI)de_getu16be_p(&d74s.pos);
		if(code==1) {
			frctx->change_flag = 1;
			d74s.op = (UI)de_getu16be_p(&d74s.pos);
			d74s.nrows = de_getu16be_p(&d74s.pos);
			d74s.nbytes = 1;
			d74s.nblocks = de_getu16be_p(&d74s.pos);
			do_delta74_blocks(c, &d74s);
		}
		else if(code==2) {
			frctx->change_flag = 1;
			d74s.op = (UI)de_getu16be_p(&d74s.pos);
			d74s.nrows = de_getu16be_p(&d74s.pos);
			d74s.nbytes = de_getu16be_p(&d74s.pos);
			d74s.nblocks = de_getu16be_p(&d74s.pos);
			do_delta74_blocks(c, &d74s);
		}
		else if(code==0) {
			break;
		}
		else {
			de_warn(c, "Bad or unsupported ANIM-J compression code: %u", code);
			goto done;
		}
	}

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x19140
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x91e(%rax)
jne 0xb4ca5
movq -0x18(%rbp), %rax
cmpq $0x140, (%rax)          # imm = 0x140
jge 0xb4ca3
movq -0x8(%rbp), %rdi
leaq 0xffe97(%rip), %rsi     # 0x1b4b33
movb $0x0, %al
callq 0x15bc10
jmp 0xb4ca5
jmp 0xb4ca7
movq -0x60(%rbp), %rax
addq $0x2, %rax
cmpq -0x58(%rbp), %rax
jl 0xb4cba
jmp 0xb4df2
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movl %eax, -0x74(%rbp)
cmpl $0x1, -0x74(%rbp)
jne 0xb4d47
movq -0x20(%rbp), %rax
movl $0x1, 0xc(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movq %rax, -0x40(%rbp)
movq $0x1, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xb5b00
jmp 0xb4deb
cmpl $0x2, -0x74(%rbp)
jne 0xb4dca
movq -0x20(%rbp), %rax
movl $0x1, 0xc(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x70(%rbp), %rsi
addq $0x10, %rsi
callq 0x165210
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xb5b00
jmp 0xb4de9
cmpl $0x0, -0x74(%rbp)
jne 0xb4dd2
jmp 0xb4df0
movq -0x8(%rbp), %rdi
movl -0x74(%rbp), %edx
leaq 0xffd8c(%rip), %rsi     # 0x1b4b6c
movb $0x0, %al
callq 0x15bc10
jmp 0xb4df2
jmp 0xb4deb
jmp 0xb4ca7
jmp 0xb4df2
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)