// File: /workspace/github_c_makefile_star2_O3/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 0x200f5
movq %rdi, %rbx
movq 0x58(%rdi), %rax
testq %rax, %rax
je 0x200f5
movq 0xf68(%rax), %rcx
testq %rcx, %rcx
je 0x200f5
cmpl $0x8, 0x478(%rcx)
jne 0x200f5
movslq 0x254(%rbx), %r14
imulq $0x66666667, %r14, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x21, %rcx
addl %edx, %ecx
cmpl $0x6, %ecx
movl $0x5, %edx
cmovgel %ecx, %edx
cmpl $0x19, %edx
movl $0x19, %ebp
cmovll %edx, %ebp
movq 0x48cc4(%rip), %rcx     # 0x68da0
cvtsi2ssl (%rcx), %xmm0
cvtsi2ss %ebp, %xmm2
movss 0x10e8(%rax), %xmm1
addss %xmm2, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x20100
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movss %xmm0, 0x10e8(%rax)
movl 0x258(%rbx), %r15d
addl $0x19, %r15d
cmpl %r15d, %r14d
jge 0x20140
movaps %xmm2, %xmm0
divss 0x32ded(%rip), %xmm0    # 0x52f10
xorps %xmm1, %xmm1
cvtsi2ss %r14d, %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 0x18750
testl %eax, %eax
je 0x20197
movq 0x58(%rbx), %rcx
cltq
movl 0x318(%rcx,%rax,4), %edx
cmpl $0xc7, %edx
jg 0x201cd
movss 0x4(%rsp), %xmm1
divss 0x32d9b(%rip), %xmm1    # 0x52f10
xorps %xmm0, %xmm0
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 0x201d6
shrl $0x2, %ebp
movq 0x58(%rbx), %r14
leaq 0x33268(%rip), %rdi     # 0x5340d
callq 0x189e0
subq 0x48c8f(%rip), %rax     # 0x68e40
sarq $0x3, %rax
movabsq $-0x3c3c3c3c3c3c3c3c, %rcx # imm = 0xC3C3C3C3C3C3C3C4
imulq %rax, %rcx
movl %ebp, 0x318(%r14,%rcx)
jmp 0x201d6
cmpl %r15d, %r14d
jge 0x200f5
movq 0x48423(%rip), %rax     # 0x68600
movq 0x20(%rax), %r14
leaq 0x33232(%rip), %rdi     # 0x5341a
callq *0x48(%rax)
movss 0x32d35(%rip), %xmm0    # 0x52f28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x3, %esi
movl %eax, %edx
movaps %xmm0, %xmm1
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax