// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/mdsprite.c
// Function: updateanimation
static void updateanimation (md2model *m, spritetype *tspr)
{
	mdanim_t *anim;
	int i, j;

	m->cframe = m->nframe = tile2model[tspr->picnum].framenum;

	for (anim = m->animations;
		  anim && anim->startframe != m->cframe;
		  anim = anim->next) ;
	if (!anim) { m->interpol = 0; return; }

	if (((int)spriteext[tspr->owner].mdanimcur) != anim->startframe ||
			(spriteext[tspr->owner].flags & SPREXT_NOMDANIM))
	{
		spriteext[tspr->owner].mdanimcur = (short)anim->startframe;
		spriteext[tspr->owner].mdanimtims = mdtims;
		m->cframe = m->nframe = anim->startframe;
		m->interpol = 0;
		return;
	}

	i = (mdtims-spriteext[tspr->owner].mdanimtims)*anim->fpssc;
	j = ((anim->endframe+1-anim->startframe)<<16);

		//Just in case you play the game for a VERY int time...
	if (i < 0) { i = 0; spriteext[tspr->owner].mdanimtims = mdtims; }
		//compare with j*2 instead of j to ensure i stays > j-65536 for MDANIM_ONESHOT
	if ((i >= j+j) && (anim->fpssc)) //Keep mdanimtims close to mdtims to avoid the use of MOD
		spriteext[tspr->owner].mdanimtims += j/anim->fpssc;

	if (anim->flags&MDANIM_ONESHOT)
		{ if (i > j-65536) i = j-65536; }
	else { if (i >= j) { i -= j; if (i >= j) i %= j; } }

	m->cframe = (i>>16)+anim->startframe;
	m->nframe = m->cframe+1; if (m->nframe > anim->endframe) m->nframe = anim->startframe;
	m->interpol = ((float)(i&65535))/65536.f;
}

// Assembly:
movswq 0xe(%rsi), %rax
leaq (%rax,%rax,2), %rax
leaq 0x5e2fe2(%rip), %rcx    # 0x649040
movl 0x8(%rcx,%rax,4), %eax
movl %eax, 0x28(%rdi)
movl %eax, 0x24(%rdi)
movq 0x40(%rdi), %r9
xorps %xmm0, %xmm0
testq %r9, %r9
je 0x66174
cmpl %eax, (%r9)
je 0x66083
movq 0x10(%r9), %r9
jmp 0x6606f
movswq 0x1e(%rsi), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x2c6c1d(%rip), %r10    # 0x32ccb0
movswl 0x4(%r10,%rcx,4), %edx
cmpl %edx, %eax
jne 0x6610f
leaq (%r10,%rcx,4), %rdx
testb $0x2, 0x8(%rdx)
jne 0x6610f
movl 0x64dff2(%rip), %r8d    # 0x6b40a0
movl %r8d, %ecx
subl (%rdx), %ecx
imull 0x8(%r9), %ecx
movl 0x4(%r9), %r11d
subl %eax, %r11d
incl %r11d
testl %ecx, %ecx
jns 0x660cb
movl %r8d, (%rdx)
xorl %ecx, %ecx
movl %r11d, %r8d
shll $0x10, %r8d
shll $0x11, %r11d
cmpl %r11d, %ecx
jl 0x660f8
movl 0x8(%r9), %r11d
testl %r11d, %r11d
je 0x660f8
movl %r8d, %eax
cltd
idivl %r11d
movswq 0x1e(%rsi), %rdx
leaq (%rdx,%rdx,2), %rdx
addl %eax, (%r10,%rdx,4)
testb $0x1, 0xc(%r9)
jne 0x66133
movl %ecx, %eax
subl %r8d, %eax
jl 0x66141
cmpl %r8d, %eax
jge 0x6617a
movl %eax, %ecx
jmp 0x66141
movw %ax, 0x4(%r10,%rcx,4)
movl 0x64df85(%rip), %eax    # 0x6b40a0
movswq 0x1e(%rsi), %rcx
leaq (%rcx,%rcx,2), %rcx
movl %eax, (%r10,%rcx,4)
movl (%r9), %eax
movl %eax, 0x28(%rdi)
movl %eax, 0x24(%rdi)
jmp 0x66174
addl $0xffff0000, %r8d       # imm = 0xFFFF0000
cmpl %r8d, %ecx
cmovgel %r8d, %ecx
movl %ecx, %eax
sarl $0x10, %eax
movl (%r9), %edx
leal (%rax,%rdx), %esi
movl %esi, 0x24(%rdi)
addl %edx, %eax
incl %eax
movl %eax, 0x28(%rdi)
cmpl 0x4(%r9), %esi
jl 0x66162
movl (%r9), %eax
movl %eax, 0x28(%rdi)
movzwl %cx, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x14440(%rip), %xmm0    # 0x7a5b4
movss %xmm0, 0x3c(%rdi)
retq
cltd
idivl %r8d
movl %edx, %ecx
jmp 0x66141
nop