// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
callq 0x2140
leaq 0x450(%rip), %rdi       # 0x36c0
callq 0x4370
callq 0x2030
testb $0x1, %al
jne 0x3283
jmp 0x3316
callq 0x2150
movl $0x1, %edi
movl $0x7, %esi
xorl %edx, %edx
callq 0x2200
movl $0x2, %edi
movl $0x5, %esi
xorl %edx, %edx
callq 0x2200
movl $0x3, %edi
movl $0x4, %esi
xorl %edx, %edx
callq 0x2200
movl $0x4, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2200
movl $0x5, %edi
xorl %esi, %esi
movl $0x7, %edx
callq 0x2200
movl $0x6, %edi
movl $0x5, %esi
movl $0x7, %edx
callq 0x2200
movl $0x7, %edx
movl $0x4, %esi
movl %edx, %edi
callq 0x2200
movl $0x8, %edi
movl $0x1, %esi
movl $0x7, %edx
callq 0x2200
callq 0x2100
movq 0x3cb6(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x21a0
movq -0x8(%rbp), %rdi
callq 0x36d0
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3750
xorl %eax, %eax
movq 0x3c8b(%rip), %rcx      # 0x6fd8
cmpq (%rcx), %rax
je 0x3368
movq 0x3c7f(%rip), %rax      # 0x6fd8
movq (%rax), %rax
movswl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3372
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x2c(%rbp)
jmp 0x3372
movl -0x2c(%rbp), %eax
movl %eax, -0x20(%rbp)
xorl %eax, %eax
movq 0x3c57(%rip), %rcx      # 0x6fd8
cmpq (%rcx), %rax
je 0x339c
movq 0x3c4b(%rip), %rax      # 0x6fd8
movq (%rax), %rax
movswl 0x6(%rax), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x33a6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x30(%rbp)
jmp 0x33a6
movl -0x30(%rbp), %eax
movl %eax, -0x24(%rbp)
movq 0x3c25(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x20c0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x34(%rbp)
subl $0xa, %eax
je 0x3674
jmp 0x33cf
movl -0x34(%rbp), %eax
subl $0xd, %eax
je 0x3674
jmp 0x33dd
movl -0x34(%rbp), %eax
subl $0x1b, %eax
je 0x36a7
jmp 0x33eb
movl -0x34(%rbp), %eax
subl $0x2b, %eax
je 0x3598
jmp 0x33f9
movl -0x34(%rbp), %eax
subl $0x2d, %eax
je 0x357f
jmp 0x3407
movl -0x34(%rbp), %eax
subl $0x51, %eax
je 0x36a7
jmp 0x3415
movl -0x34(%rbp), %eax
subl $0x71, %eax
je 0x36a7
jmp 0x3423
movl -0x34(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x350b
jmp 0x3433
movl -0x34(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x34ad
jmp 0x343f
movl -0x34(%rbp), %eax
subl $0x104, %eax            # imm = 0x104
je 0x357f
jmp 0x344f
movl -0x34(%rbp), %eax
subl $0x105, %eax            # imm = 0x105
je 0x3598
jmp 0x345f
movl -0x34(%rbp), %eax
subl $0x152, %eax            # imm = 0x152
je 0x35b4
jmp 0x346f
movl -0x34(%rbp), %eax
subl $0x153, %eax            # imm = 0x153
je 0x361c
jmp 0x347f
movl -0x34(%rbp), %eax
subl $0x157, %eax            # imm = 0x157
je 0x3674
jmp 0x348f
movl -0x34(%rbp), %eax
subl $0x19a, %eax            # imm = 0x19A
jne 0x36ad
jmp 0x349f
movq -0x8(%rbp), %rdi
callq 0x3990
jmp 0x36ad
movl 0x3cd1(%rip), %eax      # 0x7184
addl $-0x1, %eax
movl %eax, 0x3cc8(%rip)      # 0x7184
cmpl $0x0, 0x3cc1(%rip)      # 0x7184
jge 0x34d4
movl 0x3cb9(%rip), %eax      # 0x7184
addl $0x1, %eax
movl %eax, 0x3cb0(%rip)      # 0x7184
movl 0x3cae(%rip), %eax      # 0x7188
cmpl 0x3ca4(%rip), %eax      # 0x7184
jle 0x3506
movl 0x3ca0(%rip), %eax      # 0x7188
addl $-0x1, %eax
movl %eax, 0x3c97(%rip)      # 0x7188
cmpl $0x0, 0x3c90(%rip)      # 0x7188
jge 0x3504
movl $0x0, 0x3c84(%rip)      # 0x7188
jmp 0x3506
jmp 0x36ad
movl 0x3c73(%rip), %eax      # 0x7184
addl $0x1, %eax
movl %eax, 0x3c6a(%rip)      # 0x7184
movl 0x3c64(%rip), %eax      # 0x7184
cmpl -0x28(%rbp), %eax
jl 0x3534
movl 0x3c59(%rip), %eax      # 0x7184
addl $-0x1, %eax
movl %eax, 0x3c50(%rip)      # 0x7184
movl 0x3c4a(%rip), %eax      # 0x7184
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x357a
movl 0x3c3e(%rip), %eax      # 0x7188
addl $0x1, %eax
movl %eax, 0x3c35(%rip)      # 0x7188
movl 0x3c2f(%rip), %eax      # 0x7188
movl 0x3c25(%rip), %ecx      # 0x7184
subl -0x20(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x3578
movl 0x3c19(%rip), %eax      # 0x7188
addl $-0x1, %eax
movl %eax, 0x3c10(%rip)      # 0x7188
jmp 0x357a
jmp 0x36ad
movq -0x8(%rbp), %rdi
movl 0x3bfb(%rip), %esi      # 0x7184
addl $0x1, %esi
xorl %edx, %edx
callq 0x39d0
jmp 0x36ad
movq -0x8(%rbp), %rdi
movl 0x3be2(%rip), %esi      # 0x7184
addl $0x1, %esi
movl $0x1, %edx
callq 0x39d0
jmp 0x36ad
movl -0x20(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl 0x3bc3(%rip), %eax      # 0x7188
movl %eax, 0x3bbd(%rip)      # 0x7188
movl -0x20(%rbp), %eax
addl 0x3bb4(%rip), %eax      # 0x7188
cmpl -0x28(%rbp), %eax
jle 0x35ea
movl 0x3ba9(%rip), %eax      # 0x7188
addl $-0x1, %eax
movl %eax, 0x3ba0(%rip)      # 0x7188
jmp 0x35cb
cmpl $0x0, 0x3b97(%rip)      # 0x7188
jge 0x35fd
movl $0x0, 0x3b8b(%rip)      # 0x7188
movl 0x3b81(%rip), %eax      # 0x7184
cmpl 0x3b7f(%rip), %eax      # 0x7188
jge 0x3617
movl 0x3b77(%rip), %eax      # 0x7188
movl %eax, 0x3b6d(%rip)      # 0x7184
jmp 0x36ad
movl -0x20(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl 0x3b59(%rip), %eax      # 0x7188
subl %ecx, %eax
movl %eax, 0x3b51(%rip)      # 0x7188
cmpl $0x0, 0x3b4a(%rip)      # 0x7188
jge 0x364a
movl $0x0, 0x3b3e(%rip)      # 0x7188
movl 0x3b34(%rip), %eax      # 0x7184
movl -0x20(%rbp), %ecx
addl 0x3b2f(%rip), %ecx      # 0x7188
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x3672
movl -0x20(%rbp), %eax
addl 0x3b1f(%rip), %eax      # 0x7188
subl $0x1, %eax
movl %eax, 0x3b12(%rip)      # 0x7184
jmp 0x36ad
movq -0x8(%rbp), %rdi
movl 0x3b06(%rip), %esi      # 0x7184
addl $0x1, %esi
movl $0x1, %edx
callq 0x39d0
movq -0x8(%rbp), %rdi
movl 0x3aef(%rip), %esi      # 0x7184
addl $0x1, %esi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x3a40
jmp 0x36ad
addq $0x40, %rsp
popq %rbp
retq
jmp 0x332f
nopw %cs:(%rax,%rax)