// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %rbx
testq %rdi, %rdi
cmoveq %rsi, %rbx
movq %rbx, %r12
testl %edx, %edx
jle 0xca68
movl %edx, %r14d
movq %rsi, %r15
xorl %ecx, %ecx
leaq 0x88d5(%rip), %rdi      # 0x15220
movq %rbx, %r12
movslq %ecx, %r13
movb (%r15,%r13), %al
cmpb $0x5c, %al
jne 0xc98d
leaq 0x1(%r13), %rcx
movb 0x1(%r15,%r13), %al
movzbl %al, %edx
cmpl $0x3e, %edx
jg 0xc9a0
leal -0x30(%rdx), %esi
cmpl $0x8, %esi
jae 0xc9cd
movb 0x2(%r15,%r13), %cl
shlb $0x6, %al
shlb $0x3, %cl
addb 0x3(%r15,%r13), %al
addq $0x3, %r13
addb %cl, %al
addb $0x50, %al
movl %r13d, %ecx
movb %al, (%r12)
incq %r12
incl %ecx
cmpl %r14d, %ecx
jl 0xc94e
jmp 0xca68
cmpl $0x61, %edx
jg 0xc9b8
cmpl $0x3f, %edx
je 0xc98d
cmpl $0x5c, %edx
je 0xc98d
cmpl $0x61, %edx
jne 0xc98d
movb $0x7, %al
jmp 0xc98d
leal -0x6e(%rdx), %esi
cmpl $0xa, %esi
ja 0xc9d7
movslq (%rdi,%rsi,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
movb $0xa, %al
jmp 0xc98d
cmpl $0x22, %edx
je 0xc98d
cmpl $0x27, %edx
jmp 0xc98d
cmpl $0x66, %edx
je 0xca61
cmpl $0x62, %edx
jne 0xc98d
movb $0x8, %al
jmp 0xc98d
callq 0x2030
movl $0xff, %r8d
leaq 0x8825(%rip), %rdi      # 0x15220
movq (%rax), %rcx
movzbl 0x2(%r15,%r13), %eax
movl (%rcx,%rax,4), %eax
movl %eax, %edx
andl %r8d, %edx
movzbl 0x3(%r15,%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 0xc98a
movb $0xd, %al
jmp 0xc98d
movb $0xb, %al
jmp 0xc98d
movb $0x9, %al
jmp 0xc98d
movb $0xc, %al
jmp 0xc98d
subl %ebx, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq