// File: /workspace/github_c_makefile_star2_O3/zenkj[P]luajit-arm64/src/host/minilua.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){
success=read_line(L,f);
n=first+1;
}
else{
luaL_checkstack(L,nargs+20,"too many arguments");
success=1;
for(n=first;nargs--&&success;n++){
if(lua_type(L,n)==3){
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':
success=read_number(L,f);
break;
case'l':
success=read_line(L,f);
break;
case'a':
read_chars(L,f,~((size_t)0));
success=1;
break;
default:
return luaL_argerror(L,n,"invalid format");
}
}
}
}
if(ferror(f))
return pushresult(L,0,NULL);
if(!success){
lua_pop(L,1);
lua_pushnil(L);
}
return n-first;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
movq 0x10(%rdi), %r13
subq 0x18(%rdi), %r13
shrq $0x4, %r13
movq %rsi, %rdi
callq 0x31a0
cmpl $0x1, %r13d
movq %r12, 0x8(%rsp)
jne 0x11baa
movq %rbx, %rdi
movq %r15, %rsi
callq 0x11a82
movl %eax, %r14d
leal 0x1(%r12), %ebp
jmp 0x11d04
leal 0x13(%r13), %esi
leaq 0x444a(%rip), %rdx      # 0x15fff
movq %rbx, %rdi
callq 0x10e19
addl $-0x2, %r13d
leaq 0x38d0(%rip), %rcx      # 0x15498
movl %r12d, %ebp
movq %rcx, %r12
movq %rbx, %rdi
movl %ebp, %esi
callq 0x9d4e
cmpq %r12, %rax
je 0x11c09
cmpl $0x3, 0x8(%rax)
jne 0x11c09
movq %rbx, %rdi
movl %ebp, %esi
callq 0xb10b
testq %rax, %rax
je 0x11ca8
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x11d63
jmp 0x11c89
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x3d8d
testq %rax, %rax
je 0x11d49
cmpb $0x2a, (%rax)
jne 0x11d49
movzbl 0x1(%rax), %eax
cmpl $0x61, %eax
je 0x11c8e
cmpl $0x6c, %eax
je 0x11c7e
cmpl $0x6e, %eax
jne 0x11d5a
movq %r15, %rdi
leaq 0x43e8(%rip), %rsi      # 0x16030
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x3080
cmpl $0x1, %eax
jne 0x11cdd
movsd 0x10(%rsp), %xmm0
movq 0x10(%rbx), %rax
movsd %xmm0, (%rax)
movl $0x3, 0x8(%rax)
movq 0x10(%rbx), %rax
movl $0x1, %r14d
jmp 0x11ceb
movq %rbx, %rdi
movq %r15, %rsi
callq 0x11a82
movl %eax, %r14d
jmp 0x11cf3
movq %rbx, %rdi
movq %r15, %rsi
movq $-0x1, %rdx
callq 0x11d63
movl $0x1, %r14d
jmp 0x11cf3
movq %r15, %rdi
callq 0x32d0
movl %eax, %r12d
movl %eax, %edi
movq %r15, %rsi
callq 0x31f0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x94a5
xorl %r14d, %r14d
cmpl $-0x1, %r12d
leaq 0x37c1(%rip), %r12      # 0x15498
setne %r14b
jmp 0x11cf3
movq 0x10(%rbx), %rax
movl $0x0, 0x8(%rax)
xorl %r14d, %r14d
addq $0x10, %rax
movq %rax, 0x10(%rbx)
incl %ebp
addl $-0x1, %r13d
jae 0x11d04
testl %r14d, %r14d
jne 0x11bce
movq %r15, %rdi
callq 0x3090
testl %eax, %eax
je 0x11d20
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x11765
movl %eax, %ebp
jmp 0x11d38
testl %r14d, %r14d
jne 0x11d34
movq 0x10(%rbx), %rax
movl $0x0, -0x8(%rax)
movq %rax, 0x10(%rbx)
subl 0x8(%rsp), %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x42c2(%rip), %rdx      # 0x16012
movq %rbx, %rdi
movl %ebp, %esi
callq 0xaa6a
leaq 0x42c0(%rip), %rdx      # 0x16021
jmp 0x11d50