// File: /workspace/github_c_makefile_star2_O1/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
cmpl $0x3e7, %esi            # imm = 0x3E7
jle 0x9d52
cmpl $0x416, %esi            # imm = 0x416
jg 0x9d80
leal -0x3e8(%rsi), %eax
cmpl $0xf, %eax
ja 0x9f97
leaq 0x1b90(%rip), %rcx      # 0xb8ac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
je 0x9e45
movl $0x1, %eax
cmpl $0x3e8, %esi            # imm = 0x3E8
je 0x9e47
xorl %eax, %eax
cmpl $0x3ea, %esi            # imm = 0x3EA
sete %al
xorl $0x3, %eax
jmp 0x9e47
leal -0x1(%rsi), %eax
cmpl $0xb, %eax
ja 0x9db7
leaq 0x1b1b(%rip), %rcx      # 0xb87c
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 0x9f22
cmpl $0x418, %esi            # imm = 0x418
jg 0x9e1b
cmpl $0x417, %esi            # imm = 0x417
je 0x9f54
cmpl $0x418, %esi            # imm = 0x418
jne 0x9f97
movq %rbx, %rdi
movl %r14d, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x9ba2
cmpl $0x19, %esi
je 0x9f84
cmpl $0x45, %esi
jne 0x9f97
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 0x9f97
cmpl $0x0, 0x30(%rbx)
jle 0x9f97
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x6a61
incl %ebp
cmpl 0x30(%rbx), %ebp
jl 0x9dfb
jmp 0x9f97
cmpl $0x419, %esi            # imm = 0x419
je 0x9f64
cmpl $0x7d4, %esi            # imm = 0x7D4
jne 0x9f97
andl $0x1, %r14d
shll $0xd, %r14d
movl $0xffffdfff, %eax       # imm = 0xFFFFDFFF
jmp 0x9f19
xorl %eax, %eax
movq %rsp, %rdx
movl %eax, (%rdx)
movq %rbx, %rdi
movl $0x8, %esi
jmp 0x9f92
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x2, %esi
jmp 0x9f92
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x6, %esi
jmp 0x9f92
movq 0x38(%rbx), %rax
movq %rax, (%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 0x9eb7
movl 0x44(%rbx), %esi
movl %esi, 0x38(%rbx)
testw %dx, %dx
sete %dl
btl $0xc, %eax
setae %al
orb %dl, %al
jne 0x9ece
movl 0x4c(%rbx), %ecx
movl %ecx, 0x3c(%rbx)
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x9af5
jmp 0x9f97
movl 0xac(%rbx), %eax
andl $0x1, %r14d
andl $-0x5, %eax
leal (%rax,%r14,4), %eax
jmp 0x9f22
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x9, %esi
callq 0x2160
andl $0x1, %r14d
shll $0xe, %r14d
movl $0xffffbfff, %eax       # imm = 0xFFFFBFFF
andl 0xac(%rbx), %eax
orl %r14d, %eax
movw %ax, 0xac(%rbx)
jmp 0x9f97
xorl %eax, %eax
testl %r14d, %r14d
setne %al
leal (%rax,%rax,2), %eax
jmp 0x9f4c
xorl %eax, %eax
testl %r14d, %r14d
setne %al
addl %eax, %eax
jmp 0x9f4c
xorl %eax, %eax
testl %r14d, %r14d
setne %al
movl %eax, 0x88(%rbx)
jmp 0x9f97
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x3, %esi
jmp 0x9f92
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x3, %esi
callq 0x2160
movq %rbx, %rdi
movl %r14d, %esi
callq 0x9ba2
jmp 0x9f97
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2160
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq