// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/DB.c
// Function: List_DB_Files
int List_DB_Files(char *path, void actor(char *path, char *extension))
{ int            status, plen, rlen, dlen;
  char          *root, *pwd, *name;
  int            isdam;
  DIR           *dirp;
  struct dirent *dp;

  status = 0;
  pwd    = PathTo(path);
  plen   = strlen(path);
  if (strcmp(path+(plen-4),".dam") == 0)
    root = Root(path,".dam");
  else
    root = Root(path,".db");
  rlen = strlen(root);

  if (root == NULL || pwd == NULL)
    { free(pwd);
      free(root);
      EXIT(1);
    }

  if ((dirp = opendir(pwd)) == NULL)
    { EPRINTF(EPLACE,"%s: Cannot open directory %s (List_DB_Files)\n",Prog_Name,pwd);
      status = -1;
      goto error;
    }

  isdam = 0;
  while ((dp = readdir(dirp)) != NULL)     //   Get case dependent root name (if necessary)
    { name = dp->d_name;
      if (strcmp(name,MyCatenate("","",root,".db")) == 0)
        break;
      if (strcmp(name,MyCatenate("","",root,".dam")) == 0)
        { isdam = 1;
          break;
        }
    }
  if (dp == NULL)
    { status = -1;
      closedir(dirp);
      goto error;
    }

  if (isdam)
    actor(MyCatenate(pwd,"/",root,".dam"),"dam");
  else
    actor(MyCatenate(pwd,"/",root,".db"),"db");

  rewinddir(dirp);                         //   Report each auxiliary file
  while ((dp = readdir(dirp)) != NULL)
    { name = dp->d_name;
      dlen = strlen(name);
#ifdef HIDE_FILES
      if (name[0] != '.')
        continue;
      dlen -= 1;
      name += 1;
#endif
      if (dlen < rlen+1)
        continue;
      if (name[rlen] != '.')
        continue;
      if (strncmp(name,root,rlen) != 0)
        continue;
      actor(MyCatenate(pwd,PATHSEP,name,""),name+(rlen+1));
    }
  closedir(dirp);

error:
  free(pwd);
  free(root);
  return (status);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2500
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10d0
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %eax
subl $0x4, %eax
cltq
addq %rax, %rdi
leaq 0x949c(%rip), %rsi      # 0xe485
callq 0x1170
cmpl $0x0, %eax
jne 0x5009
movq -0x8(%rbp), %rdi
leaq 0x9487(%rip), %rsi      # 0xe485
callq 0x2590
movq %rax, -0x28(%rbp)
jmp 0x501d
movq -0x8(%rbp), %rdi
leaq 0x9476(%rip), %rsi      # 0xe48a
callq 0x2590
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x10d0
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x5037
cmpq $0x0, -0x30(%rbp)
jne 0x5053
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
callq 0x1030
movl $0x1, %edi
callq 0x1260
movq -0x30(%rbp), %rdi
callq 0x10c0
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x5095
movq 0xcf8b(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
movq 0xfa11(%rip), %rdx      # 0x14a88
movq -0x30(%rbp), %rcx
leaq 0x9587(%rip), %rsi      # 0xe609
movb $0x0, %al
callq 0x1180
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x52a1
movl $0x0, -0x3c(%rbp)
movq -0x48(%rbp), %rdi
callq 0x11d0
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x5135
movq -0x50(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rdx
leaq 0x988b(%rip), %rsi      # 0xe95d
leaq 0x93b1(%rip), %rcx      # 0xe48a
movq %rsi, %rdi
callq 0x4550
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x1170
cmpl $0x0, %eax
jne 0x50f4
jmp 0x5135
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rdx
leaq 0x9856(%rip), %rsi      # 0xe95d
leaq 0x9377(%rip), %rcx      # 0xe485
movq %rsi, %rdi
callq 0x4550
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x1170
cmpl $0x0, %eax
jne 0x5130
movl $0x1, -0x3c(%rbp)
jmp 0x5135
jmp 0x509c
cmpq $0x0, -0x50(%rbp)
jne 0x5151
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rdi
callq 0x1150
jmp 0x52a1
cmpl $0x0, -0x3c(%rbp)
je 0x518c
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x9320(%rip), %rsi      # 0xe48e
leaq 0x9310(%rip), %rcx      # 0xe485
callq 0x4550
movq %rax, %rdi
movq -0x68(%rbp), %rax
leaq 0x92fe(%rip), %rsi      # 0xe486
callq *%rax
jmp 0x51bf
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x92eb(%rip), %rsi      # 0xe48e
leaq 0x92e0(%rip), %rcx      # 0xe48a
callq 0x4550
movq %rax, %rdi
movq -0x70(%rbp), %rax
leaq 0x92ce(%rip), %rsi      # 0xe48b
callq *%rax
movq -0x48(%rbp), %rdi
callq 0x1140
movq -0x48(%rbp), %rdi
callq 0x11d0
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x5298
movq -0x50(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x10d0
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0x5205
jmp 0x51c8
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x5229
jmp 0x51c8
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2e, %eax
je 0x523c
jmp 0x51c8
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x1c(%rbp), %rdx
callq 0x1060
cmpl $0x0, %eax
je 0x5257
jmp 0x51c8
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x927f(%rip), %rsi      # 0xe4ed
leaq 0x96e8(%rip), %rcx      # 0xe95d
callq 0x4550
movq %rax, %rdi
movq -0x78(%rbp), %rax
movq -0x38(%rbp), %rsi
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
addq %rcx, %rsi
callq *%rax
jmp 0x51c8
movq -0x48(%rbp), %rdi
callq 0x1150
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x28(%rbp), %rdi
callq 0x1030
movl -0x14(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nop