// File: /workspace/github_c_makefile_star2_O3/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, 0xc(%rsp)
leaq 0x7d62(%rip), %rsi      # 0xc49f
xorl %edi, %edi
callq 0x21e0
leaq 0x8b38(%rip), %rdi      # 0xd283
movl $0x2, %esi
callq 0x2070
cmpl $0x2, %eax
jne 0x49cd
leaq 0x8b21(%rip), %rdi      # 0xd286
movl $0x3, %esi
callq 0x2070
cmpl $0x3, %eax
jne 0x49cd
movq (%rbx), %r14
movq %r14, %rdi
movl $0x2f, %esi
callq 0x20f0
leaq 0x1(%rax), %r12
testq %rax, %rax
cmoveq %r14, %r12
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpb $0x64, (%r12)
jne 0x47c7
cmpb $0x6f, 0x1(%r12)
movl 0xc(%rsp), %edx
jne 0x47cb
cmpb $0x73, 0x2(%r12)
jne 0x47cb
leaq 0x3(%r12), %rdi
callq 0x46d2
movl 0xc(%rsp), %edx
movl %eax, %r15d
jmp 0x47cb
movl 0xc(%rsp), %edx
movq %r12, (%rbx)
cmpl $0x2, %edx
jl 0x4914
movl $0x1, %r12d
movl $0x0, 0x10(%rsp)
movl $0x1, %r14d
movslq %r12d, %rbp
movq (%rbx,%rbp,8), %r13
cmpb $0x2d, (%r13)
jne 0x48c6
cmpb $0x2d, 0x1(%r13)
jne 0x482a
testl %r15d, %r15d
jns 0x48e8
leaq 0x2(%r13), %rdi
callq 0x46d2
movl %eax, %r15d
testl %eax, %eax
movl 0xc(%rsp), %edx
jns 0x48d0
jmp 0x49f5
cmpb $0x66, 0x1(%r13)
jne 0x4877
cmpb $0x0, 0x2(%r13)
jne 0x4877
leal 0x1(%r12), %ebp
cmpl %edx, %ebp
jge 0x4877
movslq %ebp, %rax
movq (%rbx,%rax,8), %r13
movq %r13, 0xc9e1(%rip)      # 0x11230
movq %r13, %rdi
movl $0x2f, %esi
callq 0x20f0
movl 0xc(%rsp), %edx
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, 0xc9c6(%rip)      # 0x11238
movl %ebp, %r12d
jmp 0x48d0
cmpb $0x68, 0x1(%r13)
jne 0x4885
cmpb $0x0, 0x2(%r13)
je 0x48de
cmpb $0x70, 0x1(%r13)
jne 0x48c6
cmpb $0x0, 0x2(%r13)
jne 0x48c6
leal 0x1(%r12), %eax
cmpl %edx, %eax
jge 0x48c6
movslq %eax, %rcx
movq (%rbx,%rcx,8), %rsi
movb (%rsi), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0x4a06
cmpb $0x0, 0x1(%rsi)
jne 0x4a06
movb %cl, 0xc99c(%rip)       # 0x1125d
movl %eax, %r12d
jmp 0x48d0
movslq %r14d, %rax
incl %r14d
movq %r13, (%rbx,%rax,8)
incl %r12d
cmpl %edx, %r12d
jl 0x47eb
jmp 0x4922
movl $0x1, 0x10(%rsp)
jmp 0x48d0
movl %r15d, %eax
leaq (%rax,%rax,2), %rax
leaq 0xc85a(%rip), %rcx      # 0x11150
movq (%rcx,%rax,8), %rdx
leaq 0x89c7(%rip), %rdi      # 0xd2c8
movq %r13, %rsi
xorl %eax, %eax
callq 0x2260
movq (%rbx,%rbp,8), %r13
jmp 0x480d
movl $0x0, 0x10(%rsp)
movl $0x1, %r14d
testl %r15d, %r15d
js 0x49e0
movl %r15d, %eax
cmpl $0x0, 0x10(%rsp)
jne 0x49a8
cmpq $0x0, 0xc8f3(%rip)      # 0x11230
je 0x49a8
leaq (%rax,%rax,2), %r15
leaq 0xc806(%rip), %r12      # 0x11150
leaq -0x48a(%rip), %rax      # 0x44c7
cmpq %rax, 0x8(%r12,%r15,8)
je 0x497f
leaq 0xc901(%rip), %rdi      # 0x11260
leaq 0x7b39(%rip), %rsi      # 0xc49f
movl $0x1, %edx
callq 0x4a10
testl %eax, %eax
jne 0x49a1
leaq (%r12,%r15,8), %rax
addq $0x8, %rax
movq (%rax), %rax
movl %r14d, %edi
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
jne 0x49a1
leaq 0x7b0d(%rip), %rsi      # 0xc49f
xorl %ebx, %ebx
xorl %edi, %edi
xorl %edx, %edx
callq 0x4a10
testl %eax, %eax
je 0x49bc
movl %eax, %edi
callq 0x2be7
leaq (%rax,%rax,2), %rax
leaq 0xc79d(%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 0x88b6(%rip), %rdi      # 0xd28a
xorl %eax, %eax
callq 0x2260
jmp 0x4778
leaq 0x14(%rsp), %rbx
movl 0x10(%rsp), %edi
movq %rbx, %rsi
callq 0x29c7
movl (%rbx), %ebx
jmp 0x49bc
leaq 0x8909(%rip), %rdi      # 0xd305
movq %r13, %rsi
xorl %eax, %eax
callq 0x2b2c
leaq 0x8916(%rip), %rdi      # 0xd323
jmp 0x49ff
nop