// File: /workspace/github_c_makefile_star2_O3/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 0x21bd9(%rip), %rax     # 0x688f8
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
movq %rdi, %rbx
decl %eax
cmpl $0x2, %eax
ja 0x46d43
movl %eax, %eax
leaq 0x12bce(%rip), %rcx     # 0x59908
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x46d4a
leaq 0x10573(%rip), %r14     # 0x572bd
movl $0xc0, %edi
addq 0x58(%rbx), %rdi
leaq 0xb5e6(%rip), %rsi      # 0x52340
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 %eax, %eax
movb %al, 0x410(%rsp)
movb %al, 0x10(%rsp)
movb %al, 0x210(%rsp)
leaq 0xbaec(%rip), %rsi      # 0x52886
movq %r15, %rdi
xorl %eax, %eax
callq 0x18fe0
testl %eax, %eax
je 0x46e33
subq $0x8, %rsp
leaq 0x10(%rsp), %r10
leaq 0x1384e(%rip), %rsi     # 0x5a60a
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 0x46e33
movl $0x616d6566, %eax       # imm = 0x616D6566
xorl 0x10(%rsp), %eax
movl $0x656c61, %ecx         # imm = 0x656C61
xorl 0x13(%rsp), %ecx
orl %eax, %ecx
je 0x46f69
movl $0x656c616d, %eax       # imm = 0x656C616D
xorl 0x10(%rsp), %eax
movzbl 0x14(%rsp), %ecx
orl %eax, %ecx
jne 0x46e33
cmpb $0x6d, 0x6(%rsp)
setne %al
movl 0x8(%rsp), %r12d
leal -0x4(%r12), %ecx
cmpl $-0x3, %ecx
setb %cl
orb %al, %cl
je 0x46fe9
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), %r10d
leal 0x3(%r10), %eax
testl %r10d, %r10d
cmovnsl %r10d, %eax
andl $-0x4, %eax
subl %eax, %r10d
jne 0x46e9b
callq 0x19a10
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
negl %ecx
leal (%rax,%rcx), %r10d
incl %r10d
movl %r10d, 0x8(%rsp)
movsbl 0x7(%rsp), %r9d
movsbl 0x6(%rsp), %r11d
leaq 0x13771(%rip), %rdx     # 0x5a624
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 0x18e10
addq $0x10, %rsp
movq 0x21677(%rip), %rax     # 0x68558
movq %rbx, %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0x8ce2cabd, %ecx, %ebp # imm = 0x8CE2CABD
movq 0x21708(%rip), %rax     # 0x68600
movq 0x30(%rax), %r14
addl $0x51f, %ebp            # imm = 0x51F
movl $0x2c0, %esi            # imm = 0x2C0
addq 0x58(%rbx), %rsi
leaq 0x1429b(%rip), %rdi     # 0x5b1ad
movq %r15, %rdx
xorl %eax, %eax
callq 0x19340
movl %ebp, %edi
movq %rax, %rsi
callq *%r14
leaq 0x210(%rsp), %rax
cmpq %rax, %r15
jne 0x46f57
movl $0xc0, %edi
addq 0x58(%rbx), %rdi
leaq 0xb3ff(%rip), %rsi      # 0x52340
movq %r15, %rdx
callq 0x18560
movq 0x58(%rbx), %rax
movl $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 0x46fe1
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), %r10d
imull $0xaaaaaaab, %r10d, %eax # imm = 0xAAAAAAAB
addl $0x2aaaaaaa, %eax       # imm = 0x2AAAAAAA
cmpl $0x55555554, %eax       # imm = 0x55555554
jbe 0x4707b
movl %r10d, %eax
shrl $0x1f, %eax
addl %r10d, %eax
andl $-0x2, %eax
subl %eax, %r10d
jmp 0x46e9b
movl $0x66, %r13d
jmp 0x46fef
movl $0x6d, %r13d
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 0x47033
cmpl $0x2, %ebp
sete %cl
cmpb $0x62, %al
setne %al
testb %al, %cl
jne 0x47033
leaq 0x410(%rsp), %rdi
movq %r14, %rsi
callq 0x18b20
testl %eax, %eax
je 0x46eda
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 0x135cc(%rip), %rdx     # 0x5a624
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 0x46ed1
callq 0x19a10
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
jmp 0x46e92