// File: /workspace/github_c_makefile_star2_O1/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, %r13d
movq %rsi, %r15
movq %rdi, %r14
callq 0x5d3d
movl %eax, %r12d
movq %r15, %rdi
callq 0x5310
cmpl $0x1, %r12d
movq %r13, 0x20(%rsp)
jne 0x1a5bf
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x1a96f
movl %eax, %ebx
leal 0x1(%r13), %ebp
jmp 0x1a91a
leal 0x13(%r12), %esi
leaq 0x88f9(%rip), %rdx      # 0x22ec4
movq %r14, %rdi
callq 0x13e55
addl $-0x2, %r12d
movl %r13d, %ebp
movq %r14, 0x18(%rsp)
movq %r14, %rdi
movl %ebp, %esi
callq 0x5f7f
movq %r14, %rdi
movl %ebp, %esi
cmpl $0x3, %eax
jne 0x1a64c
callq 0x1465a
testq %rax, %rax
je 0x1a77e
movq %rax, %rbx
movq %r14, %rdi
leaq 0x28(%rsp), %r14
movq %r14, %rsi
callq 0x149f7
movq %r14, %rdi
movq %rbx, %rsi
callq 0x146f3
movl $0x1, %esi
movq %rax, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x50e0
movq %rax, %r13
addq %rax, 0x38(%rsp)
movq %r14, %rdi
callq 0x148ef
xorl %ebx, %ebx
testq %r13, %r13
jmp 0x1a7a8
xorl %edx, %edx
callq 0x14535
xorl %ecx, %ecx
cmpb $0x2a, (%rax)
sete %cl
movzbl (%rax,%rcx), %eax
cmpl $0x6b, %eax
jg 0x1a6c9
cmpl $0x4c, %eax
leaq 0x28(%rsp), %rbx
je 0x1a7d1
cmpl $0x61, %eax
jne 0x1a7b0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x149f7
movl $0x2000, %esi           # imm = 0x2000
movq %rbx, %rdi
callq 0x146f3
movl $0x1, %esi
movl $0x2000, %edx           # imm = 0x2000
movq %rax, %rdi
movq %r15, %rcx
callq 0x50e0
addq %rax, 0x38(%rsp)
cmpq $0x2000, %rax           # imm = 0x2000
je 0x1a686
movq %rbx, %rdi
callq 0x148ef
movb $0x1, %al
movl $0x1, %ebx
jmp 0x1a8fa
cmpl $0x6c, %eax
je 0x1a7db
cmpl $0x6e, %eax
jne 0x1a7b0
movq %r15, 0x28(%rsp)
movl $0x0, 0x34(%rsp)
callq 0x5100
movq (%rax), %rax
movsbl (%rax), %eax
movl %eax, 0x14(%rsp)
movq 0x28(%rsp), %rdi
callq 0x54f0
movl %eax, %ebx
movl %eax, 0x30(%rsp)
callq 0x5540
movq (%rax), %rax
movslq %ebx, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x1a6f7
cmpl $0x2d, %ebx
je 0x1a723
cmpl $0x2b, %ebx
jne 0x1a72d
leaq 0x28(%rsp), %rdi
callq 0x1aaba
xorl %r13d, %r13d
cmpl $0x30, 0x30(%rsp)
jne 0x1a7f2
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x1aaba
leaq 0x87b1(%rip), %rcx      # 0x22f00
movl $0x0, %esi
testl %eax, %eax
je 0x1a825
movl 0x30(%rsp), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x1a802
movq %rbx, %rdi
callq 0x1aaba
testl %eax, %eax
sete %al
jmp 0x1a804
movq %r15, %rdi
callq 0x54f0
movl %eax, %r13d
movl %eax, %edi
movq %r15, %rsi
callq 0x5380
movq %r14, %rdi
leaq 0x952b(%rip), %rsi      # 0x23cc8
callq 0x645b
xorl %ebx, %ebx
cmpl $-0x1, %r13d
setne %bl
jmp 0x1a8fe
movq %r14, %rdi
movl %ebp, %esi
leaq 0x8732(%rip), %rdx      # 0x22eee
callq 0x13ea8
movl %eax, 0x4(%rsp)
movl $0x1, %ebx
xorl %eax, %eax
jmp 0x1a8fa
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
jmp 0x1a7e6
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x1a96f
movl %eax, %ebx
jmp 0x1a8f8
leaq 0x8707(%rip), %rcx      # 0x22f00
xorl %esi, %esi
leaq 0x28(%rsp), %rbx
jmp 0x1a825
movb $0x1, %al
movzbl %al, %r13d
testb %r13b, %r13b
leaq 0x86eb(%rip), %rcx      # 0x22efd
leaq 0x86e7(%rip), %rax      # 0x22f00
cmovneq %rax, %rcx
movl %r13d, %eax
xorb $0x1, %al
movzbl %al, %esi
movq %rcx, 0x8(%rsp)
movq %rbx, %rdi
movl %esi, 0x10(%rsp)
callq 0x1aa68
movq %rbx, %rdx
movl %eax, %ebx
addl %r13d, %ebx
movl 0x30(%rsp), %eax
cmpl 0x14(%rsp), %eax
setne %cl
cmpl $0x2e, %eax
setne %al
testb %al, %cl
jne 0x1a870
movq %rdx, %r13
movq %rdx, %rdi
callq 0x1aaba
testl %eax, %eax
je 0x1a870
movq %r13, %rdi
movl 0x10(%rsp), %esi
callq 0x1aa68
addl %eax, %ebx
movq 0x8(%rsp), %rdx
testl %ebx, %ebx
jle 0x1a8bf
movl 0x30(%rsp), %eax
movsbl (%rdx), %ecx
cmpl %ecx, %eax
je 0x1a88c
movsbl 0x1(%rdx), %ecx
cmpl %ecx, %eax
jne 0x1a8bf
leaq 0x28(%rsp), %rdi
callq 0x1aaba
testl %eax, %eax
je 0x1a8bf
movl 0x30(%rsp), %eax
cmpl $0x2d, %eax
leaq 0x28(%rsp), %rbx
je 0x1a8ad
cmpl $0x2b, %eax
jne 0x1a8b5
movq %rbx, %rdi
callq 0x1aaba
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1aa68
movl 0x30(%rsp), %edi
movq 0x28(%rsp), %rsi
callq 0x5380
movslq 0x34(%rsp), %rax
movb $0x0, 0x38(%rsp,%rax)
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x6163
movl $0x1, %ebx
testq %rax, %rax
jne 0x1a8f8
movq %r14, %rdi
callq 0x63bd
xorl %ebx, %ebx
movb $0x1, %al
testb %al, %al
je 0x1a959
incl %ebp
addl $-0x1, %r12d
jae 0x1a915
testl %ebx, %ebx
movq 0x18(%rsp), %r14
jne 0x1a5df
jmp 0x1a91a
movq 0x18(%rsp), %r14
movq %r15, %rdi
callq 0x50d0
testl %eax, %eax
je 0x1a938
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x14198
movl %eax, 0x4(%rsp)
jmp 0x1a959
testl %ebx, %ebx
jne 0x1a951
movq %r14, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5d51
movq %r14, %rdi
callq 0x63bd
subl 0x20(%rsp), %ebp
movl %ebp, 0x4(%rsp)
movl 0x4(%rsp), %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq