// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::accsock(bamboo::tcpsvr_tag*, char*)
static int accsock(tcpsvr_t *tcpsvr, char *msg)
	{
		struct sockaddr_in addr;
		socket_t sock;
		socklen_t len = sizeof(addr);
		int i, err;

		tracet(4, "accsock: sock=%d\n", tcpsvr->svr.sock);

		for (i = 0; i < MAXCLI; i++) if (tcpsvr->cli[i].state == 0) break;
		if (i >= MAXCLI) return 0; /* too many client */

		if ((sock = accept_nb(tcpsvr->svr.sock, (struct sockaddr *)&addr, &len)) == (socket_t)-1) {
			err = errsock();
			sprintf(msg, "accept error (%d)", err);
			tracet(1, "accsock: accept error sock=%d err=%d\n", tcpsvr->svr.sock, err);
			closesocket(tcpsvr->svr.sock);
			tcpsvr->svr.state = 0;
			return 0;
		}
		if (sock == 0) return 0;
		if (!setsock(sock, msg)) return 0;

		tcpsvr->cli[i].sock = sock;
		memcpy(&tcpsvr->cli[i].addr, &addr, sizeof(addr));
		strcpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr));
		sprintf(msg, "%s", tcpsvr->cli[i].saddr);
		tracet(3, "accsock: connected sock=%d addr=%s i=%d\n",
			tcpsvr->cli[i].sock, tcpsvr->cli[i].saddr, i);
		tcpsvr->cli[i].state = 2;
		tcpsvr->cli[i].tact = tickget();
		return 1;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x10, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x118(%rax), %edx
movl $0x4, %edi
leaq 0x24479(%rip), %rsi     # 0xc9446
movb $0x0, %al
callq 0x95890
movl $0x0, -0x34(%rbp)
cmpl $0x100, -0x34(%rbp)     # imm = 0x100
jge 0xa5010
movq -0x10(%rbp), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0x34(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0xa5003
jmp 0xa5010
jmp 0xa5005
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa4fdb
cmpl $0x100, -0x34(%rbp)     # imm = 0x100
jl 0xa5025
movl $0x0, -0x4(%rbp)
jmp 0xa5229
movq -0x10(%rbp), %rax
movl 0x118(%rax), %edi
leaq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xa5240
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
jne 0xa50a6
callq 0xa43f0
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movl -0x38(%rbp), %edx
leaq 0x243fe(%rip), %rsi     # 0xc9458
movb $0x0, %al
callq 0x9150
movq -0x10(%rbp), %rax
movl 0x118(%rax), %edx
movl -0x38(%rbp), %ecx
movl $0x1, %edi
leaq 0x243f0(%rip), %rsi     # 0xc946a
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rax
movl 0x118(%rax), %edi
callq 0x9e90
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa5229
cmpl $0x0, -0x2c(%rbp)
jne 0xa50b8
movl $0x0, -0x4(%rbp)
jmp 0xa5229
movl -0x2c(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0xa4400
cmpl $0x0, %eax
jne 0xa50d5
movl $0x0, -0x4(%rbp)
jmp 0xa5229
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0x34(%rbp), %rdx
imulq $0x128, %rdx, %rdx      # imm = 0x128
addq %rdx, %rax
movl %ecx, 0x118(%rax)
movq -0x10(%rbp), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0x34(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0x108(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x110(%rax)
movq -0x10(%rbp), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0x34(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %edi
callq 0x9300
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x96f0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x128, %rdx            # imm = 0x128
movslq -0x34(%rbp), %rax
imulq $0x128, %rax, %rax      # imm = 0x128
addq %rax, %rdx
addq $0x4, %rdx
leaq 0x23c61(%rip), %rsi     # 0xc8de7
movb $0x0, %al
callq 0x9150
movq -0x10(%rbp), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0x34(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
movl 0x118(%rax), %edx
movq -0x10(%rbp), %rcx
addq $0x128, %rcx            # imm = 0x128
movslq -0x34(%rbp), %rax
imulq $0x128, %rax, %rax      # imm = 0x128
addq %rax, %rcx
addq $0x4, %rcx
movl -0x34(%rbp), %r8d
movl $0x3, %edi
leaq 0x242b8(%rip), %rsi     # 0xc9490
movb $0x0, %al
callq 0x95890
movq -0x10(%rbp), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0x34(%rbp), %rcx
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
movl $0x2, (%rax)
callq 0x8f860
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq $0x128, %rax            # imm = 0x128
movslq -0x34(%rbp), %rdx
imulq $0x128, %rdx, %rdx      # imm = 0x128
addq %rdx, %rax
movl %ecx, 0x120(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)