// File: /workspace/github_c_makefile_star2_O0/neovim[P]libvterm/src/state.c
// Function: on_escape
static int on_escape(const char *bytes, size_t len, void *user)
{
  VTermState *state = user;

  /* Easier to decode this from the first byte, even though the final
   * byte terminates it
   */
  switch(bytes[0]) {
  case ' ':
    if(len != 2)
      return 0;

    switch(bytes[1]) {
      case 'F': // S7C1T
        state->vt->mode.ctrl8bit = 0;
        break;

      case 'G': // S8C1T
        state->vt->mode.ctrl8bit = 1;
        break;

      default:
        return 0;
    }
    return 2;

  case '#':
    if(len != 2)
      return 0;

    switch(bytes[1]) {
      case '3': // DECDHL top
        if(state->mode.leftrightmargin)
          break;
        set_lineinfo(state, state->pos.row, NO_FORCE, DWL_ON, DHL_TOP);
        break;

      case '4': // DECDHL bottom
        if(state->mode.leftrightmargin)
          break;
        set_lineinfo(state, state->pos.row, NO_FORCE, DWL_ON, DHL_BOTTOM);
        break;

      case '5': // DECSWL
        if(state->mode.leftrightmargin)
          break;
        set_lineinfo(state, state->pos.row, NO_FORCE, DWL_OFF, DHL_OFF);
        break;

      case '6': // DECDWL
        if(state->mode.leftrightmargin)
          break;
        set_lineinfo(state, state->pos.row, NO_FORCE, DWL_ON, DHL_OFF);
        break;

      case '8': // DECALN
      {
        VTermPos pos;
        uint32_t E[] = { 'E', 0 };
        for(pos.row = 0; pos.row < state->rows; pos.row++)
          for(pos.col = 0; pos.col < ROWWIDTH(state, pos.row); pos.col++)
            putglyph(state, E, 1, pos);
        break;
      }

      default:
        return 0;
    }
    return 2;

  case '(': case ')': case '*': case '+': // SCS
    if(len != 2)
      return 0;

    {
      int setnum = bytes[0] - 0x28;
      VTermEncoding *newenc = vterm_lookup_encoding(ENC_SINGLE_94, bytes[1]);

      if(newenc) {
        state->encoding[setnum].enc = newenc;

        if(newenc->init)
          (*newenc->init)(newenc, state->encoding[setnum].data);
      }
    }

    return 2;

  case '7': // DECSC
    savecursor(state, 1);
    return 1;

  case '8': // DECRC
    savecursor(state, 0);
    return 1;

  case '<': // Ignored by VT100. Used in VT52 mode to switch up to VT100
    return 1;

  case '=': // DECKPAM
    state->mode.keypad = 1;
    return 1;

  case '>': // DECKPNM
    state->mode.keypad = 0;
    return 1;

  case 'c': // RIS - ECMA-48 8.3.105
  {
    VTermPos oldpos = state->pos;
    vterm_state_reset(state, 1);
    if(state->callbacks && state->callbacks->movecursor)
      (*state->callbacks->movecursor)(state->pos, oldpos, state->mode.cursor_visible, state->cbdata);
    return 1;
  }

  case 'n': // LS2 - ECMA-48 8.3.78
    state->gl_set = 2;
    return 1;

  case 'o': // LS3 - ECMA-48 8.3.80
    state->gl_set = 3;
    return 1;

  case '~': // LS1R - ECMA-48 8.3.77
    state->gr_set = 1;
    return 1;

  case '}': // LS2R - ECMA-48 8.3.79
    state->gr_set = 2;
    return 1;

  case '|': // LS3R - ECMA-48 8.3.81
    state->gr_set = 3;
    return 1;

  default:
    return 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
addl $-0x20, %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x5e, %eax
ja 0xbecb
movq -0x58(%rbp), %rax
leaq 0x7ba0(%rip), %rcx      # 0x135f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x2, -0x18(%rbp)
je 0xba6c
movl $0x0, -0x4(%rbp)
jmp 0xbed2
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, -0x5c(%rbp)
subl $0x46, %eax
je 0xba88
jmp 0xba7e
movl -0x5c(%rbp), %eax
subl $0x47, %eax
je 0xba9d
jmp 0xbab2
movq -0x28(%rbp), %rax
movq (%rax), %rax
movb 0x18(%rax), %cl
andb $-0x3, %cl
orb $0x0, %cl
movb %cl, 0x18(%rax)
jmp 0xbabe
movq -0x28(%rbp), %rax
movq (%rax), %rax
movb 0x18(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x18(%rax)
jmp 0xbabe
movl $0x0, -0x4(%rbp)
jmp 0xbed2
movl $0x2, -0x4(%rbp)
jmp 0xbed2
cmpq $0x2, -0x18(%rbp)
je 0xbadd
movl $0x0, -0x4(%rbp)
jmp 0xbed2
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
addl $-0x33, %eax
movl %eax, %ecx
movq %rcx, -0x68(%rbp)
subl $0x5, %eax
ja 0xbcaa
movq -0x68(%rbp), %rax
leaq 0x7c6a(%rip), %rcx      # 0x1376c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
movw 0xac(%rax), %ax
shrw $0xc, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xbb2b
jmp 0xbcb6
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x38(%rax), %esi
xorl %edx, %edx
movl $0x1, %r8d
movl %r8d, %ecx
callq 0xa320
jmp 0xbcb6
movq -0x28(%rbp), %rax
movw 0xac(%rax), %ax
shrw $0xc, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xbb6b
jmp 0xbcb6
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x38(%rax), %esi
xorl %edx, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xa320
jmp 0xbcb6
movq -0x28(%rbp), %rax
movw 0xac(%rax), %ax
shrw $0xc, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xbbad
jmp 0xbcb6
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x38(%rax), %esi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0xa320
jmp 0xbcb6
movq -0x28(%rbp), %rax
movw 0xac(%rax), %ax
shrw $0xc, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xbbeb
jmp 0xbcb6
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x38(%rax), %esi
xorl %r8d, %r8d
movl $0x1, %ecx
movl %r8d, %edx
callq 0xa320
jmp 0xbcb6
movq 0x7d3a(%rip), %rax      # 0x1394c
movq %rax, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0xbca8
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x28(%rbp), %rax
movq 0x70(%rax), %rax
movslq -0x30(%rbp), %rcx
movb (%rax,%rcx,4), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0xbc63
movq -0x28(%rbp), %rax
movl 0x34(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x70(%rbp)
jmp 0xbc6d
movq -0x28(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
movl -0x70(%rbp), %ecx
cmpl %ecx, %eax
jge 0xbc98
movq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rcx
movl $0x1, %edx
callq 0xf3c0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xbc30
jmp 0xbc9a
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xbc1d
jmp 0xbcb6
movl $0x0, -0x4(%rbp)
jmp 0xbed2
movl $0x2, -0x4(%rbp)
jmp 0xbed2
cmpq $0x2, -0x18(%rbp)
je 0xbcd5
movl $0x0, -0x4(%rbp)
jmp 0xbed2
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
subl $0x28, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, %edi
movsbl 0x1(%rax), %esi
callq 0x2140
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xbd4e
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
addq $0xb0, %rax
movslq -0x3c(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
cmpq $0x0, (%rax)
je 0xbd4c
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0xb0, %rsi
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rsi
addq $0x8, %rsi
callq *%rax
jmp 0xbd4e
movl $0x2, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0xfb90
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0xfb90
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movw 0xac(%rax), %cx
andw $-0x2, %cx
orw $0x1, %cx
movw %cx, 0xac(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movw 0xac(%rax), %cx
andw $-0x2, %cx
orw $0x0, %cx
movw %cx, 0xac(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x2110
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xbe4f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0xbe4f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rsi
movq -0x28(%rbp), %rcx
movw 0xac(%rcx), %cx
shrw $0x5, %cx
andw $0x1, %cx
movzwl %cx, %edx
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq 0x38(%rsi), %rdi
movq -0x50(%rbp), %rsi
callq *%rax
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movl $0x2, 0x128(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movl $0x3, 0x128(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movl $0x1, 0x12c(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movl $0x2, 0x12c(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movq -0x28(%rbp), %rax
movl $0x3, 0x12c(%rax)
movl $0x1, -0x4(%rbp)
jmp 0xbed2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)