// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5d90
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x52f0
cmpl $0x0, -0x20(%rbp)
jne 0x29ba4
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x29d70
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x29d1f
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
addl $0x14, %esi
leaq 0xcb1f(%rip), %rdx      # 0x366d4
callq 0x1f930
movl $0x1, -0x24(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x20(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x39(%rbp)
je 0x29be6
cmpl $0x0, -0x24(%rbp)
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x29bf2
jmp 0x29d1d
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x61f0
cmpl $0x3, %eax
jne 0x29c4b
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x20550
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x29c2c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x29f40
movl %eax, -0x40(%rbp)
jmp 0x29c40
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x29f90
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x29d0d
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x20390
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
jne 0x29c77
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
addl $-0x4c, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x22, %eax
ja 0x29cf3
movq -0x48(%rbp), %rax
leaq 0xc8fd(%rip), %rcx      # 0x36594
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2a020
movl %eax, -0x24(%rbp)
jmp 0x29d0b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x29d70
movl %eax, -0x24(%rbp)
jmp 0x29d0b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x29d70
movl %eax, -0x24(%rbp)
jmp 0x29d0b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2a210
movl $0x1, -0x24(%rbp)
jmp 0x29d0b
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
leaq 0xc9fd(%rip), %rdx      # 0x366fe
callq 0x1fab0
movl %eax, -0x4(%rbp)
jmp 0x29d67
jmp 0x29d0d
jmp 0x29d0f
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x29bc7
jmp 0x29d1f
movq -0x18(%rbp), %rdi
callq 0x50d0
cmpl $0x0, %eax
je 0x29d41
movq -0x10(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x1fe50
movl %eax, -0x4(%rbp)
jmp 0x29d67
cmpl $0x0, -0x24(%rbp)
jne 0x29d5e
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5dc0
movq -0x10(%rbp), %rdi
callq 0x6b60
movl -0x28(%rbp), %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq