// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x202ef
movq %rdi, %rbx
movq 0x58(%rdi), %rax
testq %rax, %rax
je 0x202ef
movq 0xf68(%rax), %rcx
testq %rcx, %rcx
je 0x202ef
cmpl $0x8, 0x478(%rcx)
jne 0x202ef
movslq 0x254(%rbx), %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x21, %rdx
addl %esi, %edx
cmpl $0x6, %edx
movl $0x5, %esi
cmovgel %edx, %esi
cmpl $0x19, %esi
movl $0x19, %ebp
cmovll %esi, %ebp
movq 0x49be1(%rip), %rdx     # 0x69da0
cvtsi2ssl (%rdx), %xmm0
cvtsi2ss %ebp, %xmm2
movss 0x10e8(%rax), %xmm1
addss %xmm2, %xmm1
ucomiss %xmm0, %xmm1
ja 0x202ef
movss %xmm0, 0x10e8(%rax)
movl 0x258(%rbx), %eax
addl $0x19, %eax
xorl %r14d, %r14d
cmpl %eax, %ecx
jge 0x2021f
movaps %xmm2, %xmm0
divss 0x33d0d(%rip), %xmm0    # 0x53f0c
xorps %xmm1, %xmm1
cvtsi2ss %ecx, %xmm1
addss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0x254(%rbx)
movl $0x1, %r14d
movss %xmm2, 0xc(%rsp)
movq %rbx, %rdi
callq 0x18750
testl %eax, %eax
je 0x20276
movq 0x58(%rbx), %rcx
cltq
movl 0x318(%rcx,%rax,4), %edx
cmpl $0xc7, %edx
jg 0x202b0
movss 0xc(%rsp), %xmm1
divss 0x33cb8(%rip), %xmm1    # 0x53f0c
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 0x202aa
shrl $0x2, %ebp
movq 0x58(%rbx), %r14
leaq 0x34179(%rip), %rdi     # 0x543fd
callq 0x189e0
subq 0x49bb0(%rip), %rax     # 0x69e40
sarq $0x3, %rax
movabsq $-0x3c3c3c3c3c3c3c3c, %rcx # imm = 0xC3C3C3C3C3C3C3C4
imulq %rax, %rcx
movl %ebp, 0x318(%r14,%rcx)
movl $0x1, %r14d
testl %r14d, %r14d
je 0x202ef
movq 0x49344(%rip), %rax     # 0x69600
movq 0x20(%rax), %r14
leaq 0x34143(%rip), %rdi     # 0x5440a
callq *0x48(%rax)
movss 0x33c56(%rip), %xmm0    # 0x53f28
xorps %xmm2, %xmm2
movq %rbx, %rdi
movl $0x3, %esi
movl %eax, %edx
movaps %xmm0, %xmm1
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmpq *%rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq