// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/main.c
// Function: peer_accept
static int peer_accept(int listen_index)
{
	listen_t* ctx = listens + listen_index;
	sock_t sock;
	sockaddr_t from = {
		.addr = {0},
		.addrlen = sizeof(struct sockaddr_storage),
	};
	peer_t* peer;

	sock = accept(ctx->sock, (struct sockaddr*) & from.addr, &from.addrlen);
	if (sock == -1) {
		loge("accept() error: errno=%d, %s \n",
			errno, strerror(errno));
		return -1;
	}
	logv("server  accept - %s\n", get_sockaddrname(&from));

	if (setnonblock(sock) != 0) {
		loge("set sock non-block failed\n");
		close(sock);
		return -1;
	}

	if (setnodelay(sock) != 0) {
		loge("set sock nodelay failed\n");
		close(sock);
		return -1;
	}

	peer = peer_new(sock, listen_index);
	if (!peer) {
		close(sock);
		return -1;
	}

	dllist_add(&peers, &peer->conn.entry);

	update_expire(&peer->conn);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %edi, -0x8(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x11337(%rip), %rax     # 0x42a90
imulq $0x90, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x88, %edx
callq 0x3200
movl $0x80, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x88(%rax), %edi
leaq -0xa0(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
addq $0x80, %rdx
callq 0x3120
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x31814
jmp 0x317b0
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x31806
callq 0x3040
movl (%rax), %eax
movl %eax, -0xac(%rbp)
callq 0x3040
movl (%rax), %edi
callq 0x3150
movl -0xac(%rbp), %r9d
movl $0x3, %edi
leaq 0x73da(%rip), %rsi      # 0x38bc2
leaq 0x818d(%rip), %rdx      # 0x3997c
movl $0x2ae, %ecx            # imm = 0x2AE
leaq 0x818d(%rip), %r8       # 0x39988
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x31808
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31994
jmp 0x31816
movb $0x0, %al
callq 0x242d0
cmpl $0x8, (%rax)
jl 0x31857
leaq -0xa0(%rbp), %rdi
callq 0x32020
movq %rax, %r9
movl $0x8, %edi
leaq 0x7385(%rip), %rsi      # 0x38bc2
leaq 0x8138(%rip), %rdx      # 0x3997c
movl $0x2b1, %ecx            # imm = 0x2B1
leaq 0x8157(%rip), %r8       # 0x399a7
movb $0x0, %al
callq 0x243b0
jmp 0x31859
movl -0x14(%rbp), %edi
callq 0x24d30
cmpl $0x0, %eax
je 0x318b0
jmp 0x31868
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x3189a
movl $0x3, %edi
leaq 0x7342(%rip), %rsi      # 0x38bc2
leaq 0x80f5(%rip), %rdx      # 0x3997c
movl $0x2b4, %ecx            # imm = 0x2B4
leaq 0x6632(%rip), %r8       # 0x37ec5
movb $0x0, %al
callq 0x243b0
jmp 0x3189c
movl -0x14(%rbp), %edi
callq 0x3680
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31994
movl -0x14(%rbp), %edi
callq 0x24ee0
cmpl $0x0, %eax
je 0x31907
jmp 0x318bf
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x318f1
movl $0x3, %edi
leaq 0x72eb(%rip), %rsi      # 0x38bc2
leaq 0x809e(%rip), %rdx      # 0x3997c
movl $0x2ba, %ecx            # imm = 0x2BA
leaq 0x80d2(%rip), %r8       # 0x399bc
movb $0x0, %al
callq 0x243b0
jmp 0x318f3
movl -0x14(%rbp), %edi
callq 0x3680
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31994
movl -0x14(%rbp), %edi
movl -0x8(%rbp), %esi
callq 0x26c60
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
jne 0x31934
movl -0x14(%rbp), %edi
callq 0x3680
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x31994
jmp 0x31936
movq -0xa8(%rbp), %rax
leaq 0x10284(%rip), %rcx     # 0x41bc8
movq %rcx, 0x40(%rax)
movq 0x10281(%rip), %rcx     # 0x41bd0
movq -0xa8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0xa8(%rbp), %rcx
addq $0x40, %rcx
movq 0x10264(%rip), %rax     # 0x41bd0
movq %rcx, (%rax)
movq -0xa8(%rbp), %rax
addq $0x40, %rax
movq %rax, 0x1024f(%rip)     # 0x41bd0
movq -0xa8(%rbp), %rdi
callq 0x32040
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq