// File: /workspace/github_c_makefile_star2_O0/lb3361[P]dosfs/dosfs.c
// Function: dosread
FRESULT dosread(int argc, const char **argv)
{
  int i;
  FRESULT res;
  
  if (argc < 2) {
  usage:
    dosreadhelp();
    exit(EXIT_FAILURE);
  }
#ifdef WIN32
  fflush(stdout);
  _setmode(_fileno(stdout), O_BINARY);
#endif
  for (i=1; i<argc; i++)
    {
      if (! strcmp(argv[i], "-o")) {
        if (++i >= argc)
          goto usage;
        if (! freopen(argv[i], "wb", stdout))
          fatal("Cannot open '%s' for writing\n", argv[i]);
      } else if (argv[i][0] == '-') {
        goto usage;
      } else {
        FIL fil;
        char *path = fix_path(argv[i]);
        char buffer[4096];
        UINT nread;
        res = f_open(&fil, path, FA_READ);
        if (res != FR_OK)
          return res;
        do {
          res = f_read(&fil, buffer, (UINT)sizeof(buffer), &nread);
          if (res != FR_OK)
            break;
          if (nread > 0)
            fwrite(buffer, 1, nread, stdout);
        } while (nread == (UINT)sizeof(buffer));
        fflush(stdout);
        f_close(&fil);
        if (res != FR_OK)
          return res;
      }
    }
  return FR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1290, %rsp           # imm = 0x1290
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x29a9
jmp 0x299a
callq 0x2940
movl $0x1, %edi
callq 0x1200
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2b30
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xec76(%rip), %rsi      # 0x11645
callq 0x1140
cmpl $0x0, %eax
jne 0x2a30
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
cmpl -0x8(%rbp), %eax
jl 0x29e9
jmp 0x299a
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x135d4(%rip), %rax     # 0x15fd0
movq (%rax), %rdx
leaq 0xec42(%rip), %rsi      # 0x11648
callq 0x1110
cmpq $0x0, %rax
jne 0x2a2b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xec27(%rip), %rdi      # 0x1164b
movb $0x0, %al
callq 0x1330
jmp 0x2b20
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2a49
jmp 0x299a
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1ed0
movq %rax, -0x280(%rbp)
movq -0x280(%rbp), %rsi
leaq -0x278(%rbp), %rdi
movl $0x1, %edx
callq 0x52e0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x2a8d
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b37
jmp 0x2a8f
leaq -0x1280(%rbp), %rsi
leaq -0x278(%rbp), %rdi
movl $0x1000, %edx           # imm = 0x1000
leaq -0x1284(%rbp), %rcx
callq 0x68d0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x2ab9
jmp 0x2af3
cmpl $0x0, -0x1284(%rbp)
jbe 0x2ae5
leaq -0x1280(%rbp), %rdi
movl -0x1284(%rbp), %eax
movl %eax, %edx
movq 0x134f8(%rip), %rax     # 0x15fd0
movq (%rax), %rcx
movl $0x1, %esi
callq 0x1210
jmp 0x2ae7
cmpl $0x1000, -0x1284(%rbp)  # imm = 0x1000
je 0x2a8f
movq 0x134d6(%rip), %rax     # 0x15fd0
movq (%rax), %rdi
callq 0x11a0
leaq -0x278(%rbp), %rdi
callq 0x7ca0
cmpl $0x0, -0x18(%rbp)
je 0x2b1c
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b37
jmp 0x2b1e
jmp 0x2b20
jmp 0x2b22
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x29b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1290, %rsp           # imm = 0x1290
popq %rbp
retq
nopw %cs:(%rax,%rax)