// File: /workspace/github_c_makefile_star2_O2/bhk[P]tooltree/monoglot/./xpio_c.c
// Function: luaopen_xpio_c
int luaopen_xpio_c(lua_State *L)
{
   // POSIX fail: SIGPIPE will terminate a program when it writes to a socket
   // that a peer has closed, unless the program takes action to block or
   // ignore SIGPIPE. BSD provides SO_NOSIGPIPE, but that is not
   // portable. The following protects us from SIGPIPE, but it also disables
   // SIGPIPE behavior for stdin/stdout.  It is unfortunate to trigger
   // global side effects, but the default SIGPIPE behavior is essentially
   // incompatible with any network programming.
   signal(SIGPIPE, SIG_IGN);

   // create table
   lua_createtable(L, 0, ARRAY_LENGTH(xpio_regs)-1);

   // bind XPIO table to each function in a C closure, so they can
   // access the appropriate metatables for sockets, etc.
   xlua_register(L, -1, xpio_regs, -1);

   // create metatables

   XLUA_NEWMT(L, XPProc);
   lua_setfield(L, -2, "_XPProc");

   XLUA_NEWMT(L, XPQueue);
   lua_setfield(L, -2, "_XPQueue");

   XLUA_NEWMT(L, XPSocket);

   // make `socket:try_accept` a closure; it creates a socket
   lua_pushvalue(L, -2);
   lua_pushcclosure(L, xpsocket_try_accept, 1);
   lua_setfield(L, -2, "try_accept");

   lua_setfield(L, -2, "_XPSocket");

   // extract environment variables

   xpio_getenv(L);
   lua_setfield(L, -2, "env");

   return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x3240
pushq $0x8
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x649a
leaq 0x1c2a7(%rip), %rsi     # 0x1f830
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x36e0
leaq 0x1c325(%rip), %r14     # 0x1f8c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3755
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x36e0
leaq 0x11a6e(%rip), %rdx     # 0x15028
pushq $-0x2
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x661d
leaq 0x1c342(%rip), %r14     # 0x1f910
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3755
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x36e0
leaq 0x11a43(%rip), %rdx     # 0x15030
movq %rbx, %rdi
movl %ebp, %esi
callq 0x661d
leaq 0x1c352(%rip), %r14     # 0x1f950
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3755
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x36e0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5b84
leaq 0x186(%rip), %rsi       # 0x37ad
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x623a
leaq 0x11a00(%rip), %rdx     # 0x15039
movq %rbx, %rdi
movl %ebp, %esi
callq 0x661d
leaq 0x119fa(%rip), %rdx     # 0x15044
movq %rbx, %rdi
movl %ebp, %esi
callq 0x661d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x649a
movq 0x1c971(%rip), %rax     # 0x1ffd8
movq (%rax), %r13
pushq $0x3d
popq %rbp
pushq $-0x3
popq %r14
movq (%r13), %r15
testq %r15, %r15
je 0x36bc
movq %r15, %rdi
movl %ebp, %esi
callq 0x3160
testq %rax, %rax
je 0x36b6
movq %rax, %r12
movq %rax, %rdx
subq %r15, %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x60a7
incq %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x60f6
movq %rbx, %rdi
movl %r14d, %esi
callq 0x6683
addq $0x8, %r13
jmp 0x3671
leaq 0x1198b(%rip), %rdx     # 0x1504e
pushq $-0x2
popq %rsi
movq %rbx, %rdi
callq 0x661d
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq