// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movl %edx, 0x3c(%rsp)
movq 0x48(%rsp), %rdi
callq 0x8e20
subl $0x1, %eax
movl %eax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0x7340
cmpl $0x0, 0x38(%rsp)
jne 0x16a4c
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl $0x1, %edx
callq 0x16c80
movl %eax, 0x34(%rsp)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x16c23
movq 0x48(%rsp), %rdi
movl 0x38(%rsp), %esi
addl $0x14, %esi
leaq 0x1f3d9(%rip), %rdx     # 0x35e38
callq 0xcd50
movl $0x1, 0x34(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x38(%rsp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, 0x38(%rsp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x1f(%rsp)
je 0x16a98
cmpl $0x0, 0x34(%rsp)
setne %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x16aa5
jmp 0x16c21
movq 0x48(%rsp), %rdi
movl 0x30(%rsp), %esi
callq 0x9350
cmpl $0x3, %eax
jne 0x16b11
movq 0x48(%rsp), %rdi
movl 0x30(%rsp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x98a0
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x16aec
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x16da0
movl %eax, 0x18(%rsp)
jmp 0x16b04
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x16df0
movl %eax, 0x18(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x34(%rsp)
jmp 0x16c0f
movq 0x48(%rsp), %rdi
movl 0x30(%rsp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x9a80
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x16b43
movq 0x20(%rsp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x2a, %ecx
movb %al, 0x17(%rsp)
je 0x16b62
movq 0x48(%rsp), %rdi
movl 0x30(%rsp), %esi
leaq 0x1f2f8(%rip), %rdx     # 0x35e4b
callq 0xc3a0
cmpl $0x0, %eax
setne %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
movq 0x20(%rsp), %rax
movsbl 0x1(%rax), %eax
addl $-0x4c, %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x22, %eax
ja 0x16bf2
movq 0x8(%rsp), %rax
leaq 0x1f146(%rip), %rcx     # 0x35cd0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x16ea0
movl %eax, 0x34(%rsp)
jmp 0x16c0d
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl $0x1, %edx
callq 0x16c80
movl %eax, 0x34(%rsp)
jmp 0x16c0d
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0x16c80
movl %eax, 0x34(%rsp)
jmp 0x16c0d
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x16f00
movl $0x1, 0x34(%rsp)
jmp 0x16c0d
movq 0x48(%rsp), %rdi
movl 0x30(%rsp), %esi
leaq 0x1f258(%rip), %rdx     # 0x35e5a
callq 0xc3a0
movl %eax, 0x54(%rsp)
jmp 0x16c74
jmp 0x16c0f
jmp 0x16c11
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x16a74
jmp 0x16c23
movq 0x40(%rsp), %rdi
callq 0x70e0
cmpl $0x0, %eax
je 0x16c48
movq 0x48(%rsp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xc760
movl %eax, 0x54(%rsp)
jmp 0x16c74
cmpl $0x0, 0x34(%rsp)
jne 0x16c68
movq 0x48(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x8e50
movq 0x48(%rsp), %rdi
callq 0x9df0
movl 0x30(%rsp), %eax
subl 0x3c(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax)