// File: /workspace/github_c_makefile_star2_O1/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 0x5e3d59(%rip), %rcx    # 0x648050
movl 0x8(%rcx,%rax,4), %ecx
movl %ecx, 0x28(%rdi)
movl %ecx, 0x24(%rdi)
movq 0x40(%rdi), %r9
xorps %xmm0, %xmm0
testq %r9, %r9
je 0x6440f
movl (%r9), %eax
cmpl %ecx, %eax
je 0x6431e
movq 0x10(%r9), %r9
jmp 0x64308
movswq 0x1e(%rsi), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x2c7982(%rip), %r10    # 0x32bcb0
movswl 0x4(%r10,%rcx,4), %edx
cmpl %edx, %eax
jne 0x643aa
leaq (%r10,%rcx,4), %rdx
testb $0x2, 0x8(%rdx)
jne 0x643aa
movl 0x64ed67(%rip), %r8d    # 0x6b30b0
movl %r8d, %ecx
subl (%rdx), %ecx
imull 0x8(%r9), %ecx
movl 0x4(%r9), %r11d
subl %eax, %r11d
incl %r11d
testl %ecx, %ecx
jns 0x64366
movl %r8d, (%rdx)
xorl %ecx, %ecx
movl %r11d, %r8d
shll $0x10, %r8d
shll $0x11, %r11d
cmpl %r11d, %ecx
jl 0x64393
movl 0x8(%r9), %r11d
testl %r11d, %r11d
je 0x64393
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 0x643ce
movl %ecx, %eax
subl %r8d, %eax
jl 0x643dc
cmpl %r8d, %eax
jge 0x64415
movl %eax, %ecx
jmp 0x643dc
movw %ax, 0x4(%r10,%rcx,4)
movl 0x64ecfa(%rip), %eax    # 0x6b30b0
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 0x6440f
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 0x643fd
movl (%r9), %eax
movl %eax, 0x28(%rdi)
movzwl %cx, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x14ec5(%rip), %xmm0    # 0x792d4
movss %xmm0, 0x3c(%rdi)
retq
cltd
idivl %r8d
movl %edx, %ecx
jmp 0x643dc
nopl (%rax)