// File: /workspace/github_c_makefile_star2_O0/neovim[P]libvterm/bin/unterm.c
// Function: main
int main(int argc, char *argv[])
{
  rows = 25;
  cols = 80;

  int opt;
  while((opt = getopt(argc, argv, "f:l:c:")) != -1) {
    switch(opt) {
      case 'f':
        if(streq(optarg, "plain"))
          format = FORMAT_PLAIN;
        else if(streq(optarg, "sgr"))
          format = FORMAT_SGR;
        else {
          fprintf(stderr, "Unrecognised format '%s'\n", optarg);
          exit(1);
        }
        break;

      case 'l':
        rows = atoi(optarg);
        if(!rows)
          rows = 25;
        break;

      case 'c':
        cols = atoi(optarg);
        if(!cols)
          cols = 80;
        break;
    }
  }

  const char *file = argv[optind++];
  int fd = open(file, O_RDONLY);
  if(fd == -1) {
    fprintf(stderr, "Cannot open %s - %s\n", file, strerror(errno));
    exit(1);
  }

  vt = vterm_new(rows, cols);
  vterm_set_utf8(vt, true);

  vts = vterm_obtain_screen(vt);
  vterm_screen_set_callbacks(vts, &cb_screen, NULL);

  vterm_screen_reset(vts, 1);

  int len;
  char buffer[1024];
  while((len = read(fd, buffer, sizeof(buffer))) > 0) {
    vterm_input_write(vt, buffer, len);
  }

  for(int row = 0; row < rows; row++) {
    dump_row(row);
  }

  close(fd);

  vterm_free(vt);

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x19, 0x37b5(%rip)     # 0x5158
movl $0x50, 0x379b(%rip)     # 0x5148
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x1661(%rip), %rdx      # 0x301c
callq 0x1150
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0x1ad8
movl -0x14(%rbp), %eax
movl %eax, -0x438(%rbp)
subl $0x63, %eax
je 0x1aa9
jmp 0x19e0
movl -0x438(%rbp), %eax
subl $0x66, %eax
je 0x1a01
jmp 0x19ed
movl -0x438(%rbp), %eax
subl $0x6c, %eax
je 0x1a7f
jmp 0x1ad3
movq 0x35d0(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
leaq 0x1611(%rip), %rsi      # 0x3023
callq 0x10d0
cmpl $0x0, %eax
jne 0x1a28
movl $0x0, 0x3736(%rip)      # 0x515c
jmp 0x1a7d
movq 0x35a9(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
leaq 0x15f0(%rip), %rsi      # 0x3029
callq 0x10d0
cmpl $0x0, %eax
jne 0x1a4f
movl $0x1, 0x370f(%rip)      # 0x515c
jmp 0x1a7b
movq 0x35a2(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
movq 0x3578(%rip), %rax      # 0x4fd8
movq (%rax), %rdx
leaq 0x15c3(%rip), %rsi      # 0x302d
movb $0x0, %al
callq 0x10e0
movl $0x1, %edi
callq 0x1170
jmp 0x1a7d
jmp 0x1ad3
movq 0x3552(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x1160
movl %eax, 0x36c4(%rip)      # 0x5158
cmpl $0x0, 0x36bd(%rip)      # 0x5158
jne 0x1aa7
movl $0x19, 0x36b1(%rip)     # 0x5158
jmp 0x1ad3
movq 0x3528(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x1160
movl %eax, 0x368a(%rip)      # 0x5148
cmpl $0x0, 0x3683(%rip)      # 0x5148
jne 0x1ad1
movl $0x50, 0x3677(%rip)     # 0x5148
jmp 0x1ad3
jmp 0x19ad
movq -0x10(%rbp), %rax
movq 0x34ed(%rip), %rcx      # 0x4fd0
movl (%rcx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movq 0x34df(%rip), %rdx      # 0x4fd0
movl %esi, (%rdx)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x1130
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x1b65
movq 0x34dd(%rip), %rax      # 0x4ff8
movq (%rax), %rax
movq %rax, -0x448(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x440(%rbp)
callq 0x1040
movl (%rax), %edi
callq 0x1190
movq -0x448(%rbp), %rdi
movq -0x440(%rbp), %rdx
movq %rax, %rcx
leaq 0x14f3(%rip), %rsi      # 0x3047
movb $0x0, %al
callq 0x10e0
movl $0x1, %edi
callq 0x1170
movl 0x35ed(%rip), %edi      # 0x5158
movl 0x35d7(%rip), %esi      # 0x5148
callq 0x10a0
movq %rax, 0x35c3(%rip)      # 0x5140
movq 0x35bc(%rip), %rdi      # 0x5140
movl $0x1, %esi
callq 0x1030
movq 0x35ab(%rip), %rdi      # 0x5140
callq 0x11a0
movq %rax, 0x35af(%rip)      # 0x5150
movq 0x35a8(%rip), %rdi      # 0x5150
leaq 0x3539(%rip), %rsi      # 0x50e8
xorl %eax, %eax
movl %eax, %edx
callq 0x1110
movq 0x3591(%rip), %rdi      # 0x5150
movl $0x1, %esi
callq 0x1060
movl -0x24(%rbp), %edi
leaq -0x430(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x10c0
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
jle 0x1bfe
movq 0x3554(%rip), %rdi      # 0x5140
leaq -0x430(%rbp), %rsi
movslq -0x28(%rbp), %rdx
callq 0x1050
jmp 0x1bc9
movl $0x0, -0x434(%rbp)
movl -0x434(%rbp), %eax
cmpl 0x3544(%rip), %eax      # 0x5158
jge 0x1c32
movl -0x434(%rbp), %edi
callq 0x12b0
movl -0x434(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x1c08
movl -0x24(%rbp), %edi
callq 0x10b0
movq 0x34ff(%rip), %rdi      # 0x5140
callq 0x1140
xorl %eax, %eax
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
nopw %cs:(%rax,%rax)