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

for(i=0;i<len;i++)
        {
        switch(src[i])
                {
                case '\a':      *(dst++) = '\\'; *(dst++) = 'a'; break;
                case '\b':      *(dst++) = '\\'; *(dst++) = 'b'; break;
                case '\f':      *(dst++) = '\\'; *(dst++) = 'f'; break;
                case '\n':      *(dst++) = '\\'; *(dst++) = 'n'; break;
                case '\r':      *(dst++) = '\\'; *(dst++) = 'r'; break;
                case '\t':      *(dst++) = '\\'; *(dst++) = 't'; break;
                case '\v':      *(dst++) = '\\'; *(dst++) = 'v'; break;
                case '\'':      *(dst++) = '\\'; *(dst++) = '\''; break;
                case '\"':      *(dst++) = '\\'; *(dst++) = '\"'; break;
                case '\\':      *(dst++) = '\\'; *(dst++) = '\\'; break;
                case '\?':      *(dst++) = '\\'; *(dst++) = '\?'; break;
                default:        if((src[i] > ' ') && (src[i] <= '~')) /* no white spaces in output */
                                        {
                                        *(dst++) = src[i];
                                        }
                                        else
                                        {
                                        val = src[i];
                                        *(dst++) = '\\';
                                        *(dst++) = (val/64) + '0'; val = val & 63;
                                        *(dst++) = (val/8)  + '0'; val = val & 7;
                                        *(dst++) = (val) + '0';
                                        }
                                break;
                }
        }

return(dst - d);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
leaq 0xc25a(%rip), %r8       # 0x12140
movq %rdi, %rax
cmpq %rcx, %rdx
je 0x5fc6
movb (%rsi,%rcx), %r9b
movzbl %r9b, %r10d
leal -0x7(%r10), %r11d
cmpl $0x6, %r11d
ja 0x5f15
movslq (%r8,%r11,4), %r9
addq %r8, %r9
jmpq *%r9
movw $0x615c, (%rax)         # imm = 0x615C
jmp 0x5f71
cmpl $0x22, %r10d
je 0x5f3b
cmpl $0x27, %r10d
je 0x5f57
cmpl $0x3f, %r10d
je 0x5f5e
cmpl $0x5c, %r10d
jne 0x5f7d
movw $0x5c5c, (%rax)         # imm = 0x5C5C
jmp 0x5f71
movw $0x765c, (%rax)         # imm = 0x765C
jmp 0x5f71
movw $0x225c, (%rax)         # imm = 0x225C
jmp 0x5f71
movw $0x745c, (%rax)         # imm = 0x745C
jmp 0x5f71
movw $0x6e5c, (%rax)         # imm = 0x6E5C
jmp 0x5f71
movw $0x625c, (%rax)         # imm = 0x625C
jmp 0x5f71
movw $0x275c, (%rax)         # imm = 0x275C
jmp 0x5f71
movw $0x3f5c, (%rax)         # imm = 0x3F5C
jmp 0x5f71
movw $0x665c, (%rax)         # imm = 0x665C
jmp 0x5f71
movw $0x725c, (%rax)         # imm = 0x725C
addq $0x2, %rax
incq %rcx
jmp 0x5ee9
leal -0x21(%r9), %r10d
cmpb $0x5d, %r10b
ja 0x5f8f
movb %r9b, (%rax)
incq %rax
jmp 0x5f75
movb $0x5c, (%rax)
movl %r9d, %r10d
shrb $0x6, %r10b
orb $0x30, %r10b
movb %r10b, 0x1(%rax)
movl %r9d, %r10d
shrb $0x3, %r10b
andb $0x7, %r10b
orb $0x30, %r10b
movb %r10b, 0x2(%rax)
andb $0x7, %r9b
orb $0x30, %r9b
movb %r9b, 0x3(%rax)
addq $0x4, %rax
jmp 0x5f75
subl %edi, %eax
popq %rbp
retq