// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_tcp.c
// Function: req_fdset
static sock_t req_fdset(channel_t* ctx, tcpreq_t *req,
	fd_set* readset, fd_set* writeset, fd_set* errorset)
{
	channel_tcp_t* c = (channel_tcp_t*)ctx;
	dlitem_t* cur, * nxt;
	reqconn_t* conn;
	conn_status cs;
	int is_sending;
	sock_t maxfd = 0;
	dllist_foreach(&req->conns, cur, nxt, reqconn_t, conn, conn.entry) {
		cs = conn->conn.status;
		if (cs == cs_socks5_handshaked || cs == cs_hp_handshaked ||
				(!conn->use_proxy && cs == cs_connected)) {
			maxfd = MAX(maxfd, conn->conn.sock);
			is_sending = stream_rsize(&conn->conn.ws) > 0;
			if (is_sending)
				FD_SET(conn->conn.sock, writeset);
			else
				FD_SET(conn->conn.sock, readset);
			FD_SET(conn->conn.sock, errorset);
		}
		else if (cs == cs_socks5_waiting_method || cs == cs_socks5_waiting_connect ||
				cs == cs_hp_waiting_connect || cs == cs_hp_waiting_data) {
			maxfd = MAX(maxfd, conn->conn.sock);
			FD_SET(conn->conn.sock, readset);
			FD_SET(conn->conn.sock, errorset);
		}
		else if (cs == cs_socks5_sending_method || cs == cs_socks5_sending_connect ||
				cs == cs_hp_sending_connect) {
			maxfd = MAX(maxfd, conn->conn.sock);
			FD_SET(conn->conn.sock, writeset);
			FD_SET(conn->conn.sock, errorset);
		}
		else if (cs == cs_connecting) {
			maxfd = MAX(maxfd, conn->conn.sock);
			FD_SET(conn->conn.sock, writeset);
			FD_SET(conn->conn.sock, errorset);
		}
	}
	return maxfd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
xorl %eax, %eax
movq %rax, %rcx
addq $0x40, %rcx
subq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
addq $0x48, %rcx
cmpq %rcx, %rax
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x17c66
jmp 0x180b9
movq -0x48(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x9, -0x4c(%rbp)
je 0x17c94
cmpl $0xd, -0x4c(%rbp)
je 0x17c94
movq -0x48(%rbp), %rax
cmpl $0x0, 0x68(%rax)
jne 0x17dc0
cmpl $0x2, -0x4c(%rbp)
jne 0x17dc0
movl -0x54(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x17caa
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x58(%rbp)
jmp 0x17cb0
movl -0x54(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x48(%rbp), %rcx
subl 0x2c(%rcx), %eax
cmpl $0x0, %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x17d23
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x68(%rbp), %rdx
movl %eax, %ecx
movq -0x60(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x17d6c
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x78(%rbp), %rdx
movl %eax, %ecx
movq -0x70(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x88(%rbp), %rdx
movl %eax, %ecx
movq -0x80(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1808b
cmpl $0x6, -0x4c(%rbp)
je 0x17ddc
cmpl $0x8, -0x4c(%rbp)
je 0x17ddc
cmpl $0xb, -0x4c(%rbp)
je 0x17ddc
cmpl $0xc, -0x4c(%rbp)
jne 0x17eb6
movl -0x54(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x17df5
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8c(%rbp)
jmp 0x17dfe
movl -0x54(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xb0(%rbp), %rdx
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xa0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xa0(%rbp), %rdx
movl %eax, %ecx
movq -0x98(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x18089
cmpl $0x5, -0x4c(%rbp)
je 0x17ecc
cmpl $0x7, -0x4c(%rbp)
je 0x17ecc
cmpl $0xa, -0x4c(%rbp)
jne 0x17fa6
movl -0x54(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x17ee5
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xb4(%rbp)
jmp 0x17eee
movl -0x54(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xd8(%rbp), %rdx
movl %eax, %ecx
movq -0xd0(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xc8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xc8(%rbp), %rdx
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x18087
cmpl $0x1, -0x4c(%rbp)
jne 0x18085
movl -0x54(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x17fc9
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
jmp 0x17fd2
movl -0x54(%rbp), %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x100(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x100(%rbp), %rdx
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xf0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0xf0(%rbp), %rdx
movl %eax, %ecx
movq -0xe8(%rbp), %rax
movslq %ecx, %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x18087
jmp 0x18089
jmp 0x1808b
jmp 0x1808d
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
xorl %eax, %eax
movq %rax, %rcx
addq $0x40, %rcx
subq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x17c49
movl -0x54(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)