// File: /workspace/github_c_makefile_star2_O0/neovim[P]libvterm/bin/vterm-ctrl.c
// Function: main
int main(int argc, char *argv[])
{
  int argi = 1;

  if(argc == 1)
    usage(0);

  wasicanon = seticanon(false, false);
  atexit(restoreicanon);

  while(argi < argc) {
    const char *arg = argv[argi++];

    if(streq(arg, "reset")) {
      printf("\x1b" "c");
    }
    else if(streq(arg, "s8c1t")) {
      switch(getchoice(&argi, argc, argv, (const char *[]){"off", "on", NULL})) {
      case 0:
        printf("\x1b F"); break;
      case 1:
        printf("\x1b G"); break;
      }
    }
    else if(streq(arg, "keypad")) {
      switch(getchoice(&argi, argc, argv, (const char *[]){"app", "num", NULL})) {
      case 0:
        printf("\x1b="); break;
      case 1:
        printf("\x1b>"); break;
      }
    }
    else if(streq(arg, "screen")) {
      do_dec_mode(5, getboolq(&argi, argc, argv), "screen");
    }
    else if(streq(arg, "cursor")) {
      do_dec_mode(25, getboolq(&argi, argc, argv), "cursor");
    }
    else if(streq(arg, "curblink")) {
      do_dec_mode(12, getboolq(&argi, argc, argv), "curblink");
    }
    else if(streq(arg, "curshape")) {
      // TODO: This ought to query the current value of DECSCUSR because it
      //   may need blinking on or off
      int shape = getchoice(&argi, argc, argv, (const char *[]){"block", "under", "bar", "query", NULL});
      switch(shape) {
        case 3: // query
          shape = query_rqss_numeric(" q");
          switch(shape) {
            case 1: case 2:
              printf("curshape block\n");
              break;
            case 3: case 4:
              printf("curshape under\n");
              break;
            case 5: case 6:
              printf("curshape bar\n");
              break;
          }
          break;

        case 0:
        case 1:
        case 2:
          printf("\x1b[%d q", 1 + (shape * 2));
          break;
      }
    }
    else if(streq(arg, "mouse")) {
      switch(getchoice(&argi, argc, argv, (const char *[]){"off", "click", "clickdrag", "motion", NULL})) {
      case 0:
        printf("\x1b[?1000l"); break;
      case 1:
        printf("\x1b[?1000h"); break;
      case 2:
        printf("\x1b[?1002h"); break;
      case 3:
        printf("\x1b[?1003h"); break;
      }
    }
    else if(streq(arg, "reportfocus")) {
      do_dec_mode(1004, getboolq(&argi, argc, argv), "reportfocus");
    }
    else if(streq(arg, "altscreen")) {
      do_dec_mode(1049, getboolq(&argi, argc, argv), "altscreen");
    }
    else if(streq(arg, "bracketpaste")) {
      do_dec_mode(2004, getboolq(&argi, argc, argv), "bracketpaste");
    }
    else if(streq(arg, "icontitle")) {
      printf("\x1b]0;%s\a", getvalue(&argi, argc, argv));
    }
    else if(streq(arg, "icon")) {
      printf("\x1b]1;%s\a", getvalue(&argi, argc, argv));
    }
    else if(streq(arg, "title")) {
      printf("\x1b]2;%s\a", getvalue(&argi, argc, argv));
    }
    else {
      fprintf(stderr, "Unrecognised command %s\n", arg);
      exit(1);
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, -0x14(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x12cd
xorl %edi, %edi
callq 0x1870
xorl %esi, %esi
movl %esi, %edi
callq 0x1210
andb $0x1, %al
movb %al, 0x2e2b(%rip)       # 0x4109
leaq -0xf5(%rip), %rdi       # 0x11f0
callq 0x1e90
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x185a
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0xcf9(%rip), %rsi       # 0x2014
callq 0x1060
cmpl $0x0, %eax
jne 0x1338
leaq 0xcee(%rip), %rdi       # 0x201a
movb $0x0, %al
callq 0x1050
jmp 0x1855
movq -0x20(%rbp), %rdi
leaq 0xcda(%rip), %rsi       # 0x201d
callq 0x1060
cmpl $0x0, %eax
jne 0x13b5
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq 0x29f5(%rip), %rax      # 0x3d50
movq %rax, -0x30(%rbp)
movups 0x29da(%rip), %xmm0     # 0x3d40
movaps %xmm0, -0x40(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x40(%rbp), %rcx
callq 0x18e0
movl %eax, %ecx
movl %ecx, -0xc4(%rbp)
testl %eax, %eax
je 0x1392
jmp 0x1385
movl -0xc4(%rbp), %eax
subl $0x1, %eax
je 0x13a2
jmp 0x13b0
leaq 0xc8e(%rip), %rdi       # 0x2027
movb $0x0, %al
callq 0x1050
jmp 0x13b0
leaq 0xc82(%rip), %rdi       # 0x202b
movb $0x0, %al
callq 0x1050
jmp 0x1853
movq -0x20(%rbp), %rdi
leaq 0xc6f(%rip), %rsi       # 0x202f
callq 0x1060
cmpl $0x0, %eax
jne 0x1432
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq 0x2990(%rip), %rax      # 0x3d68
movq %rax, -0x50(%rbp)
movups 0x2975(%rip), %xmm0     # 0x3d58
movaps %xmm0, -0x60(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x60(%rbp), %rcx
callq 0x18e0
movl %eax, %ecx
movl %ecx, -0xc8(%rbp)
testl %eax, %eax
je 0x140f
jmp 0x1402
movl -0xc8(%rbp), %eax
subl $0x1, %eax
je 0x141f
jmp 0x142d
leaq 0xc28(%rip), %rdi       # 0x203e
movb $0x0, %al
callq 0x1050
jmp 0x142d
leaq 0xc1b(%rip), %rdi       # 0x2041
movb $0x0, %al
callq 0x1050
jmp 0x1851
movq -0x20(%rbp), %rdi
leaq 0xcbb(%rip), %rsi       # 0x20f8
callq 0x1060
cmpl $0x0, %eax
jne 0x146f
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1a10
movl %eax, %esi
movl $0x5, %edi
leaq 0xc93(%rip), %rdx       # 0x20f8
callq 0x1980
jmp 0x184f
movq -0x20(%rbp), %rdi
leaq 0xbca(%rip), %rsi       # 0x2044
callq 0x1060
cmpl $0x0, %eax
jne 0x14ac
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1a10
movl %eax, %esi
movl $0x19, %edi
leaq 0xba2(%rip), %rdx       # 0x2044
callq 0x1980
jmp 0x184d
movq -0x20(%rbp), %rdi
leaq 0xb94(%rip), %rsi       # 0x204b
callq 0x1060
cmpl $0x0, %eax
jne 0x14e9
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1a10
movl %eax, %esi
movl $0xc, %edi
leaq 0xb6c(%rip), %rdx       # 0x204b
callq 0x1980
jmp 0x184b
movq -0x20(%rbp), %rdi
leaq 0xb60(%rip), %rsi       # 0x2054
callq 0x1060
cmpl $0x0, %eax
jne 0x15f1
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq 0x2880(%rip), %rax      # 0x3d90
movq %rax, -0x70(%rbp)
movups 0x2865(%rip), %xmm0     # 0x3d80
movaps %xmm0, -0x80(%rbp)
movups 0x284a(%rip), %xmm0     # 0x3d70
movaps %xmm0, -0x90(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x90(%rbp), %rcx
callq 0x18e0
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0xcc(%rbp)
subl $0x3, %eax
jb 0x15d6
jmp 0x1554
movl -0xcc(%rbp), %eax
subl $0x3, %eax
jne 0x15ec
jmp 0x1565
leaq 0xb39(%rip), %rdi       # 0x20a5
callq 0x1a70
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0xd0(%rbp)
decl %eax
subl $0x2, %eax
jb 0x15a6
jmp 0x1586
movl -0xd0(%rbp), %eax
addl $-0x3, %eax
subl $0x2, %eax
jb 0x15b6
jmp 0x1596
movl -0xd0(%rbp), %eax
addl $-0x5, %eax
subl $0x2, %eax
jb 0x15c6
jmp 0x15d4
leaq 0xac6(%rip), %rdi       # 0x2073
movb $0x0, %al
callq 0x1050
jmp 0x15d4
leaq 0xac6(%rip), %rdi       # 0x2083
movb $0x0, %al
callq 0x1050
jmp 0x15d4
leaq 0xac6(%rip), %rdi       # 0x2093
movb $0x0, %al
callq 0x1050
jmp 0x15ec
movl -0x64(%rbp), %esi
shll %esi
addl $0x1, %esi
leaq 0xabc(%rip), %rdi       # 0x20a1
movb $0x0, %al
callq 0x1050
jmp 0x1849
movq -0x20(%rbp), %rdi
leaq 0xaac(%rip), %rsi       # 0x20a8
callq 0x1060
cmpl $0x0, %eax
jne 0x16b3
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
movq 0x27a0(%rip), %rax      # 0x3db8
movq %rax, -0xa0(%rbp)
movups 0x2782(%rip), %xmm0     # 0x3da8
movaps %xmm0, -0xb0(%rbp)
movups 0x2764(%rip), %xmm0     # 0x3d98
movaps %xmm0, -0xc0(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0xc0(%rbp), %rcx
callq 0x18e0
movl %eax, %ecx
movq %rcx, -0xd8(%rbp)
subl $0x3, %eax
ja 0x16ae
movq -0xd8(%rbp), %rax
leaq 0x99d(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xa4e(%rip), %rdi       # 0x20c5
movb $0x0, %al
callq 0x1050
jmp 0x16ae
leaq 0xa47(%rip), %rdi       # 0x20ce
movb $0x0, %al
callq 0x1050
jmp 0x16ae
leaq 0xa40(%rip), %rdi       # 0x20d7
movb $0x0, %al
callq 0x1050
jmp 0x16ae
leaq 0xa39(%rip), %rdi       # 0x20e0
movb $0x0, %al
callq 0x1050
jmp 0x1847
movq -0x20(%rbp), %rdi
leaq 0xa2b(%rip), %rsi       # 0x20e9
callq 0x1060
cmpl $0x0, %eax
jne 0x16f0
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1a10
movl %eax, %esi
movl $0x3ec, %edi            # imm = 0x3EC
leaq 0xa03(%rip), %rdx       # 0x20e9
callq 0x1980
jmp 0x1845
movq -0x20(%rbp), %rdi
leaq 0x9fa(%rip), %rsi       # 0x20f5
callq 0x1060
cmpl $0x0, %eax
jne 0x172d
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1a10
movl %eax, %esi
movl $0x419, %edi            # imm = 0x419
leaq 0x9d2(%rip), %rdx       # 0x20f5
callq 0x1980
jmp 0x1843
movq -0x20(%rbp), %rdi
leaq 0x9c7(%rip), %rsi       # 0x20ff
callq 0x1060
cmpl $0x0, %eax
jne 0x176a
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1a10
movl %eax, %esi
movl $0x7d4, %edi            # imm = 0x7D4
leaq 0x99f(%rip), %rdx       # 0x20ff
callq 0x1980
jmp 0x1841
movq -0x20(%rbp), %rdi
leaq 0x997(%rip), %rsi       # 0x210c
callq 0x1060
cmpl $0x0, %eax
jne 0x17a5
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1bc0
movq %rax, %rsi
leaq 0x97d(%rip), %rdi       # 0x2116
movb $0x0, %al
callq 0x1050
jmp 0x183f
movq -0x20(%rbp), %rdi
leaq 0x96e(%rip), %rsi       # 0x211e
callq 0x1060
cmpl $0x0, %eax
jne 0x17dd
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1bc0
movq %rax, %rsi
leaq 0x94f(%rip), %rdi       # 0x2123
movb $0x0, %al
callq 0x1050
jmp 0x183d
movq -0x20(%rbp), %rdi
leaq 0x928(%rip), %rsi       # 0x2110
callq 0x1060
cmpl $0x0, %eax
jne 0x1815
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x14(%rbp), %rdi
callq 0x1bc0
movq %rax, %rsi
leaq 0x91f(%rip), %rdi       # 0x212b
movb $0x0, %al
callq 0x1050
jmp 0x183b
movq 0x27dc(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x909(%rip), %rsi       # 0x2133
movb $0x0, %al
callq 0x1080
movl $0x1, %edi
callq 0x10d0
jmp 0x183d
jmp 0x183f
jmp 0x1841
jmp 0x1843
jmp 0x1845
jmp 0x1847
jmp 0x1849
jmp 0x184b
jmp 0x184d
jmp 0x184f
jmp 0x1851
jmp 0x1853
jmp 0x1855
jmp 0x12ea
xorl %eax, %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)