// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rsi, %rbp
movq %rdi, %rbx
leaq 0x1eaad(%rip), %rax     # 0x29c96
movb (%rax), %al
cmpb $0x49, %al
leaq 0x14390(%rip), %rdx     # 0x1f584
leaq 0x1438c(%rip), %rcx     # 0x1f587
cmoveq %rdx, %rcx
cmpb $0x42, %al
leaq 0x14379(%rip), %rax     # 0x1f581
cmoveq %rax, %rcx
movzwl (%rcx), %eax
movw %ax, 0x23514(%rip)      # 0x2e72a
movq %rcx, 0x8(%rsp)
movb 0x2(%rcx), %cl
movb %cl, 0x23508(%rip)      # 0x2e72c
movw %ax, 0x234f5(%rip)      # 0x2e720
movb %cl, 0x234f1(%rip)      # 0x2e722
movzbl (%rbp), %r14d
cmpl $0x5c, %r14d
je 0xb2b3
testl %r14d, %r14d
je 0xb5da
cmpb $0x26, %r14b
jne 0xb3c9
leaq 0x22472(%rip), %rax     # 0x2d6c8
cmpl $0x2, (%rax)
je 0xb3c9
cmpb $0x23, 0x1(%rbp)
jne 0xb2fc
callq 0x5340
movq (%rax), %rax
movsbq 0x2(%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xb2fc
movsbq 0x3(%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xb2fc
movsbq 0x4(%rbp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xb2fc
cmpb $0x3b, 0x5(%rbp)
jne 0xb2fc
leaq 0x2(%rbp), %rdi
addq $0x5, %rbp
callq 0x52d0
movl %eax, %r14d
movq %rbp, %rax
jmp 0xb3b2
movq %rbx, %r12
leaq 0x1(%rbp), %r15
movb 0x1(%rbp), %r14b
callq 0x5340
movq (%rax), %rax
movsbq %r14b, %rbx
testb $0x20, 0x1(%rax,%rbx,2)
jne 0xb2ee
movq %rax, 0x10(%rsp)
movsbl %r14b, %r13d
leaq 0x1f8f3(%rip), %rdi     # 0x2abd4
movl %r13d, %esi
callq 0x5120
testq %rax, %rax
je 0xb349
movb $0x20, %r14b
movq %r15, %rbp
movq %r12, %rbx
jmp 0xb5cc
movq 0x1f8dd(%rip), %r12     # 0x2abe0
testq %r12, %r12
je 0xb398
leaq 0x1f8dd(%rip), %r13     # 0x2abf0
movq %r12, %rdi
callq 0x5100
movq %rax, %r15
movq %rbp, %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0xa340
testl %eax, %eax
je 0xb3a0
movq %r13, 0x234d1(%rip)     # 0x2e808
movq (%r13), %r12
addq $0x10, %r13
testq %r12, %r12
jne 0xb313
jmp 0xb3c9
movl %r13d, 0x4(%rsp)
movl %r14d, %eax
andb $-0x8, %al
cmpb $0x30, %al
jne 0xb491
xorl %eax, %eax
xorl %r14d, %r14d
movq %r12, %rbx
movb (%r15,%rax), %cl
movl %ecx, %edx
andb $-0x8, %dl
cmpb $0x30, %dl
jne 0xb38a
shlb $0x3, %r14b
addb %cl, %r14b
addb $-0x30, %r14b
incq %rax
cmpq $0x3, %rax
jne 0xb363
movl $0x3, %eax
movl %eax, %eax
leaq (%r15,%rax), %rbp
decq %rbp
jmp 0xb5cc
movb $0x26, %r14b
jmp 0xb5cc
movslq %r15d, %rax
addq %rbp, %rax
decq %rax
cmpq %rbp, %rax
je 0xb3c9
movb -0x8(%r13), %r14b
cmpb $0x22, %r14b
jne 0xb3c1
movb $0x5c, (%rbx)
incq %rbx
movb $0x22, %r14b
movq %rax, %rbp
jmp 0xb5cc
cmpb $0x3c, %r14b
jne 0xb5cc
movsbl 0x1(%rbp), %eax
movslq %eax, %r12
movl $0x5, %edx
leaq 0x141a4(%rip), %rdi     # 0x1f58a
movl %r12d, %esi
callq 0x51e0
testq %rax, %rax
je 0xb3f9
cmpb $0x3e, 0x2(%rbp)
je 0xb42e
movb $0x3c, %r14b
cmpb $0x2f, %r12b
jne 0xb5cc
movsbl 0x2(%rbp), %esi
movl $0x5, %edx
leaq 0x14174(%rip), %rdi     # 0x1f58a
callq 0x51e0
testq %rax, %rax
je 0xb5cc
cmpb $0x3e, 0x3(%rbp)
jne 0xb5cc
incq %rbp
callq 0x5030
movq (%rax), %rax
movb (%rax,%r12,4), %al
cmpb $0x49, %al
leaq 0x232da(%rip), %rsi     # 0x2e720
leaq 0x14137(%rip), %rcx     # 0x1f584
cmoveq %rcx, %rsi
cmpb $0x42, %al
leaq 0x14127(%rip), %rax     # 0x1f581
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0xa6da
movq %rax, %rbx
cmpb $0x3e, 0x1(%rbp)
leaq 0x1(%rbp), %rbp
jne 0xb469
leaq 0x2224e(%rip), %rax     # 0x2d6c8
cmpl $0x2, (%rax)
movl $0x20, %r14d
movl $0x3e, %eax
cmovel %eax, %r14d
jmp 0xb5cc
callq 0x5330
movq (%rax), %rax
cmpl $0x78, (%rax,%rbx,4)
jne 0xb505
addq $0x2, %rbp
movb $0x1, %cl
xorl %edx, %edx
xorl %eax, %eax
movq %r12, %rbx
movq 0x10(%rsp), %r8
movsbq (%rbp,%rdx), %rdx
testq %rdx, %rdx
je 0xb54a
movzwl (%r8,%rdx,2), %esi
btl $0xc, %esi
jae 0xb54a
btl $0x9, %esi
movl $0xd0, %edi
jae 0xb4db
movl $0xa9, %edi
shlb $0x4, %al
btl $0x8, %esi
movl $0xc9, %esi
cmovbl %esi, %edi
addb %dl, %al
addb %dil, %al
movl $0x1, %edx
testb $0x1, %cl
movl $0x0, %ecx
jne 0xb4b1
movl $0x2, %edx
jmp 0xb561
cmpb $0x66, %r14b
movq %r12, %rbx
jne 0xb56c
leaq 0x221b3(%rip), %rax     # 0x2d6c8
cmpl $0x2, (%rax)
movl $0x20, %r14d
movl $0x3e, %eax
cmovel %eax, %r14d
movzbl 0x2(%rbp), %eax
addq $0x2, %rbp
cmpl $0x4f, %eax
jg 0xb58c
cmpl $0x42, %eax
je 0xb5ae
cmpl $0x49, %eax
jne 0xb5a2
movq %rbx, %rdi
leaq 0x1403c(%rip), %rsi     # 0x1f584
jmp 0xb5c4
movl %ecx, %edx
notb %dl
movzbl %dl, %edx
andl $0x1, %edx
movzbl %r14b, %esi
movzbl %al, %eax
testb $0x1, %cl
cmovnel %esi, %eax
addq %rdx, %rbp
decq %rbp
movl %eax, %r14d
jmp 0xb5cc
leaq 0x1f668(%rip), %rdi     # 0x2abdb
movl 0x4(%rsp), %esi
callq 0x5120
testq %rax, %rax
je 0xb587
movb $0x5c, (%rbx)
incq %rbx
movq %r15, %rbp
jmp 0xb5cc
cmpl $0x50, %eax
je 0xb5ba
cmpl $0x52, %eax
jne 0xb5a2
movq %rbx, %rdi
leaq 0x13fe7(%rip), %rsi     # 0x1f587
jmp 0xb5c4
movb $0x20, (%rbx)
incq %rbx
movb (%rbp), %r14b
jmp 0xb5cc
movq %rbx, %rdi
leaq 0x13fc9(%rip), %rsi     # 0x1f581
jmp 0xb5c4
movq %rbx, %rdi
leaq 0x2315c(%rip), %rsi     # 0x2e720
callq 0xa6da
movq %rax, %rbx
movb %r14b, (%rbx)
incq %rbx
incq %rbp
jmp 0xb231
leaq 0x220e7(%rip), %rax     # 0x2d6c8
cmpl $0x2, (%rax)
jne 0xb60c
movb 0x2313f(%rip), %al      # 0x2e72b
movq 0x8(%rsp), %rcx
cmpb 0x1(%rcx), %al
je 0xb60c
movw $0x2f3c, (%rbx)         # imm = 0x2F3C
movb 0x2312a(%rip), %al      # 0x2e72b
movb %al, 0x2(%rbx)
movb $0x3e, 0x3(%rbx)
addq $0x4, %rbx
movb $0x0, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq