// File: /workspace/github_c_makefile_star2_O2/msteveb[P]autosetup/./jimsh0.c
// Function: JimEscape
static int JimEscape(char *dest, const char *s, int slen)
{
    char *p = dest;
    int i, len;

    for (i = 0; i < slen; i++) {
        switch (s[i]) {
            case '\\':
                switch (s[i + 1]) {
                    case 'a':
                        *p++ = 0x7;
                        i++;
                        break;
                    case 'b':
                        *p++ = 0x8;
                        i++;
                        break;
                    case 'f':
                        *p++ = 0xc;
                        i++;
                        break;
                    case 'n':
                        *p++ = 0xa;
                        i++;
                        break;
                    case 'r':
                        *p++ = 0xd;
                        i++;
                        break;
                    case 't':
                        *p++ = 0x9;
                        i++;
                        break;
                    case 'u':
                    case 'U':
                    case 'x':
                        {
                            unsigned val = 0;
                            int k;
                            int maxchars = 2;

                            i++;

                            if (s[i] == 'U') {
                                maxchars = 8;
                            }
                            else if (s[i] == 'u') {
                                if (s[i + 1] == '{') {
                                    maxchars = 6;
                                    i++;
                                }
                                else {
                                    maxchars = 4;
                                }
                            }

                            for (k = 0; k < maxchars; k++) {
                                int c = xdigitval(s[i + k + 1]);
                                if (c == -1) {
                                    break;
                                }
                                val = (val << 4) | c;
                            }

                            if (s[i] == '{') {
                                if (k == 0 || val > 0x1fffff || s[i + k + 1] != '}') {

                                    i--;
                                    k = 0;
                                }
                                else {

                                    k++;
                                }
                            }
                            if (k) {

                                if (s[i] == 'x') {
                                    *p++ = val;
                                }
                                else {
                                    p += utf8_fromunicode(p, val);
                                }
                                i += k;
                                break;
                            }

                            *p++ = s[i];
                        }
                        break;
                    case 'v':
                        *p++ = 0xb;
                        i++;
                        break;
                    case '\0':
                        *p++ = '\\';
                        i++;
                        break;
                    case '\n':

                        *p++ = ' ';
                        do {
                            i++;
                        } while (s[i + 1] == ' ' || s[i + 1] == '\t');
                        break;
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':

                        {
                            int val = 0;
                            int c = odigitval(s[i + 1]);

                            val = c;
                            c = odigitval(s[i + 2]);
                            if (c == -1) {
                                *p++ = val;
                                i++;
                                break;
                            }
                            val = (val * 8) + c;
                            c = odigitval(s[i + 3]);
                            if (c == -1) {
                                *p++ = val;
                                i += 2;
                                break;
                            }
                            val = (val * 8) + c;
                            *p++ = val;
                            i += 3;
                        }
                        break;
                    default:
                        *p++ = s[i + 1];
                        i++;
                        break;
                }
                break;
            default:
                *p++ = s[i];
                break;
        }
    }
    len = p - dest;
    *p = '\0';
    return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r14d
movq %rsi, %r15
leaq 0x1(%rsi), %r10
leaq 0x2(%rsi), %r11
xorl %eax, %eax
leaq 0xcfd1(%rip), %rbx      # 0x23220
movq %rdi, %r12
cmpl %r14d, %eax
jge 0x164aa
movslq %eax, %rcx
movb (%r15,%rcx), %dl
cmpb $0x5c, %dl
jne 0x162cc
leaq 0x1(%rcx), %rax
movb 0x1(%r15,%rcx), %sil
movzbl %sil, %r8d
leal -0x30(%r8), %edx
cmpl $0x8, %edx
jb 0x162d2
leal -0x6e(%r8), %edx
cmpl $0xa, %edx
jbe 0x16320
testl %r8d, %r8d
je 0x16467
cmpl $0xa, %r8d
je 0x16447
cmpl $0x55, %r8d
je 0x16388
cmpl $0x66, %r8d
je 0x1643d
cmpl $0x62, %r8d
je 0x16433
cmpl $0x61, %r8d
jne 0x16347
movb $0x7, (%r12)
jmp 0x1633d
movb %dl, (%r12)
jmp 0x1633d
movsbl 0x2(%r15,%rcx), %esi
movl %esi, %r8d
andl $-0x8, %r8d
cmpl $0x30, %r8d
setne %r9b
addl $-0x30, %esi
cmpl $-0x1, %esi
sete %r8b
orb %r9b, %r8b
jne 0x16339
leal (%rsi,%rdx,8), %edx
movsbl 0x3(%r15,%rcx), %eax
movl %eax, %esi
andl $-0x8, %esi
cmpl $0x30, %esi
setne %sil
addl $-0x30, %eax
cmpl $-0x1, %eax
sete %r8b
orb %sil, %r8b
je 0x16330
addq $0x2, %rcx
jmp 0x16337
movslq (%rbx,%rdx,4), %rdx
addq %rbx, %rdx
jmpq *%rdx
movb $0xa, (%r12)
jmp 0x1633d
addq $0x3, %rcx
leal (%rax,%rdx,8), %edx
movl %ecx, %eax
movb %dl, (%r12)
incq %r12
incl %eax
jmp 0x16252
movb %sil, (%r12)
jmp 0x1633d
movl %eax, %r13d
pushq $0x2
jmp 0x1638d
movb $0x9, (%r12)
jmp 0x1633d
movb $0xd, (%r12)
jmp 0x1633d
leaq 0x2(%rcx), %r13
xorl %edx, %edx
cmpb $0x7b, 0x2(%r15,%rcx)
sete %dl
cmovnel %eax, %r13d
leal 0x4(,%rdx,2), %ecx
movslq %r13d, %rax
jmp 0x1638e
movb $0xb, (%r12)
jmp 0x1633d
movl %eax, %r13d
pushq $0x8
popq %rcx
movl %ecx, %ecx
leaq (%r10,%rax), %rdx
xorl %ebx, %ebx
xorl %esi, %esi
cmpq %rbx, %rcx
je 0x163d8
movsbl (%rdx,%rbx), %r9d
leal -0x30(%r9), %r8d
cmpl $0xa, %r8d
jb 0x163cd
leal -0x61(%r9), %r8d
cmpl $0x5, %r8d
ja 0x163bc
addl $-0x57, %r9d
jmp 0x163ca
leal -0x47(%r9), %r8d
cmpl $-0x6, %r8d
jb 0x163da
addl $-0x37, %r9d
movl %r9d, %r8d
shll $0x4, %esi
orl %r8d, %esi
incq %rbx
jmp 0x16398
movl %ecx, %ebx
movb (%r15,%rax), %al
cmpb $0x7b, %al
jne 0x1640b
testl %ebx, %ebx
je 0x1641c
cmpl $0x1fffff, %esi         # imm = 0x1FFFFF
ja 0x1641c
leal (%rbx,%r13), %eax
cltq
cmpb $0x7d, (%r10,%rax)
jne 0x1641c
movq %r11, -0x30(%rbp)
movq %r10, -0x38(%rbp)
movq %rdi, -0x40(%rbp)
incl %ebx
jmp 0x1647d
testl %ebx, %ebx
je 0x16427
cmpb $0x78, %al
jne 0x16471
movb %sil, (%r12)
incq %r12
jmp 0x16499
movslq %r13d, %r13
movb -0x1(%r15,%r13), %al
decq %r13
movb %al, (%r12)
incq %r12
movl %r13d, %eax
jmp 0x1649e
movb $0x8, (%r12)
jmp 0x1633d
movb $0xc, (%r12)
jmp 0x1633d
movb $0x20, (%r12)
addq %r11, %rcx
movzbl (%rcx), %edx
cmpl $0x20, %edx
je 0x16460
cmpl $0x9, %edx
jne 0x1633d
incq %rcx
incl %eax
jmp 0x1644f
movb $0x5c, (%r12)
jmp 0x1633d
movq %r11, -0x30(%rbp)
movq %r10, -0x38(%rbp)
movq %rdi, -0x40(%rbp)
movq %r12, %rdi
callq 0x10c08
movl %eax, %eax
addq %r12, %rax
movq %rax, %r12
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %r10
movq -0x30(%rbp), %r11
addl %r13d, %ebx
movl %ebx, %eax
leaq 0xcd7b(%rip), %rbx      # 0x23220
jmp 0x16340
movl %r12d, %eax
subl %edi, %eax
movb $0x0, (%r12)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq