// File: /workspace/github_c_makefile_star2_O3/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
subq $0x10, %rsp
movq %rdi, %rbx
movaps 0x5506(%rip), %xmm0     # 0xc720
movups %xmm0, 0x44(%rdi)
movl $0xffff89e0, %eax       # imm = 0xFFFF89E0
andl 0xac(%rdi), %eax
orl $0x4, %eax
movw %ax, 0xac(%rdi)
movl $0x0, 0x84(%rdi)
movq (%rdi), %rax
andb $-0x3, 0x18(%rax)
movl %esi, %ebp
cmpl $0x0, 0x34(%rdi)
jle 0x727e
xorl %eax, %eax
movl %eax, %ecx
movq 0x58(%rbx), %rdx
andl $0x7, %ecx
je 0x726e
movl $0x1, %esi
shll %cl, %esi
movl %eax, %ecx
shrl $0x3, %ecx
notb %sil
andb %sil, (%rdx,%rcx)
jmp 0x7277
movl %eax, %ecx
shrl $0x3, %ecx
orb $0x1, (%rdx,%rcx)
incl %eax
cmpl 0x34(%rbx), %eax
jl 0x724e
cmpl $0x0, 0x30(%rbx)
jle 0x72a5
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x73b5
incl %r14d
cmpl 0x30(%rbx), %r14d
jl 0x7287
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x72bd
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x72bd
movq 0x10(%rbx), %rdi
callq *%rax
movq %rbx, %rdi
callq 0x3523
movq (%rbx), %rax
testb $0x1, 0x18(%rax)
jne 0x72da
movl $0x1, %edi
movl $0x42, %esi
jmp 0x72e1
xorl %edi, %edi
movl $0x75, %esi
callq 0x2130
movq %rax, %r14
leaq 0xb8(%rbx), %r15
xorl %r12d, %r12d
movq %r14, 0xb0(%rbx,%r12)
movq (%r14), %rax
testq %rax, %rax
je 0x730c
leaq (%r15,%r12), %rsi
movq %r14, %rdi
callq *%rax
addq $0x18, %r12
cmpq $0x60, %r12
jne 0x72f3
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x128(%rbx)
movl $0x0, 0x130(%rbx)
andb $-0x2, 0x18c(%rbx)
movl $0x1, %r15d
movq %rsp, %r14
movl %r15d, (%r14)
movq %rbx, %rdi
movl $0x1, %esi
movq %r14, %rdx
callq 0x2150
movl %r15d, (%r14)
movq %rsp, %r14
movq %rbx, %rdi
movl $0x2, %esi
movq %r14, %rdx
callq 0x2150
movl %r15d, (%r14)
movq %rsp, %rdx
movq %rbx, %rdi
movl $0x7, %esi
callq 0x2150
testl %ebp, %ebp
je 0x73a8
movq $0x0, 0x38(%rbx)
movl $0x0, 0x40(%rbx)
movl 0x30(%rbx), %esi
movl 0x34(%rbx), %edx
shlq $0x20, %rsi
shlq $0x20, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x7433
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq