// File: /workspace/github_c_makefile_star2_O1/wahern[P]cqueues/src/socket.c
// Function: lso_pair
static lso_nargs_t lso_pair(lua_State *L) {
	struct luasocket *a = NULL, *b = NULL;
	struct so_options opts;
	int fd[2] = { -1, -1 };
	int type, error;

	if (lua_istable(L, 1)) {
		opts = lso_checkopts(L, 1);

		lua_getfield(L, 1, "type");
		type = luaL_optinteger(L, -1, SOCK_STREAM);
		lua_pop(L, 1);
	} else {
		opts = *so_opts();
		type = luaL_optinteger(L, 1, SOCK_STREAM);
	}

	a = lso_newsocket(L, type);
	b = lso_newsocket(L, type);

#if defined SOCK_CLOEXEC
	if (0 != socketpair(AF_UNIX, type|SOCK_CLOEXEC, PF_UNSPEC, fd))
		goto syerr;
#else
	if (0 != socketpair(AF_UNIX, type, PF_UNSPEC, fd))
		goto syerr;
#endif

	opts.fd_close.arg = a;
	opts.fd_close.cb = &lso_closefd;

	if (!(a->socket = so_fdopen(fd[0], &opts, &error)))
		goto error;

	fd[0] = -1;

	if ((error = lso_prepsocket(a)))
		goto error;

	opts.fd_close.arg = b;
	opts.fd_close.cb = &lso_closefd;

	if (!(b->socket = so_fdopen(fd[1], &opts, &error)))
		goto error;

	fd[1] = -1;

	if ((error = lso_prepsocket(b)))
		goto error;

	return 2;
syerr:
	error = errno;
error:
	cqs_closefd(&fd[0]);
	cqs_closefd(&fd[1]);

	lua_pushnil(L);
	lua_pushnil(L);
	lua_pushinteger(L, error);

	return 3;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq $-0x1, 0x8(%rsp)
movl $0x1, %esi
callq 0xf260
cmpl $0x5, %eax
jne 0x1b14a
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x19dc5
leaq 0x1dcf5(%rip), %rdx     # 0x38e0e
movq %rbx, %rdi
movl $0x1, %esi
callq 0xf1e0
movl $0x1, %edx
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xf400
movq %rax, %r12
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x10640
jmp 0x1b1b0
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movw $0x100, 0x20(%rsp)      # imm = 0x100
xorl %eax, %eax
movl %eax, 0x22(%rsp)
movw $0x0, 0x26(%rsp)
movups %xmm0, 0x2f(%rsp)
movups %xmm0, 0x3f(%rsp)
movb $0x0, 0x4f(%rsp)
movl %eax, 0x59(%rsp)
movl %eax, 0x5c(%rsp)
movl %eax, 0x28(%rsp)
movw $0x101, 0x2c(%rsp)      # imm = 0x101
movb $0x1, %al
movb %al, 0x2e(%rsp)
movq $0x1, 0x50(%rsp)
movb %al, 0x58(%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movl $0x1, %esi
callq 0xf400
movq %rax, %r12
movq %rbx, %rdi
movl %r12d, %esi
callq 0x15e40
movq %rax, %r15
movq %rbx, %rdi
movl %r12d, %esi
callq 0x15e40
movq %rax, %r14
orl $0x80000, %r12d         # imm = 0x80000
leaq 0x8(%rsp), %rcx
movl $0x1, %edi
movl %r12d, %esi
xorl %edx, %edx
callq 0xfb60
testl %eax, %eax
je 0x1b250
callq 0xf0a0
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movl 0x8(%rsp), %edi
cmpl $-0x1, %edi
je 0x1b20c
callq 0x10a10
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movl 0xc(%rsp), %edi
cmpl $-0x1, %edi
je 0x1b222
callq 0x10a10
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0xf980
movq %rbx, %rdi
callq 0xf980
movslq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0xf910
movl $0x3, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x10(%rsp), %rsi
movq %r15, 0x28(%rsi)
leaq -0x5309(%rip), %r12     # 0x15f57
movq %r12, 0x30(%rsi)
movl 0x8(%rsp), %edi
leaq 0x4(%rsp), %rdx
callq 0xf2f0
movq %rax, 0x128(%r15)
testq %rax, %rax
je 0x1b1f6
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movq %r15, %rdi
callq 0x1636e
movl %eax, 0x4(%rsp)
testl %eax, %eax
jne 0x1b1f6
leaq 0x10(%rsp), %rsi
movq %r14, 0x28(%rsi)
movq %r12, 0x30(%rsi)
movl 0xc(%rsp), %edi
leaq 0x4(%rsp), %rdx
callq 0xf2f0
movq %rax, 0x128(%r14)
testq %rax, %rax
je 0x1b1f6
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movq %r14, %rdi
callq 0x1636e
movl %eax, 0x4(%rsp)
testl %eax, %eax
jne 0x1b1f6
movl $0x2, %eax
jmp 0x1b244