// File: /workspace/github_c_makefile_star2_O0/lb3361[P]dosfs/dosfs.c
// Function: doswrite
FRESULT doswrite(int argc, const char **argv)
{
  int i;
  char *s;
  char *path = 0;
  BYTE mode = FA_WRITE | FA_CREATE_NEW;
  FRESULT res;
  FIL fil;
  char buffer[4096];
  UINT nread, nwritten;
  int dflag = 0;

  for (i=1; i<argc; i++) {
    if (! strcmp(argv[i],"-a"))
      mode = FA_WRITE | FA_OPEN_APPEND;
    else if (! strcmp(argv[i],"-q"))
      mode = FA_WRITE | FA_CREATE_ALWAYS;
    else if (! strcmp(argv[i],"-i")) {
      if (++i >= argc)
        goto usage;
      if (! freopen(argv[i], "rb", stdin))
        fatal("Cannot open '%s' for reading.\n", argv[i]);
    } else if (! strcmp(argv[i],"-d"))
      dflag = 1;
    else if (argv[i][0] == '-')
      goto usage;
    else if (! path)
      path = fix_path(argv[i]);
    else
      goto usage;
  }
  if (!path) {
  usage:
    doswritehelp();
    exit(EXIT_FAILURE);
  }
#ifdef WIN32
  fflush(stdin);
  _setmode(_fileno(stdin), O_BINARY);
#endif
  if (dflag && (s = strrchr(path, '/'))) {
    *s = 0;
    if ((res = rmkdir(path, 1)) != FR_OK)
      return res;
    *s = '/';
  }
  res = f_open(&fil, path, mode);
  if (res != FR_OK)
    return res;
  for(;;) {
    nread = fread(buffer, 1, sizeof(buffer), stdin);
    if (nread == 0)
      break;
    res = f_write(&fil, buffer, nread, &nwritten);
    if (res != FR_OK)
      break;
    if (nwritten < nread)
      break;
  }
  f_close(&fil);
  if (ferror(stdin))
    fatal("I/O error reading data from stdin\n");
  if (nread && res != FR_OK)
    return res;
  if (nread && nwritten < nread)
    fatal("Filesystem is full\n");
  return FR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x12a0, %rsp           # imm = 0x12A0
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movb $0x6, -0x29(%rbp)
movl $0x0, -0x129c(%rbp)
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2d04
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xebcd(%rip), %rsi      # 0x117ab
callq 0x1140
cmpl $0x0, %eax
jne 0x2bf1
movb $0x32, -0x29(%rbp)
jmp 0x2cf4
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xebaa(%rip), %rsi      # 0x117ae
callq 0x1140
cmpl $0x0, %eax
jne 0x2c17
movb $0xa, -0x29(%rbp)
jmp 0x2cf2
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xeb87(%rip), %rsi      # 0x117b1
callq 0x1140
cmpl $0x0, %eax
jne 0x2c8b
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
cmpl -0x8(%rbp), %eax
jl 0x2c47
jmp 0x2d0d
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x1337e(%rip), %rax     # 0x15fd8
movq (%rax), %rdx
leaq 0xeb50(%rip), %rsi      # 0x117b4
callq 0x1110
cmpq $0x0, %rax
jne 0x2c89
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xeb35(%rip), %rdi      # 0x117b7
movb $0x0, %al
callq 0x1330
jmp 0x2cf0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xeb38(%rip), %rsi      # 0x117d6
callq 0x1140
cmpl $0x0, %eax
jne 0x2cb4
movl $0x1, -0x129c(%rbp)
jmp 0x2cee
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2cca
jmp 0x2d0d
cmpq $0x0, -0x28(%rbp)
jne 0x2ce8
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1ed0
movq %rax, -0x28(%rbp)
jmp 0x2cea
jmp 0x2d0d
jmp 0x2cec
jmp 0x2cee
jmp 0x2cf0
jmp 0x2cf2
jmp 0x2cf4
jmp 0x2cf6
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2bbf
cmpq $0x0, -0x28(%rbp)
jne 0x2d1c
jmp 0x2d0d
callq 0x2b50
movl $0x1, %edi
callq 0x1200
cmpl $0x0, -0x129c(%rbp)
je 0x2d6c
movq -0x28(%rbp), %rdi
movl $0x2f, %esi
callq 0x10e0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x2d6c
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x20e0
movl %eax, -0x30(%rbp)
cmpl $0x0, %eax
je 0x2d65
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2e75
movq -0x20(%rbp), %rax
movb $0x2f, (%rax)
movq -0x28(%rbp), %rsi
leaq -0x290(%rbp), %rdi
movzbl -0x29(%rbp), %edx
callq 0x52e0
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2d94
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2e75
jmp 0x2d96
leaq -0x1290(%rbp), %rdi
movq 0x13234(%rip), %rax     # 0x15fd8
movq (%rax), %rcx
movl $0x1, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x10a0
movl %eax, -0x1294(%rbp)
cmpl $0x0, -0x1294(%rbp)
jne 0x2dc7
jmp 0x2e04
leaq -0x1290(%rbp), %rsi
movl -0x1294(%rbp), %edx
leaq -0x290(%rbp), %rdi
leaq -0x1298(%rbp), %rcx
callq 0x6d80
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2df2
jmp 0x2e04
movl -0x1298(%rbp), %eax
cmpl -0x1294(%rbp), %eax
jae 0x2e02
jmp 0x2e04
jmp 0x2d96
leaq -0x290(%rbp), %rdi
callq 0x7ca0
movq 0x131c1(%rip), %rax     # 0x15fd8
movq (%rax), %rdi
callq 0x1090
cmpl $0x0, %eax
je 0x2e32
leaq 0xe9ae(%rip), %rdi      # 0x117d9
movb $0x0, %al
callq 0x1330
cmpl $0x0, -0x1294(%rbp)
je 0x2e49
cmpl $0x0, -0x30(%rbp)
je 0x2e49
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2e75
cmpl $0x0, -0x1294(%rbp)
je 0x2e6e
movl -0x1298(%rbp), %eax
cmpl -0x1294(%rbp), %eax
jae 0x2e6e
leaq 0xe995(%rip), %rdi      # 0x117fc
movb $0x0, %al
callq 0x1330
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x12a0, %rsp           # imm = 0x12A0
popq %rbp
retq
nopw %cs:(%rax,%rax)