// File: /workspace/github_c_makefile_star2_O3/Cotix[P]cReddit/libreddit/token.c
// Function: redditParseEscCodesGeneric
static void *redditParseEscCodesGeneric (const void *text, int len, int wide)
{
    struct charParser parser;

    if (len == 0)
        return NULL;

    parser.wide = wide;
    parser.text = text;
    parser.cur = 0;
    parser.offset = 0;

    if (wide)
        parser.new_text = rmalloc((len + 1) * sizeof(wchar_t));
    else
        parser.new_text = rmalloc((len + 1) * sizeof(char));

    for (parser.cur = 0; parser.cur < len; parser.cur++)
        parseChar(&parser);

    if (wide)
        ((wchar_t*)(parser.new_text))[parser.offset] = L'\0';
    else
        ((char*)(parser.new_text))[parser.offset] = '\0';

    return parser.new_text;
}

// Assembly:
testl %esi, %esi
je 0x4ed5
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r15
movslq %esi, %rax
leaq 0x1(%rax), %rcx
testl %edx, %edx
leaq 0x4(,%rax,4), %rdi
cmoveq %rcx, %rdi
callq 0x3520
movq %rax, %rdx
xorl %r13d, %r13d
testl %ebp, %ebp
jle 0x4ec7
movdqa 0x15e5(%rip), %xmm0     # 0x6340
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
punpcklwd %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3]
movdqa %xmm0, 0x20(%rsp)
pshufd $0xf5, 0x160e(%rip), %xmm0 # xmm0 = mem[1,1,3,3]
movdqa %xmm0, 0x10(%rsp)
xorl %r12d, %r12d
movq %r15, 0x8(%rsp)
movslq %r13d, %rax
movsbl (%r15,%rax), %edi
cmpl $0x5c, %edi
jne 0x4dc4
movzbl 0x1(%r15,%rax), %ecx
incq %rax
cmpl $0x22, %ecx
je 0x4e94
cmpl $0x75, %ecx
je 0x4df7
cmpl $0x6e, %ecx
jne 0x4eb7
movslq %r12d, %rcx
testl %ebx, %ebx
je 0x4eb0
movl $0xa, (%rdx,%rcx,4)
jmp 0x4eb4
movslq %r12d, %r14
testl %ebx, %ebx
je 0x4dee
movl %ebp, %r15d
movl %ebx, %ebp
movq %rdx, %rbx
callq 0x21d0
movq %rbx, %rdx
movl %ebp, %ebx
movl %r15d, %ebp
movq 0x8(%rsp), %r15
movl %eax, (%rdx,%r14,4)
jmp 0x4e8c
movb %dil, (%rdx,%r14)
jmp 0x4e8c
testl %ebx, %ebx
je 0x4ea4
movd 0x1(%r15,%rax), %xmm0
punpcklbw %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3],xmm1[4],xmm0[4],xmm1[5],xmm0[5],xmm1[6],xmm0[6],xmm1[7],xmm0[7]
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
punpcklwd %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3]
movdqa 0x20(%rsp), %xmm2
pcmpgtb %xmm0, %xmm2
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
psrad $0x18, %xmm0
movdqa %xmm0, %xmm1
paddd 0x151f(%rip), %xmm1     # 0x6350
pand 0x1527(%rip), %xmm0     # 0x6360
paddd 0x152f(%rip), %xmm0     # 0x6370
pand %xmm2, %xmm1
pandn %xmm0, %xmm2
por %xmm1, %xmm2
pshufd $0xf5, %xmm2, %xmm0     # xmm0 = xmm2[1,1,3,3]
pmuludq 0x1526(%rip), %xmm2     # 0x6380
pshufd $0xe8, %xmm2, %xmm1     # xmm1 = xmm2[0,2,2,3]
pmuludq 0x10(%rsp), %xmm0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
por %xmm1, %xmm0
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
por %xmm0, %xmm1
addl $0x5, %r13d
movslq %r12d, %rax
movd %xmm1, (%rdx,%rax,4)
incl %r12d
movl %r13d, %eax
jmp 0x4eb7
movslq %r12d, %rcx
testl %ebx, %ebx
je 0x4eaa
movl $0x22, (%rdx,%rcx,4)
jmp 0x4eb4
addl $0x5, %r13d
jmp 0x4e8f
movb $0x22, (%rdx,%rcx)
jmp 0x4eb4
movb $0xa, (%rdx,%rcx)
incl %r12d
incl %eax
movl %eax, %r13d
cmpl %ebp, %eax
jl 0x4d80
movslq %r12d, %r13
testl %ebx, %ebx
je 0x4ed9
movl $0x0, (%rdx,%r13,4)
jmp 0x4ede
xorl %edx, %edx
jmp 0x4eec
movb $0x0, (%rdx,%r13)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movq %rdx, %rax
retq