// File: /workspace/github_cpp_makefile_star2_O2/lianxings[P]ftp_benchmark/ftplib.cc
// Function: ftplib::FtpAcceptConnection(ftphandle*, ftphandle*)
int ftplib::FtpAcceptConnection(ftphandle *nData, ftphandle *nControl)
{
	int sData;
	struct sockaddr addr;
	socklen_t l;
	int i;
	struct timeval tv;
	fd_set mask;
	int rv = 0;

	FD_ZERO(&mask);
	FD_SET(nControl->handle, &mask);
	FD_SET(nData->handle, &mask);
	tv.tv_usec = 0;
	tv.tv_sec = ACCEPT_TIMEOUT;
	i = nControl->handle;
	if (i < nData->handle) 
        i = nData->handle;
	i = select(i+1, &mask, NULL, NULL, &tv);

	if (i == -1) 	{
		strncpy(nControl->response, strerror(errno), sizeof(nControl->response));
		net_close(nData->handle);
		nData->handle = 0;
		rv = 0;
	} else if (i == 0) 	{
		strcpy(nControl->response, "timed out waiting for connection");
		net_close(nData->handle);
		nData->handle = 0;
		rv = 0;
	} else 	{
		if (FD_ISSET(nData->handle, &mask)) 	{
			l = sizeof(addr);
			sData = accept(nData->handle, &addr, &l);
			i = errno;
			net_close(nData->handle);
 			if (sData > 0) 	{
				rv = 1;
				nData->handle = sData;
				nData->ctrl = nControl;
			} else	{
				strncpy(nControl->response, strerror(i), sizeof(nControl->response));
				nData->handle = 0;
				rv = 0;
			}
		}
		else if (FD_ISSET(nControl->handle, &mask)) {
			net_close(nData->handle);
			nData->handle = 0;
			readresp('2', nControl);
			rv = 0;
		}
	}
    
	return rv;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb0, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
xorl %eax, %eax
cmpq $0x10, %rax
je 0xcbf3
andq $0x0, 0x30(%rsp,%rax,8)
incq %rax
jmp 0xcbe2
movl 0x10(%r14), %esi
pushq $0x40
popq %rbp
movl %esi, %eax
cltd
idivl %ebp
movslq %eax, %rdx
shll $0x6, %eax
movl %esi, %ecx
subl %eax, %ecx
pushq $0x1
popq %r8
movq %r8, %rax
shlq %cl, %rax
orq %rax, 0x30(%rsp,%rdx,8)
movl 0x10(%rbx), %edi
movl %edi, %eax
cltd
idivl %ebp
movslq %eax, %rdx
shll $0x6, %eax
movl %edi, %ecx
subl %eax, %ecx
shlq %cl, %r8
orq %r8, 0x30(%rsp,%rdx,8)
leaq 0x10(%rsp), %r8
andq $0x0, 0x8(%r8)
movq $0x1e, (%r8)
cmpl %edi, %esi
cmovgl %esi, %edi
incl %edi
xorl %r12d, %r12d
leaq 0x30(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4390
testl %eax, %eax
je 0xcc9b
cmpl $-0x1, %eax
jne 0xcccf
addq $0x88, %r14
callq 0x4040
movl (%rax), %edi
callq 0x4110
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
movq %rax, %rsi
callq 0x41e0
movl 0x10(%rbx), %edi
callq 0x4740
andl $0x0, 0x10(%rbx)
xorl %r12d, %r12d
jmp 0xcd4a
movups 0x4af6(%rip), %xmm0     # 0x11798
movups %xmm0, 0x98(%r14)
movups 0x4ad7(%rip), %xmm0     # 0x11788
movups %xmm0, 0x88(%r14)
movb $0x0, 0xa8(%r14)
movl 0x10(%rbx), %edi
callq 0x4740
andl $0x0, 0x10(%rbx)
jmp 0xcd4a
movl 0x10(%rbx), %edi
movl %edi, %eax
cltd
idivl %ebp
cltq
movq 0x30(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0xcd1c
leaq 0xc(%rsp), %rdx
movl $0x10, (%rdx)
leaq 0x20(%rsp), %rsi
callq 0x4100
movl %eax, %ebp
callq 0x4040
movl (%rax), %r15d
movl 0x10(%rbx), %edi
callq 0x4740
testl %ebp, %ebp
jle 0xcd5d
movl %ebp, 0x10(%rbx)
movq %r14, 0x30(%rbx)
pushq $0x1
popq %r12
jmp 0xcd4a
movl 0x10(%r14), %eax
cltd
idivl %ebp
cltq
movq 0x30(%rsp,%rax,8), %rax
xorl %r12d, %r12d
btq %rdx, %rax
jae 0xcd4a
callq 0x4740
andl $0x0, 0x10(%rbx)
pushq $0x32
popq %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0xc65c
movl %r12d, %eax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addq $0x88, %r14
movl %r15d, %edi
callq 0x4110
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
movq %rax, %rsi
callq 0x41e0
jmp 0xcc8f
nop