// File: /workspace/github_c_makefile_star2_O1/mmayer[P]pcal/src/pcalutil.c
// Function: cvt_escape
void cvt_escape (char *obuf, char *ibuf)
{
   char c, c2, *po, *pi, *p, *dfltfont;
   static char whitespace[] = "abnrtv"; /* see ANSI spec, 2.2.2 */
   static char no_cvt[] = "\"'\\";
   
   dfltfont = fontstyle[0] == BOLD   ? BOLD_FONT :
      fontstyle[0] == ITALIC ? ITALIC_FONT :
      ROMAN_FONT ;

   strcpy(currfont, dfltfont);   /* defaults for font style */
   strcpy(prevfont, dfltfont);
   
   for (po = obuf, pi = ibuf; (c = *pi) != '\0'; *po++ = c, pi++) {

      /* handle escape sequences here:
        
          escaped whitespace and ANSI escapes (except \f) are all converted to
          a single space;

          octal and hex constants are converted in place;

          escaped single/double quotes are left escaped for loadwords() to
          handle later on;
        
          if the output is PostScript:

            \f[BIR] is converted to " .[bir] ";
            \fP is converted to the previous " .[bir] ";
            <[BI]> is converted to " .[bi] ";
            </[BI]> is converted to the previous " .[bir] "
        
          if the output is HTML:

            \f[BI] is converted to "<[BI]>";
            \f[PR] is converted to the previous "</[BI]>";
            <[BI]> and </[BI]> are copied intact

       */
      if (c == '\\') {
         c2 = *++pi;
         if (isspace((int)c2) || strchr(whitespace, c2)) {
            c = ' ';
         }
         else if (isodigit(c2)) {   /* octal */
            pi = octal_esc(pi, &c);
         }
         else if (tolower(c2) == 'x') {   /* hex */
            pi = hex_esc(pi, &c);
         }
         else if (c2 == 'f') {   /* \f[BIPR] */
            c = output_type == OUTPUT_HTML ? '>' : ' ';
            if (*++pi == BOLD) po = set_fontstyle(po, BOLD_FONT);
            else if (*pi == ITALIC) po = set_fontstyle(po, ITALIC_FONT);
            else if (*pi == PREVFONT) po = set_fontstyle(po, prevfont);
            else if (*pi == ROMAN) po = set_fontstyle(po, ROMAN_FONT);
            else {   /* unrecognized \f escape */
               *po++ = ' ';
               c = *pi;
            }
         }
         else {
            if (strchr(no_cvt, c2)) *po++ = c;   /* leave escaped */
            c = c2;
         }
      }
      else if (output_type != OUTPUT_HTML && (p = html_esc(pi, &c2)) != pi) {
         /* convert special HTML character back to ASCII */
         pi = p;
         if (c2 == '"') *po++ = '\\';
         c = c2;
      }
      else if (HTML_ESCAPE(pi)) {
         /* convert HTML escape to PostScript */
         c2 = *++pi;
         if ((c2 = toupper(c2)) == BOLD) po = set_fontstyle(po, BOLD_FONT);
         else if (c2 == ITALIC) po = set_fontstyle(po, ITALIC_FONT);
         else po = set_fontstyle(po, prevfont); /* </[BI]> */

         while ((c = *++pi) != '>')
            ;

         c = output_type == OUTPUT_HTML ? '>' : ' ';
      }
   }
   
   /* if generating HTML, reset font at end of line if necessary */
   if (output_type == OUTPUT_HTML && currfont[1] != dfltfont[1]) {
      *po++ = '<';
      *po++ = '/';
      *po++ = currfont[1];
      *po++ = '>';
   }
   *po = '\0';

   return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbp
movq %rdi, %r12
leaq 0x1e07c(%rip), %rax     # 0x28c96
movb (%rax), %al
cmpb $0x49, %al
leaq 0x138e8(%rip), %rdx     # 0x1e50d
leaq 0x138e4(%rip), %rcx     # 0x1e510
cmoveq %rdx, %rcx
cmpb $0x42, %al
leaq 0x138d1(%rip), %rax     # 0x1e50a
cmoveq %rax, %rcx
movzwl (%rcx), %eax
movw %ax, 0x22ae3(%rip)      # 0x2d72a
movq %rcx, 0x20(%rsp)
movb 0x2(%rcx), %cl
movb %cl, 0x22ad7(%rip)      # 0x2d72c
movw %ax, 0x22ac4(%rip)      # 0x2d720
movb %cl, 0x22ac0(%rip)      # 0x2d722
movzbl (%rbp), %r15d
cmpl $0x5c, %r15d
je 0xac8a
leaq 0x21a54(%rip), %rax     # 0x2c6c8
testl %r15d, %r15d
je 0xb07f
cmpl $0x2, (%rax)
jne 0xacf1
movl %r14d, %r8d
jmp 0xae2b
movl %r15d, 0x14(%rsp)
leaq 0x1(%rbp), %rbx
movb 0x1(%rbp), %r14b
callq 0x5340
movl %r14d, %r8d
movq (%rax), %rax
movsbq %r14b, %r13
movb $0x20, %r14b
testb $0x20, 0x1(%rax,%r13,2)
jne 0xadce
movq %rax, 0x18(%rsp)
movq %r12, 0x8(%rsp)
movsbl %r8b, %r15d
leaq 0x1ef0a(%rip), %rdi     # 0x29bd4
movl %r15d, %esi
movl %r8d, %r12d
callq 0x5120
testq %rax, %rax
je 0xadd6
movq %rbx, %rbp
movq 0x8(%rsp), %rax
movl %r12d, %r8d
movq %rax, %r12
jmp 0xaef7
movq %r12, 0x8(%rsp)
movl %r15d, 0x14(%rsp)
cmpb $0x26, %r15b
jne 0xadac
cmpb $0x23, 0x1(%rbp)
jne 0xad4f
callq 0x5340
movq (%rax), %rax
movsbq 0x2(%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xad4f
movsbq 0x3(%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xad4f
movsbq 0x4(%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xad4f
cmpb $0x3b, 0x5(%rbp)
jne 0xad4f
leaq 0x2(%rbp), %rdi
leaq 0x5(%rbp), %rbx
callq 0x52d0
movl %eax, %r14d
jmp 0xadb3
movq 0x1ee8a(%rip), %r12     # 0x29be0
testq %r12, %r12
je 0xadac
leaq -0x1(%rbp), %rax
movq %rax, 0x18(%rsp)
leaq 0x1ee85(%rip), %r13     # 0x29bf0
movq %r12, %rdi
callq 0x5100
movq %rax, %r15
movq %rbp, %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0x9d60
testl %eax, %eax
jne 0xad94
movb -0x8(%r13), %r14b
movslq %r15d, %rbx
addq 0x18(%rsp), %rbx
testl %eax, %eax
je 0xadb3
movq %r13, 0x22a69(%rip)     # 0x2d808
movq (%r13), %r12
addq $0x10, %r13
testq %r12, %r12
jne 0xad6b
movb (%rbp), %r14b
movq %rbp, %rbx
cmpq %rbp, %rbx
movq 0x8(%rsp), %r12
je 0xae23
cmpb $0x22, %r14b
jne 0xadcb
movb $0x5c, (%r12)
incq %r12
movl %r14d, %r8d
movq %rbx, %rbp
jmp 0xaef7
movl %r12d, %eax
andb $-0x8, %al
cmpb $0x30, %al
movl %r12d, %r8d
jne 0xaf09
xorl %eax, %eax
xorl %r14d, %r14d
movq 0x8(%rsp), %r12
movb (%rbx,%rax), %cl
movl %ecx, %edx
andb $-0x8, %dl
cmpb $0x30, %dl
jne 0xae15
addb $-0x30, %cl
movzbl %cl, %ecx
leal (%rcx,%r14,8), %r14d
incq %rax
cmpq $0x3, %rax
jne 0xadf0
movl $0x3, %eax
movl %eax, %eax
leaq (%rbx,%rax), %rbp
decq %rbp
jmp 0xaef7
movl %r14d, %r8d
movl 0x14(%rsp), %r15d
cmpb $0x3c, (%rbp)
jne 0xaeec
movl %r8d, %ebx
movsbl 0x1(%rbp), %eax
movslq %eax, %r14
movl $0x5, %edx
leaq 0x136c8(%rip), %rdi     # 0x1e513
movl %r14d, %esi
callq 0x51e0
testq %rax, %rax
je 0xae5e
cmpb $0x3e, 0x2(%rbp)
je 0xae88
cmpb $0x2f, %r14b
jne 0xaef1
movsbl 0x2(%rbp), %esi
movl $0x5, %edx
leaq 0x1369b(%rip), %rdi     # 0x1e513
callq 0x51e0
testq %rax, %rax
je 0xaef1
cmpb $0x3e, 0x3(%rbp)
jne 0xaef1
incq %rbp
callq 0x5030
movq (%rax), %rax
movb (%rax,%r14,4), %cl
cmpb $0x49, %cl
leaq 0x2287f(%rip), %rsi     # 0x2d720
leaq 0x13665(%rip), %rax     # 0x1e50d
cmoveq %rax, %rsi
movl %ecx, %ebx
cmpb $0x42, %cl
leaq 0x13652(%rip), %rax     # 0x1e50a
cmoveq %rax, %rsi
movq %r12, %rdi
callq 0xa0f9
movq %rax, %r12
cmpb $0x3e, 0x1(%rbp)
leaq 0x1(%rbp), %rbp
jne 0xaec7
leaq 0x217f0(%rip), %rax     # 0x2c6c8
cmpl $0x2, (%rax)
movl $0x20, %r14d
movl $0x3e, %eax
cmovel %eax, %r14d
jmp 0xaef4
movl %r15d, %r14d
jmp 0xaef7
movl %r15d, %r14d
movl %ebx, %r8d
movb %r14b, (%r12)
incq %r12
incq %rbp
movl %r8d, %r14d
jmp 0xac62
movb %r8b, 0x7(%rsp)
callq 0x5330
movq (%rax), %rax
cmpl $0x78, (%rax,%r13,4)
jne 0xaf95
addq $0x2, %rbp
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x8(%rsp), %r12
movl $0xffffffc9, %r8d       # imm = 0xFFFFFFC9
movq 0x18(%rsp), %r9
movsbl (%rbp,%rax), %edx
testl %edx, %edx
je 0xaf79
movslq %edx, %rsi
movzwl (%r9,%rsi,2), %esi
btl $0xc, %esi
jae 0xaf79
btl $0x9, %esi
movl $0xffffffd0, %edi       # imm = 0xFFFFFFD0
jae 0xaf5c
movl $0xffffffa9, %edi       # imm = 0xFFFFFFA9
shll $0x4, %ecx
btl $0x8, %esi
cmovbl %r8d, %edi
addl %edx, %ecx
addl %edi, %ecx
incq %rax
cmpq $0x1, %rax
je 0xaf35
movl $0x2, %eax
testl %eax, %eax
movb 0x7(%rsp), %r8b
movzbl %r8b, %r14d
cmovnel %ecx, %r14d
movl %eax, %eax
addq %rax, %rbp
decq %rbp
jmp 0xaef7
movb 0x7(%rsp), %r8b
cmpb $0x66, %r8b
jne 0xafe8
leaq 0x21721(%rip), %rax     # 0x2c6c8
cmpl $0x2, (%rax)
movl $0x20, %r14d
movl $0x3e, %eax
cmovel %eax, %r14d
movzbl 0x2(%rbp), %eax
addq $0x2, %rbp
cmpl $0x4f, %eax
jg 0xb019
cmpl $0x42, %eax
movq 0x8(%rsp), %r12
je 0xb05a
cmpl $0x49, %eax
jne 0xb049
movq %r12, %rdi
leaq 0x1352a(%rip), %rsi     # 0x1e50d
jmp 0xb070
leaq 0x1ebec(%rip), %rdi     # 0x29bdb
movl %r15d, %esi
callq 0x5120
testq %rax, %rax
je 0xb034
movq 0x8(%rsp), %r12
movl 0x14(%rsp), %eax
movb %al, (%r12)
incq %r12
movb 0x7(%rsp), %r8b
movl %r8d, %r14d
jmp 0xadce
cmpl $0x50, %eax
movq 0x8(%rsp), %r12
je 0xb066
cmpl $0x52, %eax
jne 0xb049
movq %r12, %rdi
leaq 0x134de(%rip), %rsi     # 0x1e510
jmp 0xb070
movb 0x7(%rsp), %r8b
movl %r8d, %r14d
movq %rbx, %rbp
movq 0x8(%rsp), %r12
jmp 0xaef7
movb $0x20, (%r12)
incq %r12
movb (%rbp), %r14b
jmp 0xaef7
movq %r12, %rdi
leaq 0x134a6(%rip), %rsi     # 0x1e50a
jmp 0xb070
movq %r12, %rdi
leaq 0x226b0(%rip), %rsi     # 0x2d720
callq 0xa0f9
movb 0x7(%rsp), %r8b
jmp 0xace9
cmpl $0x2, (%rax)
jne 0xb0b0
movb 0x226a1(%rip), %al      # 0x2d72b
movq 0x20(%rsp), %rcx
cmpb 0x1(%rcx), %al
je 0xb0b0
movw $0x2f3c, (%r12)         # imm = 0x2F3C
movb 0x2268a(%rip), %al      # 0x2d72b
movb %al, 0x2(%r12)
movb $0x3e, 0x3(%r12)
addq $0x4, %r12
movb $0x0, (%r12)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq