// File: /workspace/github_c_makefile_star2_O3/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 0xa686
cmpl $0x416, %esi            # imm = 0x416
jg 0xa6b4
leal -0x3e8(%rsi), %eax
cmpl $0xf, %eax
ja 0xa8cb
leaq 0x22ec(%rip), %rcx      # 0xc93c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r14d, %r14d
je 0xa779
movl $0x1, %eax
cmpl $0x3e8, %esi            # imm = 0x3E8
je 0xa77b
xorl %eax, %eax
cmpl $0x3ea, %esi            # imm = 0x3EA
sete %al
xorl $0x3, %eax
jmp 0xa77b
leal -0x1(%rsi), %eax
cmpl $0xb, %eax
ja 0xa6eb
leaq 0x2277(%rip), %rcx      # 0xc90c
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 0xa856
cmpl $0x418, %esi            # imm = 0x418
jg 0xa74f
cmpl $0x417, %esi            # imm = 0x417
je 0xa888
cmpl $0x418, %esi            # imm = 0x418
jne 0xa8cb
movq %rbx, %rdi
movl %r14d, %esi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xa4e3
cmpl $0x19, %esi
je 0xa8b8
cmpl $0x45, %esi
jne 0xa8cb
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 0xa8cb
cmpl $0x0, 0x30(%rbx)
jle 0xa8cb
xorl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
movl $0x1, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x73b5
incl %ebp
cmpl 0x30(%rbx), %ebp
jl 0xa72f
jmp 0xa8cb
cmpl $0x419, %esi            # imm = 0x419
je 0xa898
cmpl $0x7d4, %esi            # imm = 0x7D4
jne 0xa8cb
andl $0x1, %r14d
shll $0xd, %r14d
movl $0xffffdfff, %eax       # imm = 0xFFFFDFFF
jmp 0xa84d
xorl %eax, %eax
movq %rsp, %rdx
movl %eax, (%rdx)
movq %rbx, %rdi
movl $0x8, %esi
jmp 0xa8c6
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x2, %esi
jmp 0xa8c6
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x6, %esi
jmp 0xa8c6
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 0xa7eb
movl 0x44(%rbx), %esi
movl %esi, 0x38(%rbx)
testw %dx, %dx
sete %dl
btl $0xc, %eax
setae %al
orb %dl, %al
jne 0xa802
movl 0x4c(%rbx), %ecx
movl %ecx, 0x3c(%rbx)
movq %rsp, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0xa42b
jmp 0xa8cb
movl 0xac(%rbx), %eax
andl $0x1, %r14d
andl $-0x5, %eax
leal (%rax,%r14,4), %eax
jmp 0xa856
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x9, %esi
callq 0x2150
andl $0x1, %r14d
shll $0xe, %r14d
movl $0xffffbfff, %eax       # imm = 0xFFFFBFFF
andl 0xac(%rbx), %eax
orl %r14d, %eax
movw %ax, 0xac(%rbx)
jmp 0xa8cb
xorl %eax, %eax
testl %r14d, %r14d
setne %al
leal (%rax,%rax,2), %eax
jmp 0xa880
xorl %eax, %eax
testl %r14d, %r14d
setne %al
addl %eax, %eax
jmp 0xa880
xorl %eax, %eax
testl %r14d, %r14d
setne %al
movl %eax, 0x88(%rbx)
jmp 0xa8cb
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x3, %esi
jmp 0xa8c6
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x3, %esi
callq 0x2150
movq %rbx, %rdi
movl %r14d, %esi
callq 0xa4e3
jmp 0xa8cb
movq %rsp, %rdx
movl %r14d, (%rdx)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2150
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq