// File: /workspace/github_cpp_makefile_star2_O3/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 0x1fba(%rip), %rdi      # 0xa924
callq 0x3420
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
testq %rax, %rax
je 0x8997
movq %rax, %rbx
movq %rax, %rdi
callq 0x3180
movq %rbx, %rdx
addq %rax, %rdx
movq %rsp, %rdi
movq %rbx, %rsi
jmp 0x89a4
leaq 0x19f5(%rip), %rdx      # 0xa393
movq %rsp, %rdi
movq %rdx, %rsi
callq 0x4b0e
cmpq $0x0, 0x8(%rsp)
jne 0x8a16
leaq 0x1f72(%rip), %rbx      # 0xa92a
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x3310
testl %eax, %eax
je 0x89fe
leaq 0x1f69(%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 0x1f57(%rip), %rbx      # 0xa947
cmoveq %r14, %rbx
leaq (%rcx,%rcx,8), %r8
addq $0x4, %r8
jmp 0x8a09
movl $0xe, %r8d
movq 0x8(%rsp), %rdx
movq %rsp, %rdi
xorl %esi, %esi
movq %rbx, %rcx
callq 0x3580
callq 0x33e0
movq (%rsp), %rdi
leaq 0x1f26(%rip), %rsi      # 0xa94c
callq 0x30f0
testq %rax, %rax
je 0x8ff0
movq %rax, %r15
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f1c(%rip), %rsi      # 0xa963
leaq 0x1f37(%rip), %rdx      # 0xa985
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x4b0e
leaq 0x40(%rsp), %r14
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f16(%rip), %rsi      # 0xa986
leaq 0x1f3d(%rip), %rdx      # 0xa9b4
movq %r14, %rdi
callq 0x4b0e
leaq 0x60(%rsp), %r14
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f21(%rip), %rsi      # 0xa9b5
leaq 0x1f53(%rip), %rdx      # 0xa9ee
movq %r14, %rdi
callq 0x4b0e
leaq 0x80(%rsp), %r14
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f31(%rip), %rsi      # 0xa9ef
leaq 0x1f4b(%rip), %rdx      # 0xaa10
movq %r14, %rdi
callq 0x4b0e
leaq 0xa0(%rsp), %r14
leaq 0xb0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f29(%rip), %rsi      # 0xaa11
leaq 0x1f4b(%rip), %rdx      # 0xaa3a
movq %r14, %rdi
callq 0x4b0e
leaq 0xc0(%rsp), %r14
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f29(%rip), %rsi      # 0xaa3b
leaq 0x1f65(%rip), %rdx      # 0xaa7e
movq %r14, %rdi
callq 0x4b0e
leaq 0xe0(%rsp), %r14
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f43(%rip), %rsi      # 0xaa7f
leaq 0x1f66(%rip), %rdx      # 0xaaa9
movq %r14, %rdi
callq 0x4b0e
leaq 0x100(%rsp), %r14
leaq 0x110(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f44(%rip), %rsi      # 0xaaaa
leaq 0x1f6f(%rip), %rdx      # 0xaadc
movq %r14, %rdi
callq 0x4b0e
leaq 0x120(%rsp), %r14
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f4d(%rip), %rsi      # 0xaadd
leaq 0x1f76(%rip), %rdx      # 0xab0d
movq %r14, %rdi
callq 0x4b0e
leaq 0x140(%rsp), %r14
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f54(%rip), %rsi      # 0xab0e
leaq 0x1f72(%rip), %rdx      # 0xab33
movq %r14, %rdi
callq 0x4b0e
leaq 0x160(%rsp), %r14
leaq 0x170(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f50(%rip), %rsi      # 0xab34
leaq 0x1f64(%rip), %rdx      # 0xab4f
movq %r14, %rdi
callq 0x4b0e
leaq 0x180(%rsp), %r14
leaq 0x190(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f42(%rip), %rsi      # 0xab50
leaq 0x1f62(%rip), %rdx      # 0xab77
movq %r14, %rdi
callq 0x4b0e
leaq 0x1a0(%rsp), %r14
leaq 0x1b0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f40(%rip), %rsi      # 0xab78
leaq 0x1f5c(%rip), %rdx      # 0xab9b
movq %r14, %rdi
callq 0x4b0e
leaq 0x1c0(%rsp), %r14
leaq 0x1d0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f3a(%rip), %rsi      # 0xab9c
leaq 0x1f5b(%rip), %rdx      # 0xabc4
movq %r14, %rdi
callq 0x4b0e
leaq 0x1e0(%rsp), %r14
leaq 0x1f0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f39(%rip), %rsi      # 0xabc5
leaq 0x1f3f(%rip), %rdx      # 0xabd2
movq %r14, %rdi
callq 0x4b0e
leaq 0x200(%rsp), %r14
leaq 0x210(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f1d(%rip), %rsi      # 0xabd3
leaq 0x1f2e(%rip), %rdx      # 0xabeb
movq %r14, %rdi
callq 0x4b0e
leaq 0x220(%rsp), %r14
leaq 0x230(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f0c(%rip), %rsi      # 0xabec
leaq 0x1f30(%rip), %rdx      # 0xac17
movq %r14, %rdi
callq 0x4b0e
leaq 0x240(%rsp), %r14
leaq 0x250(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f0e(%rip), %rsi      # 0xac18
leaq 0x1f24(%rip), %rdx      # 0xac35
movq %r14, %rdi
callq 0x4b0e
leaq 0x260(%rsp), %r14
leaq 0x270(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f02(%rip), %rsi      # 0xac36
leaq 0x1f28(%rip), %rdx      # 0xac63
movq %r14, %rdi
callq 0x4b0e
leaq 0x280(%rsp), %r14
leaq 0x290(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f06(%rip), %rsi      # 0xac64
leaq 0x1f25(%rip), %rdx      # 0xac8a
movq %r14, %rdi
callq 0x4b0e
leaq 0x2a0(%rsp), %r14
leaq 0x2b0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f03(%rip), %rsi      # 0xac8b
leaq 0x1f2e(%rip), %rdx      # 0xacbd
movq %r14, %rdi
callq 0x4b0e
leaq 0x2c0(%rsp), %r14
leaq 0x2d0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1f0c(%rip), %rsi      # 0xacbe
leaq 0x1f30(%rip), %rdx      # 0xace9
movq %r14, %rdi
callq 0x4b0e
leaq 0x2e0(%rsp), %r14
leaq 0x2f0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1de9(%rip), %rsi      # 0xabc5
leaq 0x1def(%rip), %rdx      # 0xabd2
movq %r14, %rdi
callq 0x4b0e
leaq 0x300(%rsp), %r14
leaq 0x310(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee4(%rip), %rsi      # 0xacea
leaq 0x1ef3(%rip), %rdx      # 0xad00
movq %r14, %rdi
callq 0x4b0e
leaq 0x320(%rsp), %r14
leaq 0x330(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ed1(%rip), %rsi      # 0xad01
leaq 0x1f02(%rip), %rdx      # 0xad39
movq %r14, %rdi
callq 0x4b0e
leaq 0x340(%rsp), %r14
leaq 0x350(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee0(%rip), %rsi      # 0xad3a
leaq 0x1f04(%rip), %rdx      # 0xad65
movq %r14, %rdi
callq 0x4b0e
leaq 0x360(%rsp), %r14
leaq 0x370(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee2(%rip), %rsi      # 0xad66
leaq 0x1f09(%rip), %rdx      # 0xad94
movq %r14, %rdi
callq 0x4b0e
leaq 0x380(%rsp), %r14
leaq 0x390(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee7(%rip), %rsi      # 0xad95
leaq 0x1f0b(%rip), %rdx      # 0xadc0
movq %r14, %rdi
callq 0x4b0e
leaq 0x3a0(%rsp), %r14
leaq 0x3b0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ee9(%rip), %rsi      # 0xadc1
leaq 0x1f0c(%rip), %rdx      # 0xadeb
movq %r14, %rdi
callq 0x4b0e
leaq 0x3c0(%rsp), %r14
leaq 0x3d0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1eea(%rip), %rsi      # 0xadec
leaq 0x1f15(%rip), %rdx      # 0xae1e
movq %r14, %rdi
callq 0x4b0e
leaq 0x3e0(%rsp), %r14
leaq 0x3f0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1ef3(%rip), %rsi      # 0xae1f
leaq 0x1f1a(%rip), %rdx      # 0xae4d
movq %r14, %rdi
callq 0x4b0e
leaq 0x400(%rsp), %r14
leaq 0x410(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x143d(%rip), %rdx      # 0xa393
movq %r14, %rdi
movq %rdx, %rsi
callq 0x4b0e
leaq 0x113e(%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 0x8f6b
movl $0xa, %edi
movq %r15, %rsi
callq 0x3440
movq %r15, %rdi
callq 0x34a0
movq (%rsp), %rdi
leaq 0x199d(%rip), %rsi      # 0xa947
callq 0x30b0
testq %rax, %rax
je 0x8fbe
movl $0x1, %edi
callq 0x3280
callq 0x35f0
callq 0x7e8c
movq $-0x400, %rbx           # imm = 0xFC00
movq -0x10(%r13), %rdi
cmpq %rdi, %r13
je 0x8fe4
movq (%r13), %rsi
incq %rsi
callq 0x3350
addq $-0x20, %r13
addq $0x20, %rbx
jne 0x8fcf
jmp 0x9001
callq 0x7e8c
leaq 0x1952(%rip), %rdi      # 0xa94e
callq 0x9214
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x9017
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 0x90b6
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
jmp 0x9069
movq %rax, %r15
addq $-0x10, %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x9084
movq (%r14), %rsi
incq %rsi
callq 0x3350
leaq -0x20(%r14), %rax
addq $-0x10, %r14
cmpq %rbx, %r14
movq %rax, %r14
jne 0x9070
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x90aa
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq %r15, %rdi
callq 0x3620
jmp 0x90b6
jmp 0x90b6
movq %rax, %r15
jmp 0x9094
movq %rax, %r15
leaq 0x420(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x3715
jmp 0x9094