// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq 0x2783a(%rip), %rax     # 0x48570
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xf280
cmpl $0x5, %eax
jne 0x20db2
movq -0x10(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
movl $0x1, %edx
callq 0x1f110
leaq -0x70(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x50, %edx
callq 0xfb40
movq -0x10(%rbp), %rdi
movl $0x1, %esi
leaq 0x2c5a7(%rip), %rdx     # 0x4d32e
callq 0xf200
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0xf450
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
jmp 0x20e29
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0xf7d0
movb $0x1, -0x10f(%rbp)
movl $0x0, -0x108(%rbp)
movb $0x1, -0x104(%rbp)
movb $0x1, -0x103(%rbp)
movb $0x1, -0x102(%rbp)
movl $0x1, %eax
movq %rax, -0xe0(%rbp)
movb $0x1, -0xd8(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x120(%rbp), %rsi
movl $0x50, %edx
callq 0xfb40
movq -0x10(%rbp), %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xf450
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x18700
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x18700
movq %rax, -0x20(%rbp)
movl -0x7c(%rbp), %esi
orl $0x80000, %esi          # imm = 0x80000
leaq -0x78(%rbp), %rcx
movl $0x1, %edi
xorl %edx, %edx
callq 0xfc40
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x20e6f
jmp 0x20f18
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x861e(%rip), %rax     # 0x18860
movq %rax, -0x40(%rbp)
movl -0x78(%rbp), %edi
leaq -0x70(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0xf330
movq -0x18(%rbp), %rcx
movq %rax, 0x128(%rcx)
cmpq $0x0, %rax
jne 0x20ea5
jmp 0x20f22
movl $0xffffffff, -0x78(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rdi
callq 0x18840
movl %eax, -0x80(%rbp)
cmpl $0x0, %eax
je 0x20ebf
jmp 0x20f22
movq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x866e(%rip), %rax     # 0x18860
movq %rax, -0x40(%rbp)
movl -0x74(%rbp), %edi
leaq -0x70(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0xf330
movq -0x20(%rbp), %rcx
movq %rax, 0x128(%rcx)
cmpq $0x0, %rax
jne 0x20ef5
jmp 0x20f22
movl $0xffffffff, -0x74(%rbp) # imm = 0xFFFFFFFF
movq -0x20(%rbp), %rdi
callq 0x18840
movl %eax, -0x80(%rbp)
cmpl $0x0, %eax
je 0x20f0f
jmp 0x20f22
movl $0x2, -0x4(%rbp)
jmp 0x20f5e
callq 0xf0a0
movl (%rax), %eax
movl %eax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x194f0
leaq -0x78(%rbp), %rdi
addq $0x4, %rdi
callq 0x194f0
movq -0x10(%rbp), %rdi
callq 0xfa10
movq -0x10(%rbp), %rdi
callq 0xfa10
movq -0x10(%rbp), %rdi
movslq -0x80(%rbp), %rsi
callq 0xf9a0
movl $0x3, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)