// File: /workspace/github_c_makefile_star2_O1/lb3361[P]dosfs/dosfs.c
// Function: dosformat
FRESULT dosformat(int argc, const char **argv)
{
  FRESULT res;
  char buffer[64*1024];
  const char *label = 0;
  MKFS_PARM parm;
  int fflag = 0;
  int sflag = 0;
  int i;
  
  memset(&parm, 0, sizeof(parm));
  parm.fmt = FM_ANY;
  parm.n_fat = 2;
  for (i=1; i<argc; i++)
    {
      if (!strcmp(argv[i], "-s")) {
        sflag = 1;
        if (VolToPart[0].pt)
          fatal("Options -s and -p are incompatible.\n");
      } else if (!strcmp(argv[i], "-F")) {
        if (++i >= argc)
          fatal("Option -F requires an argument.\n");
        if (!strcasecmp(argv[i],"fat"))
          fflag |= FM_FAT;
        else if (!strcasecmp(argv[i],"fat32"))
          fflag |= FM_FAT32;
        else if (!strcasecmp(argv[i],"exfat"))
          fflag |= FM_EXFAT;
        else
          fatal("Valid arguments for option -f are: fat fat32 exfat\n");
      } else if (argv[i][0] == '-') {
        goto usage;
      } else if (! label) {
        label = argv[i];
      } else {
      usage:
        dosformathelp();
        exit(EXIT_FAILURE);
      }
    }
  parm.fmt = (fflag) ? fflag : FM_ANY;
  if (sflag)
    parm.fmt |= FM_SFD;

  if (VolToPart[0].pt) {
    if (! prompt("Erase partition %d in [%s]", VolToPart[0].pt, sfn))
      return FR_OK;
  } else {
    if (! prompt("Erase everything in [%s]", sfn))
      return FR_OK;
  }
  res = f_mkfs("", &parm, buffer, sizeof(buffer));
  if (res != FR_OK)
    fatal_code(res);
  if ((res = f_mount(&vol, "", 1)) != FR_OK)
    fatal_code(res);
  if (label)
    res = f_setlabel(label);
  return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10028, %rsp          # imm = 0x10028
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movw $0x207, 0x10(%rsp)      # imm = 0x207
cmpl $0x2, %edi
jl 0x4774
movq %rsi, %r14
movl %edi, %ebp
xorl %r12d, %r12d
movl $0x1, %r15d
movb 0xcbbb(%rip), %al       # 0x1125d
movb %al, 0xb(%rsp)
movl $0x0, 0xc(%rsp)
xorl %r13d, %r13d
movslq %r15d, %rax
movq (%r14,%rax,8), %rbx
movq %rbx, %rdi
leaq 0x7de5(%rip), %rsi      # 0xc4a7
callq 0x2170
testl %eax, %eax
je 0x46f4
movq %rbx, %rdi
leaq 0x8a88(%rip), %rsi      # 0xd15d
callq 0x2170
testl %eax, %eax
je 0x470f
cmpb $0x2d, (%rbx)
je 0x4835
testq %r13, %r13
movq %rbx, %r13
je 0x4705
jmp 0x4835
movl $0x1, %r12d
cmpb $0x0, 0xb(%rsp)
jne 0x483a
incl %r15d
cmpl %ebp, %r15d
jl 0x46b1
jmp 0x477d
incl %r15d
cmpl %ebp, %r15d
jge 0x4843
movslq %r15d, %rax
movq (%r14,%rax,8), %rbx
movq %rbx, %rdi
leaq 0x8a5d(%rip), %rsi      # 0xd189
callq 0x2050
testl %eax, %eax
je 0x4766
movq %rbx, %rdi
leaq 0x8a42(%rip), %rsi      # 0xd181
callq 0x2050
testl %eax, %eax
je 0x476d
movq %rbx, %rdi
leaq 0x8a35(%rip), %rsi      # 0xd187
callq 0x2050
testl %eax, %eax
jne 0x484c
orl $0x4, 0xc(%rsp)
jmp 0x4705
orl $0x1, 0xc(%rsp)
jmp 0x4705
orl $0x2, 0xc(%rsp)
jmp 0x4705
movb $0x1, %al
xorl %r13d, %r13d
xorl %edx, %edx
jmp 0x4787
testl %r12d, %r12d
sete %al
movl 0xc(%rsp), %edx
testl %edx, %edx
movl $0x7, %ecx
cmovnel %edx, %ecx
movl %ecx, %edx
orb $0x8, %dl
movzbl %dl, %edx
testb %al, %al
cmovnel %ecx, %edx
movb %dl, 0x10(%rsp)
movzbl 0xcab4(%rip), %esi      # 0x1125d
testl %esi, %esi
jne 0x47ba
xorl %ebp, %ebp
callq 0x295d
testb $0x1, %al
je 0x47d5
jmp 0x4821
movq 0xca77(%rip), %rdx      # 0x11238
leaq 0x89f9(%rip), %rdi      # 0xd1c1
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2348
testl %eax, %eax
je 0x4821
leaq 0x7cc3(%rip), %rdi      # 0xc49f
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movl $0x10000, %ecx          # imm = 0x10000
callq 0x96a5
testl %eax, %eax
jne 0x485a
leaq 0xca65(%rip), %rdi      # 0x11260
leaq 0x7c9d(%rip), %rsi      # 0xc49f
movl $0x1, %edx
callq 0x4ba4
movl %eax, %ebp
testl %eax, %eax
jne 0x4861
testq %r13, %r13
je 0x4821
movq %r13, %rdi
callq 0x903b
movl %eax, %ebp
movl %ebp, %eax
addq $0x10028, %rsp          # imm = 0x10028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x294f
leaq 0x88f7(%rip), %rdi      # 0xd138
jmp 0x4853
leaq 0x8916(%rip), %rdi      # 0xd160
jmp 0x4853
leaq 0x893a(%rip), %rdi      # 0xd18d
xorl %eax, %eax
callq 0x2aec
movl %eax, %edi
callq 0x2ba7
movl %ebp, %edi
callq 0x2ba7