// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movaps %xmm0, 0x70(%rax)
movaps %xmm0, 0x60(%rax)
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x40(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movl 0x10(%rdx), %r9d
leal 0x3f(%r9), %edx
testl %r9d, %r9d
cmovnsl %r9d, %edx
movl %edx, %r8d
andl $-0x40, %r8d
movl %r9d, %ecx
subl %r8d, %ecx
movl $0x1, %r8d
shlq %cl, %r8
sarl $0x6, %edx
movslq %edx, %rcx
orq %r8, 0x30(%rsp,%rcx,8)
movq %rsi, %r14
movl $0x1, %esi
movl 0x10(%r14), %edx
leal 0x3f(%rdx), %r8d
testl %edx, %edx
cmovnsl %edx, %r8d
movl %r8d, %r10d
andl $-0x40, %r10d
movl %edx, %ecx
subl %r10d, %ecx
shlq %cl, %rsi
sarl $0x6, %r8d
movslq %r8d, %rcx
orq %rsi, 0x30(%rsp,%rcx,8)
movq %rdi, %r15
leaq 0x10(%rsp), %r8
movq $0x0, 0x8(%r8)
movq $0x1e, (%r8)
cmpl %edx, %r9d
cmovgl %r9d, %edx
incl %edx
xorl %r12d, %r12d
movl %edx, %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4390
testl %eax, %eax
je 0xeebe
cmpl $-0x1, %eax
jne 0xeef7
addq $0x88, %rbx
callq 0x4050
movl (%rax), %edi
callq 0x4130
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
movq %rax, %rsi
callq 0x41e0
movl 0x10(%r14), %edi
callq 0x4760
movl $0x0, 0x10(%r14)
xorl %r12d, %r12d
jmp 0xef8b
movups 0x4933(%rip), %xmm0     # 0x137f8
movups %xmm0, 0x98(%rbx)
movups 0x4915(%rip), %xmm0     # 0x137e8
movups %xmm0, 0x88(%rbx)
movb $0x0, 0xa8(%rbx)
movl 0x10(%r14), %edi
callq 0x4760
movl $0x0, 0x10(%r14)
jmp 0xef8b
movl 0x10(%r14), %edi
leal 0x3f(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
sarl $0x6, %eax
cltq
movq 0x30(%rsp,%rax,8), %rax
btq %rdi, %rax
jae 0xef4f
leaq 0xc(%rsp), %rdx
movl $0x10, (%rdx)
leaq 0x20(%rsp), %rsi
callq 0x4120
movl %eax, %ebp
callq 0x4050
movl (%rax), %r15d
movl 0x10(%r14), %edi
callq 0x4760
testl %ebp, %ebp
jle 0xef9e
movl %ebp, 0x10(%r14)
movq %rbx, 0x30(%r14)
movl $0x1, %r12d
jmp 0xef8b
movl 0x10(%rbx), %eax
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
movq 0x30(%rsp,%rcx,8), %rcx
xorl %r12d, %r12d
btq %rax, %rcx
jae 0xef8b
callq 0x4760
movl $0x0, 0x10(%r14)
movq %r15, %rdi
movl $0x32, %esi
movq %rbx, %rdx
callq 0xe73c
movl %r12d, %eax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addq $0x88, %rbx
movl %r15d, %edi
callq 0x4130
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
movq %rax, %rsi
callq 0x41e0
jmp 0xeeae