// File: /workspace/github_c_makefile_star2_O3/kobolt[P]curses-collection/difftree/navi.c
// Function: diff_navi_loop
void diff_navi_loop(diff_node_t *node, char *root1, char *root2)
{
  int c, maxy, maxx, list_size;

  initscr();
  atexit(diff_navi_exit_handler);
  if (has_colors()) {
    start_color();
    init_pair(COLOR_EQUAL,            COLOR_WHITE,   COLOR_BLACK);
    init_pair(COLOR_DIFFERS,          COLOR_MAGENTA, COLOR_BLACK);
    init_pair(COLOR_ADDED,            COLOR_BLUE,    COLOR_BLACK);
    init_pair(COLOR_MISSING,          COLOR_RED,     COLOR_BLACK);
    init_pair(COLOR_SELECTED_EQUAL,   COLOR_BLACK,   COLOR_WHITE);
    init_pair(COLOR_SELECTED_DIFFERS, COLOR_MAGENTA, COLOR_WHITE);
    init_pair(COLOR_SELECTED_ADDED,   COLOR_BLUE,    COLOR_WHITE);
    init_pair(COLOR_SELECTED_MISSING, COLOR_RED,     COLOR_WHITE);
  }
  noecho();
  keypad(stdscr, TRUE);

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

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

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

    case KEY_DOWN:
      selected_entry++;
      if (selected_entry >= list_size)
        selected_entry--;
      if (selected_entry > maxy - 1) {
        scroll_offset++;
        if (scroll_offset > selected_entry - maxy + 1)
          scroll_offset--;
      }
      break;

    case KEY_LEFT:
    case '-':
      diff_navi_list_expand(node, selected_entry + 1, false);
      break;

    case KEY_RIGHT:
    case '+':
      diff_navi_list_expand(node, selected_entry + 1, true);
      break;

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

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

    case KEY_ENTER:
    case '\n':
    case '\r':
      /* For ease of use, attempt to expand with "Enter" as well: */
      diff_navi_list_expand(node, selected_entry + 1, true);
      diff_navi_call_program(node, selected_entry + 1, root1, root2);
      break;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3028, %rsp           # imm = 0x3028
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
callq 0x2150
leaq 0x45e(%rip), %rdi       # 0x3358
callq 0x39d0
callq 0x2030
testb %al, %al
je 0x2fa2
callq 0x2160
movl $0x1, %edi
movl $0x7, %esi
xorl %edx, %edx
callq 0x2210
movl $0x2, %edi
movl $0x5, %esi
xorl %edx, %edx
callq 0x2210
movl $0x3, %edi
movl $0x4, %esi
xorl %edx, %edx
callq 0x2210
movl $0x4, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2210
movl $0x5, %edi
xorl %esi, %esi
movl $0x7, %edx
callq 0x2210
movl $0x6, %edi
movl $0x5, %esi
movl $0x7, %edx
callq 0x2210
movl $0x7, %edi
movl $0x4, %esi
movl $0x7, %edx
callq 0x2210
movl $0x8, %edi
movl $0x1, %esi
movl $0x7, %edx
callq 0x2210
callq 0x2110
movq 0x302a(%rip), %rbx      # 0x5fd8
movq (%rbx), %rdi
movl $0x1, %esi
callq 0x21b0
leaq 0xc(%rsp), %r12
leaq 0x10d9(%rip), %r14      # 0x40a0
movq %r15, %rdi
callq 0x335d
movl %eax, %ebp
movq %r15, %rdi
callq 0x33a4
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2feb
movswl 0x4(%rdi), %r13d
incl %r13d
jmp 0x2ff1
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
callq 0x20d0
cmpl $0x101, %eax            # imm = 0x101
jle 0x3047
cmpl $0x151, %eax            # imm = 0x151
jg 0x3079
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
cmpl $0x3, %eax
ja 0x2fc7
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movl 0x316f(%rip), %eax      # 0x618c
leal 0x1(%rax), %ecx
cmpl %ebp, %ecx
cmovll %ecx, %eax
movl %eax, 0x3161(%rip)      # 0x618c
subl %r13d, %eax
jl 0x2fc7
movl 0x315a(%rip), %ecx      # 0x6190
xorl %edx, %edx
cmpl %eax, %ecx
setle %dl
addl %ecx, %edx
movl %edx, 0x314b(%rip)      # 0x6190
jmp 0x2fc7
cmpl $0x2a, %eax
jle 0x30d4
cmpl $0x2c, %eax
jle 0x318f
cmpl $0x2d, %eax
jne 0x322f
movl 0x3124(%rip), %esi      # 0x618c
incl %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x3534
jmp 0x2fc7
cmpl $0x156, %eax            # imm = 0x156
jg 0x30ec
cmpl $0x152, %eax            # imm = 0x152
je 0x31ed
cmpl $0x153, %eax            # imm = 0x153
jne 0x2fc7
movl %r13d, %ecx
shrl $0x1f, %ecx
addl %r13d, %ecx
sarl %ecx
movl 0x30e9(%rip), %eax      # 0x6190
subl %ecx, %eax
testl %eax, %eax
jg 0x30af
xorl %eax, %eax
movl %eax, 0x30db(%rip)      # 0x6190
addl %eax, %r13d
cmpl %r13d, 0x30cd(%rip)     # 0x618c
jl 0x2fc7
decl %r13d
movl %r13d, 0x30bd(%rip)     # 0x618c
jmp 0x2fc7
cmpl $0xa, %eax
je 0x310d
cmpl $0xd, %eax
je 0x310d
cmpl $0x1b, %eax
jne 0x2fc7
jmp 0x323d
cmpl $0x157, %eax            # imm = 0x157
je 0x310d
cmpl $0x19a, %eax            # imm = 0x19A
jne 0x2fc7
callq 0x22a0
movq %r15, %rdi
callq 0x33a4
jmp 0x3178
movl 0x3079(%rip), %esi      # 0x618c
incl %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x3534
movl 0x3064(%rip), %esi      # 0x618c
incl %esi
movl $0x0, 0xc(%rsp)
movq %r15, %rdi
movq %r12, %rdx
callq 0x38e3
testq %rax, %rax
je 0x2fc7
movq %rax, %rbp
cmpl $0x2, 0x4(%rax)
jne 0x2fc7
callq 0x22a0
callq 0x22d0
cmpl $-0x1, %eax
je 0x3178
testl %eax, %eax
jle 0x324f
movl %eax, %edi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x2240
callq 0x2080
movq (%rbx), %rdi
movl $0x1, %esi
callq 0x21b0
jmp 0x2fc7
cmpl $0x2b, %eax
jne 0x2fc7
movl 0x2fee(%rip), %esi      # 0x618c
incl %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x3534
jmp 0x2fc7
movl 0x2fd4(%rip), %ecx      # 0x618c
xorl %eax, %eax
testl %ecx, %ecx
setg %al
subl %eax, %ecx
movl %ecx, 0x2fc5(%rip)      # 0x618c
movl 0x2fc3(%rip), %eax      # 0x6190
cmpl %ecx, %eax
jle 0x2fc7
cmpl $0x2, %eax
movl $0x1, %ecx
cmovll %ecx, %eax
decl %eax
movl %eax, 0x2fa8(%rip)      # 0x6190
jmp 0x2fc7
movl %r13d, %ecx
shrl $0x1f, %ecx
addl %r13d, %ecx
sarl %ecx
movl 0x2f92(%rip), %eax      # 0x6190
addl %r13d, %eax
addl %ecx, %eax
cmpl %eax, %ebp
jl 0x3209
movl %eax, %ebp
subl %r13d, %ebp
testl %ebp, %ebp
jg 0x3212
xorl %ebp, %ebp
movl %ebp, 0x2f78(%rip)      # 0x6190
cmpl %ebp, 0x2f6e(%rip)      # 0x618c
jge 0x2fc7
movl %ebp, 0x2f62(%rip)      # 0x618c
jmp 0x2fc7
cmpl $0x51, %eax
je 0x323d
cmpl $0x71, %eax
jne 0x2fc7
addq $0x3028, %rsp           # imm = 0x3028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4(%rsp), %rdi
callq 0x2190
callq 0x22d0
cmpl $-0x1, %eax
je 0x3351
testl %eax, %eax
jle 0x32a0
movl 0x4(%rsp), %edi
xorl %esi, %esi
callq 0x2120
movl 0x4(%rsp), %edi
callq 0x2180
movl 0x8(%rsp), %edi
callq 0x2180
leaq 0xe61(%rip), %rdi       # 0x40f0
movq %rdi, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22b0
jmp 0x3351
leaq 0x1020(%rsp), %r12
movq %rbp, %rdi
movq %r12, %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x253e
leaq 0xd45(%rip), %r13       # 0x4004
leaq 0x20(%rsp), %r15
movl $0x1000, %esi           # imm = 0x1000
movq %r15, %rdi
movq %r13, %rdx
movq 0x10(%rsp), %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x2140
movq %rbp, %rdi
movq %r12, %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x253e
leaq 0x2020(%rsp), %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
movq %r13, %rdx
movq 0x18(%rsp), %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x2140
movl 0x8(%rsp), %edi
movl $0x1, %esi
callq 0x2120
movl 0x4(%rsp), %edi
callq 0x2180
movl 0x8(%rsp), %edi
callq 0x2180
leaq 0xdbe(%rip), %rdi       # 0x40f5
leaq 0xdbc(%rip), %rdx       # 0x40fa
movq %rdi, %rsi
movq %r15, %rcx
movq %r14, %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x22b0
xorl %edi, %edi
callq 0x20a0