// File: /workspace/github_c_makefile_star2_O0/sguerrini97[P]ps3linux-ps3vuart-tools/util/util.c
// Function: parse_hex
int
parse_hex(const char *s, unsigned char *b, int maxlen)
{
	int len;
	char c;
	int i;

	len = strlen(s);
	if (len % 2)
		return (-1);

	for (i = 0; (i < (len / 2)) && (i < maxlen); i++) {
		if (!isxdigit(s[2 * i + 0]) || !isxdigit(s[2 * i + 1]))
			return (-1);

		b[i] = 0;

		c = tolower(s[2 * i + 0]);
		if (isdigit(c))
			b[i] += (c - '0') * 16;
		else
			b[i] += (c - 'a' + 10) * 16;

		c = tolower(s[2 * i + 1]);
		if (isdigit(c))
			b[i] += c - '0';
		else
			b[i] += c - 'a' + 10;
	}

	return (i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2050
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x552b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x56c9
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movl -0x20(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x29(%rbp)
jge 0x5557
movl -0x28(%rbp), %eax
cmpl -0x1c(%rbp), %eax
setl %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x5563
jmp 0x56c3
callq 0x2140
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl -0x28(%rbp), %edx
shll %edx
addl $0x0, %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x55bb
callq 0x2140
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movl -0x28(%rbp), %edx
shll %edx
addl $0x1, %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
jne 0x55c7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x56c9
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
shll %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edi
callq 0x20e0
movb %al, -0x21(%rbp)
callq 0x2140
movq (%rax), %rax
movsbl -0x21(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x5628
movsbl -0x21(%rbp), %esi
subl $0x30, %esi
shll $0x4, %esi
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x5646
movsbl -0x21(%rbp), %esi
subl $0x61, %esi
addl $0xa, %esi
shll $0x4, %esi
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edi
callq 0x20e0
movb %al, -0x21(%rbp)
callq 0x2140
movq (%rax), %rax
movsbl -0x21(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x5698
movsbl -0x21(%rbp), %esi
subl $0x30, %esi
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x56b3
movsbl -0x21(%rbp), %esi
subl $0x61, %esi
addl $0xa, %esi
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
jmp 0x56b5
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x5532
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)