// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/dosfs.c
// Function: main
int main(int argc, const char **argv)
{
  int i, j;
  int nargc = 0;
  const char **nargv = argv;
  const char *progname = 0;
  int cmdno = -1;
  int help = 0;
  FRESULT res;
  
  /* try to make utf8 locale */
#ifdef WIN32
  if (setlocale(LC_CTYPE, ".UTF8"))
    recode_arguments_as_utf8(argc, argv, __wargv);
#else
  setlocale(LC_CTYPE, "");
#endif
  if (mblen("\xc2\xa9", 2) != 2 ||
      mblen("\xe2\x89\xa0", 3) != 3)
    warning("The current locale does not seem to be using UTF-8 encoding.\n");
  /* identify progname */
  if ((progname = strrchr(argv[0], '/')))
    progname += 1;
  else
    progname = argv[0];
  /* default command from progname */
  if (! strncmp(progname, "dos", 3))
    cmdno = search_cmd(progname + 3);

  /* parse common options */
  nargv[nargc++] = progname;
  for (int i = 1; i < argc; i++)
    {
      if (argv[i][0] == '-' && argv[i][1] == '-')
        {
          if (cmdno >= 0)
            warning("Subcommand %s overrides previously selected subcommand --%s\n",
                    argv[i], commands[cmdno].cmd);
          if ((cmdno = search_cmd(argv[i]+2)) < 0)
            fatal("Unrecognized subcommand : %s\n", argv[i]);
          continue;
        }
      if (!strcmp(argv[i], "-f") && i + 1 < argc)
        {
          fn = argv[i + 1];
          sfn = strrchr(fn, '/');
          sfn = (sfn) ? sfn + 1 : fn;
          i += 1;
          continue;
        }
      if (! strcmp(argv[i], "-h"))
        {
          help = 1;
          continue;
        }
#if FF_MULTI_PARTITION
      if (!strcmp(argv[i], "-p") && i + 1 < argc)
        {
          const char *p = argv[i + 1];
          if (p[0] >= '0' && p[0] <= '9' && !p[1])
            VolToPart[0].pt = p[0] - '0';
          else
            fatal("Not a valid partition number: %s\n", p);
          i += 1;
          continue;
        }
#endif
      nargv[nargc++] = argv[i];
    }
  /* Check */
  if (cmdno < 0) {
    common_usage();
    if (help)
      for (i=0; commands[i].cmd; i++) {
        fprintf(stderr,"----------------------------------------\n");
        commands[i].help();
      }
    return EXIT_FAILURE;
  }
  if (help || fn == 0) {
    commands[cmdno].help();
    return EXIT_FAILURE;
  }
  /* Mount, run, unmount */
  if (commands[cmdno].run != dosformat)
    if ((res = f_mount(&vol, "", 1)) != FR_OK)
      fatal_code(res);
  if ((res = commands[cmdno].run(nargc, nargv)) != FR_OK)
    fatal_code(res);
  if ((res = f_mount(NULL, "", 0)) != FR_OK && j >= 0)
    fatal_code(res);
  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x7bce(%rip), %rsi      # 0xc49f
xorl %edi, %edi
callq 0x21f0
leaq 0x89bf(%rip), %rdi      # 0xd29e
movl $0x2, %esi
callq 0x2070
cmpl $0x2, %eax
jne 0x4b60
leaq 0x89a8(%rip), %rdi      # 0xd2a1
movl $0x3, %esi
callq 0x2070
cmpl $0x3, %eax
jne 0x4b60
movq (%rbx), %r15
movq %r15, %rdi
movl $0x2f, %esi
callq 0x2100
leaq 0x1(%rax), %r14
testq %rax, %rax
cmoveq %r15, %r14
leaq 0x89b5(%rip), %rsi      # 0xd2e3
movl $0x3, %edx
movq %r14, %rdi
callq 0x2080
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x4951
leaq 0x3(%r14), %rdi
callq 0x4868
movl %eax, %r15d
movq %r14, (%rbx)
cmpl $0x2, %ebp
jl 0x4aa7
movl $0x1, %r13d
movl $0x0, 0xc(%rsp)
movl $0x1, 0x10(%rsp)
movslq %r13d, %r14
movq (%rbx,%r14,8), %r12
cmpb $0x2d, (%r12)
jne 0x49b0
cmpb $0x2d, 0x1(%r12)
jne 0x49b0
testl %r15d, %r15d
jns 0x4a7f
movq (%rbx,%r14,8), %r12
leaq 0x2(%r12), %rdi
callq 0x4868
movl %eax, %r15d
testl %eax, %eax
jns 0x4a71
jmp 0x4b88
movq %r12, %rdi
leaq 0x8988(%rip), %rsi      # 0xd342
callq 0x2170
testl %eax, %eax
jne 0x49fe
leal 0x1(%r13), %r14d
cmpl %ebp, %r14d
jge 0x49fe
movslq %r14d, %rax
movq (%rbx,%rax,8), %r12
movq %r12, 0xc856(%rip)      # 0x11230
movq %r12, %rdi
movl $0x2f, %esi
callq 0x2100
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %r12, %rcx
movq %rcx, 0xc83f(%rip)      # 0x11238
movl %r14d, %r13d
jmp 0x4a71
movq %r12, %rdi
leaq 0x893d(%rip), %rsi      # 0xd345
callq 0x2170
testl %eax, %eax
je 0x4a69
movq %r12, %rdi
leaq 0x892d(%rip), %rsi      # 0xd348
callq 0x2170
testl %eax, %eax
jne 0x4a56
leal 0x1(%r13), %eax
cmpl %ebp, %eax
jge 0x4a56
movslq %eax, %rcx
movq (%rbx,%rcx,8), %rsi
movb (%rsi), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0x4b94
cmpb $0x0, 0x1(%rsi)
jne 0x4b94
movb %cl, 0xc80c(%rip)       # 0x1125d
movl %eax, %r13d
jmp 0x4a71
movl 0x10(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x10(%rsp)
movq %r12, (%rbx,%rax,8)
jmp 0x4a71
movl $0x1, 0xc(%rsp)
incl %r13d
cmpl %ebp, %r13d
jl 0x4973
jmp 0x4ab7
movl %r15d, %eax
leaq (%rax,%rax,2), %rax
leaq 0xc6c3(%rip), %rcx      # 0x11150
movq (%rcx,%rax,8), %rdx
leaq 0x884f(%rip), %rdi      # 0xd2e7
movq %r12, %rsi
xorl %eax, %eax
callq 0x2270
jmp 0x4992
movl $0x0, 0xc(%rsp)
movl $0x1, 0x10(%rsp)
testl %r15d, %r15d
js 0x4b73
movl %r15d, %eax
cmpl $0x0, 0xc(%rsp)
jne 0x4b3b
cmpq $0x0, 0xc75e(%rip)      # 0x11230
je 0x4b3b
leaq (%rax,%rax,2), %r14
leaq 0xc671(%rip), %r15      # 0x11150
leaq -0x481(%rip), %rax      # 0x4665
cmpq %rax, 0x8(%r15,%r14,8)
je 0x4b09
leaq 0xc76c(%rip), %rdi      # 0x11260
leaq 0x79a4(%rip), %rsi      # 0xc49f
movl $0x1, %edx
callq 0x4ba4
testl %eax, %eax
jne 0x4b34
leaq (%r15,%r14,8), %rax
addq $0x8, %rax
movl 0x10(%rsp), %edi
movq %rbx, %rsi
callq *(%rax)
testl %eax, %eax
jne 0x4b34
leaq 0x797a(%rip), %rsi      # 0xc49f
xorl %ebx, %ebx
xorl %edi, %edi
xorl %edx, %edx
callq 0x4ba4
testl %eax, %eax
je 0x4b4f
movl %eax, %edi
callq 0x2ba7
leaq (%rax,%rax,2), %rax
leaq 0xc60a(%rip), %rcx      # 0x11150
callq *0x10(%rcx,%rax,8)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x873e(%rip), %rdi      # 0xd2a5
xorl %eax, %eax
callq 0x2270
jmp 0x490c
leaq 0x14(%rsp), %rbx
movl 0xc(%rsp), %edi
movq %rbx, %rsi
callq 0x2982
movl (%rbx), %ebx
jmp 0x4b4f
leaq 0x8795(%rip), %rdi      # 0xd324
movq %r12, %rsi
jmp 0x4b9b
leaq 0x87b0(%rip), %rdi      # 0xd34b
xorl %eax, %eax
callq 0x2aec
nop