// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
movq %rdi, %rbx
movl $0x1, %esi
movl $0xd, %edi
callq 0x3240
movq %rbx, %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x68d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5c5f
movl %eax, %ebp
leaq 0x1c1cd(%rip), %r15     # 0x1f838
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5f7e
movq -0x8(%r15), %r14
movq (%r15), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x666d
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x6a5a
cmpq $0x0, 0x10(%r15)
leaq 0x10(%r15), %r15
jne 0x366b
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x68d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5f7e
leaq 0x1c1fc(%rip), %r14     # 0x1f8c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x670b
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x6ac0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5f7e
leaq 0x13aaf(%rip), %rdx     # 0x1719f
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5c5f
movl %eax, %ebp
leaq 0xf93(%rip), %r15       # 0x46a6
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x666d
movq (%r14), %rdx
movq 0x18(%r14), %r15
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6a5a
addq $0x10, %r14
testq %r15, %r15
jne 0x3713
leaq 0x138e7(%rip), %rdx     # 0x17028
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x68d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5f7e
leaq 0x1c1a2(%rip), %r14     # 0x1f910
movq %rbx, %rdi
movq %r14, %rsi
callq 0x670b
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x6ac0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5f7e
leaq 0x13a05(%rip), %rdx     # 0x1719f
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5c5f
movl %eax, %ebp
leaq 0x12ec(%rip), %r15      # 0x4aa9
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x666d
movq (%r14), %rdx
movq 0x18(%r14), %r15
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6a5a
addq $0x10, %r14
testq %r15, %r15
jne 0x37bd
leaq 0x13845(%rip), %rdx     # 0x17030
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x68d0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5f7e
leaq 0x1c138(%rip), %r14     # 0x1f950
movq %rbx, %rdi
movq %r14, %rsi
callq 0x670b
movq %rbx, %rdi
movl $0xfff0b9d8, %esi       # imm = 0xFFF0B9D8
callq 0x6ac0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5f7e
leaq 0x1395b(%rip), %rdx     # 0x1719f
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5c5f
movl %eax, %ebp
leaq 0x19fc(%rip), %r15      # 0x5263
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x666d
movq (%r14), %rdx
movq 0x18(%r14), %r15
movq %rbx, %rdi
movl %ebp, %esi
callq 0x6a5a
addq $0x10, %r14
testq %r15, %r15
jne 0x3867
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5f7e
leaq 0xc8(%rip), %rsi        # 0x396a
movq %rbx, %rdi
movl $0x1, %edx
callq 0x666d
leaq 0x13783(%rip), %rdx     # 0x17039
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
leaq 0x1377a(%rip), %rdx     # 0x17044
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x68d0
movq 0x1c6ee(%rip), %rax     # 0x1ffd8
movq (%rax), %r12
movq (%r12), %r14
testq %r14, %r14
je 0x3948
addq $0x8, %r12
movq %r14, %rdi
movl $0x3d, %esi
callq 0x3160
testq %rax, %rax
je 0x393b
movq %rax, %r15
movq %rax, %rdx
subq %r14, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x64d7
incq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6526
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x6ac0
movq (%r12), %r14
addq $0x8, %r12
testq %r14, %r14
jne 0x38fa
leaq 0x136ff(%rip), %rdx     # 0x1704e
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6a5a
movl $0x1, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq