// File: /workspace/github_cpp_makefile_star2_O1/Linkerist[P]xs/src/ui.cc
// Function: user_interaction(int)
bool
user_interaction(int c)
{
 int num;
 string curen;

 switch (c) {
  // ==== Exits
  case CTRL('['): // vi
  case CTRL('g'): // emacs
   abort_xs();
   break;
  case 'q':
   finish(".", false);
   break;
  case 13: // ENTER
   // choose dir at cur pos
   return false;
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
  case '8':
  case '9':
   num =  c - '0' + shorties_offset;
   if(mode == LIST) {
	if (entry_nr_exists(num)) {
	 CurrPosition = num + yoffset;
	 return opt_no_resolve;
	}
   } else {
	CurrPosition = num + yoffset;
	return true;
   }
   break;

  // ==== Modes
  case '.':
   // show hidden files
   toggle_hidden();
   break;
  case '\t': // TAB
   toggle_mode();
   break;      

  // ==== Navigate The List
#if TERMINFO
  case KEY_DOWN:
#endif
   // navigate list++
   cur_pos_adjust(+1);
   break;

#if TERMINFO
  case KEY_UP:
#endif
   // navigate list--
   cur_pos_adjust(-1);
   break;

  case '^':       // vi?
  case CTRL('a'): // emacs
#if TERMINFO
  case KEY_HOME:
#endif
   // go to top
   CurrPosition = 0;
   yoffset = 0;
   break;

# if TERMINFO
  case KEY_END:
#endif
   // go to end
   if (mode == BROWSE)
	CurrPosition = cur_list.size() - 1;
   else if (mode == LIST)
	CurrPosition = default_list.size() - 1;

   yoffset = max_yoffset();
   break;

  //==== move the shortcut digits ('shorties')
  // FIXME maybe change the scrolling behaviour to not take the window but the whole
  // list? That means recentering when shorties leave the screen (adjust yoffset and
  // CurrPosition) 
#if TERMINFO      
  case KEY_NPAGE:
#endif
   for(int i = 0; i < 10; i++)
	cur_pos_adjust(+1, false);
   break;

#if TERMINFO
  case KEY_PPAGE:
#endif
   for(int i = 0; i < 10; i++)
	cur_pos_adjust(-1, false);
   break;

#if TERMINFO
  case KEY_LEFT:
#endif
   // up dir
   if (mode == BROWSE)
	//             LastPositions[get_current_dir_name()] = CurrPosition;
	LastPositions[get_cwd_as_charp()] = CurrPosition;
   else if (mode == LIST)
	mode = BROWSE;

   list_from_dir("..");
   break;

#if TERMINFO
  case KEY_RIGHT:
#endif
   // descend dir at cur pos
   curen = current_entry();
   if (mode == BROWSE)
	LastPositions[get_cwd_as_charp()] = CurrPosition;
   else
	mode = BROWSE;

   list_from_dir(curen.c_str());
   break;

  case '?':
   helpscreen();
   break;

#if TERMINFO
  case KEY_BACKSPACE:
#endif
   // delete dir acp
   if (mode == LIST && !NeedleGiven)
	delete_from_default_list(CurrPosition);
   else
	beep();

   break;

  #if TERMINFO
  case KEY_IC:
  #endif
  case 'a':
   // add dir acp (if in browse mode)
   if (!NeedleGiven) {
	if (mode == BROWSE)
	 add_to_default_list(current_entry());
	else
	 add_to_default_list(get_cwd_as_string());
   } else
	beep();

   break;

  case 'A':
   if (!NeedleGiven) {
	// add dir acp (if in browse mode) (ask for desc)
	if (mode == BROWSE)
	 add_to_default_list(current_entry(),"",true);
	else
	 add_to_default_list(get_cwd_as_string(),"",true);
   } else
	beep();

   break;
  case 'c':
   if (!NeedleGiven)
	// add the current dir in every mode
	add_to_default_list(get_cwd_as_string());
   else
	beep();

   break;
  case 'C':
   if (!NeedleGiven)
	// add the current dir in every mode (ask for desc)
	add_to_default_list(get_cwd_as_string(), "", true);
   else
	beep();

   break;

  // ==== EDIT the list
  case 'v':
  case 'e':
   if (!NeedleGiven)
	edit_list_file();
   else
	beep();

   break;

  case 'm':
   swap_two_entries(1);
   break;
  case 'M':
   swap_two_entries(-1);
   break;
  case 't':
  case 's':
   swap_two_entries(0);
   break;

  // ==== Filesystem Hotspots
  case '~':
   mode = BROWSE;
   list_from_dir(getenv("HOME"));
   break;
  case '/':
   mode = BROWSE;
   list_from_dir("/");
   break;
  default:
   beep();
   message("unknown command");
 }
 return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
leaq 0xf8(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
cmpl $0x5d, %edi
jg 0x7f7d
cmpl $0xc, %edi
jle 0x807e
leal -0x2e(%rdi), %eax
cmpl $0x1f, %eax
ja 0x8230
leaq 0x289c(%rip), %rcx      # 0xa7e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x6631(%rip), %eax      # 0xe584
leal (%rdi,%rax), %ebp
addl $-0x30, %ebp
leaq 0x6588(%rip), %rax      # 0xe4e8
cmpl $0x0, (%rax)
je 0x810a
addl 0x660d(%rip), %ebp      # 0xe57c
leaq 0x653e(%rip), %rax      # 0xe4b4
movl %ebp, (%rax)
jmp 0x864c
movl $0x1, %eax
cmpl $0x101, %edi            # imm = 0x101
jg 0x803f
leal -0x6d(%rdi), %ecx
cmpl $0x9, %ecx
jbe 0x80a1
leal -0x5e(%rdi), %eax
cmpl $0x7, %eax
ja 0x824a
leaq 0x28b3(%rip), %rcx      # 0xa860
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x64f3(%rip), %rax      # 0xe4b0
cmpb $0x0, (%rax)
jne 0x84db
leaq 0x128(%rsp), %rdi
callq 0x40a1
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x23b0(%rip), %rdx      # 0xa393
leaq 0x28(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x128(%rsp), %rdi
leaq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x618a
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x801b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x138(%rsp), %rax
movq -0x10(%rax), %rdi
movb $0x1, %bl
cmpq %rax, %rdi
je 0x864e
movq 0x138(%rsp), %rsi
jmp 0x8704
cmpl $0x14a, %edi            # imm = 0x14A
jg 0x80b8
addl $0xfffffefe, %edi       # imm = 0xFFFFFEFE
cmpl $0x5, %edi
ja 0x8270
leaq 0x284b(%rip), %rcx      # 0xa8a8
movslq (%rcx,%rdi,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movb $0x1, %bl
movl %eax, %edi
movl $0x1, %esi
callq 0x5f4a
jmp 0x864e
cmpl $0x1, %edi
je 0x80f4
cmpl $0x7, %edi
je 0x823e
cmpl $0x9, %edi
jne 0x8270
movb $0x1, %bl
callq 0x88e8
jmp 0x864e
leaq 0x27d8(%rip), %rdx      # 0xa880
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %eax, %eax
jmp 0x8498
cmpl $0x152, %edi            # imm = 0x152
jg 0x8138
cmpl $0x14b, %edi            # imm = 0x14B
je 0x8188
cmpl $0x152, %edi            # imm = 0x152
jne 0x8270
movl $0xa, %ebp
movl $0x1, %edi
xorl %esi, %esi
callq 0x5f4a
movb $0x1, %bl
decl %ebp
jne 0x80dd
jmp 0x864e
leaq 0x63b9(%rip), %rax      # 0xe4b4
xorl %ecx, %ecx
movl %ecx, (%rax)
movl %ecx, 0x6477(%rip)      # 0xe57c
jmp 0x864c
movl %ebp, %edi
callq 0x600a
movb $0x1, %bl
testb %al, %al
je 0x864e
addl 0x645b(%rip), %ebp      # 0xe57c
leaq 0x638c(%rip), %rax      # 0xe4b4
movl %ebp, (%rax)
leaq 0x63bd(%rip), %rax      # 0xe4ee
movb (%rax), %bl
jmp 0x864e
cmpl $0x168, %edi            # imm = 0x168
je 0x835f
cmpl $0x153, %edi            # imm = 0x153
jne 0x8270
movl $0xa, %ebp
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
callq 0x5f4a
movb $0x1, %bl
decl %ebp
jne 0x8155
jmp 0x864e
leaq 0x633d(%rip), %rax      # 0xe4b0
cmpb $0x0, (%rax)
jne 0x84db
movb $0x1, %bl
callq 0x657e
jmp 0x864e
leaq 0x6321(%rip), %rax      # 0xe4b0
cmpb $0x0, (%rax)
jne 0x84db
leaq 0x6349(%rip), %rax      # 0xe4e8
cmpl $0x1, (%rax)
jne 0x84fa
leaq 0x1a8(%rsp), %rdi
callq 0x6045
leaq 0xb8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x21cb(%rip), %rdx      # 0xa393
leaq 0xa8(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x1a8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
xorl %edx, %edx
callq 0x618a
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
je 0x820c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
movb $0x1, %bl
cmpq %rax, %rdi
je 0x864e
movq 0x1b8(%rsp), %rsi
jmp 0x8704
cmpl $0xd, %edi
je 0x84f3
cmpl $0x1b, %edi
jne 0x8270
movb $0x1, %bl
callq 0x4011
jmp 0x864e
cmpl $0x7e, %edi
jne 0x8270
leaq 0x6292(%rip), %rax      # 0xe4e8
movl $0x1, (%rax)
leaq 0x1dd4(%rip), %rdi      # 0xa037
callq 0x3420
movq %rax, %rdi
jmp 0x8590
callq 0x3090
movb $0x1, %bl
leaq 0x2642(%rip), %rdi      # 0xa8c0
callq 0x924b
jmp 0x864e
leaq 0xd8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1f16(%rip), %rsi      # 0xa1b1
leaq 0x1f10(%rip), %rdx      # 0xa1b2
leaq 0xc8(%rsp), %rdi
callq 0x4b08
leaq 0xc8(%rsp), %rdi
xorl %esi, %esi
callq 0x41e9
movq 0xc8(%rsp), %rdi
movb $0x1, %bl
cmpq %r14, %rdi
je 0x864e
movq 0xd8(%rsp), %rsi
jmp 0x8704
leaq 0x1c8(%rsp), %rdi
callq 0x6045
leaq 0xe8(%rsp), %rdi
leaq 0x1c8(%rsp), %rbx
movq %rbx, %rsi
callq 0x3430
movq (%rbx), %rdi
leaq 0x1d8(%rsp), %rax
cmpq %rax, %rdi
je 0x8323
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x61be(%rip), %rax      # 0xe4e8
cmpl $0x1, (%rax)
jne 0x8582
leaq 0x617a(%rip), %rax      # 0xe4b4
movl (%rax), %ebx
callq 0x4035
leaq 0x1c8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x6165(%rip), %rdi      # 0xe4b8
callq 0x68d4
movl %ebx, (%rax)
jmp 0x8588
leaq 0x6182(%rip), %rax      # 0xe4e8
movl (%rax), %eax
cmpl $0x1, %eax
je 0x8624
testl %eax, %eax
jne 0x8641
leaq 0x6110(%rip), %rax      # 0xe490
jmp 0x862b
leaq 0x615c(%rip), %rax      # 0xe4e8
movl (%rax), %ecx
leaq 0x1e1b(%rip), %r14      # 0xa1b0
testl %ecx, %ecx
je 0x867b
cmpl $0x1, %ecx
jne 0x8681
leaq 0x6107(%rip), %rax      # 0xe4b4
movl (%rax), %ebx
callq 0x4035
leaq 0x1c8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x60f2(%rip), %rdi      # 0xe4b8
callq 0x68d4
movl %ebx, (%rax)
jmp 0x8681
leaq 0x610f(%rip), %rax      # 0xe4e8
cmpl $0x0, (%rax)
jne 0x84db
leaq 0x60c7(%rip), %rax      # 0xe4b0
cmpb $0x0, (%rax)
jne 0x84db
leaq 0x60bb(%rip), %rax      # 0xe4b4
movl (%rax), %edi
movb $0x1, %bl
callq 0x652a
jmp 0x864e
leaq 0x60a2(%rip), %rax      # 0xe4b0
cmpb $0x0, (%rax)
jne 0x84db
leaq 0x108(%rsp), %rdi
callq 0x40a1
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1f5f(%rip), %rdx      # 0xa393
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x108(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x618a
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x846f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
movb $0x1, %bl
cmpq %rax, %rdi
je 0x864e
movq 0x118(%rsp), %rsi
jmp 0x8704
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movb $0x1, %bl
movl %eax, %edi
callq 0x9109
jmp 0x864e
movb $0x1, %bl
callq 0x44cd
jmp 0x864e
leaq 0x602f(%rip), %rax      # 0xe4e8
movl $0x1, (%rax)
leaq 0x1b6f(%rip), %r14      # 0xa035
jmp 0x8681
leaq 0x5fde(%rip), %rax      # 0xe4b0
cmpb $0x0, (%rax)
je 0x859c
movb $0x1, %bl
callq 0x3090
jmp 0x864e
movb $0x1, %bl
callq 0x897a
jmp 0x864e
xorl %ebx, %ebx
jmp 0x864e
leaq 0x188(%rsp), %rdi
callq 0x40a1
leaq 0x98(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1e79(%rip), %rdx      # 0xa393
leaq 0x88(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x188(%rsp), %rdi
leaq 0x88(%rsp), %rsi
xorl %edx, %edx
callq 0x618a
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x855e
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
movb $0x1, %bl
cmpq %rax, %rdi
je 0x864e
movq 0x198(%rsp), %rsi
jmp 0x8704
movl $0x1, (%rax)
movq 0xe8(%rsp), %rdi
movb $0x1, %bl
callq 0x50fa
jmp 0x864e
leaq 0x5f45(%rip), %rax      # 0xe4e8
cmpl $0x1, (%rax)
jne 0x868d
leaq 0x168(%rsp), %rdi
callq 0x6045
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1dca(%rip), %rdx      # 0xa393
leaq 0x68(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x168(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x1, %edx
callq 0x618a
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x8604
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x178(%rsp), %rax
movq -0x10(%rax), %rdi
movb $0x1, %bl
cmpq %rax, %rdi
je 0x864e
movq 0x178(%rsp), %rsi
jmp 0x8704
leaq 0x5e4d(%rip), %rax      # 0xe478
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x6, %rcx
decl %ecx
leaq 0x5e75(%rip), %rax      # 0xe4b4
movl %ecx, (%rax)
callq 0x44ea
movl %eax, 0x5f30(%rip)      # 0xe57c
movb $0x1, %bl
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x866b
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3350
movl %ebx, %eax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, (%rax)
movb $0x1, %bl
movq %r14, %rdi
callq 0x50fa
jmp 0x864e
leaq 0x148(%rsp), %rdi
callq 0x40a1
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1ce9(%rip), %rdx      # 0xa393
leaq 0x48(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x148(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movl $0x1, %edx
callq 0x618a
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x86e5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
movb $0x1, %bl
cmpq %rax, %rdi
je 0x864e
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x864e
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x874c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x874c
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x8771
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x8771
movq %rax, %rbx
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x88c3
movq 0x158(%rsp), %rsi
jmp 0x88b0
movq %rax, %rbx
leaq 0x178(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x88c3
movq 0x178(%rsp), %rsi
jmp 0x88b0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x87b2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x87b2
movq %rax, %rbx
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x88c3
movq 0x118(%rsp), %rsi
jmp 0x88b0
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x881b
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x881b
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
je 0x883d
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x883d
movq %rax, %rbx
leaq 0x198(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x88c3
movq 0x198(%rsp), %rsi
jmp 0x88b0
movq %rax, %rbx
leaq 0x1b8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x88c3
movq 0x1b8(%rsp), %rsi
jmp 0x88b0
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x8877
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x8877
movq %rax, %rbx
leaq 0x138(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x88c3
movq 0x138(%rsp), %rsi
jmp 0x88b0
jmp 0x88c0
jmp 0x88c0
jmp 0x88c0
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x88c3
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x88c3
jmp 0x88c0
jmp 0x88c0
jmp 0x88c0
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x88e0
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3350
movq %rbx, %rdi
callq 0x3620