// File: /workspace/github_c_makefile_star2_O2/neovim[P]libvterm/src/state.c
// Function: vterm_state_reset
void vterm_state_reset(VTermState *state, int hard)
{
  state->scrollregion_top = 0;
  state->scrollregion_bottom = -1;
  state->scrollregion_left = 0;
  state->scrollregion_right = -1;

  state->mode.keypad          = 0;
  state->mode.cursor          = 0;
  state->mode.autowrap        = 1;
  state->mode.insert          = 0;
  state->mode.newline         = 0;
  state->mode.alt_screen      = 0;
  state->mode.origin          = 0;
  state->mode.leftrightmargin = 0;
  state->mode.bracketpaste    = 0;
  state->mode.report_focus    = 0;

  state->mouse_flags = 0;

  state->vt->mode.ctrl8bit   = 0;

  for(int col = 0; col < state->cols; col++)
    if(col % 8 == 0)
      set_col_tabstop(state, col);
    else
      clear_col_tabstop(state, col);

  for(int row = 0; row < state->rows; row++)
    set_lineinfo(state, row, FORCE, DWL_OFF, DHL_OFF);

  if(state->callbacks && state->callbacks->initpen)
    (*state->callbacks->initpen)(state->cbdata);

  vterm_state_resetpen(state);

  VTermEncoding *default_enc = state->vt->mode.utf8 ?
      vterm_lookup_encoding(ENC_UTF8,      'u') :
      vterm_lookup_encoding(ENC_SINGLE_94, 'B');

  for(int i = 0; i < 4; i++) {
    state->encoding[i].enc = default_enc;
    if(default_enc->init)
      (*default_enc->init)(default_enc, state->encoding[i].data);
  }

  state->gl_set = 0;
  state->gr_set = 1;
  state->gsingle_set = 0;

  state->protected_cell = 0;

  // Initialise the props
  settermprop_bool(state, VTERM_PROP_CURSORVISIBLE, 1);
  settermprop_bool(state, VTERM_PROP_CURSORBLINK,   1);
  settermprop_int (state, VTERM_PROP_CURSORSHAPE,   VTERM_PROP_CURSORSHAPE_BLOCK);

  if(hard) {
    state->pos.row = 0;
    state->pos.col = 0;
    state->at_phantom = 0;

    VTermRect rect = { 0, state->rows, 0, state->cols };
    erase(state, rect, 0);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movaps 0x4716(%rip), %xmm0     # 0xa680
movups %xmm0, 0x44(%rdi)
movl $0xffff89e0, %eax       # imm = 0xFFFF89E0
andl 0xac(%rdi), %eax
orl $0x4, %eax
movw %ax, 0xac(%rdi)
andl $0x0, 0x84(%rdi)
movq (%rdi), %rax
andb $-0x3, 0x18(%rax)
xorl %r14d, %r14d
cmpl 0x34(%rbx), %r14d
jge 0x5fc0
testb $0x7, %r14b
je 0x5fad
movq %rbx, %rdi
movl %r14d, %esi
callq 0x60d5
jmp 0x5fbb
movq 0x58(%rbx), %rax
movl %r14d, %ecx
shrl $0x3, %ecx
orb $0x1, (%rax,%rcx)
incl %r14d
jmp 0x5f94
xorl %r14d, %r14d
pushq $0x1
popq %r15
cmpl 0x30(%rbx), %r14d
jge 0x5fe5
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x60ef
incl %r14d
jmp 0x5fc7
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x5ffd
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x5ffd
movq 0x10(%rbx), %rdi
callq *%rax
movq %rbx, %rdi
callq 0x33b7
movq (%rbx), %rax
testb $0x1, 0x18(%rax)
jne 0x6016
pushq $0x1
popq %rdi
pushq $0x42
popq %rsi
jmp 0x601b
pushq $0x75
popq %rsi
xorl %edi, %edi
callq 0x2130
movq %rax, %r14
leaq 0xb8(%rbx), %r15
xorl %r12d, %r12d
cmpq $0x60, %r12
je 0x6052
movq %r14, 0xb0(%rbx,%r12)
movq (%r14), %rax
testq %rax, %rax
je 0x604c
leaq (%r15,%r12), %rsi
movq %r14, %rdi
callq *%rax
addq $0x18, %r12
jmp 0x602d
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x128(%rbx)
andl $0x0, 0x130(%rbx)
andb $-0x2, 0x18c(%rbx)
pushq $0x1
popq %r14
movq %rbx, %rdi
movl %r14d, %esi
movl %r14d, %edx
callq 0x616d
pushq $0x2
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x616d
pushq $0x7
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x6185
testl %ebp, %ebp
je 0x60cc
andq $0x0, 0x38(%rbx)
andl $0x0, 0x40(%rbx)
movl 0x30(%rbx), %esi
movl 0x34(%rbx), %edx
shlq $0x20, %rsi
shlq $0x20, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x619d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq