// File: /workspace/github_cpp_makefile_star2_O1/Linkerist[P]xs/src/ui.cc
// Function: helpscreen()
void
helpscreen(void)
{
#define PAGERENV "PAGER"
 const char * __pager = getenv(PAGERENV);
 string pager = __pager == NULL ? "" : string(__pager);
#undef PAGERENV
 if (pager.empty()) {
  // FIXME:  how to detect debian and the /usr/bin/pager rule?
  struct stat buf;
  if (stat("/usr/bin/pager", &buf) == 0)
   pager = "/usr/bin/pager";
  else {
   if (stat("/usr/bin/less", &buf) == 0)
	pager = "/usr/bin/less";
   else
	pager = "more";
  }
 }

 endwin();
 FILE * help = popen(pager.c_str(), "w");
 // FIXME: error checking this doesn't work, er?
 if (help == NULL) {
  init_curses();
  message("could not open pager");
  return;
 }

 int l = 0;
 string help_lines[] = {
  "xs - Linkerist <Linkerist@163.com>",
  "<UP>/<DOWN>  move selection up/down and scroll",
  "             please see manpage for alternative bindings!",
  "<ENTER>      select current entry",
  "<TAB>        toggle modes: LIST or BROWSE",
  "<HOME>/<END> goto first/last entry in list if available in terminal",
  "c            add current directory to list",
  "C            same as 'c' but ask for a description",
  "<PgUP/Dn>    scroll the list 10 lines up or down",
  "e,v          edit the list in $EDITOR",
  "H,?          show this help",
  "~,/          browse home/root directory",
  "q            quit - saving the list",
  "C-c,C-g,C-[  abort - don't save the list",
  "             ",
  "Commands in BROWSE-mode:",
  "<LEFT>       descent into current directory",
  "<RIGHT>      up one directory",
  "[num]        make [num] the highlighted entry",
  "a            add current entry to list",
  "A            same as 'a' but ask for a description",
  ".            toggle display of hidden files",
  "             ",
  "Commands in LIST-mode:",
  "[num]        select and resolve entry [num] if displayed",
  "<LEFT>       descent into the current entry",
  "<RIGHT>      up one directory from current dir",
  "d            delete current entry from list",
  "a            add current directory to list",
  "s,t          swap(transpose) two lines in the list",
  "M/m          move an entry up down in the list",
  ""
 };

 int help_lines_size = 31;
 while (l < help_lines_size) {
  fprintf(help, "%s\n", help_lines[l].c_str());
  ++l;
 }
 fprintf(help, "\n");

 pclose(help);

 if (strstr(pager.c_str(), "more"))
  sleep(1);

 refresh();
 init_curses();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x420, %rsp            # imm = 0x420
leaq 0x1f93(%rip), %rdi      # 0xa924
callq 0x3420
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
testq %rax, %rax
je 0x89be
movq %rax, %rbx
movq %rax, %rdi
callq 0x3180
movq %rbx, %rdx
addq %rax, %rdx
movq %rsp, %rdi
movq %rbx, %rsi
jmp 0x89cb
leaq 0x19ce(%rip), %rdx      # 0xa393
movq %rsp, %rdi
movq %rdx, %rsi
callq 0x4b08
cmpq $0x0, 0x8(%rsp)
jne 0x8a3d
leaq 0x1f4b(%rip), %rbx      # 0xa92a
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x3310
testl %eax, %eax
je 0x8a25
leaq 0x1f42(%rip), %r14      # 0xa939
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x3310
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movq 0x8(%rsp), %rdx
leaq 0x1f30(%rip), %rbx      # 0xa947
cmoveq %r14, %rbx
leaq (%rcx,%rcx,8), %r8
addq $0x4, %r8
jmp 0x8a30
movl $0xe, %r8d
movq 0x8(%rsp), %rdx
movq %rsp, %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x3580
callq 0x33e0
movq (%rsp), %rdi
leaq 0x1eff(%rip), %rsi      # 0xa94c
callq 0x30f0
testq %rax, %rax
je 0x9017
movq %rax, %r15
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ef5(%rip), %rsi      # 0xa963
leaq 0x1f10(%rip), %rdx      # 0xa985
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x4b08
leaq 0x40(%rsp), %r14
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1eef(%rip), %rsi      # 0xa986
leaq 0x1f16(%rip), %rdx      # 0xa9b4
movq %r14, %rdi
callq 0x4b08
leaq 0x60(%rsp), %r14
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1efa(%rip), %rsi      # 0xa9b5
leaq 0x1f2c(%rip), %rdx      # 0xa9ee
movq %r14, %rdi
callq 0x4b08
leaq 0x80(%rsp), %r14
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f0a(%rip), %rsi      # 0xa9ef
leaq 0x1f24(%rip), %rdx      # 0xaa10
movq %r14, %rdi
callq 0x4b08
leaq 0xa0(%rsp), %r14
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f02(%rip), %rsi      # 0xaa11
leaq 0x1f24(%rip), %rdx      # 0xaa3a
movq %r14, %rdi
callq 0x4b08
leaq 0xc0(%rsp), %r14
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f02(%rip), %rsi      # 0xaa3b
leaq 0x1f3e(%rip), %rdx      # 0xaa7e
movq %r14, %rdi
callq 0x4b08
leaq 0xe0(%rsp), %r14
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f1c(%rip), %rsi      # 0xaa7f
leaq 0x1f3f(%rip), %rdx      # 0xaaa9
movq %r14, %rdi
callq 0x4b08
leaq 0x100(%rsp), %r14
leaq 0x110(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f1d(%rip), %rsi      # 0xaaaa
leaq 0x1f48(%rip), %rdx      # 0xaadc
movq %r14, %rdi
callq 0x4b08
leaq 0x120(%rsp), %r14
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f26(%rip), %rsi      # 0xaadd
leaq 0x1f4f(%rip), %rdx      # 0xab0d
movq %r14, %rdi
callq 0x4b08
leaq 0x140(%rsp), %r14
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f2d(%rip), %rsi      # 0xab0e
leaq 0x1f4b(%rip), %rdx      # 0xab33
movq %r14, %rdi
callq 0x4b08
leaq 0x160(%rsp), %r14
leaq 0x170(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f29(%rip), %rsi      # 0xab34
leaq 0x1f3d(%rip), %rdx      # 0xab4f
movq %r14, %rdi
callq 0x4b08
leaq 0x180(%rsp), %r14
leaq 0x190(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f1b(%rip), %rsi      # 0xab50
leaq 0x1f3b(%rip), %rdx      # 0xab77
movq %r14, %rdi
callq 0x4b08
leaq 0x1a0(%rsp), %r14
leaq 0x1b0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f19(%rip), %rsi      # 0xab78
leaq 0x1f35(%rip), %rdx      # 0xab9b
movq %r14, %rdi
callq 0x4b08
leaq 0x1c0(%rsp), %r14
leaq 0x1d0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f13(%rip), %rsi      # 0xab9c
leaq 0x1f34(%rip), %rdx      # 0xabc4
movq %r14, %rdi
callq 0x4b08
leaq 0x1e0(%rsp), %r14
leaq 0x1f0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f12(%rip), %rsi      # 0xabc5
leaq 0x1f18(%rip), %rdx      # 0xabd2
movq %r14, %rdi
callq 0x4b08
leaq 0x200(%rsp), %r14
leaq 0x210(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ef6(%rip), %rsi      # 0xabd3
leaq 0x1f07(%rip), %rdx      # 0xabeb
movq %r14, %rdi
callq 0x4b08
leaq 0x220(%rsp), %r14
leaq 0x230(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee5(%rip), %rsi      # 0xabec
leaq 0x1f09(%rip), %rdx      # 0xac17
movq %r14, %rdi
callq 0x4b08
leaq 0x240(%rsp), %r14
leaq 0x250(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee7(%rip), %rsi      # 0xac18
leaq 0x1efd(%rip), %rdx      # 0xac35
movq %r14, %rdi
callq 0x4b08
leaq 0x260(%rsp), %r14
leaq 0x270(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1edb(%rip), %rsi      # 0xac36
leaq 0x1f01(%rip), %rdx      # 0xac63
movq %r14, %rdi
callq 0x4b08
leaq 0x280(%rsp), %r14
leaq 0x290(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1edf(%rip), %rsi      # 0xac64
leaq 0x1efe(%rip), %rdx      # 0xac8a
movq %r14, %rdi
callq 0x4b08
leaq 0x2a0(%rsp), %r14
leaq 0x2b0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1edc(%rip), %rsi      # 0xac8b
leaq 0x1f07(%rip), %rdx      # 0xacbd
movq %r14, %rdi
callq 0x4b08
leaq 0x2c0(%rsp), %r14
leaq 0x2d0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee5(%rip), %rsi      # 0xacbe
leaq 0x1f09(%rip), %rdx      # 0xace9
movq %r14, %rdi
callq 0x4b08
leaq 0x2e0(%rsp), %r14
leaq 0x2f0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1dc2(%rip), %rsi      # 0xabc5
leaq 0x1dc8(%rip), %rdx      # 0xabd2
movq %r14, %rdi
callq 0x4b08
leaq 0x300(%rsp), %r14
leaq 0x310(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ebd(%rip), %rsi      # 0xacea
leaq 0x1ecc(%rip), %rdx      # 0xad00
movq %r14, %rdi
callq 0x4b08
leaq 0x320(%rsp), %r14
leaq 0x330(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1eaa(%rip), %rsi      # 0xad01
leaq 0x1edb(%rip), %rdx      # 0xad39
movq %r14, %rdi
callq 0x4b08
leaq 0x340(%rsp), %r14
leaq 0x350(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1eb9(%rip), %rsi      # 0xad3a
leaq 0x1edd(%rip), %rdx      # 0xad65
movq %r14, %rdi
callq 0x4b08
leaq 0x360(%rsp), %r14
leaq 0x370(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ebb(%rip), %rsi      # 0xad66
leaq 0x1ee2(%rip), %rdx      # 0xad94
movq %r14, %rdi
callq 0x4b08
leaq 0x380(%rsp), %r14
leaq 0x390(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ec0(%rip), %rsi      # 0xad95
leaq 0x1ee4(%rip), %rdx      # 0xadc0
movq %r14, %rdi
callq 0x4b08
leaq 0x3a0(%rsp), %r14
leaq 0x3b0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ec2(%rip), %rsi      # 0xadc1
leaq 0x1ee5(%rip), %rdx      # 0xadeb
movq %r14, %rdi
callq 0x4b08
leaq 0x3c0(%rsp), %r14
leaq 0x3d0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ec3(%rip), %rsi      # 0xadec
leaq 0x1eee(%rip), %rdx      # 0xae1e
movq %r14, %rdi
callq 0x4b08
leaq 0x3e0(%rsp), %r14
leaq 0x3f0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ecc(%rip), %rsi      # 0xae1f
leaq 0x1ef3(%rip), %rdx      # 0xae4d
movq %r14, %rdi
callq 0x4b08
leaq 0x400(%rsp), %r14
leaq 0x410(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1416(%rip), %rdx      # 0xa393
movq %r14, %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x1117(%rip), %rbx      # 0xa0a6
xorl %r14d, %r14d
movq 0x20(%rsp,%r14), %rdx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x34c0
addq $0x20, %r14
cmpq $0x3e0, %r14            # imm = 0x3E0
jne 0x8f92
movl $0xa, %edi
movq %r15, %rsi
callq 0x3440
movq %r15, %rdi
callq 0x34a0
movq (%rsp), %rdi
leaq 0x1976(%rip), %rsi      # 0xa947
callq 0x30b0
testq %rax, %rax
je 0x8fe5
movl $0x1, %edi
callq 0x3280
callq 0x35f0
callq 0x7eb3
movq $-0x400, %rbx           # imm = 0xFC00
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x900b
movq (%r13), %rsi
incq %rsi
callq 0x3350
addq $-0x20, %r13
addq $0x20, %rbx
jne 0x8ff6
jmp 0x9028
callq 0x7eb3
leaq 0x192b(%rip), %rdi      # 0xa94e
callq 0x924b
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x903e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
addq $0x420, %rsp            # imm = 0x420
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x90ed
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
jmp 0x9090
movq %rax, %r15
cmpq %r14, %rbx
je 0x90c5
addq $-0x10, %r14
leaq 0x20(%rsp), %rbx
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x90b5
movq (%r14), %rsi
incq %rsi
callq 0x3350
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %rbx, %r14
movq %rax, %r14
jne 0x90a1
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x90db
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq %r15, %rdi
callq 0x3620
movq %rax, %r15
movq %rbx, %r14
jmp 0x9093
jmp 0x90ed
movq %rax, %r15
jmp 0x90c5
movq %rax, %r15
leaq 0x420(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x3715
jmp 0x90c5