// File: /workspace/github_c_makefile_star2_O1/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, %r14
callq 0x7683
movl %eax, %r12d
movq %r15, %rdi
callq 0x6350
cmpl $0x1, %r12d
movq %r13, 0x10(%rsp)
jne 0xeba6
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xee17
movl %eax, %ebx
leal 0x1(%r13), %ebp
movq %r14, %r13
jmp 0xedc2
leal 0x13(%r12), %esi
leaq 0x11f9c(%rip), %rdx     # 0x20b4e
movq %r14, %rdi
callq 0x9593
addl $-0x2, %r12d
movl %r13d, %ebp
movq %r14, %r13
movq %r14, 0x8(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x7889
movq %r13, %rdi
movl %ebp, %esi
xorl %edx, %edx
cmpl $0x3, %eax
jne 0xec38
callq 0x7b1d
testq %rax, %rax
je 0xed2b
movq %rax, %rbx
movq %r13, %rdi
leaq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0x999b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x97c0
movl $0x1, %esi
movq %rax, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x6100
movq %rax, %r13
addq %rax, 0x28(%rsp)
movq %r14, %rdi
callq 0x98d0
xorl %ebx, %ebx
testq %r13, %r13
jmp 0xed55
callq 0x7bdc
movq %rax, %rbx
testq %rax, %rax
je 0xec4a
cmpb $0x2a, (%rbx)
je 0xec5b
movq %r13, %rdi
movl %ebp, %esi
leaq 0x11f0b(%rip), %rdx     # 0x20b61
callq 0x8f3e
movzbl 0x1(%rbx), %eax
cmpl $0x6b, %eax
jg 0xece9
cmpl $0x4c, %eax
leaq 0x18(%rsp), %r14
je 0xed78
cmpl $0x61, %eax
jne 0xed5a
movq %r13, %rdi
movq %r14, %rsi
callq 0x999b
movl $0x2000, %ebx           # imm = 0x2000
movl $0x2000, %r13d          # imm = 0x2000
movq %r14, %rdi
movq %rbx, %rsi
callq 0x97c0
movl $0x1, %esi
movq %rax, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x6100
addq %rax, 0x28(%rsp)
cmpq %rbx, %rax
setae %dl
movq %rbx, %rcx
shrq $0x3e, %rcx
sete %cl
andb %dl, %cl
shlq %cl, %r13
cmpq %rbx, %rax
movq %r13, %rbx
jae 0xec95
movq %r14, %rdi
callq 0x98d0
movb $0x1, %al
movl $0x1, %ebx
jmp 0xed96
cmpl $0x6c, %eax
leaq 0x18(%rsp), %rdx
je 0xed82
cmpl $0x6e, %eax
jne 0xed5a
movq %r15, %rdi
leaq 0x11e79(%rip), %rsi     # 0x20b7f
xorl %eax, %eax
callq 0x60d0
cmpl $0x1, %eax
jne 0xedb1
movsd 0x18(%rsp), %xmm0
movq %r13, %rdi
callq 0x7d72
movl $0x1, %ebx
jmp 0xed94
movq %r15, %rdi
callq 0x65a0
movq %r13, %rbx
movl %eax, %r13d
movl %eax, %edi
movq %r15, %rsi
callq 0x63e0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7dc7
xorl %ebx, %ebx
cmpl $-0x1, %r13d
setne %bl
jmp 0xed9a
movq %r13, %rdi
movl %ebp, %esi
leaq 0x11e0a(%rip), %rdx     # 0x20b70
callq 0x8f3e
movl %eax, 0x4(%rsp)
movl $0x1, %ebx
xorl %eax, %eax
jmp 0xed96
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
jmp 0xed8d
movq %r13, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xee17
movl %eax, %ebx
movb $0x1, %al
testb %al, %al
je 0xee01
incl %ebp
addl $-0x1, %r12d
jae 0xedbd
testl %ebx, %ebx
movq 0x8(%rsp), %r13
jne 0xebc9
jmp 0xedc2
movq %r13, %rdi
callq 0x7d5e
xorl %ebx, %ebx
jmp 0xed94
movq 0x8(%rsp), %r13
movq %r15, %rdi
callq 0x60e0
testl %eax, %eax
je 0xede0
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x91d4
movl %eax, 0x4(%rsp)
jmp 0xee01
testl %ebx, %ebx
jne 0xedf9
movq %r13, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7697
movq %r13, %rdi
callq 0x7d5e
subl 0x10(%rsp), %ebp
movl %ebp, 0x4(%rsp)
movl 0x4(%rsp), %eax
addq $0x2038, %rsp           # imm = 0x2038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq