// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/socket.c
// Function: lso_checkopts
static struct so_options lso_checkopts(lua_State *L, int index) {
	struct so_options opts = *so_opts();

	/* TODO: Support explicit interface name via .if_name/.name */
	if (lso_altfield(L, index, "bind", "sa_bind")) {
		static const int regindex;
		struct sockaddr *sa;
		const char *addr = NULL;
		size_t plen;
		const char *path = NULL;
		int port = -1, error;

		if (lua_istable(L, -1)) {
			if (lso_altfield(L, -1, "path", "sun_path") || lso_rawgeti(L, -1, 1)) {
				path = luaL_checklstring(L, -1, &plen);
				lua_pop(L, 1);
			} else {
				if (lso_altfield(L, -1, "addr", "address", "sin_addr", "sin6_addr") || lso_rawgeti(L, -1, 1)) {
					addr = luaL_checkstring(L, -1);
					lua_pop(L, 1);
				}

				if (lso_altfield(L, -1, "port", "sin_port", "sin6_port") || lso_rawgeti(L, -1, 2)) {
					port = luaL_checkint(L, -1);
					lua_pop(L, 1);
				}
			}
		} else {
			addr = luaL_checkstring(L, -1);
		}

		luaL_argcheck(L, path != NULL || addr != NULL, index, "no bind address specified");

		if (path) {
			sa = lso_singleton(L, CQS_UNIQUE_LIGHTUSERDATA_MASK(&regindex), NULL, sizeof(struct sockaddr_un));
			sa->sa_family = AF_UNIX;
			memcpy(((struct sockaddr_un*)sa)->sun_path, path, MIN(plen, sizeof(((struct sockaddr_un*)sa)->sun_path)));
		} else {
			sa = lso_singleton(L, CQS_UNIQUE_LIGHTUSERDATA_MASK(&regindex), NULL, sizeof(struct sockaddr_storage));
			if (!sa_pton(sa, sizeof(struct sockaddr_storage), addr, NULL, &error))
				luaL_argerror(L, index, lua_pushfstring(L, "%s: unable to parse bind address (%s)", addr, cqs_strerror(error)));

			if (port >= 0)
				*sa_port(sa, &(unsigned short){ 0 }, NULL) = htons((unsigned short)port);
		}

		opts.sa_bind = sa;

		lua_pop(L, 1);
	}

	if (lso_altfield(L, index, "mode", "sun_mode")) {
		opts.sun_mode = S_IFSOCK | lso_checkperm(L, -1);
		lua_pop(L, 1);
	}

	if (lso_altfield(L, index, "mask", "sun_mask")) {
		opts.sun_mask = S_IFSOCK | lso_checkperm(L, -1);
		lua_pop(L, 1);
	}

	if (lso_altfield(L, index, "unlink", "sun_unlink"))
		opts.sun_unlink = lso_popbool(L);

	if (lso_altfield(L, index, "reuseaddr", "sin_reuseaddr"))
		opts.sin_reuseaddr = lso_popbool(L);

	if (lso_altfield(L, index, "reuseport", "sin_reuseport"))
		opts.sin_reuseport = lso_popbool(L);

	if (lso_altfield(L, index, "broadcast", "sin_broadcast"))
		opts.sin_broadcast = lso_popbool(L);

	if (lso_altfield(L, index, "nodelay", "sin_nodelay"))
		opts.sin_nodelay = lso_popbool(L);

	if (lso_altfield(L, index, "nopush", "sin_nopush"))
		opts.sin_nopush = lso_popbool(L);

	if (lso_altfield(L, index, "v6only", "sin_v6only"))
		opts.sin_v6only = (lso_popbool(L))? SO_V6ONLY_ENABLE : SO_V6ONLY_DISABLE;

	if (lso_altfield(L, index, "oobinline", "sin_oobinline"))
		opts.sin_oobinline = lso_popbool(L);

	if (lso_altfield(L, index, "nonblock", "fd_nonblock"))
		opts.fd_nonblock = lso_popbool(L);

	if (lso_altfield(L, index, "cloexec", "fd_cloexec"))
		opts.fd_cloexec = lso_popbool(L);

	if (lso_altfield(L, index, "nosigpipe", "fd_nosigpipe"))
		opts.fd_nosigpipe = lso_popbool(L);

	if (lso_altfield(L, index, "verify", "tls_verify"))
		opts.tls_verify = lso_popbool(L);

	if (lso_altfield(L, index, "sendname", "tls_sendname")) {
		if (lua_isboolean(L, -1)) {
			opts.tls_sendname = (lua_toboolean(L, -1))? SO_OPTS_TLS_HOSTNAME : NULL;
		} else {
			opts.tls_sendname = luaL_checkstring(L, -1);
		}

		lua_pop(L, 1);
	}

	if (lso_altfield(L, index, "time", "st_time"))
		opts.st_time = lso_popbool(L);

	return opts;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0xd0(%rbp)
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
xorl %esi, %esi
movl $0x50, %edx
callq 0xf7d0
movq -0xd0(%rbp), %rdi
movb $0x1, 0x11(%rdi)
movb $0x1, 0x1c(%rdi)
movb $0x1, 0x1d(%rdi)
movb $0x1, 0x1e(%rdi)
movl $0x1, %eax
movq %rax, 0x40(%rdi)
movb $0x1, 0x48(%rdi)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x2e43b(%rip), %rdx     # 0x4d5ac
leaq 0x29809(%rip), %rcx     # 0x48981
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f18d
jmp 0x1f527
movq $0x0, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xf280
cmpl $0x5, %eax
jne 0x1f305
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x297c2(%rip), %rdx     # 0x4898d
leaq 0x297b7(%rip), %rcx     # 0x48989
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f1fb
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x1fae0
testb $0x1, %al
jne 0x1f1fb
jmp 0x1f224
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rdx
callq 0xf6a0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
jmp 0x1f303
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x29774(%rip), %rdx     # 0x489a8
leaq 0x29757(%rip), %rcx     # 0x48992
leaq 0x29758(%rip), %r8      # 0x4899a
leaq 0x2975a(%rip), %r9      # 0x489a3
xorl %eax, %eax
movq $0x0, (%rsp)
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f277
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x1fae0
testb $0x1, %al
jne 0x1f277
jmp 0x1f29b
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0xf6a0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x29710(%rip), %rdx     # 0x489bb
leaq 0x296fb(%rip), %rcx     # 0x489ad
leaq 0x296fd(%rip), %r8      # 0x489b6
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f2e2
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x2, %edx
callq 0x1fae0
testb $0x1, %al
jne 0x1f2e2
jmp 0x1f301
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x10c70
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
jmp 0x1f303
jmp 0x1f31b
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0xf6a0
movq %rax, -0x20(%rbp)
movb $0x1, %al
cmpq $0x0, -0x30(%rbp)
movb %al, -0xd9(%rbp)
jne 0x1f358
movb $0x1, %al
cmpq $0x0, -0x20(%rbp)
movb %al, -0xd9(%rbp)
jne 0x1f358
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29679(%rip), %rdx     # 0x489c0
callq 0xf440
cmpl $0x0, %eax
setne %al
movb %al, -0xd9(%rbp)
movb -0xd9(%rbp), %al
cmpq $0x0, -0x30(%rbp)
je 0x1f3ea
movq -0x8(%rbp), %rdi
leaq 0x29398(%rip), %rsi     # 0x4870c
xorl %eax, %eax
movl %eax, %edx
movl $0x6e, %ecx
callq 0x19030
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movw $0x1, (%rax)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movq %rax, -0xf0(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x6c, -0x28(%rbp)
jae 0x1f3bd
movq -0x28(%rbp), %rax
movq %rax, -0xf8(%rbp)
jmp 0x1f3cb
movl $0x6c, %eax
movq %rax, -0xf8(%rbp)
jmp 0x1f3cb
movq -0xe8(%rbp), %rsi
movq -0xf0(%rbp), %rdi
movq -0xf8(%rbp), %rdx
callq 0xfb40
jmp 0x1f50b
movq -0x8(%rbp), %rdi
leaq 0x29317(%rip), %rsi     # 0x4870c
xorl %eax, %eax
movl %eax, %edx
movl $0x80, %ecx
callq 0x19030
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x80, %esi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x38(%rbp), %r8
callq 0x103d0
cmpq $0x0, %rax
jne 0x1f4bc
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xfc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x11c(%rbp)
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0xf7d0
movl -0x11c(%rbp), %edi
leaq -0xb8(%rbp), %rsi
movl $0x80, %edx
callq 0xf270
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rdx
movq %rax, %rcx
leaq 0x2953a(%rip), %rsi     # 0x489da
movb $0x0, %al
callq 0x10130
movq -0x108(%rbp), %rdi
movl -0xfc(%rbp), %esi
movq %rax, %rdx
callq 0xf440
cmpl $0x0, -0x34(%rbp)
jl 0x1f509
movl -0x34(%rbp), %eax
movzwl %ax, %edi
callq 0xf0e0
movw %ax, -0x11e(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movw $0x0, -0xc2(%rbp)
movq -0xc0(%rbp), %rdi
leaq -0xc2(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x1fb40
movw -0x11e(%rbp), %cx
movw %cx, (%rax)
jmp 0x1f50b
movq -0xd0(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x2937b(%rip), %rdx     # 0x488b0
leaq 0x294c4(%rip), %rcx     # 0x48a00
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f54e
jmp 0x1f57c
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1fbd0
movl %eax, %ecx
movq -0xd0(%rbp), %rax
orl $0xc000, %ecx           # imm = 0xC000
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29483(%rip), %rdx     # 0x48a0d
leaq 0x29478(%rip), %rcx     # 0x48a09
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f5a3
jmp 0x1f5d1
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1fbd0
movl %eax, %ecx
movq -0xd0(%rbp), %rax
orl $0xc000, %ecx           # imm = 0xC000
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29437(%rip), %rdx     # 0x48a16
leaq 0x2942c(%rip), %rcx     # 0x48a12
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f5f8
jmp 0x1f610
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x10(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29403(%rip), %rdx     # 0x48a21
leaq 0x293f8(%rip), %rcx     # 0x48a1d
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f637
jmp 0x1f64f
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x11(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x293d2(%rip), %rdx     # 0x48a2f
leaq 0x293c7(%rip), %rcx     # 0x48a2b
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f676
jmp 0x1f68e
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x12(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x293a1(%rip), %rdx     # 0x48a3d
leaq 0x29396(%rip), %rcx     # 0x48a39
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f6b5
jmp 0x1f6cd
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x13(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29370(%rip), %rdx     # 0x48a4b
leaq 0x29365(%rip), %rcx     # 0x48a47
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f6f4
jmp 0x1f70c
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x14(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x2933d(%rip), %rdx     # 0x48a57
leaq 0x29332(%rip), %rcx     # 0x48a53
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f733
jmp 0x1f74b
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x15(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29309(%rip), %rdx     # 0x48a62
leaq 0x292fe(%rip), %rcx     # 0x48a5e
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f772
jmp 0x1f799
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %sil
movq -0xd0(%rbp), %rax
movl $0x2, %ecx
movl $0x1, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x292c6(%rip), %rdx     # 0x48a6d
leaq 0x292bb(%rip), %rcx     # 0x48a69
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f7c0
jmp 0x1f7d8
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x16(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29294(%rip), %rdx     # 0x48a7a
leaq 0x2928a(%rip), %rcx     # 0x48a77
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f7ff
jmp 0x1f817
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x1c(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29261(%rip), %rdx     # 0x48a86
leaq 0x29257(%rip), %rcx     # 0x48a83
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f83e
jmp 0x1f856
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x1d(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x2922d(%rip), %rdx     # 0x48a91
leaq 0x29223(%rip), %rcx     # 0x48a8e
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f87d
jmp 0x1f895
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x1e(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x291fc(%rip), %rdx     # 0x48a9f
leaq 0x291f1(%rip), %rcx     # 0x48a9b
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f8bc
jmp 0x1f8d4
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x38(%rax)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x291c8(%rip), %rdx     # 0x48aaa
leaq 0x291bd(%rip), %rcx     # 0x48aa6
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f8fb
jmp 0x1f967
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xf280
cmpl $0x1, %eax
jne 0x1f939
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xf590
movl %eax, %esi
movq -0xd0(%rbp), %rax
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovneq %rdx, %rcx
movq %rcx, 0x40(%rax)
jmp 0x1f959
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0xf6a0
movq %rax, %rcx
movq -0xd0(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x107f0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
leaq 0x29141(%rip), %rdx     # 0x48ab6
leaq 0x29137(%rip), %rcx     # 0x48ab3
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x1f9c0
testb $0x1, %al
jne 0x1f98e
jmp 0x1f9a6
movq -0x8(%rbp), %rdi
callq 0x1fd00
movb %al, %cl
movq -0xd0(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x48(%rax)
movq -0xd8(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)