// File: /workspace/github_c_makefile_star2_O2/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
imulq $0xc, %rax, %rax
leaq 0x5e6a7c(%rip), %rcx    # 0x642040
movl 0x8(%rax,%rcx), %eax
movl %eax, 0x28(%rdi)
movl %eax, 0x24(%rdi)
leaq 0x40(%rdi), %r9
xorps %xmm0, %xmm0
movq (%r9), %r9
testq %r9, %r9
je 0x5b6da
cmpl %eax, (%r9)
je 0x5b5ec
addq $0x10, %r9
jmp 0x5b5d5
movswq 0x1e(%rsi), %rcx
imulq $0xc, %rcx, %rcx
leaq 0x2ca6b4(%rip), %r10    # 0x325cb0
movswl 0x4(%r10,%rcx), %edx
cmpl %edx, %eax
jne 0x5b678
leaq (%r10,%rcx), %rdx
testb $0x2, 0x8(%rdx)
jne 0x5b678
movl 0x651a89(%rip), %r8d    # 0x6ad0a0
movl %r8d, %ecx
subl (%rdx), %ecx
imull 0x8(%r9), %ecx
movl 0x4(%r9), %r11d
subl %eax, %r11d
incl %r11d
testl %ecx, %ecx
jns 0x5b634
movl %r8d, (%rdx)
xorl %ecx, %ecx
movl %r11d, %r8d
shll $0x10, %r8d
shll $0x11, %r11d
cmpl %r11d, %ecx
jl 0x5b661
movl 0x8(%r9), %r11d
testl %r11d, %r11d
je 0x5b661
movl %r8d, %eax
cltd
idivl %r11d
movswq 0x1e(%rsi), %rdx
imulq $0xc, %rdx, %rdx
addl %eax, (%r10,%rdx)
testb $0x1, 0xc(%r9)
jne 0x5b69c
movl %ecx, %eax
subl %r8d, %eax
jl 0x5b6aa
cmpl %r8d, %eax
jge 0x5b6e0
movl %eax, %ecx
jmp 0x5b6aa
movw %ax, 0x4(%r10,%rcx)
movl 0x651a1c(%rip), %eax    # 0x6ad0a0
movswq 0x1e(%rsi), %rcx
imulq $0xc, %rcx, %rcx
movl %eax, (%r10,%rcx)
movl (%r9), %eax
movl %eax, 0x28(%rdi)
movl %eax, 0x24(%rdi)
jmp 0x5b6da
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 0x5b6cb
movl (%r9), %eax
movl %eax, 0x28(%rdi)
movzwl %cx, %eax
cvtsi2ss %eax, %xmm0
mulss 0x13c5a(%rip), %xmm0    # 0x6f334
movss %xmm0, 0x3c(%rdi)
retq
cltd
idivl %r8d
movl %edx, %ecx
jmp 0x5b6aa