// File: /workspace/github_c_makefile_star2_O1/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       # 0x3350
callq 0x39c0
callq 0x2030
testb %al, %al
je 0x2f9a
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 0x3032(%rip), %rbx      # 0x5fd8
movq (%rbx), %rdi
movl $0x1, %esi
callq 0x21b0
leaq 0xc(%rsp), %r12
leaq 0x10e1(%rip), %r14      # 0x40a0
movq %r15, %rdi
callq 0x3355
movl %eax, %ebp
movq %r15, %rdi
callq 0x339c
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2fe3
movswl 0x4(%rdi), %r13d
incl %r13d
jmp 0x2fe9
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
callq 0x20d0
cmpl $0x101, %eax            # imm = 0x101
jle 0x303f
cmpl $0x151, %eax            # imm = 0x151
jg 0x3071
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
cmpl $0x3, %eax
ja 0x2fbf
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movl 0x3177(%rip), %eax      # 0x618c
leal 0x1(%rax), %ecx
cmpl %ebp, %ecx
cmovll %ecx, %eax
movl %eax, 0x3169(%rip)      # 0x618c
subl %r13d, %eax
jl 0x2fbf
movl 0x3162(%rip), %ecx      # 0x6190
xorl %edx, %edx
cmpl %eax, %ecx
setle %dl
addl %ecx, %edx
movl %edx, 0x3153(%rip)      # 0x6190
jmp 0x2fbf
cmpl $0x2a, %eax
jle 0x30cc
cmpl $0x2c, %eax
jle 0x3187
cmpl $0x2d, %eax
jne 0x3227
movl 0x312c(%rip), %esi      # 0x618c
incl %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x351c
jmp 0x2fbf
cmpl $0x156, %eax            # imm = 0x156
jg 0x30e4
cmpl $0x152, %eax            # imm = 0x152
je 0x31e5
cmpl $0x153, %eax            # imm = 0x153
jne 0x2fbf
movl %r13d, %ecx
shrl $0x1f, %ecx
addl %r13d, %ecx
sarl %ecx
movl 0x30f1(%rip), %eax      # 0x6190
subl %ecx, %eax
testl %eax, %eax
jg 0x30a7
xorl %eax, %eax
movl %eax, 0x30e3(%rip)      # 0x6190
addl %eax, %r13d
cmpl %r13d, 0x30d5(%rip)     # 0x618c
jl 0x2fbf
decl %r13d
movl %r13d, 0x30c5(%rip)     # 0x618c
jmp 0x2fbf
cmpl $0xa, %eax
je 0x3105
cmpl $0xd, %eax
je 0x3105
cmpl $0x1b, %eax
jne 0x2fbf
jmp 0x3235
cmpl $0x157, %eax            # imm = 0x157
je 0x3105
cmpl $0x19a, %eax            # imm = 0x19A
jne 0x2fbf
callq 0x22a0
movq %r15, %rdi
callq 0x339c
jmp 0x3170
movl 0x3081(%rip), %esi      # 0x618c
incl %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x351c
movl 0x306c(%rip), %esi      # 0x618c
incl %esi
movl $0x0, 0xc(%rsp)
movq %r15, %rdi
movq %r12, %rdx
callq 0x38cb
testq %rax, %rax
je 0x2fbf
movq %rax, %rbp
cmpl $0x2, 0x4(%rax)
jne 0x2fbf
callq 0x22a0
callq 0x22d0
cmpl $-0x1, %eax
je 0x3170
testl %eax, %eax
jle 0x3247
movl %eax, %edi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x2240
callq 0x2080
movq (%rbx), %rdi
movl $0x1, %esi
callq 0x21b0
jmp 0x2fbf
cmpl $0x2b, %eax
jne 0x2fbf
movl 0x2ff6(%rip), %esi      # 0x618c
incl %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x351c
jmp 0x2fbf
movl 0x2fdc(%rip), %ecx      # 0x618c
xorl %eax, %eax
testl %ecx, %ecx
setg %al
subl %eax, %ecx
movl %ecx, 0x2fcd(%rip)      # 0x618c
movl 0x2fcb(%rip), %eax      # 0x6190
cmpl %ecx, %eax
jle 0x2fbf
cmpl $0x2, %eax
movl $0x1, %ecx
cmovll %ecx, %eax
decl %eax
movl %eax, 0x2fb0(%rip)      # 0x6190
jmp 0x2fbf
movl 0x2fa5(%rip), %ecx      # 0x6190
addl %r13d, %ecx
movl %r13d, %eax
shrl $0x1f, %eax
addl %r13d, %eax
sarl %eax
addl %ecx, %eax
cmpl %eax, %ebp
jl 0x3201
movl %eax, %ebp
subl %r13d, %ebp
testl %ebp, %ebp
jg 0x320a
xorl %ebp, %ebp
movl %ebp, 0x2f80(%rip)      # 0x6190
cmpl %ebp, 0x2f76(%rip)      # 0x618c
jge 0x2fbf
movl %ebp, 0x2f6a(%rip)      # 0x618c
jmp 0x2fbf
cmpl $0x51, %eax
je 0x3235
cmpl $0x71, %eax
jne 0x2fbf
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 0x3349
testl %eax, %eax
jle 0x3298
movl 0x4(%rsp), %edi
xorl %esi, %esi
callq 0x2120
movl 0x4(%rsp), %edi
callq 0x2180
movl 0x8(%rsp), %edi
callq 0x2180
leaq 0xe69(%rip), %rdi       # 0x40f0
movq %rdi, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22b0
jmp 0x3349
leaq 0x1020(%rsp), %r12
movq %rbp, %rdi
movq %r12, %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x2537
leaq 0xd4d(%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 0x2537
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 0xdc6(%rip), %rdi       # 0x40f5
leaq 0xdc4(%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