// File: /workspace/github_c_makefile_star2_O2/neovim[P]libvterm/src/state.c
// Function: set_dec_mode
static void set_dec_mode(VTermState *state, int num, int val)
{
  switch(num) {
  case 1:
    state->mode.cursor = val;
    break;

  case 5: // DECSCNM - screen mode
    settermprop_bool(state, VTERM_PROP_REVERSE, val);
    break;

  case 6: // DECOM - origin mode
    {
      VTermPos oldpos = state->pos;
      state->mode.origin = val;
      state->pos.row = state->mode.origin ? state->scrollregion_top : 0;
      state->pos.col = state->mode.origin ? SCROLLREGION_LEFT(state) : 0;
      updatecursor(state, &oldpos, 1);
    }
    break;

  case 7:
    state->mode.autowrap = val;
    break;

  case 12:
    settermprop_bool(state, VTERM_PROP_CURSORBLINK, val);
    break;

  case 25:
    settermprop_bool(state, VTERM_PROP_CURSORVISIBLE, val);
    break;

  case 69: // DECVSSM - vertical split screen mode
           // DECLRMM - left/right margin mode
    state->mode.leftrightmargin = val;
    if(val) {
      // Setting DECVSSM must clear doublewidth/doubleheight state of every line
      for(int row = 0; row < state->rows; row++)
        set_lineinfo(state, row, FORCE, DWL_OFF, DHL_OFF);
    }

    break;

  case 1000:
  case 1002:
  case 1003:
    settermprop_int(state, VTERM_PROP_MOUSE,
        !val          ? VTERM_PROP_MOUSE_NONE  :
        (num == 1000) ? VTERM_PROP_MOUSE_CLICK :
        (num == 1002) ? VTERM_PROP_MOUSE_DRAG  :
                        VTERM_PROP_MOUSE_MOVE);
    break;

  case 1004:
    settermprop_bool(state, VTERM_PROP_FOCUSREPORT, val);
    state->mode.report_focus = val;
    break;

  case 1005:
    state->mouse_protocol = val ? MOUSE_UTF8 : MOUSE_X10;
    break;

  case 1006:
    state->mouse_protocol = val ? MOUSE_SGR : MOUSE_X10;
    break;

  case 1015:
    state->mouse_protocol = val ? MOUSE_RXVT : MOUSE_X10;
    break;

  case 1047:
    settermprop_bool(state, VTERM_PROP_ALTSCREEN, val);
    break;

  case 1048:
    savecursor(state, val);
    break;

  case 1049:
    settermprop_bool(state, VTERM_PROP_ALTSCREEN, val);
    savecursor(state, val);
    break;

  case 2004:
    state->mode.bracketpaste = val;
    break;

  default:
    DEBUG_LOG("libvterm: Unknown DEC mode %d\n", num);
    return;
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edx, %r14d
movq %rdi, %rbx
leal -0x3e8(%rsi), %eax
cmpl $0xf, %eax
jbe 0x917a
leal -0x1(%rsi), %eax
cmpl $0xb, %eax
jbe 0x91a3
cmpl $0x19, %esi
je 0x9342
cmpl $0x45, %esi
je 0x92ff
cmpl $0x417, %esi            # imm = 0x417
je 0x92da
cmpl $0x418, %esi            # imm = 0x418
je 0x92ec
cmpl $0x419, %esi            # imm = 0x419
je 0x92de
cmpl $0x7d4, %esi            # imm = 0x7D4
jne 0x92b0
andl $0x1, %r14d
shll $0xd, %r14d
movl $0xffffdfff, %eax       # imm = 0xFFFFDFFF
jmp 0x91eb
leaq 0x178b(%rip), %rcx      # 0xa90c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
je 0x91c9
cmpl $0x3e8, %esi            # imm = 0x3E8
jne 0x92b9
pushq $0x1
popq %rdx
jmp 0x92c7
leaq 0x1732(%rip), %rcx      # 0xa8dc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0xac(%rbx), %eax
andl $0x1, %r14d
andl $-0x3, %eax
leal (%rax,%r14,2), %eax
jmp 0x92a9
xorl %edx, %edx
jmp 0x92c7
pushq $0x9
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x616d
andl $0x1, %r14d
shll $0xe, %r14d
movl $0xffffbfff, %eax       # imm = 0xFFFFBFFF
andl 0xac(%rbx), %eax
orl %r14d, %eax
jmp 0x92a9
xorl %eax, %eax
testl %r14d, %r14d
setne %al
jmp 0x921a
xorl %eax, %eax
testl %r14d, %r14d
setne %al
addl %eax, %eax
jmp 0x921a
xorl %eax, %eax
testl %r14d, %r14d
setne %al
leal (%rax,%rax,2), %eax
movl %eax, 0x88(%rbx)
jmp 0x92b0
pushq $0x2
jmp 0x9344
movq 0x38(%rbx), %rax
movq %rax, 0x8(%rsp)
movl 0xac(%rbx), %eax
movl %r14d, %edx
andl $0x1, %edx
shll $0xa, %edx
movl %eax, %ecx
andl $0xfffffbff, %ecx       # imm = 0xFFFFFBFF
orl %edx, %ecx
movw %cx, 0xac(%rbx)
xorl %ecx, %ecx
movl $0x0, %esi
testb $0x1, %r14b
je 0x9265
movl 0x44(%rbx), %esi
movl %esi, 0x38(%rbx)
testw %dx, %dx
sete %dl
btl $0xc, %eax
setae %al
orb %dl, %al
jne 0x927c
movl 0x4c(%rbx), %ecx
movl %ecx, 0x3c(%rbx)
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x8f00
jmp 0x92b0
pushq $0x6
jmp 0x9344
movl 0xac(%rbx), %eax
andl $0x1, %r14d
andl $-0x5, %eax
leal (%rax,%r14,4), %eax
movw %ax, 0xac(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
xorl %edx, %edx
cmpl $0x3ea, %esi            # imm = 0x3EA
sete %dl
xorl $0x3, %edx
pushq $0x8
popq %rsi
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x6185
pushq $0x3
jmp 0x9344
pushq $0x3
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x616d
movq %rbx, %rdi
movl %r14d, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x8fbd
movl %r14d, %eax
andl $0x1, %eax
movl $0xffffefff, %ecx       # imm = 0xFFFFEFFF
andl 0xac(%rbx), %ecx
shll $0xc, %eax
orl %eax, %ecx
movw %cx, 0xac(%rbx)
testl %r14d, %r14d
je 0x92b0
xorl %ebp, %ebp
pushq $0x1
popq %r14
cmpl 0x30(%rbx), %ebp
jge 0x92b0
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x60ef
incl %ebp
jmp 0x9327
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl %r14d, %edx
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x616d