// File: /workspace/github_c_makefile_star2_O1/QwazyWabbitWOS[P]lmctf60/g_runes.c
// Function: Rune_Think
void Rune_Think (edict_t *self)
{
	edict_t *spot;
	static qboolean forward = true;
	
	if (self->solid != SOLID_NOT)
	{
		switch (self->runetype)
		{
		case RUNE_DAMAGE:
			//screwy stuff to fix animation due to gimblelock
			if (forward == true)
			{
				self->s.frame++;
				if (self->s.frame >= 5)
					forward = false;
			}
			else
			{
				self->s.frame--;
				if (self->s.frame <= 0)
					forward = true;
			}
			break;
		case RUNE_HASTE:
			//screwy stuff to fix animation due to gimblelock
			switch (self->s.frame)
			{
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 9:
			case 10:
			case 11:
			case 12:
			case 13:
			case 14:
			case 15:
				self->s.frame++;
				break;
			default:
				self->s.frame = 5;
				break;
			}
			break;
		case RUNE_RESIST:
			self->s.frame = ((self->s.frame + 1) % 15);
			break;
		case RUNE_REGEN:
			self->s.frame = ((self->s.frame + 1) % 14);
			break;
		case RUNE_VAMP:                                   //added by Vampire
			self->s.frame = ((self->s.frame + 1) % 15);   
			break;                                        
		default:
			break;
		}
	}
	self->think = Rune_Think;
	self->nextthink = level.time + FRAMETIME;
	
	// Let's reuse last_move_time
	if (self->last_move_time + RUNETHINKTIME < level.time)
	{
		//	spot = SelectRuneSpawnPoint();
		
		spot = SelectRuneSpawnPoint();
		
		if (!spot)
			spot = redflag;
		
		if (spot)
		{
			VectorCopy (spot->s.origin, self->s.origin);
			tossrune (self, 0);
		}
		self->last_move_time = level.time;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x108(%rdi)
je 0x1f87a
movl 0x478(%rbx), %ecx
leal -0x1(%rcx), %eax
cmpl $0x7, %eax
ja 0x1f7ff
leaq 0x34ae2(%rip), %rcx     # 0x542b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x38(%rbx), %eax
cmpb $0x0, 0x4f83f(%rip)     # 0x6f020
je 0x1f91f
leal -0x1(%rax), %ecx
movl %ecx, 0x38(%rbx)
cmpl $0x1, %eax
jg 0x1f87a
movb $0x0, 0x4f823(%rip)     # 0x6f020
jmp 0x1f87a
cmpl $0x10, %ecx
jne 0x1f87a
movl 0x38(%rbx), %eax
movl %eax, %ecx
incl %ecx
movslq %ecx, %rcx
imulq $-0x77777777, %rcx, %rcx # imm = 0x88888889
shrq $0x20, %rcx
addl %eax, %ecx
incl %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x3, %ecx
addl %edx, %ecx
leal (%rcx,%rcx,4), %ecx
leal (%rcx,%rcx,2), %ecx
negl %ecx
jmp 0x1f873
movl 0x38(%rbx), %eax
leal -0x1(%rax), %ecx
cmpl $0xe, %ecx
ja 0x1f913
incl %eax
movl %eax, 0x38(%rbx)
jmp 0x1f87a
movl 0x38(%rbx), %eax
movl %eax, %ecx
incl %ecx
movslq %ecx, %rcx
imulq $-0x6db6db6d, %rcx, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
incl %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x3, %ecx
addl %edx, %ecx
movl %ecx, %edx
shll $0x4, %edx
addl %ecx, %ecx
subl %edx, %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x38(%rbx)
movq 0x4a39f(%rip), %rax     # 0x69c20
movq %rax, 0x210(%rbx)
movq 0x4a511(%rip), %r14     # 0x69da0
movss 0x4(%r14), %xmm0
movss 0x349f3(%rip), %xmm1    # 0x54290
addss %xmm0, %xmm1
movss %xmm1, 0x200(%rbx)
movss 0x250(%rbx), %xmm1
addss 0x349db(%rip), %xmm1    # 0x54294
ucomiss %xmm1, %xmm0
jbe 0x1f90b
callq 0x183d0
testq %rax, %rax
jne 0x1f8d2
movq 0x49f29(%rip), %rax     # 0x697f8
movq (%rax), %rax
testq %rax, %rax
je 0x1f8fd
movss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rbx)
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rbx)
movss 0xc(%rax), %xmm0
movss %xmm0, 0xc(%rbx)
movq %rbx, %rdi
callq 0x1f93a
movss 0x4(%r14), %xmm0
movss %xmm0, 0x250(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0x5, 0x38(%rbx)
jmp 0x1f87a
leal 0x1(%rax), %ecx
movl %ecx, 0x38(%rbx)
cmpl $0x4, %eax
jl 0x1f87a
movb $0x1, 0x4f6eb(%rip)     # 0x6f020
jmp 0x1f87a