// File: /workspace/github_c_makefile_star2_O2/bluecmd[P]fst-example/gtkwave/fstapi.c
// Function: fstUtilityEscToBin
int fstUtilityEscToBin(unsigned char *d, unsigned char *s, int len)
{
unsigned char *src = s;
unsigned char *dst = (!d) ? s : (s = d);
unsigned char val[3];
int i;

for(i=0;i<len;i++)
        {
        if(src[i] != '\\')
                {
                *(dst++) = src[i];
                }
                else
                {
                switch(src[++i])
                        {
                        case 'a':       *(dst++) = '\a'; break;
                        case 'b':       *(dst++) = '\b'; break;
                        case 'f':       *(dst++) = '\f'; break;
                        case 'n':       *(dst++) = '\n'; break;
                        case 'r':       *(dst++) = '\r'; break;
                        case 't':       *(dst++) = '\t'; break;
                        case 'v':       *(dst++) = '\v'; break;
                        case '\'':      *(dst++) = '\''; break;
                        case '\"':      *(dst++) = '\"'; break;
                        case '\\':      *(dst++) = '\\'; break;
                        case '\?':      *(dst++) = '\?'; break;

                        case 'x':       val[0] = toupper(src[++i]);
                                        val[1] = toupper(src[++i]);
                                        val[0] = ((val[0]>='A')&&(val[0]<='F')) ? (val[0] - 'A' + 10) : (val[0] - '0');
                                        val[1] = ((val[1]>='A')&&(val[1]<='F')) ? (val[1] - 'A' + 10) : (val[1] - '0');
                                        *(dst++) = val[0] * 16 + val[1];
                                        break;

                        case '0':
                        case '1':
                        case '2':
                        case '3':
                        case '4':
                        case '5':
                        case '6':
                        case '7':       val[0] = src[  i] - '0';
                                        val[1] = src[++i] - '0';
                                        val[2] = src[++i] - '0';
                                        *(dst++) = val[0] * 64 + val[1] * 8 + val[2];
                                        break;

                        default:        *(dst++) = src[i]; break;
                        }
                }
        }

return(dst - s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
testq %rdi, %rdi
cmoveq %rsi, %r15
xorl %r12d, %r12d
leaq 0x7074(%rip), %rdi      # 0x12220
xorl %ecx, %ecx
cmpl %ebx, %ecx
jge 0xb2c2
movslq %ecx, %r13
movb (%r14,%r13), %al
cmpb $0x5c, %al
jne 0xb227
movb 0x1(%r14,%r13), %al
movzbl %al, %edx
leal -0x30(%rdx), %ecx
cmpl $0x8, %ecx
jb 0xb20c
leaq 0x1(%r13), %rcx
leal -0x6e(%rdx), %esi
cmpl $0xa, %esi
jbe 0xb235
cmpl $0x22, %edx
je 0xb227
cmpl $0x27, %edx
je 0xb227
cmpl $0x3f, %edx
je 0xb227
cmpl $0x5c, %edx
je 0xb227
cmpl $0x61, %edx
je 0xb2bb
cmpl $0x66, %edx
je 0xb2b4
cmpl $0x62, %edx
jne 0xb227
movb $0x8, %al
jmp 0xb227
movb 0x2(%r14,%r13), %cl
shlb $0x6, %al
shlb $0x3, %cl
addb 0x3(%r14,%r13), %al
addq $0x3, %r13
addb %cl, %al
addb $0x50, %al
movl %r13d, %ecx
movb %al, (%r15,%r12)
incl %ecx
incq %r12
jmp 0xb1ae
movslq (%rdi,%rsi,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
movb $0xa, %al
jmp 0xb227
callq 0x2030
movl $0xff, %r8d
leaq 0x6fcc(%rip), %rdi      # 0x12220
movq (%rax), %rcx
movzbl 0x2(%r14,%r13), %eax
movl (%rcx,%rax,4), %eax
movl %eax, %edx
andl %r8d, %edx
movzbl 0x3(%r14,%r13), %esi
addq $0x3, %r13
movl (%rcx,%rsi,4), %ecx
addl $-0x41, %edx
leal -0x30(%rax), %esi
addl $-0x37, %eax
cmpl $0x6, %edx
cmovael %esi, %eax
movl %ecx, %edx
andl %r8d, %edx
addl $-0x41, %edx
leal 0xd0(%rcx), %esi
addl $0xc9, %ecx
cmpl $0x6, %edx
cmovael %esi, %ecx
shll $0x4, %eax
addl %ecx, %eax
jmp 0xb224
movb $0xb, %al
jmp 0xb227
movb $0xd, %al
jmp 0xb227
movb $0x9, %al
jmp 0xb227
movb $0xc, %al
jmp 0xb227
movb $0x7, %al
jmp 0xb227
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq