// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movl %edi, %ebx
xorl %r14d, %r14d
testb $0x1, %bpl
je 0x2362b
movl %ebx, %edi
movl $0x1, %esi
xorl %eax, %eax
callq 0xf7b0
cmpl $-0x1, %eax
setne %cl
andb %cl, %al
movzbl %al, %r14d
testb $0x2, %bpl
je 0x23655
movl %ebx, %edi
movl $0x3, %esi
xorl %eax, %eax
callq 0xf7b0
leal 0x2(%r14), %ecx
btl $0xb, %eax
cmovael %r14d, %ecx
cmpl $-0x1, %eax
cmovel %r14d, %ecx
movl %ecx, %r14d
testb $0x4, %bpl
je 0x23693
movq %rsp, %r8
movl $0x4, (%r8)
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movl $0x1, %esi
movl $0x2, %edx
movq %r15, %rcx
callq 0xf9a0
leal 0x4(%r14), %ecx
cmpl $0x0, (%r15)
cmovel %r14d, %ecx
testl %eax, %eax
cmovnel %r14d, %ecx
movl %ecx, %r14d
testb $0x8, %bpl
je 0x236d1
movq %rsp, %r8
movl $0x4, (%r8)
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movl $0x1, %esi
movl $0xf, %edx
movq %r15, %rcx
callq 0xf9a0
leal 0x8(%r14), %ecx
cmpl $0x0, (%r15)
cmovel %r14d, %ecx
testl %eax, %eax
cmovnel %r14d, %ecx
movl %ecx, %r14d
testb $0x10, %bpl
je 0x2370f
movq %rsp, %r8
movl $0x4, (%r8)
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movl $0x1, %esi
movl $0x6, %edx
movq %r15, %rcx
callq 0xf9a0
leal 0x10(%r14), %ecx
cmpl $0x0, (%r15)
cmovel %r14d, %ecx
testl %eax, %eax
cmovnel %r14d, %ecx
movl %ecx, %r14d
testb $0x20, %bpl
je 0x2374d
movq %rsp, %r8
movl $0x4, (%r8)
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movl $0x6, %esi
movl $0x1, %edx
movq %r15, %rcx
callq 0xf9a0
leal 0x20(%r14), %ecx
cmpl $0x0, (%r15)
cmovel %r14d, %ecx
testl %eax, %eax
cmovnel %r14d, %ecx
movl %ecx, %r14d
testb $0x40, %bpl
je 0x2378b
movq %rsp, %r8
movl $0x4, (%r8)
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movl $0x6, %esi
movl $0x3, %edx
movq %r15, %rcx
callq 0xf9a0
leal 0x40(%r14), %ecx
cmpl $0x0, (%r15)
cmovel %r14d, %ecx
testl %eax, %eax
cmovnel %r14d, %ecx
movl %ecx, %r14d
btl $0x8, %ebp
jae 0x237cc
movq %rsp, %r8
movl $0x4, (%r8)
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movl $0x29, %esi
movl $0x1a, %edx
movq %r15, %rcx
callq 0xf9a0
leal 0x100(%r14), %ecx
cmpl $0x0, (%r15)
cmovel %r14d, %ecx
testl %eax, %eax
cmovnel %r14d, %ecx
movl %ecx, %r14d
btl $0x9, %ebp
jae 0x2380d
movq %rsp, %r8
movl $0x4, (%r8)
leaq 0x4(%rsp), %r15
movl %ebx, %edi
movl $0x1, %esi
movl $0xa, %edx
movq %r15, %rcx
callq 0xf9a0
leal 0x200(%r14), %ecx
cmpl $0x0, (%r15)
cmovel %r14d, %ecx
testl %eax, %eax
cmovnel %r14d, %ecx
movl %ecx, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq