// File: /workspace/github_c_makefile_star2_O2/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 0x7423
movl %eax, %r14d
movq %r15, %rdi
callq 0x6340
movl %r14d, %ebp
decl %ebp
movq %r13, 0x8(%rsp)
je 0xe1b0
addl $0x13, %r14d
leaq 0x10b60(%rip), %rdx     # 0x1eb1e
movq %rbx, %rdi
movl %r14d, %esi
callq 0x9291
pushq $0x1
popq %r12
leaq 0x18(%rsp), %r14
movq %rbx, 0x10(%rsp)
addl $-0x1, %ebp
jae 0xe1c4
testl %r12d, %r12d
je 0xe1c4
movq %rbx, %rdi
movl %r13d, %esi
callq 0x7624
movq %rbx, %rdi
movl %r13d, %esi
xorl %edx, %edx
cmpl $0x3, %eax
jne 0xe056
callq 0x78a4
testq %rax, %rax
je 0xe0d6
movq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9657
movq %r14, %rdi
movq %r12, %rsi
callq 0x94ad
movq %rax, %rdi
pushq $0x1
popq %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6100
movq %rax, %r14
addq %rax, 0x28(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x95ae
xorl %r12d, %r12d
testq %r14, %r14
jmp 0xe0fe
callq 0x7967
movq %rax, %r12
testq %rax, %rax
je 0xe06a
cmpb $0x2a, (%r12)
je 0xe07c
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x10aba(%rip), %rdx     # 0x1eb31
callq 0x8c84
movzbl 0x1(%r12), %eax
cmpl $0x4c, %eax
je 0xe180
cmpl $0x61, %eax
je 0xe10c
cmpl $0x6c, %eax
je 0xe18a
cmpl $0x6e, %eax
jne 0xe213
movq %r15, %rdi
leaq 0x10aa3(%rip), %rsi     # 0x1eb4f
movq %r14, %rdx
xorl %eax, %eax
callq 0x60d0
cmpl $0x1, %eax
jne 0xe1a3
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x7adc
pushq $0x1
popq %r12
jmp 0xe19b
movq %r15, %rdi
callq 0x6590
movl %eax, %r14d
movl %eax, %edi
movq %r15, %rsi
callq 0x63d0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7b27
xorl %r12d, %r12d
cmpl $-0x1, %r14d
leaq 0x18(%rsp), %r14
setne %r12b
jmp 0xe19b
movl %r13d, 0x4(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9657
movl $0x2000, %r12d          # imm = 0x2000
movq %r14, %rbx
movl $0x2000, %r14d          # imm = 0x2000
pushq $0x1
popq %r13
movq %rbx, %rdi
movq %r12, %rsi
callq 0x94ad
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x6100
addq %rax, 0x28(%rsp)
movq %r12, %rcx
shrq $0x3e, %rcx
sete %cl
shlq %cl, %r14
cmpq %r12, %rax
movq %r14, %r12
jae 0xe12f
movq %rbx, %rdi
callq 0x95ae
pushq $0x1
popq %r12
movq %rbx, %r14
movq 0x10(%rsp), %rbx
movl 0x4(%rsp), %r13d
jmp 0xe19b
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
jmp 0xe193
movq %rbx, %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0xe227
movl %eax, %r12d
incl %r13d
jmp 0xdfd7
movq %rbx, %rdi
callq 0x7acb
xorl %r12d, %r12d
jmp 0xe19b
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe227
movl %eax, %r12d
incl %r13d
movq %r15, %rdi
callq 0x60e0
testl %eax, %eax
je 0xe1e1
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x8f0e
movl %eax, %r13d
jmp 0xe1fe
testl %r12d, %r12d
jne 0xe1f9
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x7437
movq %rbx, %rdi
callq 0x7acb
subl 0x8(%rsp), %r13d
movl %r13d, %eax
addq $0x2038, %rsp           # imm = 0x2038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10926(%rip), %rdx     # 0x1eb40
movq %rbx, %rdi
movl %r13d, %esi
callq 0x8c84
jmp 0xe1dc