// File: /workspace/github_cpp_makefile_star2_O1/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 0x5271(%rip), %rdx      # 0xa393
leaq 0xa0(%rsp), %rdi
movq %rdx, %rsi
callq 0x4b08
leaq 0x5077(%rip), %rsi      # 0xa1b0
movq %rbx, %rdi
callq 0x3490
testl %eax, %eax
jne 0x518a
leaq 0x188(%rsp), %rdi
callq 0x40a1
leaq 0xa0(%rsp), %rdi
leaq 0x188(%rsp), %r14
movq %r14, %rsi
callq 0x3430
movq (%r14), %rdi
leaq 0x198(%rsp), %rax
cmpq %rax, %rdi
je 0x518a
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x3350
movq %rbx, %rdi
callq 0x34f0
testl %eax, %eax
jns 0x51f7
leaq 0x198(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x500a(%rip), %rsi      # 0xa1b3
leaq 0x501b(%rip), %rdx      # 0xa1cb
leaq 0x188(%rsp), %rdi
callq 0x4b08
leaq 0x188(%rsp), %rdi
movq %rbx, %rsi
callq 0x3680
movq 0x188(%rsp), %rdi
callq 0x924b
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0x51f7
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0xc0(%rsp), %rdi
callq 0x40a1
movq 0xc0(%rsp), %rdi
callq 0x3530
movq %rax, 0xe0(%rsp)
testq %rax, %rax
jne 0x529b
leaq 0x198(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x4f9b(%rip), %rsi      # 0xa1cc
leaq 0x4fa7(%rip), %rdx      # 0xa1df
leaq 0x188(%rsp), %rdi
callq 0x4b08
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
leaq 0x188(%rsp), %rdi
callq 0x3110
movq 0x188(%rsp), %rdi
callq 0x924b
movl $0x1, %edi
callq 0x3280
callq 0x4011
movq 0x188(%rsp), %rdi
cmpq %rbx, %rdi
je 0x529b
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x92da(%rip), %rax      # 0xe57c
movl $0x0, (%rax)
leaq 0x92d5(%rip), %rax      # 0xe584
movl $0x1, %ebx
movl %ebx, (%rax)
leaq 0x91bb(%rip), %rdi      # 0xe478
movq (%rdi), %rsi
callq 0x699c
leaq 0x91e8(%rip), %rax      # 0xe4b4
movl %ebx, (%rax)
leaq 0x90(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x4ed0(%rip), %rsi      # 0xa1b1
leaq 0x4eca(%rip), %rdx      # 0xa1b2
leaq 0x80(%rsp), %rdi
callq 0x4b08
leaq 0x40(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x6938
leaq 0x9162(%rip), %rdi      # 0xe478
leaq 0x40(%rsp), %rsi
callq 0x69cc
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x533b
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x50(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x5356
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 0x573b
addq $0x13, %r14
movq %r14, %rdi
callq 0x5091
testb %al, %al
jne 0x5368
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 0x4c61(%rip), %rsi      # 0xa035
leaq 0x4c5b(%rip), %rdx      # 0xa036
callq 0x4b08
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 0x5425
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x542b
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 0x4b08
movq %rbp, %r13
movq (%rsp), %rcx
movl $0xf, %esi
leaq 0x10(%rsp), %rbp
cmpq %rbp, %rcx
je 0x5485
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %r8
movq 0xf0(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x54b7
movl $0xf, %esi
cmpq %rbx, 0xe8(%rsp)
je 0x54b2
movq 0xf8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x54c9
movq 0xe8(%rsp), %rsi
movq %rsp, %rdi
callq 0x3110
jmp 0x54da
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 0x54fa
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x5502
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 0x5541
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0xe8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x555e
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5579
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x559e
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 0x55fb
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x5620
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 0x5716
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 0x9867
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x56a8
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3350
movq %r12, %r14
movq %r12, %rdi
movq %rsp, %rsi
movq %r15, %rdx
callq 0x6938
leaq 0x8db8(%rip), %rdi      # 0xe478
movq %r14, %rsi
callq 0x69cc
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x56e4
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x56fb
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5716
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5368
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x5368
leaq 0x80(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x4a62(%rip), %rcx      # 0xa1b0
movl $0x2, %r8d
xorl %esi, %esi
callq 0x3580
leaq 0x20(%rsp), %rdi
callq 0x40a1
leaq 0x8d0c(%rip), %rcx      # 0xe478
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cmpq $0x40, %rax
jne 0x5897
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 0x9867
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 0x5804
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x581f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0x583c
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x40(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x6938
leaq 0x8c1e(%rip), %rdi      # 0xe478
leaq 0x40(%rsp), %rsi
callq 0x69cc
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x5880
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x5897
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0x8bda(%rip), %rax      # 0xe478
movq (%rax), %r14
movq 0x8(%rax), %r15
cmpq %r15, %r14
leaq 0xb0(%rsp), %r13
je 0x58df
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 0x6c30
movq %r14, %rdi
movq %r15, %rsi
callq 0x6d14
movq 0xc0(%rsp), %rax
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8bc2(%rip), %r14      # 0xe4b8
movq %r14, %rdi
callq 0x7728
addq $0x8, %r14
cmpq %r14, %rax
je 0x59f6
movq 0xc0(%rsp), %rax
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8b96(%rip), %rdi      # 0xe4b8
callq 0x68d4
movl (%rax), %eax
leaq 0x8b84(%rip), %rcx      # 0xe4b4
movl %eax, (%rcx)
leaq 0x8b7b(%rip), %rax      # 0xe4b4
movl (%rax), %edi
callq 0x44aa
testb %al, %al
jne 0x5958
leaq 0x8b69(%rip), %rax      # 0xe4b4
movl (%rax), %eax
decl %eax
leaq 0x8c26(%rip), %rcx      # 0xe57c
movl %eax, (%rcx)
movq 0xe0(%rsp), %rdi
callq 0x35c0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5981
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x59a6
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59c7
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0xa0(%rsp), %rdi
cmpq %r13, %rdi
je 0x59e4
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), %rbx
testq %rbx, %rbx
je 0x5932
leaq 0x8a6a(%rip), %rax      # 0xe478
movq (%rax), %r15
movq 0x8(%rax), %r12
cmpq %r12, %r15
je 0x5932
xorl %ebp, %ebp
movq 0xa0(%rsp), %r14
movq 0x28(%r15), %rdx
cmpq %rbx, %rdx
jne 0x5a46
testq %rdx, %rdx
je 0x5a56
movq 0x20(%r15), %rdi
movq %r14, %rsi
callq 0x3360
testl %eax, %eax
je 0x5a56
addq $0x40, %r15
incl %ebp
cmpq %r12, %r15
jne 0x5a28
jmp 0x5932
leaq 0x8a57(%rip), %rax      # 0xe4b4
movl %ebp, (%rax)
jmp 0x5932
jmp 0x5b1f
jmp 0x5b27
jmp 0x5b27
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x689e
jmp 0x5c41
jmp 0x5bb2
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5aad
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x5aad
movq %rax, %r14
movq 0x168(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5c41
movq 0x178(%rsp), %rsi
jmp 0x5c39
jmp 0x5bb2
jmp 0x5bb2
movq %rax, %r14
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0x5cb0
movq 0x198(%rsp), %rsi
jmp 0x5ca8
jmp 0x5bb2
jmp 0x5c5f
jmp 0x5c5f
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x689e
jmp 0x5c72
movq %rax, %r14
jmp 0x5c72
movq %rax, %r14
jmp 0x5c8f
movq %rax, %r14
jmp 0x5cb0
movq %rax, %r14
movq 0x188(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5c8f
movq 0x198(%rsp), %rsi
jmp 0x5c87
jmp 0x5bb2
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x689e
jmp 0x5b64
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5c41
movq 0x10(%rsp), %rsi
jmp 0x5c39
movq %rax, %r14
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x5c41
movq 0x118(%rsp), %rsi
jmp 0x5c39
jmp 0x5bb2
jmp 0x5bb2
movq %rax, %r14
jmp 0x5bdf
movq %rax, %r14
jmp 0x5c41
movq %rax, %r14
jmp 0x5bfa
movq %rax, %r14
movq 0xe8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5bdf
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3350
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5bfa
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x5c41
movq 0x158(%rsp), %rsi
jmp 0x5c39
movq %rax, %r14
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x5c41
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x5c62
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3350
jmp 0x5c62
movq %rax, %r14
leaq 0xb0(%rsp), %r12
leaq 0x90(%rsp), %rbx
movq 0x80(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5c8f
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x3350
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5cb0
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x3350
movq 0xa0(%rsp), %rdi
cmpq %r12, %rdi
je 0x5ccd
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3350
movq %r14, %rdi
callq 0x3620