// File: /workspace/github_c_makefile_star2_O2/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, %r14d
movq %rsi, %r15
movq %rdi, %r12
callq 0x5b1d
movl %eax, %ebx
movq %r15, %rdi
callq 0x52f0
movl %ebx, %ebp
decl %ebp
movq %r12, 0x8(%rsp)
je 0x18f78
addl $0x13, %ebx
leaq 0x8350(%rip), %rdx      # 0x20fe4
movq %r12, %rdi
movl %ebx, %esi
callq 0x12a9f
pushq $0x1
popq %r12
pushq $0x1
popq %r13
movq %r14, 0x18(%rsp)
movl %r14d, %ebx
addl $-0x1, %ebp
movq 0x8(%rsp), %r14
jae 0x18f71
testl %r12d, %r12d
je 0x18f71
movq %r14, %rdi
movl %ebx, %esi
callq 0x5d12
movq %r14, %rdi
movl %ebx, %esi
cmpl $0x3, %eax
jne 0x18d3c
callq 0x13252
movq %r14, %r13
testq %rax, %rax
leaq 0x28(%rsp), %r12
je 0x18e13
movq %rax, %r14
movq %r13, %rdi
movq %r12, %rsi
callq 0x13589
movq %r12, %rdi
movq %r14, %rsi
callq 0x132de
movq %rax, %rdi
pushq $0x1
popq %r13
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x50d0
movq %rax, %r14
addq %rax, 0x38(%rsp)
movq %r12, %rdi
callq 0x134ba
xorl %r12d, %r12d
testq %r14, %r14
setne %r12b
jmp 0x18f6a
xorl %edx, %edx
callq 0x13131
xorl %ecx, %ecx
cmpb $0x2a, (%rax)
sete %cl
movzbl (%rax,%rcx), %eax
cmpl $0x4c, %eax
leaq 0x28(%rsp), %r12
je 0x18e94
cmpl $0x61, %eax
je 0x18e4b
cmpl $0x6c, %eax
je 0x18e9e
cmpl $0x6e, %eax
jne 0x18fdf
movq %r15, 0x28(%rsp)
andl $0x0, 0x34(%rsp)
callq 0x50f0
movq (%rax), %rax
movb (%rax), %al
movb %al, 0x6(%rsp)
movb $0x2e, 0x7(%rsp)
movq %r15, %rdi
callq 0x54d0
movl %eax, %r14d
callq 0x5520
movq (%rax), %rax
movslq %r14d, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x18d95
movl %r14d, 0x30(%rsp)
movq %r12, %rdi
leaq 0x7d30(%rip), %rsi      # 0x20af1
callq 0x190e4
movq %r12, %rdi
leaq 0x824d(%rip), %rsi      # 0x2101d
callq 0x190e4
testl %eax, %eax
je 0x18eb4
movq %r12, %rdi
leaq 0x7d04(%rip), %rsi      # 0x20aeb
callq 0x190e4
movl %eax, %edx
movl %eax, %r13d
xorl $0x1, %r13d
testl %eax, %eax
leaq 0x8222(%rip), %rcx      # 0x21020
leaq 0x821e(%rip), %rax      # 0x21023
cmoveq %rax, %rcx
movq %rcx, 0x20(%rsp)
jmp 0x18ec5
movq %r15, %rdi
callq 0x54d0
movl %eax, %r14d
movl %eax, %edi
movq %r15, %rsi
callq 0x5360
movq %r13, %rdi
leaq 0x8fb6(%rip), %rsi      # 0x21de8
callq 0x61d0
xorl %r12d, %r12d
cmpl $-0x1, %r14d
setne %r12b
pushq $0x1
popq %r13
jmp 0x18f6a
movq %r14, %rdi
movq %r12, %rsi
callq 0x13589
movl $0x2000, %esi           # imm = 0x2000
movq %r12, %rdi
callq 0x132de
movl $0x2000, %edx           # imm = 0x2000
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rcx
callq 0x50d0
addq %rax, 0x38(%rsp)
cmpq $0x2000, %rax           # imm = 0x2000
je 0x18e56
movq %r12, %rdi
callq 0x134ba
pushq $0x1
popq %r12
jmp 0x18f6a
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
jmp 0x18ea7
movq %r14, %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x18ff2
movl %eax, %r12d
jmp 0x18f6a
xorl %r13d, %r13d
leaq 0x8165(%rip), %rax      # 0x21023
movq %rax, 0x20(%rsp)
xorl %edx, %edx
movq %r12, %rdi
movl %edx, 0x14(%rsp)
movl %edx, %esi
callq 0x190f9
movl %eax, %r14d
addl %r13d, %r14d
movq %r12, %rdi
leaq 0x6(%rsp), %rsi
callq 0x190e4
testl %eax, %eax
je 0x18ef9
movq %r12, %rdi
movl 0x14(%rsp), %esi
callq 0x190f9
addl %eax, %r14d
testl %r14d, %r14d
jle 0x18f28
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0x190e4
testl %eax, %eax
je 0x18f28
movq %r12, %rdi
leaq 0x7bd8(%rip), %rsi      # 0x20af1
callq 0x190e4
movq %r12, %rdi
xorl %esi, %esi
callq 0x190f9
movl 0x30(%rsp), %edi
movq 0x28(%rsp), %rsi
callq 0x5360
movslq 0x34(%rsp), %rax
movb $0x0, 0x38(%rsp,%rax)
movq 0x8(%rsp), %r14
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x5eec
pushq $0x1
popq %r12
testq %rax, %rax
pushq $0x1
popq %r13
jne 0x18f6a
movq %r14, %rdi
callq 0x6135
xorl %r12d, %r12d
incl %ebx
jmp 0x18cae
movq 0x18(%rsp), %r14
jmp 0x18f8d
pushq $0x1
popq %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x18ff2
movl %eax, %r12d
leal 0x1(%r14), %ebx
movq %r15, %rdi
callq 0x50c0
testl %eax, %eax
je 0x18fab
movq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x12dc6
movl %eax, %ebx
jmp 0x18fcb
testl %r12d, %r12d
jne 0x18fc8
pushq $-0x2
popq %rsi
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x5b31
movq %r15, %rdi
callq 0x6135
subl %r14d, %ebx
movl %ebx, %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8028(%rip), %rdx      # 0x2100e
movq %r14, %rdi
movl %ebx, %esi
callq 0x12af2
jmp 0x18fa7