// File: /workspace/github_c_makefile_star2_O0/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_3/exercise_3_02/escape.c
// Function: unescape
void unescape(char dest[], char src[])
{
  int i, j;
  for (i = j = 0; src[i] != '\0'; ++i, ++j)
  {
    switch (src[i])
    {
    case '\\':
      switch (src[++i])
      {
      case 'a':
        dest[j] = '\a';
        break;

      case 'b':
        dest[j] = '\b';
        break;

      case 'f':
        dest[j] = '\f';
        break;

      case 'n':
        dest[j] = '\n';
        break;

      case 'r':
        dest[j] = '\r';
        break;

      case 't':
        dest[j] = '\t';
        break;

      case 'v':
        dest[j] = '\v';
        break;

      case '\\':
        dest[j] = '\\';
        break;

      case '?':
        dest[j] = '\?';
        break;

      case '\'':
        dest[j] = '\'';
        break;

      case '"':
        dest[j] = '\"';
        break;

      default:
        dest[j++] = '\\';
        dest[j] = src[i];
        break;
      }
      break;

    default:
      dest[j] = src[i];
      break;
    }
  }

  if (src[i] == '\0')
  {
    dest[j] = src[i];
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x1674
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb (%rax,%rcx), %al
subb $0x5c, %al
jne 0x1645
jmp 0x1534
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rax
movl %eax, %edx
incl %edx
movl %edx, -0x14(%rbp)
movsbl 0x1(%rax,%rcx), %eax
addl $-0x22, %eax
movl %eax, %ecx
movq %rcx, -0x20(%rbp)
subl $0x54, %eax
ja 0x1617
movq -0x20(%rbp), %rax
leaq 0xbf7(%rip), %rcx       # 0x215c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x7, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x8, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0xc, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0xa, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0xd, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x9, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0xb, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x5c, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x3f, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x27, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb $0x22, (%rax,%rcx)
jmp 0x1643
movq -0x8(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x18(%rbp)
movslq %ecx, %rcx
movb $0x5c, (%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x165b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x165d
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x150a
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x169b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
popq %rbp
retq