// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/lua-5.1.5/src/liolib.c
// Function: g_read
static int g_read (lua_State *L, FILE *f, int first) {
  int nargs = lua_gettop(L) - 1;
  int success;
  int n;
  clearerr(f);
  if (nargs == 0) {  /* no arguments? */
    success = read_line(L, f);
    n = first+1;  /* to return 1 result */
  }
  else {  /* ensure stack space for all results and for auxlib's buffer */
    luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
    success = 1;
    for (n = first; nargs-- && success; n++) {
      if (lua_type(L, n) == LUA_TNUMBER) {
        size_t l = (size_t)lua_tointeger(L, n);
        success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
      }
      else {
        const char *p = lua_tostring(L, n);
        luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
        switch (p[1]) {
          case 'n':  /* number */
            success = read_number(L, f);
            break;
          case 'l':  /* line */
            success = read_line(L, f);
            break;
          case 'a':  /* file */
            read_chars(L, f, ~((size_t)0));  /* read MAX_SIZE_T chars */
            success = 1; /* always success */
            break;
          default:
            return luaL_argerror(L, n, "invalid format");
        }
      }
    }
  }
  if (ferror(f))
    return pushresult(L, 0, NULL);
  if (!success) {
    lua_pop(L, 1);  /* remove last result */
    lua_pushnil(L);  /* push nil instead */
  }
  return n - first;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
movq 0x10(%rdi), %r13
subq 0x18(%rdi), %r13
shrq $0x4, %r13
movq %rsi, %rdi
callq 0xb100
cmpl $0x1, %r13d
movq %r12, 0x8(%rsp)
jne 0x69bb4
movq %rbx, %rdi
movq %r15, %rsi
callq 0x69a74
movl %eax, %r14d
leal 0x1(%r12), %ebp
jmp 0x69d0e
leal 0x13(%r13), %esi
leaq 0x84daa(%rip), %rdx     # 0xee969
movq %rbx, %rdi
callq 0x5b2dd
addl $-0x2, %r13d
leaq 0x83b3e(%rip), %rcx     # 0xed710
movl %r12d, %ebp
movq %rcx, %r12
movq %rbx, %rdi
movl %ebp, %esi
callq 0x57945
cmpq %r12, %rax
je 0x69c13
cmpl $0x3, 0x8(%rax)
jne 0x69c13
movq %rbx, %rdi
movl %ebp, %esi
callq 0x57fed
testq %rax, %rax
je 0x69cb2
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x69d75
jmp 0x69c93
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x58042
testq %rax, %rax
je 0x69d5b
cmpb $0x2a, (%rax)
jne 0x69d5b
movzbl 0x1(%rax), %eax
cmpl $0x61, %eax
je 0x69c98
cmpl $0x6c, %eax
je 0x69c88
cmpl $0x6e, %eax
jne 0x69d6c
movq %r15, %rdi
leaq 0x86580(%rip), %rsi     # 0xf01d2
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xbbd0
cmpl $0x1, %eax
jne 0x69ce7
movsd 0x10(%rsp), %xmm0
movq 0x10(%rbx), %rax
movsd %xmm0, (%rax)
movl $0x3, 0x8(%rax)
movq 0x10(%rbx), %rax
movl $0x1, %r14d
jmp 0x69cf5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x69a74
movl %eax, %r14d
jmp 0x69cfd
movq %rbx, %rdi
movq %r15, %rsi
movq $-0x1, %rdx
callq 0x69d75
movl $0x1, %r14d
jmp 0x69cfd
movq %r15, %rdi
callq 0xb190
movl %eax, %r12d
movl %eax, %edi
movq %r15, %rsi
callq 0xb0d0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x58391
xorl %r14d, %r14d
cmpl $-0x1, %r12d
leaq 0x83a2f(%rip), %r12     # 0xed710
setne %r14b
jmp 0x69cfd
movq 0x10(%rbx), %rax
movl $0x0, 0x8(%rax)
xorl %r14d, %r14d
addq $0x10, %rax
movq %rax, 0x10(%rbx)
incl %ebp
addl $-0x1, %r13d
jae 0x69d0e
testl %r14d, %r14d
jne 0x69bd8
movq %r15, %rdi
callq 0xbc30
testl %eax, %eax
je 0x69d2a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x69862
movl %eax, %ebp
jmp 0x69d4a
testl %r14d, %r14d
jne 0x69d46
movq 0x10(%rbx), %rax
leaq -0x10(%rax), %rcx
movq %rcx, 0x10(%rbx)
movl $0x0, -0x8(%rax)
movq %rax, 0x10(%rbx)
subl 0x8(%rsp), %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x84af1(%rip), %rdx     # 0xee853
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5aeac
leaq 0x84c09(%rip), %rdx     # 0xee97c
jmp 0x69d62