// File: /workspace/github_c_makefile_star2_O1/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 0x4dcc(%rip), %xmm0     # 0xb690
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 0x692a
xorl %eax, %eax
movl %eax, %ecx
andl $0x7, %ecx
je 0x6916
movl $0x1, %edx
shll %cl, %edx
movq 0x58(%rbx), %rcx
movl %eax, %esi
shrl $0x3, %esi
notb %dl
andb %dl, (%rcx,%rsi)
jmp 0x6923
movq 0x58(%rbx), %rcx
movl %eax, %edx
shrl $0x3, %edx
orb $0x1, (%rcx,%rdx)
incl %eax
cmpl 0x34(%rbx), %eax
jl 0x68f8
cmpl $0x0, 0x30(%rbx)
jle 0x6951
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x6a61
incl %r14d
cmpl 0x30(%rbx), %r14d
jl 0x6933
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x6969
movq 0x28(%rax), %rax
testq %rax, %rax
je 0x6969
movq 0x10(%rbx), %rdi
callq *%rax
movq %rbx, %rdi
callq 0x3524
movq (%rbx), %rax
testb $0x1, 0x18(%rax)
jne 0x6986
movl $0x1, %edi
movl $0x42, %esi
jmp 0x698d
xorl %edi, %edi
movl $0x75, %esi
callq 0x2140
movq %rax, %r14
leaq 0xb8(%rbx), %r15
xorl %r12d, %r12d
movq %r14, 0xb0(%rbx,%r12)
movq (%r14), %rax
testq %rax, %rax
je 0x69b8
leaq (%r15,%r12), %rsi
movq %r14, %rdi
callq *%rax
addq $0x18, %r12
cmpq $0x60, %r12
jne 0x699f
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 0x2160
movl %r15d, (%r14)
movq %rsp, %r14
movq %rbx, %rdi
movl $0x2, %esi
movq %r14, %rdx
callq 0x2160
movl %r15d, (%r14)
movq %rsp, %rdx
movq %rbx, %rdi
movl $0x7, %esi
callq 0x2160
testl %ebp, %ebp
je 0x6a54
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 0x6ae6
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq