// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %rsi, %rbx
movl %edi, (%rsp)
leaq 0x70ea(%rip), %rsi      # 0xb49f
xorl %edi, %edi
callq 0x21e0
leaq 0x7ec0(%rip), %rdi      # 0xc283
pushq $0x2
popq %rsi
callq 0x2070
cmpl $0x2, %eax
jne 0x43e4
leaq 0x7eaf(%rip), %rdi      # 0xc286
pushq $0x3
popq %rsi
callq 0x2070
cmpl $0x3, %eax
je 0x43f2
leaq 0x7e9f(%rip), %rdi      # 0xc28a
xorl %eax, %eax
callq 0x2401
movq (%rbx), %r14
pushq $0x2f
popq %rsi
movq %r14, %rdi
callq 0x20f0
leaq 0x1(%rax), %r12
testq %rax, %rax
cmoveq %r14, %r12
pushq $-0x1
popq %r15
cmpb $0x64, (%r12)
jne 0x443b
cmpb $0x6f, 0x1(%r12)
movl (%rsp), %edx
jne 0x443e
cmpb $0x73, 0x2(%r12)
jne 0x443e
leaq 0x3(%r12), %rdi
callq 0x42e8
movl (%rsp), %edx
movl %eax, %r15d
jmp 0x443e
movl (%rsp), %edx
movq %r12, (%rbx)
pushq $0x1
popq %rax
movl %eax, %r14d
movl $0x0, 0x4(%rsp)
movl %eax, %r12d
movl %r15d, %eax
cmpl %edx, %r12d
jge 0x4570
movslq %r12d, %rbp
movq (%rbx,%rbp,8), %r13
cmpb $0x2d, (%r13)
jne 0x4555
cmpb $0x2d, 0x1(%r13)
jne 0x44bc
testl %r15d, %r15d
js 0x44a0
imulq $0x18, %rax, %rax
leaq 0xccc9(%rip), %rcx      # 0x11150
movq (%rax,%rcx), %rdx
leaq 0x7e36(%rip), %rdi      # 0xc2c8
movq %r13, %rsi
xorl %eax, %eax
callq 0x2401
movq (%rbx,%rbp,8), %r13
leaq 0x2(%r13), %rdi
callq 0x42e8
movl %eax, %r15d
testl %eax, %eax
movl (%rsp), %edx
jns 0x455f
jmp 0x4671
cmpb $0x66, 0x1(%r13)
jne 0x4506
cmpb $0x0, 0x2(%r13)
jne 0x4506
leal 0x1(%r12), %ebp
cmpl %edx, %ebp
jge 0x4506
movslq %ebp, %rax
movq (%rbx,%rax,8), %r13
movq %r13, 0xcd4f(%rip)      # 0x11230
movq %r13, %rdi
pushq $0x2f
popq %rsi
callq 0x20f0
movl (%rsp), %edx
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, 0xcd37(%rip)      # 0x11238
movl %ebp, %r12d
jmp 0x455f
cmpb $0x68, 0x1(%r13)
jne 0x4514
cmpb $0x0, 0x2(%r13)
je 0x4567
cmpb $0x70, 0x1(%r13)
jne 0x4555
cmpb $0x0, 0x2(%r13)
jne 0x4555
leal 0x1(%r12), %eax
cmpl %edx, %eax
jge 0x4555
movslq %eax, %rcx
movq (%rbx,%rcx,8), %rsi
movb (%rsi), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0x4682
cmpb $0x0, 0x1(%rsi)
jne 0x4682
movb %cl, 0xcd0d(%rip)       # 0x1125d
movl %eax, %r12d
jmp 0x455f
movslq %r14d, %rax
incl %r14d
movq %r13, (%rbx,%rax,8)
incl %r12d
jmp 0x4452
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
jmp 0x455f
testl %r15d, %r15d
js 0x45ff
cmpl $0x0, 0x4(%rsp)
jne 0x464e
cmpq $0x0, 0xcca4(%rip)      # 0x11230
je 0x464e
imulq $0x18, %rax, %r15
leaq -0x4a4(%rip), %rax      # 0x40f9
leaq 0xcbac(%rip), %rcx      # 0x11150
cmpq %rax, 0x8(%r15,%rcx)
je 0x45d6
leaq 0xccae(%rip), %rdi      # 0x11260
leaq 0x6ee6(%rip), %rsi      # 0xb49f
pushq $0x1
popq %rdx
callq 0x468c
testl %eax, %eax
jne 0x45f8
leaq 0xcb84(%rip), %rax      # 0x11150
addq %r15, %rax
addq $0x8, %rax
movq (%rax), %rax
movl %r14d, %edi
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
jne 0x45f8
leaq 0x6eb6(%rip), %rsi      # 0xb49f
xorl %ebx, %ebx
xorl %edi, %edi
xorl %edx, %edx
callq 0x468c
testl %eax, %eax
je 0x4660
movl %eax, %edi
callq 0x24bb
callq 0x4329
pushq $0x1
popq %rbx
cmpl $0x0, 0x4(%rsp)
je 0x4660
leaq 0xcb4b(%rip), %r13      # 0x11160
movq 0xc9dc(%rip), %rbp      # 0x10ff8
leaq 0x7d22(%rip), %r14      # 0xc345
pushq $0x29
popq %r15
pushq $0x1
popq %r12
cmpq $0x0, -0x10(%r13)
je 0x4660
movq (%rbp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2230
callq *(%r13)
addq $0x18, %r13
jmp 0x462b
imulq $0x18, %rax, %rax
leaq 0xcaf7(%rip), %rcx      # 0x11150
callq *0x10(%rax,%rcx)
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7c8d(%rip), %rdi      # 0xc305
movq %r13, %rsi
xorl %eax, %eax
callq 0x234c
leaq 0x7c9a(%rip), %rdi      # 0xc323
jmp 0x467b
nop