// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x21737
movq -0x8(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x21737
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0xf68(%rax)
je 0x21737
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0xf68(%rax), %rax
cmpl $0x8, 0x478(%rax)
jne 0x21735
movq -0x8(%rbp), %rax
movl 0x254(%rax), %eax
movl $0x5, %ecx
cltd
idivl %ecx
movl %eax, -0x14(%rbp)
cmpl $0x5, -0x14(%rbp)
jge 0x21521
movl $0x5, -0x14(%rbp)
cmpl $0x19, -0x14(%rbp)
jle 0x2152e
movl $0x19, -0x14(%rbp)
movq 0x6186b(%rip), %rax     # 0x82da0
cvtsi2ssl (%rax), %xmm1
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0x10e8(%rax), %xmm0
cvtsi2ssl -0x14(%rbp), %xmm2
addss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2155c
jmp 0x21737
movq 0x6183d(%rip), %rax     # 0x82da0
cvtsi2ssl (%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0x10e8(%rax)
movq -0x8(%rbp), %rax
movl 0x254(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x258(%rcx), %ecx
addl $0x19, %ecx
cmpl %ecx, %eax
jge 0x215f6
cvtsi2ssl -0x14(%rbp), %xmm1
movss 0x4e971(%rip), %xmm0    # 0x6ff10
divss %xmm0, %xmm1
movq -0x8(%rbp), %rax
cvtsi2ssl 0x254(%rax), %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, 0x254(%rax)
movq -0x8(%rbp), %rax
movl 0x254(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x258(%rcx), %ecx
addl $0x19, %ecx
cmpl %ecx, %eax
jle 0x215ef
movq -0x8(%rbp), %rax
movl 0x258(%rax), %ecx
addl $0x19, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x254(%rax)
movl $0x1, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x187c0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x2165f
movl -0x14(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x20(%rbp)
leaq 0x4ee0c(%rip), %rdi     # 0x70435
callq 0x18a90
movq 0x6180b(%rip), %rcx     # 0x82e40
subq %rcx, %rax
movl $0x88, %ecx
cqto
idivq %rcx
movl -0x24(%rbp), %edx
movq %rax, %rcx
movq -0x20(%rbp), %rax
movl %edx, 0x318(%rax,%rcx,4)
movl $0x1, -0x10(%rbp)
jmp 0x216e6
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $0xc8, 0x318(%rax,%rcx,4)
jge 0x216e4
cvtsi2ssl -0x14(%rbp), %xmm1
movss 0x4e88b(%rip), %xmm0    # 0x6ff10
divss %xmm0, %xmm1
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
cvtsi2ssl 0x318(%rax,%rcx,4), %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %edx
movl %edx, 0x318(%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
cmpl $0xc8, 0x318(%rax,%rcx,4)
jle 0x216dd
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xc(%rbp), %rcx
movl $0xc8, 0x318(%rax,%rcx,4)
movl $0x1, -0x10(%rbp)
jmp 0x216e6
cmpl $0x0, -0x10(%rbp)
je 0x21733
movq 0x60f0d(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x4ed38(%rip), %rdi     # 0x70442
movq 0x60eef(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x38(%rbp), %rdi
movl %eax, %edx
movq -0x30(%rbp), %rax
movl $0x3, %esi
movss 0x4e7c1(%rip), %xmm1    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm1, %xmm0
callq *%rax
jmp 0x21735
jmp 0x21737
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)