// File: /workspace/github_c_makefile_star2_O3/tylerneylon[P]APIsWithLua/lua/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)luaL_checkinteger(L, n);
        success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
      }
      else {
        const char *p = luaL_checkstring(L, n);
        if (*p == '*') p++;  /* skip optional '*' (for compatibility) */
        switch (*p) {
          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 $0x2048, %rsp           # imm = 0x2048
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x5d39
movl %eax, %r12d
movq %r15, %rdi
callq 0x5300
cmpl $0x1, %r12d
movq %rbp, 0x20(%rsp)
jne 0x1b121
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x1b4b4
movl %eax, %r14d
incl %ebp
jmp 0x1b453
leal 0x13(%r12), %esi
leaq 0x8e27(%rip), %rdx      # 0x23f54
movq %rbx, %rdi
callq 0x14929
addl $-0x2, %r12d
leaq 0x28(%rsp), %r13
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x608f
movq %rbx, %rdi
movl %ebp, %esi
cmpl $0x3, %eax
jne 0x1b1ac
callq 0x15124
testq %rax, %rax
je 0x1b2e6
movq %rax, %r14
movq %rbx, %rdi
movq %r13, %rsi
callq 0x154c8
movq %r13, %rdi
movq %r14, %rsi
callq 0x151bd
movl $0x1, %esi
movq %rax, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x50d0
movq %rax, %rbx
addq %rax, 0x38(%rsp)
movq %r13, %rdi
callq 0x153c0
xorl %r14d, %r14d
testq %rbx, %rbx
jmp 0x1b312
xorl %edx, %edx
callq 0x14fff
xorl %ecx, %ecx
cmpb $0x2a, (%rax)
sete %cl
movzbl (%rax,%rcx), %eax
cmpl $0x6b, %eax
jg 0x1b223
cmpl $0x4c, %eax
je 0x1b31b
cmpl $0x61, %eax
jne 0x1b4a1
movq %rbx, %rdi
movq %r13, %rsi
callq 0x154c8
movl $0x2000, %esi           # imm = 0x2000
movq %r13, %rdi
callq 0x151bd
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %rax, %rdi
movq %r15, %rcx
callq 0x50d0
addq %rax, 0x38(%rsp)
cmpq $0x2000, %rax           # imm = 0x2000
je 0x1b1e1
movq %r13, %rdi
callq 0x153c0
movl $0x1, %r14d
jmp 0x1b436
cmpl $0x6c, %eax
je 0x1b325
cmpl $0x6e, %eax
jne 0x1b4a1
movq %r15, 0x28(%rsp)
movl $0x0, 0x34(%rsp)
callq 0x50f0
movq (%rax), %rax
movsbl (%rax), %eax
movl %eax, 0x1c(%rsp)
movq %r15, %rdi
callq 0x54e0
movl %eax, %r14d
callq 0x5530
movq (%rax), %rax
movslq %r14d, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x1b251
movl %r14d, 0x30(%rsp)
cmpl $0x2d, %r14d
je 0x1b27f
cmpl $0x2b, %r14d
jne 0x1b28c
movq %r13, %rdi
callq 0x1b60d
movl 0x30(%rsp), %r14d
xorl %esi, %esi
cmpl $0x30, %r14d
jne 0x1b33d
movq %r13, %rdi
callq 0x1b60d
testl %eax, %eax
je 0x1b34d
movl 0x30(%rsp), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x1b351
movq %r13, %rdi
callq 0x1b60d
movl %eax, %ebx
xorl $0x1, %ebx
xorl %esi, %esi
testl %eax, %eax
setne %sil
leaq 0x8cbc(%rip), %rcx      # 0x23f90
leaq 0x8cb2(%rip), %rax      # 0x23f8d
cmovneq %rax, %rcx
movq %rcx, 0x8(%rsp)
jmp 0x1b364
movq %r15, %rdi
callq 0x54e0
movq %rbx, %r14
movl %eax, %ebx
movl %eax, %edi
movq %r15, %rsi
callq 0x5370
movq %r14, %rdi
leaq 0x9a81(%rip), %rsi      # 0x24d88
callq 0x656b
xorl %r14d, %r14d
cmpl $-0x1, %ebx
setne %r14b
jmp 0x1b436
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
jmp 0x1b330
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x1b4b4
movl %eax, %r14d
jmp 0x1b436
xorl %ebx, %ebx
leaq 0x8c4a(%rip), %rax      # 0x23f90
movq %rax, 0x8(%rsp)
jmp 0x1b364
xorl %ebx, %ebx
jmp 0x1b356
movl $0x1, %ebx
leaq 0x8c33(%rip), %rax      # 0x23f90
movq %rax, 0x8(%rsp)
xorl %esi, %esi
movq %r13, %rdi
movl %esi, 0x18(%rsp)
callq 0x1b5bd
movl %eax, %r14d
addl %ebx, %r14d
movl 0x30(%rsp), %eax
cmpl 0x1c(%rsp), %eax
setne %cl
cmpl $0x2e, %eax
setne %al
testb %al, %cl
jne 0x1b3ad
movq %r13, %rdi
callq 0x1b60d
testl %eax, %eax
movq 0x10(%rsp), %rbx
je 0x1b3b2
movq %r13, %rdi
movl 0x18(%rsp), %esi
callq 0x1b5bd
addl %eax, %r14d
jmp 0x1b3b2
movq 0x10(%rsp), %rbx
movl 0x30(%rsp), %edi
testl %r14d, %r14d
jle 0x1b3ff
movq 0x8(%rsp), %rcx
movsbl (%rcx), %eax
cmpl %eax, %edi
je 0x1b3cf
movsbl 0x1(%rcx), %eax
cmpl %eax, %edi
jne 0x1b3ff
movq %r13, %rdi
callq 0x1b60d
movl 0x30(%rsp), %edi
testl %eax, %eax
je 0x1b3ff
cmpl $0x2d, %edi
je 0x1b3e9
cmpl $0x2b, %edi
jne 0x1b3f1
movq %r13, %rdi
callq 0x1b60d
movq %r13, %rdi
xorl %esi, %esi
callq 0x1b5bd
movl 0x30(%rsp), %edi
movq 0x28(%rsp), %rsi
callq 0x5370
movslq 0x34(%rsp), %rax
movb $0x0, 0x38(%rsp,%rax)
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0x626f
movl $0x1, %r14d
testq %rax, %rax
jne 0x1b436
movq %rbx, %rdi
callq 0x64cd
xorl %r14d, %r14d
incl %ebp
addl $-0x1, %r12d
jae 0x1b44e
testl %r14d, %r14d
movq 0x10(%rsp), %rbx
jne 0x1b143
jmp 0x1b453
movq 0x10(%rsp), %rbx
movq %r15, %rdi
callq 0x50c0
testl %eax, %eax
je 0x1b46f
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x14c62
movl %eax, %ebp
jmp 0x1b48d
testl %r14d, %r14d
jne 0x1b489
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5d4d
movq %rbx, %rdi
callq 0x64cd
subl 0x20(%rsp), %ebp
movl %ebp, %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8ad6(%rip), %rdx      # 0x23f7e
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1497c
jmp 0x1b46b