// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_char_string_to_rune_string
CeRune_t* ce_char_string_to_rune_string(const char* char_str){
     // we can just use the strlen, and it'll be over allocated because the command string will always be
     // the same size or small than the char string
     size_t str_len = strlen(char_str);

     int* int_str = malloc((str_len + 1) * sizeof(*int_str));
     if(!int_str) return NULL;

     int* int_itr = int_str;
     const char* char_itr = char_str;
     while(*char_itr){
          if(!isprint((int)(*char_itr))){
               free(int_str);
               ce_log("found unprintable char at position %d %d\n", char_itr - char_str, *char_itr);
               return NULL;
          }

          if(*char_itr == '\\'){
               char_itr++;
               switch(*char_itr){
               default:
                    ce_log("unrecognized escape char %c\n", *char_itr);
                    free(int_str);
                    return NULL;
               case 'b':
                    *int_itr = KEY_ONLY_BACKSPACE;
                    break;
               case 'e':
                    *int_itr = KEY_ESCAPE;
                    break;
               case 'r':
                    *int_itr = KEY_CARRIAGE_RETURN;
                    break;
               case 't':
                    *int_itr = CE_TAB;
                    break;
               case 'u':
                    *int_itr = KEY_UP_ARROW;
                    break;
               case 'd':
                    *int_itr = KEY_DOWN_ARROW;
                    break;
               case 'l':
                    *int_itr = KEY_LEFT_ARROW;
                    break;
               case 'i':
                    *int_itr = KEY_RIGHT_ARROW;
                    break;
               case '\\':
                    *int_itr = '\\';
                    break;
               case '^':
                    char_itr++;
                    if(*char_itr >= 'a' && *char_itr <= 'z'){
                         if(*char_itr == 'r'){
                              *int_itr = KEY_REDO;
                         }else{
                              *int_itr = (*char_itr - 'a') + 1;
                         }
                    }else if(*char_itr == '['){
                         *int_itr = 27;
                    }else if(*char_itr == '\\'){
                         *int_itr = 28;
                    }else if(*char_itr == ']'){
                         *int_itr = 29;
                    }else if(*char_itr == '^'){
                         *int_itr = 30;
                    }else if(*char_itr == '_'){
                         *int_itr = 31;
                    }
                    break;
               }

               char_itr++;
               int_itr++;
          }else{
               *int_itr = *char_itr;
               char_itr++;
               int_itr++;
          }
     }

     *int_itr = 0; // NULL terminate

     return int_str;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0xd210
leaq 0x4(,%rax,4), %rdi
callq 0xd4c0
testq %rax, %rax
je 0x1078c
movq %rax, %rbx
movb (%r14), %bpl
movq %rax, %rcx
testb %bpl, %bpl
je 0x10746
callq 0xd720
movq (%rax), %rax
leaq 0x1da53(%rip), %rdx     # 0x2e068
leaq 0x1da14(%rip), %rsi     # 0x2e030
leaq 0x1da6d(%rip), %rdi     # 0x2e090
movq %r14, %r15
movq %rbx, %rcx
movsbq %bpl, %r8
testb $0x40, 0x1(%rax,%r8,2)
je 0x1074e
cmpb $0x5c, %bpl
jne 0x10667
leaq 0x1(%r15), %r9
movzbl 0x1(%r15), %r8d
leal -0x5c(%r8), %r10d
cmpl $0xd, %r10d
ja 0x10670
movslq (%rsi,%r10,4), %r10
addq %rsi, %r10
jmpq *%r10
movl $0x5c, %r8d
jmp 0x106ee
movsbl %bpl, %r8d
jmp 0x106f1
leal -0x6c(%r8), %r10d
cmpl $0x9, %r10d
ja 0x10772
movslq (%rdx,%r10,4), %r10
addq %rdx, %r10
jmpq *%r10
movl $0x104, %r8d            # imm = 0x104
jmp 0x106ee
movl $0x102, %r8d            # imm = 0x102
jmp 0x106ee
movl $0x105, %r8d            # imm = 0x105
jmp 0x106ee
movzbl 0x2(%r15), %r9d
addq $0x2, %r15
leal -0x61(%r9), %r8d
cmpb $0x19, %r8b
ja 0x1070a
movl $0x173, %r8d            # imm = 0x173
cmpl $0x72, %r9d
je 0x106f1
addl $-0x60, %r9d
movl %r9d, %r8d
jmp 0x106f1
movl $0x107, %r8d            # imm = 0x107
jmp 0x106ee
movl $0x1b, %r8d
jmp 0x106ee
movl $0x103, %r8d            # imm = 0x103
jmp 0x106ee
movl $0x157, %r8d            # imm = 0x157
jmp 0x106ee
movl $0x9, %r8d
movq %r9, %r15
movl %r8d, (%rcx)
addq $0x4, %rcx
movb 0x1(%r15), %bpl
incq %r15
testb %bpl, %bpl
jne 0x10629
jmp 0x10746
addl $-0x5b, %r9d
cmpl $0x4, %r9d
ja 0x106f4
movslq (%rdi,%r9,4), %r8
addq %rdi, %r8
jmpq *%r8
movl $0x1b, %r8d
jmp 0x106f1
movl $0x1f, %r8d
jmp 0x106f1
movl $0x1d, %r8d
jmp 0x106f1
movl $0x1e, %r8d
jmp 0x106f1
movl $0x1c, %r8d
jmp 0x106f1
movl $0x0, (%rcx)
jmp 0x1078e
movq %rbx, %rdi
callq 0xd090
movsbl (%r15), %edx
subq %r14, %r15
leaq 0x1e0ba(%rip), %rdi     # 0x2e81e
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0xd954
jmp 0x1078e
movsbl %r8b, %esi
leaq 0x1e0cb(%rip), %rdi     # 0x2e848
xorl %eax, %eax
callq 0xd954
movq %rbx, %rdi
callq 0xd090
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq