// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_items.c
// Function: PrecacheItem
void PrecacheItem (gitem_t *it)
{
	char	*s, *start;
	char	data[MAX_QPATH];
	int		len;
	gitem_t	*ammo;

	if (!it)
		return;

	if (it->pickup_sound)
		gi.soundindex (it->pickup_sound);
	if (it->world_model)
		gi.modelindex (it->world_model);
	if (it->view_model)
		gi.modelindex (it->view_model);
	if (it->icon)
		gi.imageindex (it->icon);

	// parse everything for its ammo
	if (it->ammo && it->ammo[0])
	{
		ammo = FindItem (it->ammo);
		if (ammo != it)
			PrecacheItem (ammo);
	}

	// parse the space seperated precache string for other items
	s = it->precaches;
	if (!s || !s[0])
		return;

	while (*s)
	{
		start = s;
		while (*s && *s != ' ')
			s++;

		len = s-start;
		if (len >= MAX_QPATH - 1 || len < 5)
			gi.error ("PrecacheItem: %s has bad precache string", it->classname);
		memcpy (data, start, len);
		data[len] = 0;
		if (*s)
			s++;

		// determine type based on extension
		if (!strcmp(data+len-3, "md2"))
			gi.modelindex (data);
		else if (!strcmp(data+len-3, "sp2"))
			gi.modelindex (data);
		else if (!strcmp(data+len-3, "wav"))
			gi.soundindex (data);
		if (!strcmp(data+len-3, "pcx"))
			gi.imageindex (data);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, (%rsp)
testq %rdi, %rdi
je 0x2f236
movq (%rsp), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x2f0aa
movq 0x37559(%rip), %rax     # 0x66600
callq *0x48(%rax)
movq (%rsp), %rax
movq 0x30(%rax), %rdi
testq %rdi, %rdi
je 0x2f0c1
movq 0x37542(%rip), %rax     # 0x66600
callq *0x40(%rax)
movq (%rsp), %rax
movq 0x40(%rax), %rdi
testq %rdi, %rdi
je 0x2f0d8
movq 0x3752b(%rip), %rax     # 0x66600
callq *0x40(%rax)
movq (%rsp), %rax
movq 0x48(%rax), %rdi
testq %rdi, %rdi
je 0x2f0ef
movq 0x37514(%rip), %rax     # 0x66600
callq *0x50(%rax)
movq (%rsp), %rax
movq 0x60(%rax), %rdi
testq %rdi, %rdi
je 0x2f114
cmpb $0x0, (%rdi)
je 0x2f114
callq 0x18a80
cmpq (%rsp), %rax
je 0x2f114
movq %rax, %rdi
callq 0x187f0
movq (%rsp), %rax
movq 0x80(%rax), %rbx
testq %rbx, %rbx
je 0x2f236
movb (%rbx), %al
testb %al, %al
je 0x2f236
movb $0x1, %cl
movq 0x374c5(%rip), %rdx     # 0x66600
leaq 0x10(%rsp), %r15
leaq 0x40(%rdx), %r12
addq $0x48, %rdx
movq %rdx, 0x8(%rsp)
movabsq $0x100000000, %r13      # imm = 0x100000000
testb %cl, %cl
je 0x2f236
pushq $-0x3f
popq %rcx
xorl %r14d, %r14d
movq %rbx, %rbp
testb $-0x21, %al
je 0x2f179
movb 0x1(%rbp), %al
incq %rbp
addq %r13, %r14
incl %ecx
jmp 0x2f168
cmpl $-0x3b, %ecx
ja 0x2f198
movq (%rsp), %rax
movq (%rax), %rsi
leaq 0x22f0d(%rip), %rdi     # 0x52099
xorl %eax, %eax
movq 0x3746b(%rip), %rcx     # 0x66600
callq *0x38(%rcx)
sarq $0x20, %r14
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x18d60
movb $0x0, 0x10(%rsp,%r14)
cmpb $0x1, (%rbp)
sbbq $-0x1, %rbp
leaq 0xd(%rsp), %rax
addq %rax, %r14
movq %r14, %rdi
leaq 0x203b4(%rip), %rsi     # 0x4f57e
callq 0x18bc0
movq %r12, %rcx
testl %eax, %eax
je 0x2f204
movq %r14, %rdi
leaq 0x20aee(%rip), %rsi     # 0x4fcce
callq 0x18bc0
movq %r12, %rcx
testl %eax, %eax
je 0x2f204
movq %r14, %rdi
leaq 0x20927(%rip), %rsi     # 0x4fb1d
callq 0x18bc0
movq 0x8(%rsp), %rcx
testl %eax, %eax
jne 0x2f209
movq %r15, %rdi
callq *(%rcx)
movq %r14, %rdi
leaq 0x22eaf(%rip), %rsi     # 0x520c2
callq 0x18bc0
testl %eax, %eax
jne 0x2f229
movq %r15, %rdi
movq 0x373da(%rip), %rax     # 0x66600
callq *0x50(%rax)
movb (%rbp), %al
movl %eax, %ecx
movq %rbp, %rbx
jmp 0x2f157
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq