// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_rune_string_to_char_string
char* ce_rune_string_to_char_string(const CeRune_t* int_str){
     // build length
     size_t len = 1; // account for NULL terminator
     const int* int_itr = int_str;
     while(*int_itr){
          if(isprint(*int_itr)){
               len++;
          }else{
               switch(*int_itr){
               default:
                    if(*int_itr >= 1 && *int_itr <= 31){
                         len += 3;
                    }else{
                         len++; // going to fill in with '~' for now
                    }
                    break;
               case KEY_ONLY_BACKSPACE:
               case KEY_ESCAPE:
               case KEY_CARRIAGE_RETURN:
               case CE_TAB:
               case KEY_UP_ARROW:
               case KEY_DOWN_ARROW:
               case KEY_LEFT_ARROW:
               case KEY_RIGHT_ARROW:
               case '\\':
                    len += 2;
                    break;
               case KEY_REDO:
                    len += 3;
                    break;
               }
          }

          int_itr++;
     }

     char* char_str = malloc(len);
     if(!char_str) return NULL;

     char* char_itr = char_str;
     int_itr = int_str;
     while(*int_itr){
          if(isprint(*int_itr)){
               *char_itr = *int_itr;
               char_itr++;
          }else{
               switch(*int_itr){
               default:
                    if(*int_itr >= 1 && *int_itr <= 26){
                         *char_itr = '\\'; char_itr++;
                         *char_itr = '^'; char_itr++;
                         *char_itr = 'a' + (*int_itr - 1); char_itr++;
                    }else if(*int_itr == 27){
                         *char_itr = '\\'; char_itr++;
                         *char_itr = '^'; char_itr++;
                         *char_itr = '['; char_itr++;
                    }else if(*int_itr == 28){
                         *char_itr = '\\'; char_itr++;
                         *char_itr = '^'; char_itr++;
                         *char_itr = '\\'; char_itr++;
                    }else if(*int_itr == 29){
                         *char_itr = '\\'; char_itr++;
                         *char_itr = '^'; char_itr++;
                         *char_itr = ']'; char_itr++;
                    }else if(*int_itr == 30){
                         *char_itr = '\\'; char_itr++;
                         *char_itr = '^'; char_itr++;
                         *char_itr = '^'; char_itr++;
                    }else if(*int_itr == 31){
                         *char_itr = '\\'; char_itr++;
                         *char_itr = '^'; char_itr++;
                         *char_itr = '_'; char_itr++;
                    }else{
                         *char_itr = '~';
                         char_itr++;
                    }
                    break;
               case KEY_ONLY_BACKSPACE:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 'b'; char_itr++;
                    break;
               case KEY_ESCAPE:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 'e'; char_itr++;
                    break;
               case KEY_CARRIAGE_RETURN:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 'r'; char_itr++;
                    break;
               case CE_TAB:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 't'; char_itr++;
                    break;
               case KEY_UP_ARROW:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 'u'; char_itr++;
                    break;
               case KEY_DOWN_ARROW:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 'd'; char_itr++;
                    break;
               case KEY_LEFT_ARROW:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 'l'; char_itr++;
                    break;
               case KEY_RIGHT_ARROW:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = 'i'; char_itr++; // NOTE: not happy with 'i'
                    break;
               case KEY_REDO:
                    *char_itr = '\\'; char_itr++;
                    *char_itr = '^'; char_itr++;
                    *char_itr = 'r'; char_itr++;
                    break;
               case '\\':
                    *char_itr = '\\'; char_itr++;
                    *char_itr = '\\'; char_itr++;
                    break;
               }
          }

          int_itr++;
     }

     char_str[len - 1] = 0;

     return char_str;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rdi), %r15d
testl %r15d, %r15d
je 0x10447
callq 0xd720
movq (%rax), %rax
leaq 0x4(%rbx), %rcx
movl $0x1, %r14d
movslq %r15d, %rdx
testb $0x40, 0x1(%rax,%rdx,2)
movl $0x1, %edx
jne 0x103f6
movl $0x2, %edx
cmpl $0x101, %r15d           # imm = 0x101
jle 0x10407
leal -0x102(%r15), %esi
cmpl $0x5, %esi
ja 0x1041b
cmpl $0x4, %esi
je 0x1041b
addq %rdx, %r14
movl (%rcx), %r15d
addq $0x4, %rcx
testl %r15d, %r15d
jne 0x103c8
jmp 0x1044d
cmpl $0x9, %r15d
je 0x103f6
cmpl $0x1b, %r15d
je 0x103f6
cmpl $0x5c, %r15d
je 0x103f6
jmp 0x10434
cmpl $0x157, %r15d           # imm = 0x157
je 0x103f6
cmpl $0x173, %r15d           # imm = 0x173
jne 0x10434
movl $0x3, %edx
jmp 0x103f6
xorl %edx, %edx
cmpl $0x20, %r15d
setb %dl
leaq 0x1(,%rdx,2), %rdx
jmp 0x103f6
movl $0x1, %r14d
movq %r14, %rdi
callq 0xd4c0
testq %rax, %rax
je 0x105bd
movq %rax, %r15
movl (%rbx), %r12d
testl %r12d, %r12d
je 0x105b5
callq 0xd720
addq $0x4, %rbx
leaq 0x1db9f(%rip), %rcx     # 0x2e01c
leaq 0x1db80(%rip), %rdx     # 0x2e004
movq %r15, %rsi
movq (%rax), %rdi
movslq %r12d, %r8
testb $0x40, 0x1(%rdi,%r8,2)
jne 0x104be
cmpl $0x101, %r12d           # imm = 0x101
jle 0x104c9
leal -0x102(%r12), %edi
cmpl $0x5, %edi
ja 0x104e2
movslq (%rdx,%rdi,4), %rdi
addq %rdx, %rdi
jmpq *%rdi
movw $0x645c, (%rsi)         # imm = 0x645C
jmp 0x10547
movb %r12b, (%rsi)
incq %rsi
jmp 0x1054b
cmpl $0x9, %r12d
je 0x10534
cmpl $0x1b, %r12d
je 0x1053b
cmpl $0x5c, %r12d
jne 0x104ff
movw $0x5c5c, (%rsi)         # imm = 0x5C5C
jmp 0x10547
cmpl $0x157, %r12d           # imm = 0x157
je 0x10542
cmpl $0x173, %r12d           # imm = 0x173
jne 0x104ff
movw $0x5e5c, (%rsi)         # imm = 0x5E5C
movb $0x72, 0x2(%rsi)
jmp 0x10512
cmpl $0x1a, %r12d
ja 0x1055d
movw $0x5e5c, (%rsi)         # imm = 0x5E5C
orb $0x60, %r12b
movb %r12b, 0x2(%rsi)
addq $0x3, %rsi
jmp 0x1054b
movw $0x625c, (%rsi)         # imm = 0x625C
jmp 0x10547
movw $0x755c, (%rsi)         # imm = 0x755C
jmp 0x10547
movw $0x695c, (%rsi)         # imm = 0x695C
jmp 0x10547
movw $0x6c5c, (%rsi)         # imm = 0x6C5C
jmp 0x10547
movw $0x745c, (%rsi)         # imm = 0x745C
jmp 0x10547
movw $0x655c, (%rsi)         # imm = 0x655C
jmp 0x10547
movw $0x725c, (%rsi)         # imm = 0x725C
addq $0x2, %rsi
movl (%rbx), %r12d
addq $0x4, %rbx
testl %r12d, %r12d
jne 0x10487
jmp 0x105b5
addl $-0x1b, %r12d
cmpl $0x4, %r12d
ja 0x105ad
movslq (%rcx,%r12,4), %rdi
addq %rcx, %rdi
jmpq *%rdi
movw $0x5e5c, (%rsi)         # imm = 0x5E5C
movb $0x5b, 0x2(%rsi)
jmp 0x10512
movw $0x5e5c, (%rsi)         # imm = 0x5E5C
movb $0x5f, 0x2(%rsi)
jmp 0x10512
movw $0x5e5c, (%rsi)         # imm = 0x5E5C
movb $0x5d, 0x2(%rsi)
jmp 0x10512
movw $0x5e5c, (%rsi)         # imm = 0x5E5C
movb $0x5e, 0x2(%rsi)
jmp 0x10512
movw $0x5e5c, (%rsi)         # imm = 0x5E5C
movb $0x5c, 0x2(%rsi)
jmp 0x10512
movb $0x7e, (%rsi)
jmp 0x104c1
movb $0x0, -0x1(%r15,%r14)
jmp 0x105c0
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq