// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/fileselect/fileselect.c
// Function: file_node_curses_loop
static void file_node_curses_loop(file_node_t *node)
{
  int c, maxy, maxx, list_size;

  initscr();
  atexit(curses_exit_handler);
  noecho();
  keypad(stdscr, TRUE);

  while (1) {
    list_size = file_node_list_size(node);
    curses_update_screen(node);
    getmaxyx(stdscr, maxy, maxx);
    c = getch();

    switch (c) {
    case KEY_RESIZE:
      curses_winch_handler(node);
      break;

    case KEY_UP:
      curses_selected_entry--;
      if (curses_selected_entry < 0)
        curses_selected_entry++;
      if (curses_scroll_offset > curses_selected_entry) {
        curses_scroll_offset--;
        if (curses_scroll_offset < 0)
          curses_scroll_offset = 0;
      }
      break;

    case KEY_NPAGE:
      curses_scroll_offset += maxy / 2;
      while (maxy + curses_scroll_offset > list_size)
        curses_scroll_offset--;
      if (curses_scroll_offset < 0)
        curses_scroll_offset = 0;
      if (curses_selected_entry < curses_scroll_offset)
        curses_selected_entry = curses_scroll_offset;
      break;

    case KEY_PPAGE:
      curses_scroll_offset -= maxy / 2;
      if (curses_scroll_offset < 0)
        curses_scroll_offset = 0;
      if (curses_selected_entry > maxy + curses_scroll_offset - 1)
        curses_selected_entry = maxy + curses_scroll_offset - 1;
      break;

    case ' ':
    case KEY_IC:
      file_node_mark(node, curses_selected_entry + 1);
      /* Move cursor to next line automatically. */
    case KEY_ENTER:
    case '\n':
    case '\r':
    case KEY_DOWN:
      curses_selected_entry++;
      if (curses_selected_entry >= list_size)
        curses_selected_entry--;
      if (curses_selected_entry > maxy - 1) {
        curses_scroll_offset++;
        if (curses_scroll_offset > curses_selected_entry - maxy + 1)
          curses_scroll_offset--;
      }
      break;

    case '\e': /* Escape */
    case 'Q':
    case 'q':
      return;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
callq 0x1100
leaq 0x5c8(%rip), %rdi       # 0x1da0
callq 0x25a0
callq 0x10d0
movq 0x37ef(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x1120
movq -0x8(%rbp), %rdi
callq 0x1db0
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1e20
xorl %eax, %eax
movq 0x37c4(%rip), %rcx      # 0x4fd8
cmpq (%rcx), %rax
je 0x182f
movq 0x37b8(%rip), %rax      # 0x4fd8
movq (%rax), %rax
movswl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1839
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x1c(%rbp)
jmp 0x1839
movl -0x1c(%rbp), %eax
movl %eax, -0x10(%rbp)
xorl %eax, %eax
movq 0x3790(%rip), %rcx      # 0x4fd8
cmpq (%rcx), %rax
je 0x1863
movq 0x3784(%rip), %rax      # 0x4fd8
movq (%rax), %rax
movswl 0x6(%rax), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x186d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x20(%rbp)
jmp 0x186d
movl -0x20(%rbp), %eax
movl %eax, -0x14(%rbp)
movq 0x375e(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
callq 0x1090
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x24(%rbp)
subl $0xa, %eax
je 0x1a89
jmp 0x1896
movl -0x24(%rbp), %eax
subl $0xd, %eax
je 0x1a89
jmp 0x18a4
movl -0x24(%rbp), %eax
subl $0x1b, %eax
je 0x1afa
jmp 0x18b2
movl -0x24(%rbp), %eax
subl $0x20, %eax
je 0x1a77
jmp 0x18c0
movl -0x24(%rbp), %eax
subl $0x51, %eax
je 0x1afa
jmp 0x18ce
movl -0x24(%rbp), %eax
subl $0x71, %eax
je 0x1afa
jmp 0x18dc
movl -0x24(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x1a89
jmp 0x18ec
movl -0x24(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x1956
jmp 0x18f8
movl -0x24(%rbp), %eax
subl $0x14b, %eax            # imm = 0x14B
je 0x1a77
jmp 0x1908
movl -0x24(%rbp), %eax
subl $0x152, %eax            # imm = 0x152
je 0x19b4
jmp 0x1918
movl -0x24(%rbp), %eax
subl $0x153, %eax            # imm = 0x153
je 0x1a1c
jmp 0x1928
movl -0x24(%rbp), %eax
subl $0x157, %eax            # imm = 0x157
je 0x1a89
jmp 0x1938
movl -0x24(%rbp), %eax
subl $0x19a, %eax            # imm = 0x19A
jne 0x1b00
jmp 0x1948
movq -0x8(%rbp), %rdi
callq 0x2060
jmp 0x1b00
movl 0x37c8(%rip), %eax      # 0x5124
addl $-0x1, %eax
movl %eax, 0x37bf(%rip)      # 0x5124
cmpl $0x0, 0x37b8(%rip)      # 0x5124
jge 0x197d
movl 0x37b0(%rip), %eax      # 0x5124
addl $0x1, %eax
movl %eax, 0x37a7(%rip)      # 0x5124
movl 0x37a5(%rip), %eax      # 0x5128
cmpl 0x379b(%rip), %eax      # 0x5124
jle 0x19af
movl 0x3797(%rip), %eax      # 0x5128
addl $-0x1, %eax
movl %eax, 0x378e(%rip)      # 0x5128
cmpl $0x0, 0x3787(%rip)      # 0x5128
jge 0x19ad
movl $0x0, 0x377b(%rip)      # 0x5128
jmp 0x19af
jmp 0x1b00
movl -0x10(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl 0x3763(%rip), %eax      # 0x5128
movl %eax, 0x375d(%rip)      # 0x5128
movl -0x10(%rbp), %eax
addl 0x3754(%rip), %eax      # 0x5128
cmpl -0x18(%rbp), %eax
jle 0x19ea
movl 0x3749(%rip), %eax      # 0x5128
addl $-0x1, %eax
movl %eax, 0x3740(%rip)      # 0x5128
jmp 0x19cb
cmpl $0x0, 0x3737(%rip)      # 0x5128
jge 0x19fd
movl $0x0, 0x372b(%rip)      # 0x5128
movl 0x3721(%rip), %eax      # 0x5124
cmpl 0x371f(%rip), %eax      # 0x5128
jge 0x1a17
movl 0x3717(%rip), %eax      # 0x5128
movl %eax, 0x370d(%rip)      # 0x5124
jmp 0x1b00
movl -0x10(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl 0x36f9(%rip), %eax      # 0x5128
subl %ecx, %eax
movl %eax, 0x36f1(%rip)      # 0x5128
cmpl $0x0, 0x36ea(%rip)      # 0x5128
jge 0x1a4a
movl $0x0, 0x36de(%rip)      # 0x5128
movl 0x36d4(%rip), %eax      # 0x5124
movl -0x10(%rbp), %ecx
addl 0x36cf(%rip), %ecx      # 0x5128
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1a72
movl -0x10(%rbp), %eax
addl 0x36bf(%rip), %eax      # 0x5128
subl $0x1, %eax
movl %eax, 0x36b2(%rip)      # 0x5124
jmp 0x1b00
movq -0x8(%rbp), %rdi
movl 0x36a3(%rip), %esi      # 0x5124
addl $0x1, %esi
callq 0x20a0
movl 0x3695(%rip), %eax      # 0x5124
addl $0x1, %eax
movl %eax, 0x368c(%rip)      # 0x5124
movl 0x3686(%rip), %eax      # 0x5124
cmpl -0x18(%rbp), %eax
jl 0x1ab2
movl 0x367b(%rip), %eax      # 0x5124
addl $-0x1, %eax
movl %eax, 0x3672(%rip)      # 0x5124
movl 0x366c(%rip), %eax      # 0x5124
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1af8
movl 0x3660(%rip), %eax      # 0x5128
addl $0x1, %eax
movl %eax, 0x3657(%rip)      # 0x5128
movl 0x3651(%rip), %eax      # 0x5128
movl 0x3647(%rip), %ecx      # 0x5124
subl -0x10(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1af6
movl 0x363b(%rip), %eax      # 0x5128
addl $-0x1, %eax
movl %eax, 0x3632(%rip)      # 0x5128
jmp 0x1af8
jmp 0x1b00
addq $0x30, %rsp
popq %rbp
retq
jmp 0x17f6
nopw %cs:(%rax,%rax)