// File: /workspace/github_c_makefile_star2_O2/lb3361[P]dosfs/dosfs.c
// Function: dosdir
FRESULT dosdir(int argc, const char **argv)
{
  int i;
  int bflag = 0;
  int sflag = 0;
  int xflag = 0;
  char *path  = "";
  char *pattern = 0;
  char label[40];
  DWORD serial;
  FRESULT res;
  int ndirs = 0;
  int nfiles = 0;
  FSIZE_t sfiles = 0;
  DWORD ncls;
  FATFS *vol;

  for (i=1; i<argc; i++) {
    if (! strcmp(argv[i], "-b"))
      bflag = 1;
    else if (! strcmp(argv[i], "-s"))
      sflag = 1;
    else if (! strcmp(argv[i], "-x"))
      xflag = 1;
    else if (argv[i][0] == '-')
      goto usage;
    else if (!path || !path[0])
      path = fix_path(argv[i]);
    else {
    usage:
      dosdirhelp();
      exit(EXIT_FAILURE);
    }
  }
  pattern = (pattern) ? pattern + 1 : path;
  if (dir_p(path)) {
    pattern = "*";
  } else if ((pattern = strrchr(path, '/'))) {
    *pattern = 0;
    pattern += 1;
  } else {
    pattern = path;
    path = "";
  }
  if (! bflag && f_getlabel("", label, &serial) == FR_OK) {
    if (label[0])
      printf(" Volume label: %s\n", label);
    else
      printf(" Volume has no label\n");
    printf(" Volume Serial Number is %04X-%04X\n", (serial >> 16) & 0xffff, serial & 0xffff);
  }
  res = rdir(path, pattern, sflag, bflag, xflag, &nfiles, &sfiles, &ndirs);
  if (res == FR_OK && ! bflag) {
    if (nfiles + ndirs == 0)
      printf("File not found\n");
    printf("\n");
    f_getfree(path, &ncls, &vol);
    printf("    %8d File(s) %12lld bytes\n", nfiles, (long long)sfiles);
    printf("    %8d Dir(s)  %12lld bytes free\n", ndirs, (long long)ncls * vol->csize * 512);
  }
  return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
andl $0x0, 0x10(%rsp)
andl $0x0, 0xc(%rsp)
movq %rsi, %r12
andq $0x0, 0x18(%rsp)
movslq %edi, %r13
leaq 0x845f(%rip), %r14      # 0xb49f
movl $0x0, 0x8(%rsp)
pushq $0x1
popq %rbp
pushq $0x1
popq %rbx
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
cmpq %r13, %rbp
jge 0x30bf
movq (%r12,%rbp,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x3097
cmpb $0x62, 0x1(%rdi)
jne 0x3073
cmpb $0x0, 0x2(%rdi)
je 0x30b3
cmpb $0x73, 0x1(%rdi)
jne 0x307f
cmpb $0x0, 0x2(%rdi)
je 0x30b9
cmpb $0x78, 0x1(%rdi)
jne 0x3217
cmpb $0x0, 0x2(%rdi)
movl %ebx, %r15d
je 0x30ae
jmp 0x3217
testq %r14, %r14
je 0x30a6
cmpb $0x0, (%r14)
jne 0x3217
callq 0x2b76
movq %rax, %r14
incq %rbp
jmp 0x3059
movl %ebx, 0x8(%rsp)
jmp 0x30ae
movl %ebx, 0x4(%rsp)
jmp 0x30ae
movq %r14, %rdi
callq 0x2c11
testl %eax, %eax
je 0x30df
movq %r14, %r12
leaq 0x83cd(%rip), %r14      # 0xb4a2
movl 0x8(%rsp), %ebx
movl 0x4(%rsp), %ebp
jmp 0x310c
pushq $0x2f
popq %rsi
movq %r14, %rdi
callq 0x20f0
testq %rax, %rax
movl 0x8(%rsp), %ebx
movl 0x4(%rsp), %ebp
je 0x3105
movb $0x0, (%rax)
incq %rax
movq %r14, %r12
movq %rax, %r14
jmp 0x310c
leaq 0x8393(%rip), %r12      # 0xb49f
testl %ebx, %ebx
jne 0x316a
leaq 0x8388(%rip), %rdi      # 0xb49f
leaq 0x30(%rsp), %rsi
leaq 0x14(%rsp), %rdx
callq 0x8225
testl %eax, %eax
jne 0x316a
cmpb $0x0, 0x30(%rsp)
je 0x3146
leaq 0x836c(%rip), %rdi      # 0xb4a4
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x20e0
jmp 0x3152
leaq 0x9222(%rip), %rdi      # 0xc36f
callq 0x2090
movl 0x14(%rsp), %esi
movzwl %si, %edx
shrl $0x10, %esi
leaq 0x8354(%rip), %rdi      # 0xb4b7
xorl %eax, %eax
callq 0x20e0
leaq 0x10(%rsp), %rax
leaq 0x18(%rsp), %r10
leaq 0xc(%rsp), %r9
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %edx
movl %ebx, %ecx
movl %r15d, %r8d
pushq %rax
pushq %r10
callq 0x2e1a
popq %rcx
popq %rdx
movl %eax, %ebp
orl %ebx, %eax
jne 0x3206
movl 0xc(%rsp), %eax
addl 0x10(%rsp), %eax
jne 0x31ac
leaq 0x91dd(%rip), %rdi      # 0xc384
callq 0x2090
pushq $0xa
popq %rdi
callq 0x2040
leaq 0x24(%rsp), %rbx
leaq 0x28(%rsp), %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x7697
movl 0xc(%rsp), %esi
movq 0x18(%rsp), %rdx
leaq 0x82ff(%rip), %rdi      # 0xb4db
xorl %eax, %eax
callq 0x20e0
movl 0x10(%rsp), %esi
movl (%rbx), %eax
movq (%r14), %rcx
movzwl 0xa(%rcx), %edx
imulq %rax, %rdx
shlq $0x9, %rdx
leaq 0x82fa(%rip), %rdi      # 0xb4f9
xorl %eax, %eax
callq 0x20e0
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2dd2
pushq $0x1
popq %rdi
callq 0x2220