// File: /workspace/github_cpp_makefile_star2_O3/Linkerist[P]xs/src/io.cc
// Function: list_from_dir(char const*)
void
list_from_dir(const char * name)
{
 string previous_dir = "";
 if (!strcmp(name, ".."))
  previous_dir = get_cwd_as_string();

 // Checking, Changing and Reading
 if (chdir(name) < 0) {
  string msg = "couldn't change to dir: ";
  msg += name;
  message(msg.c_str());
 }
   
 DIR * THISDIR;
 string cwd = get_cwd_as_string();
 THISDIR = opendir(cwd.c_str());

 if (THISDIR == NULL) {
  string msg = "couldn't read dir: ";
  msg += cwd;
  message(msg.c_str());
  sleep(1);
  abort_xs();
 }
 yoffset = 0;
 shorties_offset = 1;
 struct dirent * en;
 struct stat buf;

 // cleanup
 cur_list.clear();

 CurrPosition = 1;

 // put the current directory on top ef every listing
 string desc = ".";
 cur_list.push_back(make_pair(desc,cwd));

 // read home dir
 while ((en = readdir(THISDIR)) != NULL) {
  /* filter dirs */
  if (dont_show(en->d_name))
   continue;
  string fullname;
  fullname = cwd + string("/") + string(en->d_name);

  fullname = canonify_filename(fullname);

  stat(fullname.c_str(), &buf);
  if (!S_ISDIR(buf.st_mode))
   continue;

  string lastdir = last_dirname(fullname);
  cur_list.push_back(make_pair(lastdir, fullname));
 }
 // empty directory listing: .. and .
 desc = "..";
 string path=get_cwd_as_string();
 if(cur_list.size() == 1) {
  path = path.substr(0, path.find(last_dirname(path)));
  cur_list.push_back(make_pair(desc,path));
 }

 sort(cur_list.begin(), cur_list.end());

 // have we remembered a current position for this dir?
 if (LastPositions.count(cwd.c_str()))
  CurrPosition = LastPositions[cwd.c_str()];
 else {
  //CurrPosition = 1;
  if(previous_dir.length() > 0) {
   int count = 0;
   for(listit it = cur_list.begin(); it != cur_list.end(); ++it, count++) {
    if(it->second == previous_dir) {
     CurrPosition = count;
     break;
    }
   }
  }
 }

 if(!visible(CurrPosition))
  yoffset = CurrPosition - 1;

 closedir(THISDIR);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdi, %rbx
leaq 0xb0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x5269(%rip), %rdx      # 0xa393
leaq 0xa0(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b0e
cmpb $0x2e, (%rbx)
jne 0x5190
cmpb $0x2e, 0x1(%rbx)
jne 0x5190
cmpb $0x0, 0x2(%rbx)
jne 0x5190
leaq 0x188(%rsp), %rdi
callq 0x40a0
leaq 0xa0(%rsp), %rdi
leaq 0x188(%rsp), %r14
movq %r14, %rsi
callq 0x3430
movq (%r14), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
je 0x5190
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x3350
movq %rbx, %rdi
callq 0x34f0
testl %eax, %eax
jns 0x51fd
leaq 0x198(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5004(%rip), %rsi      # 0xa1b3
leaq 0x5015(%rip), %rdx      # 0xa1cb
leaq 0x188(%rsp), %rdi
callq 0x4b0e
leaq 0x188(%rsp), %rdi
movq %rbx, %rsi
callq 0x3680
movq 0x188(%rsp), %rdi
callq 0x9214
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0x51fd
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0xc0(%rsp), %rdi
callq 0x40a0
movq 0xc0(%rsp), %rdi
callq 0x3530
movq %rax, 0xe0(%rsp)
testq %rax, %rax
jne 0x52a1
leaq 0x198(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x4f95(%rip), %rsi      # 0xa1cc
leaq 0x4fa1(%rip), %rdx      # 0xa1df
leaq 0x188(%rsp), %rdi
callq 0x4b0e
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
leaq 0x188(%rsp), %rdi
callq 0x3110
movq 0x188(%rsp), %rdi
callq 0x9214
movl $0x1, %edi
callq 0x3280
callq 0x4010
movq 0x188(%rsp), %rdi
cmpq %rbx, %rdi
je 0x52a1
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x92d4(%rip), %rax      # 0xe57c
movl $0x0, (%rax)
leaq 0x92cf(%rip), %rax      # 0xe584
movl $0x1, %ebx
movl %ebx, (%rax)
leaq 0x91b5(%rip), %rdi      # 0xe478
movq (%rdi), %rsi
callq 0x69c2
leaq 0x91e2(%rip), %rax      # 0xe4b4
movl %ebx, (%rax)
leaq 0x90(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x4eca(%rip), %rsi      # 0xa1b1
leaq 0x4ec4(%rip), %rdx      # 0xa1b2
leaq 0x80(%rsp), %rdi
callq 0x4b0e
leaq 0x40(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x695e
leaq 0x915c(%rip), %rdi      # 0xe478
leaq 0x40(%rsp), %rsi
callq 0x69f2
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5341
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x50(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x535c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0xf8(%rsp), %rbx
leaq 0x20(%rsp), %r15
leaq 0x40(%rsp), %r12
movq 0xe0(%rsp), %rdi
callq 0x3550
movq %rax, %r14
testq %rax, %rax
je 0x573c
addq $0x13, %r14
movq %r14, %rdi
callq 0x509d
testb %al, %al
jne 0x536e
movq %r13, %rbp
movq %r15, %r13
movq %rbx, %r15
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
leaq 0x158(%rsp), %rax
movq %rax, 0x148(%rsp)
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
leaq 0x4c5b(%rip), %rsi      # 0xa035
leaq 0x4c55(%rip), %rdx      # 0xa036
callq 0x4b0e
movq 0xc0(%rsp), %rcx
movq 0xc8(%rsp), %r8
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33b0
leaq 0x10(%rsp), %rsi
movq %rsi, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq %r15, %rbx
je 0x542b
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x5431
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %r13, %r15
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, 0xe8(%rsp)
movq %r14, %rdi
callq 0x3180
leaq (%rax,%r14), %rdx
leaq 0xe8(%rsp), %rdi
movq %r14, %rsi
callq 0x4b0e
movq %rbp, %r13
movq (%rsp), %rcx
movl $0xf, %edi
leaq 0x10(%rsp), %rbp
cmpq %rbp, %rcx
je 0x548b
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0xe8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x54c0
movl $0xf, %edi
cmpq %rbx, %rsi
je 0x54bb
movq 0xf8(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x54ca
movq %rsp, %rdi
callq 0x3110
jmp 0x54db
leaq 0xe8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33b0
movq %r13, 0x40(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x54fb
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x5503
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq %r15, %rdi
movq %r12, %rsi
callq 0x3430
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x5542
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0xe8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x555f
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x557a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x559f
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %rbp
movq %rbp, %rdi
callq 0x4a20
movq %r12, %r14
movq %r12, %rdi
movq %rbp, %rsi
callq 0x39fc
movq %r15, %rdi
movq %r14, %rsi
callq 0x3430
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x55fc
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x5621
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x20(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x3310
movl 0x1a0(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x5717
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0x4a20
movq %rsp, %rdi
movq %r14, %rsi
callq 0x9830
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x56a9
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3350
movq %r12, %r14
movq %r12, %rdi
movq %rsp, %rsi
movq %r15, %rdx
callq 0x695e
leaq 0x8db7(%rip), %rdi      # 0xe478
movq %r14, %rsi
callq 0x69f2
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x56e5
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x56fc
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5717
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x536e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x536e
leaq 0x80(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x4a61(%rip), %rcx      # 0xa1b0
movl $0x2, %r8d
xorl %esi, %esi
callq 0x3580
leaq 0x20(%rsp), %rdi
callq 0x40a0
leaq 0x8d0b(%rip), %rax      # 0xe478
movq (%rax), %r14
movq 0x8(%rax), %r15
movq %r15, %rax
subq %r14, %rax
cmpq $0x40, %rax
jne 0x58a8
leaq 0x178(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x168(%rsp), %rdi
callq 0x4a20
movq %rsp, %rdi
leaq 0x168(%rsp), %rsi
callq 0x9830
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %edx, %edx
callq 0x3610
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x3370
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %r14
movq %r14, %rsi
callq 0x3430
movq (%r14), %rdi
cmpq %r13, %rdi
je 0x580b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5826
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5843
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x40(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x695e
leaq 0x8c17(%rip), %r15      # 0xe478
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
callq 0x69f2
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x588a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x58a1
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%r15), %r14
movq 0x8(%r15), %r15
cmpq %r15, %r14
leaq 0xb0(%rsp), %r13
je 0x58e2
movq %r15, %rax
subq %r14, %rax
sarq $0x6, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x6c5c
movq %r14, %rdi
movq %r15, %rsi
callq 0x6d30
movq 0xc0(%rsp), %rax
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8bbf(%rip), %r14      # 0xe4b8
movq %r14, %rdi
callq 0x770c
addq $0x8, %r14
cmpq %r14, %rax
je 0x59f9
movq 0xc0(%rsp), %rax
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8b93(%rip), %rdi      # 0xe4b8
callq 0x68fa
movl (%rax), %eax
leaq 0x8b81(%rip), %rcx      # 0xe4b4
movl %eax, (%rcx)
leaq 0x8b78(%rip), %rax      # 0xe4b4
movl (%rax), %edi
callq 0x44a9
testb %al, %al
jne 0x595b
leaq 0x8b66(%rip), %rax      # 0xe4b4
movl (%rax), %eax
decl %eax
leaq 0x8c23(%rip), %rcx      # 0xe57c
movl %eax, (%rcx)
movq 0xe0(%rsp), %rdi
callq 0x35c0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5984
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x59a9
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59ca
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0xa0(%rsp), %rdi
cmpq %r13, %rdi
je 0x59e7
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3350
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa8(%rsp), %r14
testq %r14, %r14
je 0x5935
leaq 0x8a67(%rip), %rax      # 0xe478
movq (%rax), %rbx
movq 0x8(%rax), %r12
cmpq %r12, %rbx
je 0x5935
xorl %ebp, %ebp
movq 0xa0(%rsp), %r15
cmpq %r14, 0x28(%rbx)
jne 0x5a44
movq 0x20(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3360
testl %eax, %eax
je 0x5a54
addq $0x40, %rbx
incl %ebp
cmpq %r12, %rbx
jne 0x5a2b
jmp 0x5935
leaq 0x8a59(%rip), %rax      # 0xe4b4
movl %ebp, (%rax)
jmp 0x5935
jmp 0x5b25
jmp 0x5b1d
jmp 0x5b25
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x68c4
jmp 0x5c3f
jmp 0x5bb0
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5aab
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x5aab
movq %rax, %r14
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5c3f
movq 0x178(%rsp), %rsi
jmp 0x5c37
jmp 0x5bb0
jmp 0x5bb0
movq %rax, %r14
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0x5cae
movq 0x198(%rsp), %rsi
jmp 0x5ca6
jmp 0x5bb0
jmp 0x5c5d
jmp 0x5c5d
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x68c4
jmp 0x5c70
movq %rax, %r14
jmp 0x5c70
movq %rax, %r14
jmp 0x5c8d
movq %rax, %r14
jmp 0x5cae
movq %rax, %r14
movq 0x188(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5c8d
movq 0x198(%rsp), %rsi
jmp 0x5c85
jmp 0x5bb0
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x68c4
jmp 0x5b62
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5c3f
movq 0x10(%rsp), %rsi
jmp 0x5c37
movq %rax, %r14
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x5c3f
movq 0x118(%rsp), %rsi
jmp 0x5c37
jmp 0x5bb0
jmp 0x5bb0
movq %rax, %r14
jmp 0x5bdd
movq %rax, %r14
jmp 0x5c3f
movq %rax, %r14
jmp 0x5bf8
movq %rax, %r14
movq 0xe8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5bdd
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5bf8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x5c3f
movq 0x158(%rsp), %rsi
jmp 0x5c37
movq %rax, %r14
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x5c3f
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5c60
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x5c60
movq %rax, %r14
leaq 0xb0(%rsp), %r12
leaq 0x90(%rsp), %rbx
movq 0x80(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5c8d
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5cae
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0xa0(%rsp), %rdi
cmpq %r12, %rdi
je 0x5ccb
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3350
movq %r14, %rdi
callq 0x3620