// File: /workspace/github_c_makefile_star2_O2/wahern[P]cqueues/src/lib/socket.c
// Function: so_getfl
int so_getfl(int fd, int which) {
	int flags = 0, getfl = 0, getfd;

	if ((which & SO_F_CLOEXEC) && -1 != (getfd = fcntl(fd, F_GETFD))) {
		if (getfd & FD_CLOEXEC)
			flags |= SO_F_CLOEXEC;
	}

	if ((which & SO_F_NONBLOCK) && -1 != (getfl = fcntl(fd, F_GETFL))) {
		if (getfl & O_NONBLOCK)
			flags |= SO_F_NONBLOCK;
	}

	if ((which & SO_F_REUSEADDR) && so_getboolopt(fd, SOL_SOCKET, SO_REUSEADDR))
		flags |= SO_F_REUSEADDR;

#if defined SO_REUSEPORT
	if ((which & SO_F_REUSEPORT) && so_getboolopt(fd, SOL_SOCKET, SO_REUSEPORT))
		flags |= SO_F_REUSEPORT;
#endif

	if ((which & SO_F_BROADCAST) && so_getboolopt(fd, SOL_SOCKET, SO_BROADCAST))
		flags |= SO_F_BROADCAST;

	if ((which & SO_F_NODELAY) && so_getboolopt(fd, IPPROTO_TCP, TCP_NODELAY))
		flags |= SO_F_NODELAY;

#if defined TCP_NOPUSH
	if ((which & SO_F_NOPUSH) && so_getboolopt(fd, IPPROTO_TCP, TCP_NOPUSH))
		flags |= SO_F_NOPUSH;
#endif

#if defined O_NOSIGPIPE || defined F_GETNOSIGPIPE || defined SO_NOSIGPIPE
	if ((which & SO_F_NOSIGPIPE)) {
#if defined O_NOSIGPIPE
		if (getfl) {
			if (getfl != -1 && (getfl & O_NOSIGPIPE))
				flags |= SO_F_NOSIGPIPE;
		} else if (-1 != (getfl = fcntl(fd, F_GETFL))) {
			if (getfl & O_NOSIGPIPE)
				flags |= SO_F_NOSIGPIPE;
		}
#elif defined F_GETNOSIGPIPE
		int nosigpipe;

		if (-1 != (nosigpipe = fcntl(fd, F_GETNOSIGPIPE))) {
			if (nosigpipe)
				flags |= SO_F_NOSIGPIPE;
		}
#else
		if (so_getboolopt(fd, SOL_SOCKET, SO_NOSIGPIPE))
			flags |= SO_F_NOSIGPIPE;
#endif
	}
#endif

	if ((which & SO_F_V6ONLY) && so_getboolopt(fd, IPPROTO_IPV6, IPV6_V6ONLY))
		flags |= SO_F_V6ONLY;

	if ((which & SO_F_OOBINLINE) && so_getboolopt(fd, SOL_SOCKET, SO_OOBINLINE))
		flags |= SO_F_OOBINLINE;

	return flags;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %ebx
xorl %r14d, %r14d
testb $0x1, %bpl
je 0x20aa4
pushq $0x1
popq %rsi
movl %ebx, %edi
xorl %eax, %eax
callq 0xf7f0
cmpl $-0x1, %eax
setne %cl
andb %cl, %al
movzbl %al, %r14d
testb $0x2, %bpl
je 0x20acc
pushq $0x3
popq %rsi
movl %ebx, %edi
xorl %eax, %eax
callq 0xf7f0
leal 0x2(%r14), %ecx
btl $0xb, %eax
cmovael %r14d, %ecx
cmpl $-0x1, %eax
cmovel %r14d, %ecx
movl %ecx, %r14d
testb $0x4, %bpl
je 0x20aec
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
movl %ebx, %edi
callq 0x20bba
leal 0x4(%r14), %ecx
testb %al, %al
cmovel %r14d, %ecx
movl %ecx, %r14d
testb $0x8, %bpl
je 0x20b0c
pushq $0x1
popq %rsi
pushq $0xf
popq %rdx
movl %ebx, %edi
callq 0x20bba
leal 0x8(%r14), %ecx
testb %al, %al
cmovel %r14d, %ecx
movl %ecx, %r14d
testb $0x10, %bpl
je 0x20b2c
pushq $0x1
popq %rsi
pushq $0x6
popq %rdx
movl %ebx, %edi
callq 0x20bba
leal 0x10(%r14), %ecx
testb %al, %al
cmovel %r14d, %ecx
movl %ecx, %r14d
testb $0x20, %bpl
je 0x20b4c
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
movl %ebx, %edi
callq 0x20bba
leal 0x20(%r14), %ecx
testb %al, %al
cmovel %r14d, %ecx
movl %ecx, %r14d
testb $0x40, %bpl
je 0x20b6c
pushq $0x6
popq %rsi
pushq $0x3
popq %rdx
movl %ebx, %edi
callq 0x20bba
leal 0x40(%r14), %ecx
testb %al, %al
cmovel %r14d, %ecx
movl %ecx, %r14d
btl $0x8, %ebp
jae 0x20b8f
pushq $0x29
popq %rsi
pushq $0x1a
popq %rdx
movl %ebx, %edi
callq 0x20bba
leal 0x100(%r14), %ecx
testb %al, %al
cmovel %r14d, %ecx
movl %ecx, %r14d
btl $0x9, %ebp
jae 0x20bb2
pushq $0x1
popq %rsi
pushq $0xa
popq %rdx
movl %ebx, %edi
callq 0x20bba
leal 0x200(%r14), %ecx
testb %al, %al
cmovel %r14d, %ecx
movl %ecx, %r14d
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq