// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x8(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2cdca
movl -0x4(%rbp), %edi
movl $0x1, %esi
movb $0x0, %al
callq 0xf830
movl %eax, %ecx
movl %ecx, -0x14(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
je 0x2cdca
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2cdc8
movl -0xc(%rbp), %eax
orl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x2cdca
movl -0x8(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2ce0a
movl -0x4(%rbp), %edi
movl $0x3, %esi
movb $0x0, %al
callq 0xf830
movl %eax, %ecx
movl %ecx, -0x10(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
je 0x2ce0a
movl -0x10(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x2ce08
movl -0xc(%rbp), %eax
orl $0x2, %eax
movl %eax, -0xc(%rbp)
jmp 0x2ce0a
movl -0x8(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x2ce36
movl -0x4(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
callq 0x2cf50
testb $0x1, %al
jne 0x2ce2d
jmp 0x2ce36
movl -0xc(%rbp), %eax
orl $0x4, %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x2ce62
movl -0x4(%rbp), %edi
movl $0x1, %esi
movl $0xf, %edx
callq 0x2cf50
testb $0x1, %al
jne 0x2ce59
jmp 0x2ce62
movl -0xc(%rbp), %eax
orl $0x8, %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x2ce8e
movl -0x4(%rbp), %edi
movl $0x1, %esi
movl $0x6, %edx
callq 0x2cf50
testb $0x1, %al
jne 0x2ce85
jmp 0x2ce8e
movl -0xc(%rbp), %eax
orl $0x10, %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x2ceba
movl -0x4(%rbp), %edi
movl $0x6, %esi
movl $0x1, %edx
callq 0x2cf50
testb $0x1, %al
jne 0x2ceb1
jmp 0x2ceba
movl -0xc(%rbp), %eax
orl $0x20, %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x2cee6
movl -0x4(%rbp), %edi
movl $0x6, %esi
movl $0x3, %edx
callq 0x2cf50
testb $0x1, %al
jne 0x2cedd
jmp 0x2cee6
movl -0xc(%rbp), %eax
orl $0x40, %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x2cf16
movl -0x4(%rbp), %edi
movl $0x29, %esi
movl $0x1a, %edx
callq 0x2cf50
testb $0x1, %al
jne 0x2cf0b
jmp 0x2cf16
movl -0xc(%rbp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x2cf46
movl -0x4(%rbp), %edi
movl $0x1, %esi
movl $0xa, %edx
callq 0x2cf50
testb $0x1, %al
jne 0x2cf3b
jmp 0x2cf46
movl -0xc(%rbp), %eax
orl $0x200, %eax            # imm = 0x200
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop