// File: /workspace/github_c_makefile_star2_O0/neovim[P]libvterm/src/state.c
// Function: on_control
static int on_control(unsigned char control, void *user)
{
  VTermState *state = user;

  VTermPos oldpos = state->pos;

  switch(control) {
  case 0x07: // BEL - ECMA-48 8.3.3
    if(state->callbacks && state->callbacks->bell)
      (*state->callbacks->bell)(state->cbdata);
    break;

  case 0x08: // BS - ECMA-48 8.3.5
    if(state->pos.col > 0)
      state->pos.col--;
    break;

  case 0x09: // HT - ECMA-48 8.3.60
    tab(state, 1, +1);
    break;

  case 0x0a: // LF - ECMA-48 8.3.74
  case 0x0b: // VT
  case 0x0c: // FF
    linefeed(state);
    if(state->mode.newline)
      state->pos.col = 0;
    break;

  case 0x0d: // CR - ECMA-48 8.3.15
    state->pos.col = 0;
    break;

  case 0x0e: // LS1 - ECMA-48 8.3.76
    state->gl_set = 1;
    break;

  case 0x0f: // LS0 - ECMA-48 8.3.75
    state->gl_set = 0;
    break;

  case 0x84: // IND - DEPRECATED but implemented for completeness
    linefeed(state);
    break;

  case 0x85: // NEL - ECMA-48 8.3.86
    linefeed(state);
    state->pos.col = 0;
    break;

  case 0x88: // HTS - ECMA-48 8.3.62
    set_col_tabstop(state, state->pos.col);
    break;

  case 0x8d: // RI - ECMA-48 8.3.104
    if(state->pos.row == state->scrollregion_top) {
      VTermRect rect = {
        .start_row = state->scrollregion_top,
        .end_row   = SCROLLREGION_BOTTOM(state),
        .start_col = SCROLLREGION_LEFT(state),
        .end_col   = SCROLLREGION_RIGHT(state),
      };

      scroll(state, rect, -1, 0);
    }
    else if(state->pos.row > 0)
        state->pos.row--;
    break;

  case 0x8e: // SS2 - ECMA-48 8.3.141
    state->gsingle_set = 2;
    break;

  case 0x8f: // SS3 - ECMA-48 8.3.142
    state->gsingle_set = 3;
    break;

  default:
    if(state->fallbacks && state->fallbacks->control)
      if((*state->fallbacks->control)(control, state->fbdata))
        return 1;

    return 0;
  }

  updatecursor(state, &oldpos, 1);

#ifdef DEBUG
  if(state->pos.row < 0 || state->pos.row >= state->rows ||
     state->pos.col < 0 || state->pos.col >= state->cols) {
    fprintf(stderr, "Position out of bounds after Ctrl %02x: (%d,%d)\n",
        control, state->pos.row, state->pos.col);
    abort();
  }
#endif

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dil, %al
movb %al, -0x5(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
movzbl -0x5(%rbp), %eax
addl $-0x7, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x88, %eax
ja 0xb99a
movq -0x38(%rbp), %rax
leaq 0x7c83(%rip), %rcx      # 0x133cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xb782
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x40(%rax)
je 0xb782
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rdi
callq *%rax
jmp 0xb9e7
movq -0x18(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jle 0xb79e
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x3c(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0xfa80
jmp 0xb9e7
movq -0x18(%rbp), %rdi
callq 0xf4a0
movq -0x18(%rbp), %rax
movw 0xac(%rax), %ax
shrw $0x4, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xb7e7
movq -0x18(%rbp), %rax
movl $0x0, 0x3c(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rax
movl $0x0, 0x3c(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rax
movl $0x1, 0x128(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rax
movl $0x0, 0x128(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rdi
callq 0xf4a0
jmp 0xb9e7
movq -0x18(%rbp), %rdi
callq 0xf4a0
movq -0x18(%rbp), %rax
movl $0x0, 0x3c(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %esi
callq 0xa2a0
jmp 0xb9e7
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jne 0xb95f
movq -0x18(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, -0x30(%rbp)
leaq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x48(%rax)
jle 0xb89e
movq -0x18(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0xb8a8
movq -0x18(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movw 0xac(%rax), %ax
shrw $0xc, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xb8e4
movq -0x18(%rbp), %rax
movl 0x4c(%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0xb8eb
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0xb8eb
movq -0x50(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x30(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movw 0xac(%rax), %ax
shrw $0xc, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xb931
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
jle 0xb931
movq -0x18(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x64(%rbp)
jmp 0xb93b
movq -0x18(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x60(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
callq 0xf600
jmp 0xb978
movq -0x18(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jle 0xb976
movq -0x18(%rbp), %rax
movl 0x38(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x38(%rax)
jmp 0xb978
jmp 0xb9e7
movq -0x18(%rbp), %rax
movl $0x2, 0x130(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rax
movl $0x3, 0x130(%rax)
jmp 0xb9e7
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xb9de
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
cmpq $0x0, (%rax)
je 0xb9de
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movb -0x5(%rbp), %cl
movq -0x18(%rbp), %rdx
movq 0x28(%rdx), %rsi
movzbl %cl, %edi
callq *%rax
cmpl $0x0, %eax
je 0xb9dc
movl $0x1, -0x4(%rbp)
jmp 0xba00
jmp 0xb9de
movl $0x0, -0x4(%rbp)
jmp 0xba00
movq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xf9d0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)