// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/p_client.c
// Function: ClientOldSetSkin
void ClientOldSetSkin(edict_t *ent, char *input)
{
	char	*s;
	//char *color;
	int 	playernum, err;
	
	char	dir[MAX_INFO_STRING], skin[MAX_INFO_STRING], set[MAX_INFO_STRING] ;
	char	color, gender;
	int 	num, dirvalid, skinvalid;
	int 	skinnum;
	char	*curset;
	
	switch ((int)skinset->value)
	{
	default:
	case 0:
		curset = "rb";
		break;
	case 1:
		curset = "lm";
		break;
	case 2:
		curset = "cr";
		break;
	case 3:
		curset = "w";
		break;
	}
	
	// get skin
	//s = input;
	
	//if (!s)
	s = Info_ValueForKey (ent->client->pers.userinfo, "skin");
	
	//initialize memory
	num = -1;
	gender = 'u'; //unassigned
	color = 'u'; //unassigned
	
	skinvalid = 0;
	dirvalid = 0;
	skinnum = 0;
	set[0] = 0;
	dir[0] = 0;
	skin[0] = 0;
	
	// See if we have only specified a skin number
	if (sscanf(s, "%d", &skinnum))
	{
		// First, check if skin matches proper format MJD Suggest Parens
		err = sscanf(s, "%[^/]/%[^-]-%c%c%d", dir, set, &color, &gender, &num);
		if (err)
		{
			// Next, check if gender matches properly
			if (!strcmp(dir, "female"))
			{
				dirvalid = 2;
				// Check if skin is valid, ignoring color
				if (gender == 'f' && num <= 2 && num >= 1)
				{
					skinvalid = 1;
				}
			}
			else if (!strcmp(dir, "male"))
			{
				dirvalid = 1;
				// Check if skin is valid, ignoring color
				if (gender == 'm' && num <= 3 && num >= 1)
				{
					skinvalid = 1;
				}
			}
		}
	}
	
	// If our skin is valid, only change if our color doesn't match
	if (skinvalid)
	{
		// Check if color doesn't match, or skin set is wrong
		if ((ent->client->ctf.teamnum == CTF_TEAM_RED && color != 'r') ||
			(ent->client->ctf.teamnum == CTF_TEAM_BLUE && color != 'b') ||
			strcmp(set, curset))
		{
			color = (ent->client->ctf.teamnum == CTF_TEAM_RED) ? 'r' : 'b';
			Com_sprintf(skin, sizeof skin, "%s/%s-%c%c%d", dir, curset, color, gender, num);
			s = skin;
		}
	}
	else
	{
		// Did we have a valid gender?
		if (!dirvalid || dirvalid == 1)
		{
			strcpy(dir, "male");
			gender = 'm';
			color = (ent->client->ctf.teamnum == CTF_TEAM_RED) ? 'r' : 'b';
			if (!(skinnum % 4))
				num = (rand() % 3) + 1;
			else
				num = skinnum % 4;
		}
		else // female
		{
			strcpy(dir, "female");
			gender = 'f';
			color = (ent->client->ctf.teamnum == CTF_TEAM_RED) ? 'r' : 'b';
			if (!(skinnum % 3))
				num = (rand() % 2) + 1;
			else
				num = skinnum % 2;
		}
		Com_sprintf(skin, sizeof skin, "%s/%s-%c%c%d", dir, curset, color, gender, num);
		s = skin;
	}
	
	playernum = ent-g_edicts-1;
	
	// combine name and skin into a configstring
	gi.configstring (CS_PLAYERSKINS+playernum, va("%s\\%s", ent->client->pers.netname, s) );
	
	if (s == skin)
	{
		Info_SetValueForKey (ent->client->pers.userinfo, "skin", s);
		ent->client->ctf.goodskin = false; // We need to re-force our skin
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x618, %rsp            # imm = 0x618
movq 0x2382a(%rip), %rax     # 0x668f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
movq %rdi, %rbx
decl %eax
cmpl $0x2, %eax
ja 0x430f2
movl %eax, %eax
leaq 0x1280f(%rip), %rcx     # 0x558f8
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x430f9
leaq 0x101a4(%rip), %r14     # 0x5329d
movl $0xc0, %edi
addq 0x58(%rbx), %rdi
leaq 0xb237(%rip), %rsi      # 0x4e340
callq 0x18c70
orl $-0x1, 0x8(%rsp)
movq %rax, %r15
movb $0x75, %al
movb %al, 0x6(%rsp)
movb %al, 0x7(%rsp)
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
xorl %eax, %eax
movb %al, 0x410(%rsp)
movb %al, 0x10(%rsp)
movb %al, 0x210(%rsp)
leaq 0xb743(%rip), %rsi      # 0x4e886
movq %r15, %rdi
xorl %eax, %eax
callq 0x19110
testl %eax, %eax
je 0x431e4
subq $0x8, %rsp
leaq 0x10(%rsp), %r10
leaq 0x13495(%rip), %rsi     # 0x565fa
leaq 0x18(%rsp), %rdx
leaq 0x418(%rsp), %rcx
leaq 0xf(%rsp), %r8
leaq 0xe(%rsp), %r9
movq %r15, %rdi
xorl %eax, %eax
pushq %r10
callq 0x19110
addq $0x10, %rsp
testl %eax, %eax
je 0x431e4
leaq 0x13476(%rip), %rsi     # 0x5660d
leaq 0x10(%rsp), %rdi
pushq $0x7
popq %rdx
callq 0x191e0
testl %eax, %eax
je 0x43300
leaq 0xaecd(%rip), %rsi      # 0x4e080
leaq 0x10(%rsp), %rdi
pushq $0x5
popq %rdx
callq 0x191e0
testl %eax, %eax
jne 0x431e4
cmpb $0x6d, 0x6(%rsp)
setne %al
movl 0x8(%rsp), %r12d
leal -0x4(%r12), %ecx
cmpl $-0x3, %ecx
setb %cl
orb %al, %cl
je 0x4336d
movb $0x0, 0x14(%rsp)
movl $0x656c616d, 0x10(%rsp) # imm = 0x656C616D
movb $0x6d, 0x6(%rsp)
movq 0x58(%rbx), %rax
cmpl $0x1, 0x1100(%rax)
sete %al
shlb $0x4, %al
orb $0x62, %al
movb %al, 0x7(%rsp)
movl 0xc(%rsp), %eax
pushq $0x4
popq %rcx
cltd
idivl %ecx
testl %edx, %edx
je 0x43224
movl %edx, %r10d
movl %edx, 0x8(%rsp)
jmp 0x4323a
callq 0x19bf0
pushq $0x3
popq %rcx
cltd
idivl %ecx
movl %edx, %r10d
incl %r10d
movl %r10d, 0x8(%rsp)
movsbl 0x7(%rsp), %r9d
movsbl 0x6(%rsp), %r11d
leaq 0x133c7(%rip), %rdx     # 0x56614
leaq 0x210(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r14, %r8
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x18f30
addq $0x10, %rsp
movq 0x232dd(%rip), %rcx     # 0x66558
movq %rbx, %rax
subq (%rcx), %rax
movl $0x4a8, %ecx            # imm = 0x4A8
cqto
idivq %rcx
movq 0x2336e(%rip), %rcx     # 0x66600
movq 0x30(%rcx), %r14
leal 0x51f(%rax), %ebp
movl $0x2c0, %esi            # imm = 0x2C0
addq 0x58(%rbx), %rsi
leaq 0x13ec1(%rip), %rdi     # 0x5716d
movq %r15, %rdx
xorl %eax, %eax
callq 0x194e0
movl %ebp, %edi
movq %rax, %rsi
callq *%r14
leaq 0x210(%rsp), %rax
cmpq %rax, %r15
jne 0x432ee
movl $0xc0, %edi
addq 0x58(%rbx), %rdi
leaq 0xb065(%rip), %rsi      # 0x4e340
movq %r15, %rdx
callq 0x185a0
movq 0x58(%rbx), %rax
andl $0x0, 0x110c(%rax)
addq $0x618, %rsp            # imm = 0x618
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x66, 0x6(%rsp)
setne %al
movl 0x8(%rsp), %r12d
leal -0x3(%r12), %ecx
cmpl $-0x2, %ecx
setb %cl
orb %al, %cl
je 0x43369
movl $0x656c61, 0x13(%rsp)   # imm = 0x656C61
movl $0x616d6566, 0x10(%rsp) # imm = 0x616D6566
movb $0x66, 0x6(%rsp)
movq 0x58(%rbx), %rax
cmpl $0x1, 0x1100(%rax)
sete %al
shlb $0x4, %al
orb $0x62, %al
movb %al, 0x7(%rsp)
movl 0xc(%rsp), %ecx
pushq $0x3
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
testl %edx, %edx
je 0x433fd
pushq $0x2
popq %rsi
movl %ecx, %eax
cltd
idivl %esi
jmp 0x4321b
pushq $0x66
jmp 0x4336f
pushq $0x6d
popq %r13
movq 0x58(%rbx), %rax
movl 0x1100(%rax), %ebp
cmpl $0x1, %ebp
sete %cl
movb 0x7(%rsp), %al
cmpb $0x72, %al
setne %dl
testb %dl, %cl
jne 0x433b5
cmpl $0x2, %ebp
sete %cl
cmpb $0x62, %al
setne %al
testb %al, %cl
jne 0x433b5
leaq 0x410(%rsp), %rdi
movq %r14, %rsi
callq 0x18bc0
testl %eax, %eax
je 0x43274
xorl %r9d, %r9d
cmpl $0x1, %ebp
sete %r9b
movl %r9d, %eax
shlb $0x4, %al
orb $0x62, %al
movb %al, 0x7(%rsp)
shll $0x4, %r9d
orl $0x62, %r9d
leaq 0x1323a(%rip), %rdx     # 0x56614
leaq 0x210(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r14, %r8
xorl %eax, %eax
pushq %r12
pushq %r13
jmp 0x4326b
callq 0x19bf0
pushq $0x2
jmp 0x4322b