// File: /workspace/github_c_makefile_star2_O2/GangZhuo[P]dohclient/src/channel_tcp.c
// Function: channel_tcp_query
int channel_tcp_query(channel_t* ctx,
	const ns_msg_t* msg,
	int use_proxy, subnet_t* subnet,
	channel_query_cb callback, void* state)
{
	channel_tcp_t* c = (channel_tcp_t*)ctx;
	tcpreq_t* req;
	int i, n = 0;

	if (use_proxy == -1) use_proxy = c->use_proxy;

	req = req_new(c, msg, callback, state);
	if (!req)
		return -1;

	dllist_add(&c->reqs, &req->entry);
	c->req_count++;

	for (i = 0; i < c->upstream_num; i++) {
		if (tcp_query(req, i, use_proxy ? 0 : -1, subnet)) {
			logw("tcp_query() error\n");
		}
		else {
			n++;
		}
	}

	if (n == 0) {
		loge("no invalid upstream\n");
		dllist_init_remove(&req->entry);
		c->req_count--;
		req_destroy(req);
		return -1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r15
movq %r8, %r12
movq %rcx, 0x20(%rsp)
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
movl %edx, 0xc(%rsp)
cmpl $-0x1, %edx
jne 0xdf79
movq 0x10(%rsp), %rax
movl 0x4b4(%rax), %eax
movl %eax, 0xc(%rsp)
pushq $0x1
popq %rdi
pushq $0x60
popq %rsi
callq 0x3250
testq %rax, %rax
je 0xe55c
movq %rax, %r14
movl (%r13), %eax
movl %eax, (%r14)
leaq 0x8(%r14), %rax
movq %rax, 0x60(%rsp)
movq 0x10(%r13), %rax
movups (%rax), %xmm0
movups %xmm0, 0x8(%r14)
movq (%rax), %rdi
callq 0x3620
movq %rax, 0x8(%r14)
movq %r12, 0x20(%r14)
movq %r15, 0x28(%r14)
movq 0x10(%rsp), %rbx
movq %rbx, 0x40(%r14)
leaq 0x48(%r14), %rax
movq %rax, 0x48(%r14)
movq %rax, 0x50(%rsp)
movq %rax, 0x50(%r14)
xorl %edi, %edi
callq 0x3320
movslq 0x4b8(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0x18(%r14)
leaq 0x58(%rbx), %rax
movq %r14, %rcx
addq $0x30, %rcx
movq %rax, 0x30(%r14)
movq 0x60(%rbx), %rax
movq %r14, 0x18(%rsp)
movq %rax, 0x38(%r14)
movq %rcx, (%rax)
movq %rcx, 0x48(%rsp)
movq %rcx, 0x60(%rbx)
incl 0x68(%rbx)
movq 0x20(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x58(%rsp)
pushq $0x70
popq %rbx
leaq 0x1321a(%rip), %rbp     # 0x2124c
xorl %r12d, %r12d
movl $0x0, 0x8(%rsp)
movq 0x10(%rsp), %rax
movslq 0x4b0(%rax), %rax
cmpq %rax, %r12
jge 0xe4ee
movq %rbp, %r15
movq %rbx, %rbp
movq 0x18(%rsp), %rbx
movq 0x40(%rbx), %r14
orl $-0x1, 0x28(%rsp)
movl $0x98, %esi
pushq $0x1
popq %rdi
callq 0x3250
testq %rax, %rax
je 0xe10a
movq %rax, %r13
movq %rbx, 0x88(%rax)
movl %r12d, 0x90(%rax)
cmpl $0x0, 0xc(%rsp)
je 0xe0b5
cmpl $0x0, 0x18(%r14)
jle 0xe0b5
movl $0x1, 0x68(%r13)
movq 0x10(%r14), %rdi
addq $0x8, %rdi
leaq 0x28(%rsp), %rsi
movq %rbp, %rbx
jmp 0xe0c1
movq %rbp, %rbx
leaq (%r14,%rbp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x179ae
movl %eax, %ebp
leal -0x3(%rbp), %eax
cmpl $-0x3, %eax
ja 0xe13c
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
leaq 0x1316b(%rip), %rbp     # 0x2124c
jl 0xe18a
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x1321d(%rip), %rdx     # 0x21311
pushq $0x53
popq %rcx
leaq 0x1321f(%rip), %r8      # 0x2131d
xorl %eax, %eax
callq 0x1662e
jmp 0xe18a
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
movq %rbp, %rbx
movq %r15, %rbp
jl 0xe192
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x131e8(%rip), %rdx     # 0x21311
pushq $0x41
popq %rcx
leaq 0x13780(%rip), %r8      # 0x218b3
xorl %eax, %eax
callq 0x1662e
jmp 0xe192
movl 0x28(%rsp), %esi
movq %r13, %rdi
callq 0x17f7d
testl %eax, %eax
je 0xe1f9
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
leaq 0x130eb(%rip), %rbp     # 0x2124c
jl 0xe181
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x131a1(%rip), %rdx     # 0x21311
pushq $0x59
popq %rcx
leaq 0x131b8(%rip), %r8      # 0x21332
xorl %eax, %eax
callq 0x1662e
movl 0x28(%rsp), %edi
callq 0x3680
movq %r13, %rdi
callq 0x3460
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe1be
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x130bb(%rip), %rdx     # 0x21266
movl $0x16e, %ecx            # imm = 0x16E
leaq 0x130f4(%rip), %r8      # 0x212ab
xorl %eax, %eax
callq 0x1662e
xorl %eax, %eax
callq 0x165f5
cmpl $0x4, (%rax)
jl 0xe1ea
pushq $0x4
popq %rdi
movq %rbp, %rsi
leaq 0x13087(%rip), %rdx     # 0x2125e
movl $0x3a6, %ecx            # imm = 0x3A6
leaq 0x1308d(%rip), %r8      # 0x21270
xorl %eax, %eax
callq 0x1662e
incq %r12
addq $0x88, %rbx
jmp 0xe03d
movl %ebp, 0x38(%r13)
leaq 0x28(%rsp), %rdi
callq 0x18296
movq 0x18(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x28(%rsp)
movw $0x1, 0x2c(%rsp)
movq 0x60(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x182e8
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x20(%rsp)
leaq 0x13014(%rip), %rbp     # 0x2124c
je 0xe2b2
leaq 0x28(%rsp), %r15
movq %r15, %rdi
pushq $0x29
popq %rsi
callq 0x19ad8
testq %rax, %rax
jne 0xe260
movq %r15, %rdi
callq 0x19bdc
testq %rax, %rax
je 0xe41f
movw $0x400, 0xa(%rax)       # imm = 0x400
movq 0x20(%rsp), %rcx
movl 0x90(%rcx), %edx
movq %rax, %rdi
movq 0x58(%rsp), %rsi
xorl %ecx, %ecx
callq 0x1a257
testl %eax, %eax
je 0xe2b2
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe44b
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x130a4(%rip), %rdx     # 0x21345
movl $0x140, %ecx            # imm = 0x140
leaq 0x12baa(%rip), %r8      # 0x20e57
jmp 0xe444
andq $0x0, 0x28(%r13)
leaq 0x20(%r13), %r15
cmpl $0x3ff, 0x30(%r13)      # imm = 0x3FF
jg 0xe304
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x1b9d4
testl %eax, %eax
je 0xe304
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe44b
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x13052(%rip), %rdx     # 0x21345
movl $0x14a, %ecx            # imm = 0x14A
leaq 0x12426(%rip), %r8      # 0x20725
jmp 0xe444
movq %r15, %rdi
xorl %esi, %esi
pushq $0x2
popq %rdx
callq 0x1bbcd
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x1a2cd
testl %eax, %eax
jle 0xe3ad
movl %eax, %ebp
leaq 0x28(%rsp), %rdi
callq 0x188ce
andl $0x0, 0x2c(%r13)
movq %r15, %rdi
xorl %esi, %esi
movl %ebp, %edx
pushq $0x2
popq %rcx
callq 0x1bcd8
movq %r13, %rax
addq $0x40, %rax
movq 0x50(%rsp), %rcx
movq %rcx, 0x40(%r13)
movq 0x18(%rsp), %rdx
movq 0x50(%rdx), %rcx
movq %rcx, 0x48(%r13)
movq %rax, (%rcx)
movq %rax, 0x50(%rdx)
movl 0x38(%r13), %ecx
movl 0x68(%r13), %eax
movl %ecx, %edx
xorl $0x2, %edx
orl %eax, %edx
jne 0xe3ea
movl (%r13), %edi
movq %r15, %rsi
callq 0x17be2
cmpl $-0x1, %eax
leaq 0x12eb9(%rip), %rbp     # 0x2124c
je 0xe48e
movl 0x28(%r13), %eax
cmpl 0x2c(%r13), %eax
jne 0xe416
movq %r15, %rdi
callq 0x1b8a6
jmp 0xe416
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
leaq 0x12e8e(%rip), %rbp     # 0x2124c
jl 0xe3e0
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x12f78(%rip), %rdx     # 0x21345
movl $0x154, %ecx            # imm = 0x154
leaq 0x12393(%rip), %r8      # 0x2076c
xorl %eax, %eax
callq 0x1662e
movq %r15, %rdi
callq 0x1b8a6
jmp 0xe44b
cmpl $0x2, %ecx
sete %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
leaq 0x12e4c(%rip), %rbp     # 0x2124c
jne 0xe416
movq %r14, %rdi
movq %r13, %rsi
callq 0xf1d4
cmpl $-0x1, %eax
je 0xe4b5
incl 0x8(%rsp)
jmp 0xe1ea
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe44b
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x12f0d(%rip), %rdx     # 0x21345
movl $0x137, %ecx            # imm = 0x137
leaq 0x129ee(%rip), %r8      # 0x20e32
xorl %eax, %eax
callq 0x1662e
leaq 0x28(%rsp), %rdi
callq 0x188ce
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe481
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x12df8(%rip), %rdx     # 0x21266
movl $0x176, %ecx            # imm = 0x176
leaq 0x12e49(%rip), %r8      # 0x212c3
xorl %eax, %eax
callq 0x1662e
movq %r13, %rdi
callq 0xf1b9
jmp 0xe1be
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe4e1
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x12dbf(%rip), %rdx     # 0x21266
movl $0x181, %ecx            # imm = 0x181
leaq 0x12e33(%rip), %r8      # 0x212e6
jmp 0xe4da
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe4e1
pushq $0x3
popq %rdi
movq %rbp, %rsi
leaq 0x12d98(%rip), %rdx     # 0x21266
movl $0x18c, %ecx            # imm = 0x18C
leaq 0x12e1e(%rip), %r8      # 0x212f8
xorl %eax, %eax
callq 0x1662e
movq %r15, %rdi
callq 0x1b8a6
jmp 0xe1be
xorl %ebp, %ebp
cmpl $0x0, 0x8(%rsp)
jne 0xe58f
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe52b
leaq 0x12d3e(%rip), %rsi     # 0x2124c
leaq 0x12d49(%rip), %rdx     # 0x2125e
leaq 0x12d67(%rip), %r8      # 0x21283
pushq $0x3
popq %rdi
movl $0x3ae, %ecx            # imm = 0x3AE
xorl %eax, %eax
callq 0x1662e
movq 0x18(%rsp), %rdi
movq 0x30(%rdi), %rax
movq 0x38(%rdi), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movq 0x48(%rsp), %rax
movups %xmm0, (%rax)
movq 0x10(%rsp), %rax
decl 0x68(%rax)
callq 0xe5a0
pushq $-0x1
popq %rbp
jmp 0xe58f
xorl %eax, %eax
callq 0x165f5
pushq $-0x1
popq %rbp
cmpl $0x3, (%rax)
jl 0xe58f
leaq 0x12cda(%rip), %rsi     # 0x2124c
leaq 0x1272e(%rip), %rdx     # 0x20ca7
leaq 0x13333(%rip), %r8      # 0x218b3
pushq $0x3
popq %rdi
movl $0x8b, %ecx
xorl %eax, %eax
callq 0x1662e
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq