// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movb $0x2, 0x11(%rsp)
movzbl 0xcd6e(%rip), %esi      # 0x1125d
movb $0x7, %al
cmpl $0x2, %edi
jl 0x45f0
movl %edi, %r15d
movq $0x0, 0x8(%rsp)
movl %esi, 0x4(%rsp)
movl $0x1, %r12d
xorl %r13d, %r13d
xorl %ebx, %ebx
movslq %r12d, %rax
movq (%r14,%rax,8), %rax
cmpb $0x2d, (%rax)
jne 0x459b
cmpb $0x73, 0x1(%rax)
jne 0x4531
cmpb $0x0, 0x2(%rax)
je 0x45b4
cmpb $0x46, 0x1(%rax)
jne 0x46a6
cmpb $0x0, 0x2(%rax)
jne 0x46a6
incl %r12d
cmpl %r15d, %r12d
jge 0x46ab
movslq %r12d, %rax
movq (%r14,%rax,8), %rbp
movq %rbp, %rdi
leaq 0x8c0c(%rip), %rsi      # 0xd16e
callq 0x2050
testl %eax, %eax
je 0x45a8
movq %rbp, %rdi
leaq 0x8bf1(%rip), %rsi      # 0xd166
callq 0x2050
testl %eax, %eax
je 0x45ae
movq %rbp, %rdi
leaq 0x8be4(%rip), %rsi      # 0xd16c
callq 0x2050
testl %eax, %eax
jne 0x46b4
orl $0x4, %r13d
jmp 0x45c9
testq %rbx, %rbx
movq %rax, %rbx
je 0x45c9
jmp 0x46a6
orl $0x1, %r13d
jmp 0x45c9
orl $0x2, %r13d
jmp 0x45c9
movl $0x1, %eax
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x4(%rsp)
jne 0x46bd
incl %r12d
cmpl %r15d, %r12d
jl 0x4515
testl %r13d, %r13d
jne 0x468a
movb $0xf, %r13b
cmpl $0x0, 0x8(%rsp)
movl 0x4(%rsp), %esi
movb $0x7, %al
je 0x45f2
jmp 0x45f5
xorl %ebx, %ebx
movl %eax, %r13d
movb %r13b, 0x10(%rsp)
testl %esi, %esi
jne 0x4609
callq 0x29a2
testb $0x1, %al
je 0x4624
jmp 0x4674
movq 0xcc28(%rip), %rdx      # 0x11238
leaq 0x8b8f(%rip), %rdi      # 0xd1a6
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2338
testl %eax, %eax
je 0x4676
leaq 0x7e74(%rip), %rdi      # 0xc49f
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movl $0x10000, %ecx          # imm = 0x10000
callq 0x93dd
testl %eax, %eax
jne 0x46cb
leaq 0xcc12(%rip), %rdi      # 0x11260
leaq 0x7e4a(%rip), %rsi      # 0xc49f
movl $0x1, %edx
callq 0x4a10
testl %eax, %eax
jne 0x46cb
testq %rbx, %rbx
je 0x4674
movq %rbx, %rdi
callq 0x8d68
movl %eax, %ebp
jmp 0x4676
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10028, %rsp          # imm = 0x10028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x8(%rsp)
movl 0x4(%rsp), %esi
jne 0x469d
movl %r13d, %eax
jmp 0x45f2
orb $0x8, %r13b
jmp 0x45f5
callq 0x2994
leaq 0x8a93(%rip), %rdi      # 0xd145
jmp 0x46c4
leaq 0x8ab7(%rip), %rdi      # 0xd172
jmp 0x46c4
leaq 0x8a5c(%rip), %rdi      # 0xd120
xorl %eax, %eax
callq 0x2b2c
movl %eax, %edi
callq 0x2be7