// File: /workspace/github_c_makefile_star2_O1/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
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movq $0x0, 0x18(%rsp)
cmpl $0x2, %edi
jl 0x3606
movq %rsi, %r12
movl %edi, %ebp
movl $0x0, (%rsp)
leaq 0x8f3d(%rip), %r15      # 0xc49f
movl $0x1, %ebx
leaq 0x8f36(%rip), %r13      # 0xc4a4
movl $0x0, 0x4(%rsp)
movl $0x0, 0x8(%rsp)
movq (%r12,%rbx,8), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x2170
testl %eax, %eax
je 0x35dd
movq %r14, %rdi
leaq 0x8f0c(%rip), %rsi      # 0xc4a7
callq 0x2170
testl %eax, %eax
je 0x35e7
movq %r14, %rdi
leaq 0x8efc(%rip), %rsi      # 0xc4aa
callq 0x2170
testl %eax, %eax
je 0x35f1
cmpb $0x2d, (%r14)
je 0x378b
testq %r15, %r15
je 0x35d0
cmpb $0x0, (%r15)
jne 0x378b
movq %r14, %rdi
callq 0x3020
movq %rax, %r15
jmp 0x35f8
movl $0x1, 0x8(%rsp)
jmp 0x35f8
movl $0x1, 0x4(%rsp)
jmp 0x35f8
movl $0x1, (%rsp)
incq %rbx
cmpq %rbx, %rbp
jne 0x357e
jmp 0x3624
movl $0x0, 0x8(%rsp)
leaq 0x8e8a(%rip), %r15      # 0xc49f
movl $0x0, 0x4(%rsp)
movl $0x0, (%rsp)
movq %r15, %rdi
callq 0x30bb
testl %eax, %eax
je 0x3648
movq %r15, %r12
leaq 0x8e68(%rip), %r15      # 0xc4a2
movl 0x8(%rsp), %ebx
movl (%rsp), %ebp
movl 0x4(%rsp), %r14d
jmp 0x367b
movq %r15, %rdi
movl $0x2f, %esi
callq 0x2100
testq %rax, %rax
movl 0x8(%rsp), %ebx
movl (%rsp), %ebp
movl 0x4(%rsp), %r14d
je 0x3674
movb $0x0, (%rax)
incq %rax
movq %r15, %r12
movq %rax, %r15
jmp 0x367b
leaq 0x8e24(%rip), %r12      # 0xc49f
testl %ebx, %ebx
jne 0x36d9
leaq 0x8e19(%rip), %rdi      # 0xc49f
leaq 0x30(%rsp), %rsi
leaq 0x14(%rsp), %rdx
callq 0x8d6c
testl %eax, %eax
jne 0x36d9
cmpb $0x0, 0x30(%rsp)
je 0x36b5
leaq 0x8e06(%rip), %rdi      # 0xc4ad
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x20f0
jmp 0x36c1
leaq 0x9cdb(%rip), %rdi      # 0xd397
callq 0x20a0
movl 0x14(%rsp), %esi
movzwl %si, %edx
shrl $0x10, %esi
leaq 0x8dee(%rip), %rdi      # 0xc4c0
xorl %eax, %eax
callq 0x20f0
leaq 0x10(%rsp), %rax
leaq 0x18(%rsp), %r10
leaq 0xc(%rsp), %r9
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
movl %ebx, %ecx
movl %ebp, %r8d
pushq %rax
pushq %r10
callq 0x3305
addq $0x10, %rsp
movl %eax, %ebp
orl %ebx, %eax
jne 0x377a
movl 0xc(%rsp), %eax
addl 0x10(%rsp), %eax
jne 0x371e
leaq 0x9c93(%rip), %rdi      # 0xd3ac
callq 0x20a0
movl $0xa, %edi
callq 0x2040
leaq 0x24(%rsp), %rbx
leaq 0x28(%rsp), %r14
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x8022
movl 0xc(%rsp), %esi
movq 0x18(%rsp), %rdx
leaq 0x8d94(%rip), %rdi      # 0xc4e4
xorl %eax, %eax
callq 0x20f0
movl 0x10(%rsp), %esi
movl (%rbx), %eax
movq (%r14), %rcx
movzwl 0xa(%rcx), %edx
imulq %rax, %rdx
shlq $0x9, %rdx
leaq 0x8d8f(%rip), %rdi      # 0xc502
xorl %eax, %eax
callq 0x20f0
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x28c4