// File: /workspace/github_c_makefile_star2_O3/bhk[P]tooltree/lua/../opensource/lua-5.2.3/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, 1);
    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, 1);
            break;
          case 'L':  /* line with end-of-line */
            success = read_line(L, f, 0);
            break;
          case 'a':  /* file */
            read_all(L, f);  /* read entire file */
            success = 1; /* always success */
            break;
          default:
            return luaL_argerror(L, n, "invalid format");
        }
      }
    }
  }
  if (ferror(f))
    return luaL_fileresult(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 $0x2038, %rsp           # imm = 0x2038
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
callq 0x7674
movl %eax, %r12d
movq %r15, %rdi
callq 0x6350
cmpl $0x1, %r12d
movq %r13, 0x10(%rsp)
jne 0xecda
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xef2f
movl %eax, %r14d
leal 0x1(%r13), %ebp
movq %r15, %rdi
callq 0x60e0
testl %eax, %eax
je 0xeee5
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x92f4
movl %eax, %ebp
jmp 0xef03
leal 0x13(%r12), %esi
leaq 0x11e64(%rip), %rdx     # 0x20b4a
movq %rbx, %rdi
callq 0x96ca
addl $-0x2, %r12d
movl %r13d, %ebp
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x7992
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
cmpl $0x3, %eax
jne 0xed6f
callq 0x7c2b
testq %rax, %rax
je 0xee69
movq %rax, %r14
movq %rbx, %rdi
leaq 0x18(%rsp), %rbx
movq %rbx, %rsi
callq 0x9ad7
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98f7
movl $0x1, %esi
movq %rax, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x6100
movq %rax, %r13
addq %rax, 0x28(%rsp)
movq %rbx, %rdi
movq 0x8(%rsp), %rbx
callq 0x9a0c
xorl %r14d, %r14d
testq %r13, %r13
jmp 0xee91
callq 0x7cea
movq %rax, %r14
testq %rax, %rax
je 0xed82
cmpb $0x2a, (%r14)
je 0xed93
movq %rbx, %rdi
movl %ebp, %esi
leaq 0x11dcf(%rip), %rdx     # 0x20b5d
callq 0x905e
movzbl 0x1(%r14), %eax
cmpl $0x6b, %eax
jg 0xee21
cmpl $0x4c, %eax
leaq 0x18(%rsp), %rbx
je 0xee97
cmpl $0x61, %eax
jne 0xef17
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x9ad7
movl $0x2000, %r14d          # imm = 0x2000
movl $0x2000, %r13d          # imm = 0x2000
movq %rbx, %rdi
movq %r14, %rsi
callq 0x98f7
movl $0x1, %esi
movq %rax, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x6100
addq %rax, 0x28(%rsp)
movq %r14, %rcx
shrq $0x3e, %rcx
sete %cl
shlq %cl, %r13
cmpq %r14, %rax
movq %r13, %r14
jae 0xedd1
movq %rbx, %rdi
callq 0x9a0c
movl $0x1, %r14d
movq 0x8(%rsp), %rbx
jmp 0xeeb9
cmpl $0x6c, %eax
leaq 0x18(%rsp), %rdx
je 0xeea6
cmpl $0x6e, %eax
jne 0xef17
movq %r15, %rdi
leaq 0x11d3d(%rip), %rsi     # 0x20b7b
xorl %eax, %eax
callq 0x60d0
cmpl $0x1, %eax
jne 0xeed3
movsd 0x18(%rsp), %xmm0
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7e80
movl $0x1, %r14d
jmp 0xeeb9
movq %r15, %rdi
callq 0x65a0
movl %eax, %r13d
movl %eax, %edi
movq %r15, %rsi
callq 0x63e0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7ecb
xorl %r14d, %r14d
cmpl $-0x1, %r13d
setne %r14b
jmp 0xeeb9
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
jmp 0xeeb1
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xef2f
movl %eax, %r14d
incl %ebp
addl $-0x1, %r12d
jae 0xecb7
testl %r14d, %r14d
jne 0xecfa
jmp 0xecb7
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7e6c
xorl %r14d, %r14d
jmp 0xeeb9
testl %r14d, %r14d
jne 0xeeff
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7688
movq %rbx, %rdi
callq 0x7e6c
subl 0x10(%rsp), %ebp
movl %ebp, %eax
addq $0x2038, %rsp           # imm = 0x2038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11c4e(%rip), %rdx     # 0x20b6c
movq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0x905e
jmp 0xecd3