// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_items.c
// Function: Pickup_Armor
qboolean Pickup_Armor (edict_t *ent, edict_t *other)
{
	int				old_armor_index;
	gitem_armor_t	*oldinfo;
	gitem_armor_t	*newinfo;
	int				newcount;
	float			salvage;
	int				salvagecount;

	// get info on new armor
	newinfo = (gitem_armor_t *)ent->item->info;

	old_armor_index = ArmorIndex (other);

	// handle armor shards specially
	if (ent->item->tag == ARMOR_SHARD)
	{
		if (!old_armor_index)
			other->client->pers.inventory[jacket_armor_index] = 2;
		else
			other->client->pers.inventory[old_armor_index] += 2;
	}

	// if player has no armor, just use it
	else if (!old_armor_index)
	{
		other->client->pers.inventory[ITEM_INDEX(ent->item)] = newinfo->base_count;
	}

	// use the better armor
	else
	{
		// get info on old armor
		if (old_armor_index == jacket_armor_index)
			oldinfo = &jacketarmor_info;
		else if (old_armor_index == combat_armor_index)
			oldinfo = &combatarmor_info;
		else // (old_armor_index == body_armor_index)
			oldinfo = &bodyarmor_info;

		if (newinfo->normal_protection > oldinfo->normal_protection)
		{
			// calc new armor values
			salvage = oldinfo->normal_protection / newinfo->normal_protection;
			salvagecount = salvage * other->client->pers.inventory[old_armor_index];
			newcount = newinfo->base_count + salvagecount;
			if (newcount > newinfo->max_count)
				newcount = newinfo->max_count;

			// zero count of old armor so it goes away
			other->client->pers.inventory[old_armor_index] = 0;

			// change armor to new item with computed value
			other->client->pers.inventory[ITEM_INDEX(ent->item)] = newcount;
		}
		else
		{
			// calc new armor values
			salvage = newinfo->normal_protection / oldinfo->normal_protection;
			salvagecount = salvage * newinfo->base_count;
			newcount = other->client->pers.inventory[old_armor_index] + salvagecount;
			if (newcount > oldinfo->max_count)
				newcount = oldinfo->max_count;

			// if we're already maxed out then we don't need the new armor
			if (other->client->pers.inventory[old_armor_index] >= newcount)
				return false;

			// update current armor value
			other->client->pers.inventory[old_armor_index] = newcount;
		}
	}

	if (!(ent->spawnflags & DROPPED_ITEM) && (deathmatch->value))
		SetRespawn (ent, 20);


#ifdef WEAP_BALANCE_OK
	//surt limit max armor pickup
	if ((int)ctfflags->value & CTF_WEAP_BALANCE)
	{
		if (other->client->pers.inventory[old_armor_index] > (other->max_health*2))
			other->client->pers.inventory[old_armor_index] = (other->max_health*2);
	}
	//end surt code
#endif

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x330(%rax), %rax
movq 0x70(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x187c0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x330(%rax), %rax
cmpl $0x4, 0x78(%rax)
jne 0x3b6f4
cmpl $0x0, -0x1c(%rbp)
jne 0x3b6d2
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movslq 0x5164f(%rip), %rcx     # 0x8cd14
movl $0x2, 0x318(%rax,%rcx,4)
jmp 0x3b6ef
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl 0x318(%rax,%rcx,4), %edx
addl $0x2, %edx
movl %edx, 0x318(%rax,%rcx,4)
jmp 0x3b8ed
cmpl $0x0, -0x1c(%rbp)
jne 0x3b744
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x330(%rax), %rax
movq 0x4771f(%rip), %rcx     # 0x82e40
subq %rcx, %rax
movl $0x88, %ecx
cqto
idivq %rcx
movl -0x4c(%rbp), %edx
movq %rax, %rcx
movq -0x48(%rbp), %rax
movl %edx, 0x318(%rax,%rcx,4)
jmp 0x3b8eb
movl -0x1c(%rbp), %eax
cmpl 0x515c7(%rip), %eax     # 0x8cd14
jne 0x3b75c
movq 0x471b2(%rip), %rax     # 0x82908
movq %rax, -0x28(%rbp)
jmp 0x3b781
movl -0x1c(%rbp), %eax
cmpl 0x515b3(%rip), %eax     # 0x8cd18
jne 0x3b774
movq 0x475fa(%rip), %rax     # 0x82d68
movq %rax, -0x28(%rbp)
jmp 0x3b77f
movq 0x46e5d(%rip), %rax     # 0x825d8
movq %rax, -0x28(%rbp)
jmp 0x3b781
movq -0x30(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
ucomiss 0x8(%rax), %xmm0
jbe 0x3b854
movq -0x28(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x30(%rbp), %rax
divss 0x8(%rax), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
cvtsi2ssl 0x318(%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0x3b7f6
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl $0x0, 0x318(%rax,%rcx,4)
movl -0x34(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x330(%rax), %rax
movq 0x4760f(%rip), %rcx     # 0x82e40
subq %rcx, %rax
movl $0x88, %ecx
cqto
idivq %rcx
movl -0x5c(%rbp), %edx
movq %rax, %rcx
movq -0x58(%rbp), %rax
movl %edx, 0x318(%rax,%rcx,4)
jmp 0x3b8e9
movq -0x30(%rbp), %rax
movss 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
divss 0x8(%rax), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
movq -0x30(%rbp), %rax
cvtsi2ssl (%rax), %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl 0x318(%rax,%rcx,4), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0x3b8b2
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl 0x318(%rax,%rcx,4), %eax
cmpl -0x34(%rbp), %eax
jl 0x3b8d3
movl $0x0, -0x4(%rbp)
jmp 0x3b934
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, 0x318(%rax,%rcx,4)
jmp 0x3b8eb
jmp 0x3b8ed
movq -0x10(%rbp), %rax
movl 0x140(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
jne 0x3b92d
movq 0x475b8(%rip), %rax     # 0x82ec0
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x3b91c
jp 0x3b91c
jmp 0x3b92d
movq -0x10(%rbp), %rdi
movss 0x352e8(%rip), %xmm0    # 0x70c10
callq 0x19750
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)