// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_runes.c
// Function: RuneThinkHook
void RuneThinkHook(edict_t *ent)
{
	int old_armor_index;
	int sound = 0; // Don't play a sound unless needed.
	int	heartrate;

	if (ent && ent->client && ent->client->rune)
	{
		
		if (ent->client->rune->runetype == RUNE_REGEN)
		{
			heartrate = ent->health / 5;
			if (heartrate < 5)
				heartrate = 5;
			if (heartrate > 25)
				heartrate = 25;
			
			if (level.framenum < ent->client->regentime + heartrate)
				return;
			
			ent->client->regentime = level.framenum;
			
			if (ent->health < ent->max_health + 25)
			{
				//bat
				ent->health+=(heartrate / 3.0f);
				//ent->health+=(heartrate/4);
				if (ent->health > ent->max_health + 25)
					ent->health = ent->max_health + 25;
				sound = 1;
			}
			
			old_armor_index = ArmorIndex (ent);
			if (!old_armor_index)
			{
				ent->client->pers.inventory[ITEM_INDEX(FindItem("Jacket Armor"))] = heartrate/4;
				sound = 1;
			}
			else
			{
				if (ent->client->pers.inventory[old_armor_index] < 200)
				{
					//bat
					ent->client->pers.inventory[old_armor_index] += heartrate / 3.0f;
					//ent->client->pers.inventory[old_armor_index] += heartrate/4;
					if (ent->client->pers.inventory[old_armor_index] > 200)
						ent->client->pers.inventory[old_armor_index] = 200;
					sound = 1;
				}
			}
			if (sound)
				gi.sound(ent, CHAN_ITEM, gi.soundindex("ctf/regen.wav"), 1, ATTN_NORM, 0);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x1e8c4
movq %rdi, %rbx
movq 0x58(%rdi), %rcx
testq %rcx, %rcx
je 0x1e8c4
movq 0xf68(%rcx), %rax
testq %rax, %rax
je 0x1e8c4
cmpl $0x8, 0x478(%rax)
jne 0x1e8c4
movl 0x254(%rbx), %ebp
pushq $0x5
popq %rsi
movl %ebp, %eax
cltd
idivl %esi
cmpl $0x6, %eax
cmovgel %eax, %esi
cmpl $0x19, %esi
pushq $0x19
popq %r14
cmovll %esi, %r14d
movq 0x484f6(%rip), %rax     # 0x66da0
cvtsi2ssl (%rax), %xmm0
cvtsi2ss %r14d, %xmm2
movss 0x10e8(%rcx), %xmm1
addss %xmm2, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1e8cf
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movss %xmm0, 0x10e8(%rcx)
movl 0x258(%rbx), %r15d
addl $0x19, %r15d
cmpl %r15d, %ebp
jge 0x1e90b
movaps %xmm2, %xmm0
divss 0x3061a(%rip), %xmm0    # 0x4ef0c
cvtsi2ss %ebp, %xmm1
addss %xmm0, %xmm1
cvttss2si %xmm1, %eax
cmpl %eax, %r15d
cmovll %r15d, %eax
movl %eax, 0x254(%rbx)
movss %xmm2, 0x4(%rsp)
movq %rbx, %rdi
callq 0x187a0
testl %eax, %eax
je 0x1e95f
movq 0x58(%rbx), %rcx
cltq
movl 0x318(%rcx,%rax,4), %edx
cmpl $0xc7, %edx
jg 0x1e98e
movss 0x4(%rsp), %xmm1
divss 0x305cc(%rip), %xmm1    # 0x4ef0c
cvtsi2ss %edx, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %edx
movl $0xc8, %esi
cmpl %esi, %edx
cmovll %edx, %esi
movl %esi, 0x318(%rcx,%rax,4)
jmp 0x1e997
shrl $0x2, %r14d
movq 0x58(%rbx), %r15
leaq 0x30a9f(%rip), %rdi     # 0x4f40d
callq 0x18a80
subq 0x484c6(%rip), %rax     # 0x66e40
movl $0x88, %ecx
cqto
idivq %rcx
movl %r14d, 0x318(%r15,%rax,4)
jmp 0x1e997
cmpl %r15d, %ebp
jge 0x1e8c4
movq 0x47c62(%rip), %rax     # 0x66600
movq 0x20(%rax), %r14
leaq 0x30a71(%rip), %rdi     # 0x4f41a
callq *0x48(%rax)
pushq $0x3
popq %rsi
movss 0x30571(%rip), %xmm0    # 0x4ef28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl %eax, %edx
movaps %xmm0, %xmm1
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax