// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/ilbm.c
// Function: do_anim_anhd
static void do_anim_anhd(deark *c, lctx *d, i64 pos, i64 len)
{
	i64 tmp;
	u8 ileave_raw;
	de_ucstring *bits_descr = NULL;
	struct frame_ctx *frctx = d->frctx;

	if(!frctx) return;
	if(len<24) return;

	frctx->op = de_getbyte(pos++);
	de_dbg(c, "operation: %d (%s)", (int)frctx->op, anim_get_op_name(frctx->op));

	if(frctx->op==ANIM_OP_XOR) {
		pos++; // Mask
		pos += 2; // w
		pos += 2; // h
		pos += 2; // x
		pos += 2; // y
	}
	else {
		pos += 9;
	}
	pos += 4; // abstime

	tmp = de_getu32be_p(&pos); // reltime
	de_dbg(c, "reltime: %.5f sec", ((double)tmp)/60.0);

	ileave_raw = de_getbyte_p(&pos);
	de_dbg(c, "interleave: %d", (int)ileave_raw);
	if(ileave_raw==0) {
		frctx->interleave = 2;
	}
	else {
		frctx->interleave = (UI)ileave_raw;
	}
	if(frctx->interleave>2 && !d->errflag) {
		de_err(c, "Unsupported interleave");
		d->errflag = 1;
	}

	pos++; // pad0

	frctx->bits = (UI)de_getu32be_p(&pos);
	bits_descr = ucstring_create(c);
	get_bits_descr(c, d, frctx, bits_descr);
	de_dbg(c, "bits: 0x%08x (%s)", frctx->bits, ucstring_getpsz_d(bits_descr));

	ucstring_destroy(bits_descr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0xb0(%rsi), %r13
testq %r13, %r13
sete %al
cmpq $0x18, %rcx
setl %cl
orb %al, %cl
jne 0x79b78
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movq %rdx, %rsi
callq 0xeead3
movb %al, 0x10(%r13)
movzbl %al, %edx
leaq 0xb2837(%rip), %rcx     # 0x12c151
cmpl $0x49, %edx
jg 0x79943
cmpl $0x8, %edx
ja 0x799bd
movl %edx, %eax
leaq 0xaf103(%rip), %rsi     # 0x128a34
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
leaq 0xaf3dd(%rip), %rcx     # 0x128d1e
jmp 0x799bd
cmpl $0x64, %edx
jg 0x7995b
cmpl $0x4a, %edx
je 0x799ad
cmpl $0x64, %edx
jne 0x799bd
leaq 0xaf458(%rip), %rcx     # 0x128db1
jmp 0x799bd
cmpl $0x65, %edx
je 0x799b6
cmpl $0x6c, %edx
jne 0x799bd
leaq 0xaf453(%rip), %rcx     # 0x128dbf
jmp 0x799bd
leaq 0xaf404(%rip), %rcx     # 0x128d79
jmp 0x799bd
leaq 0xaf3b7(%rip), %rcx     # 0x128d35
jmp 0x799bd
leaq 0xaf3a2(%rip), %rcx     # 0x128d29
jmp 0x799bd
leaq 0xaf3ab(%rip), %rcx     # 0x128d3b
jmp 0x799bd
leaq 0xaf3ad(%rip), %rcx     # 0x128d46
jmp 0x799bd
leaq 0xaf383(%rip), %rcx     # 0x128d25
jmp 0x799bd
leaq 0xaf3ac(%rip), %rcx     # 0x128d57
jmp 0x799bd
leaq 0xaf3e8(%rip), %rcx     # 0x128d9c
jmp 0x799bd
leaq 0xaf3fb(%rip), %rcx     # 0x128db8
leaq 0xaf2fd(%rip), %rsi     # 0x128cc1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
addq $0xe, %r15
movq %rsp, %r12
movq %r15, (%r12)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeed31
cvtsi2sd %rax, %xmm0
divsd 0xaf0ee(%rip), %xmm0    # 0x128ae0
leaq 0xaf2db(%rip), %rsi     # 0x128cd4
movq %rbx, %rdi
movb $0x1, %al
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeeb4b
movzbl %al, %ebp
leaq 0xaf2cd(%rip), %rsi     # 0x128ce6
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
testb %bpl, %bpl
je 0x79a56
movl %ebp, 0x14(%r13)
cmpb $0x3, %bpl
jb 0x79a5e
cmpl $0x0, 0x1c(%r14)
jne 0x79a5e
leaq 0xaf2b3(%rip), %rsi     # 0x128cf5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movl $0x1, 0x1c(%r14)
jmp 0x79a5e
movl $0x2, 0x14(%r13)
movq %rsp, %rsi
incq (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeed31
movl %eax, 0x18(%r13)
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r15
movl 0x18(%r13), %ebp
movzbl 0x10(%r13), %eax
cmpl $0x8, %eax
ja 0x79ab4
movl $0x1b0, %ecx            # imm = 0x1B0
btl %eax, %ecx
jae 0x79ab4
testb $0x1, %bpl
je 0x79ab4
leaq 0xaf333(%rip), %rsi     # 0x128dd4
movq %r15, %rdi
callq 0xf7105
decl %ebp
movb $0x1, 0x46(%r14)
movb 0x10(%r13), %al
andb $-0x2, %al
cmpb $0x4, %al
jne 0x79b37
testb $0x2, %bpl
je 0x79ad7
leaq 0xaf25e(%rip), %rsi     # 0x128d25
movq %r15, %rdi
callq 0xf7105
addl $-0x2, %ebp
movb $0x1, 0x45(%r14)
testb $0x4, %bpl
je 0x79aef
leaq 0xaf2fa(%rip), %rsi     # 0x128dde
movq %r15, %rdi
callq 0xf7105
addl $-0x4, %ebp
testb $0x8, %bpl
je 0x79b07
leaq 0xaf2f0(%rip), %rsi     # 0x128dec
movq %r15, %rdi
callq 0xf7105
addl $-0x8, %ebp
testb $0x10, %bpl
je 0x79b1f
leaq 0xaf2dc(%rip), %rsi     # 0x128df0
movq %r15, %rdi
callq 0xf7105
addl $-0x10, %ebp
testb $0x20, %bpl
je 0x79b37
leaq 0xaf2cd(%rip), %rsi     # 0x128df9
movq %r15, %rdi
callq 0xf7105
addl $-0x20, %ebp
testl %ebp, %ebp
je 0x79b4e
leaq 0xd0c8a(%rip), %rsi     # 0x14a7cc
movq %r15, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xf7132
movl 0x18(%r13), %ebp
movq %r15, %rdi
callq 0xf70f6
leaq 0xaf1ab(%rip), %rsi     # 0x128d0c
movq %rbx, %rdi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe8617
movq %r15, %rdi
callq 0xf6753
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq