// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x610, %rsp            # imm = 0x610
movq 0x21fdd(%rip), %rax     # 0x698f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
movq %rdi, %rbx
decl %eax
cmpl $0x2, %eax
ja 0x4793f
movl %eax, %eax
leaq 0x12cfa(%rip), %rcx     # 0x5a630
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x47946
leaq 0x1087e(%rip), %r14     # 0x581c4
movl $0xc0, %edi
addq 0x58(%rbx), %rdi
leaq 0xb9ea(%rip), %rsi      # 0x53340
callq 0x18bb0
movq %rax, %r15
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movb $0x75, %al
movb %al, 0x6(%rsp)
movb %al, 0x7(%rsp)
leaq 0xc(%rsp), %rdx
movl $0x0, (%rdx)
xorl %r12d, %r12d
movb %r12b, 0x410(%rsp)
movb %r12b, 0x10(%rsp)
movb %r12b, 0x210(%rsp)
leaq 0xbeec(%rip), %rsi      # 0x53886
movq %r15, %rdi
xorl %eax, %eax
callq 0x18fe0
movb $0x1, %bpl
testl %eax, %eax
je 0x47a1c
subq $0x8, %rsp
leaq 0x10(%rsp), %r10
leaq 0x1398f(%rip), %rsi     # 0x5b34a
xorl %r12d, %r12d
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 0x18fe0
addq $0x10, %rsp
testl %eax, %eax
je 0x47a1c
movl $0x616d6566, %eax       # imm = 0x616D6566
xorl 0x10(%rsp), %eax
movl $0x656c61, %ecx         # imm = 0x656C61
xorl 0x13(%rsp), %ecx
orl %eax, %ecx
je 0x47b31
movl $0x656c616d, %eax       # imm = 0x656C616D
xorl 0x10(%rsp), %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
je 0x47c57
xorl %r12d, %r12d
movb $0x1, %al
testb %al, %al
je 0x47a78
orb %r12b, %bpl
cmpb $0x1, %bpl
jne 0x47adf
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
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $-0x4, %ecx
subl %ecx, %eax
je 0x47b52
movl %eax, 0x8(%rsp)
jmp 0x47b8b
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 0x47abc
cmpl $0x2, %ebp
sete %cl
cmpb $0x62, %al
setne %al
testb %al, %cl
jne 0x47abc
leaq 0x410(%rsp), %rdi
movq %r14, %rsi
callq 0x18b20
testl %eax, %eax
je 0x47bca
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
jmp 0x47b91
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), %eax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
addl $0x2aaaaaaa, %ecx       # imm = 0x2AAAAAAA
cmpl $0x55555554, %ecx       # imm = 0x55555554
jbe 0x47b72
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
subl %ecx, %eax
jmp 0x47b87
cmpb $0x66, 0x6(%rsp)
setne %cl
movl 0x8(%rsp), %eax
addl $-0x3, %eax
cmpl $-0x2, %eax
setb %al
orb %cl, %al
xorl %ebp, %ebp
xorl %r12d, %r12d
jmp 0x47a1e
callq 0x19a20
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
jmp 0x47b81
callq 0x19a20
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
negl %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x8(%rsp)
movsbl 0x7(%rsp), %r9d
movsbl 0x6(%rsp), %r10d
movl 0x8(%rsp), %r11d
leaq 0x137c1(%rip), %rdx     # 0x5b364
leaq 0x210(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r14, %r8
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x18e10
addq $0x10, %rsp
movq 0x21987(%rip), %rax     # 0x69558
movq %rbx, %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x8ce2cabd, %ecx, %ebp # imm = 0x8CE2CABD
movq 0x21a18(%rip), %rax     # 0x69600
movq 0x30(%rax), %r14
addl $0x51f, %ebp            # imm = 0x51F
movl $0x2c0, %esi            # imm = 0x2C0
addq 0x58(%rbx), %rsi
leaq 0x1423b(%rip), %rdi     # 0x5be3d
movq %r15, %rdx
xorl %eax, %eax
callq 0x19340
movl %ebp, %edi
movq %rax, %rsi
callq *%r14
leaq 0x210(%rsp), %rax
cmpq %rax, %r15
jne 0x47c47
movl $0xc0, %edi
addq 0x58(%rbx), %rdi
leaq 0xb70f(%rip), %rsi      # 0x53340
movq %r15, %rdx
callq 0x18560
movq 0x58(%rbx), %rax
movl $0x0, 0x110c(%rax)
addq $0x610, %rsp            # imm = 0x610
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x6d, 0x6(%rsp)
setne %cl
movl 0x8(%rsp), %eax
addl $-0x4, %eax
cmpl $-0x3, %eax
setb %al
orb %cl, %al
movb $0x1, %r12b
xorl %ebp, %ebp
jmp 0x47a1e