// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
movl %edx, 0xc(%rsp)
cmpl $-0x1, %edx
jne 0xeafa
movl 0x4b4(%rbx), %eax
movl %eax, 0xc(%rsp)
movl $0x60, %edi
callq 0x34b0
testq %rax, %rax
je 0xeb86
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movzwl (%r13), %eax
movw %ax, (%r14)
movzwl 0x2(%r13), %eax
movw %ax, 0x2(%r14)
movq 0x10(%r13), %rax
movups (%rax), %xmm0
movups %xmm0, 0x8(%r14)
movq (%rax), %rdi
callq 0x3610
movq %rax, 0x8(%r14)
movq %r12, 0x20(%r14)
movq %r15, 0x28(%r14)
movq %rbx, 0x40(%r14)
movq %r14, %rax
addq $0x48, %rax
movq %rax, 0x48(%r14)
movq %rax, 0x50(%r14)
xorl %edi, %edi
callq 0x3310
movslq 0x4b8(%rbx), %rcx
addq %rax, %rcx
movq %rcx, 0x18(%r14)
movq %r14, %r15
jmp 0xebbe
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xebbe
leaq 0x146a0(%rip), %rsi     # 0x2323c
leaq 0x140fc(%rip), %rdx     # 0x22c9f
leaq 0x14cf9(%rip), %r8      # 0x238a3
xorl %r15d, %r15d
movl $0x3, %edi
movl $0x8b, %ecx
xorl %eax, %eax
callq 0x17d92
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r15, %r15
je 0xf1e7
leaq 0x58(%rbx), %rax
leaq 0x30(%r15), %r14
movq %rax, 0x30(%r15)
movq 0x60(%rbx), %rax
movq %rax, 0x38(%r15)
movq %r14, (%rax)
movq %r14, 0x60(%rbx)
incl 0x68(%rbx)
cmpl $0x0, 0x4b0(%rbx)
jle 0xf18b
movq %r14, 0x40(%rsp)
leaq 0x8(%r15), %rax
movq %rax, 0x60(%rsp)
movq 0x18(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x58(%rsp)
leaq 0x48(%r15), %rax
movq %rax, 0x48(%rsp)
movl $0x70, %r12d
xorl %r14d, %r14d
movl $0x0, 0x8(%rsp)
movq %r15, (%rsp)
movq %rbx, 0x10(%rsp)
movq 0x40(%r15), %r13
movl $0xffffffff, 0x20(%rsp) # imm = 0xFFFFFFFF
movl $0x98, %edi
callq 0x34b0
testq %rax, %rax
je 0xecea
movq %rax, %rbp
movl $0x98, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x31e0
movq %r15, 0x88(%rbp)
movl %r14d, 0x90(%rbp)
cmpl $0x0, 0xc(%rsp)
je 0xec95
cmpl $0x0, 0x18(%r13)
jle 0xec95
movq $0x1, 0x68(%rbp)
movq 0x10(%r13), %rdi
addq $0x8, %rdi
jmp 0xec99
leaq (%r12,%r13), %rdi
leaq 0x20(%rsp), %rsi
callq 0x191a7
movl %eax, %r15d
leal -0x3(%r15), %eax
cmpl $-0x3, %eax
ja 0xed20
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xed6f
movl $0x3, %edi
leaq 0x14571(%rip), %rsi     # 0x2323c
leaq 0x1462f(%rip), %rdx     # 0x23301
movl $0x53, %ecx
leaq 0x1462f(%rip), %r8      # 0x2330d
xorl %eax, %eax
callq 0x17d92
jmp 0xed6f
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xed1c
movl $0x3, %edi
leaq 0x1453a(%rip), %rsi     # 0x2323c
leaq 0x145f8(%rip), %rdx     # 0x23301
movl $0x41, %ecx
leaq 0x14b8e(%rip), %r8      # 0x238a3
xorl %eax, %eax
callq 0x17d92
xorl %ebp, %ebp
jmp 0xed7d
movl 0x20(%rsp), %esi
movq %rbp, %rdi
callq 0x197c8
testl %eax, %eax
je 0xefa7
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xed66
movl $0x3, %edi
leaq 0x144f0(%rip), %rsi     # 0x2323c
leaq 0x145ae(%rip), %rdx     # 0x23301
movl $0x59, %ecx
leaq 0x145c3(%rip), %r8      # 0x23322
xorl %eax, %eax
callq 0x17d92
movl 0x20(%rsp), %edi
callq 0x3670
movq %rbp, %rdi
callq 0x3450
xorl %ebp, %ebp
movq (%rsp), %r15
testq %rbp, %rbp
je 0xee60
leaq 0x20(%rsp), %rdi
callq 0x19b12
movzwl (%r15), %eax
movw %ax, 0x20(%rsp)
movzwl 0x2(%r15), %eax
movw %ax, 0x22(%rsp)
movw $0x1, 0x24(%rsp)
movq 0x60(%rsp), %rdi
movl $0x1, %esi
callq 0x19b6a
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0xee9b
movq %r12, %r15
movq %rbx, %r12
movq %r13, %rbx
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movl $0x29, %esi
callq 0x1b531
testq %rax, %rax
jne 0xedfb
movq %r13, %rdi
callq 0x1b653
testq %rax, %rax
je 0xf02e
movw $0x400, 0xa(%rax)       # imm = 0x400
movq 0x18(%rsp), %rcx
movl 0x90(%rcx), %edx
movq %rax, %rdi
movq 0x58(%rsp), %rsi
xorl %ecx, %ecx
callq 0x1bd22
testl %eax, %eax
movq %rbx, %r13
movq %r12, %rbx
movq %r15, %r12
movq (%rsp), %r15
je 0xee9b
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf06a
movl $0x3, %edi
leaq 0x143f4(%rip), %rsi     # 0x2323c
leaq 0x144e6(%rip), %rdx     # 0x23335
movl $0x140, %ecx            # imm = 0x140
leaq 0x13ff4(%rip), %r8      # 0x22e4f
jmp 0xf063
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf0bf
movl $0x3, %edi
leaq 0x143c0(%rip), %rsi     # 0x2323c
leaq 0x143d3(%rip), %rdx     # 0x23256
movl $0x16e, %ecx            # imm = 0x16E
leaq 0x1440c(%rip), %r8      # 0x2329b
xorl %eax, %eax
callq 0x17d92
jmp 0xf0bf
leaq 0x20(%rbp), %r15
movq $0x0, 0x28(%rbp)
cmpl $0x3ff, 0x30(%rbp)      # imm = 0x3FF
jg 0xeef9
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x1d737
testl %eax, %eax
je 0xeef9
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
movq (%rsp), %r15
jl 0xf06a
movl $0x3, %edi
leaq 0x1435b(%rip), %rsi     # 0x2323c
leaq 0x1444d(%rip), %rdx     # 0x23335
movl $0x14a, %ecx            # imm = 0x14A
leaq 0x13851(%rip), %r8      # 0x22745
jmp 0xf063
movq %r13, 0x50(%rsp)
movq %r15, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x1d916
movq %r15, %rdi
leaq 0x20(%rsp), %r13
movq %r13, %rsi
xorl %edx, %edx
callq 0x1bdbb
testl %eax, %eax
jle 0xefb0
movl %eax, %ebx
movq %r13, %rdi
callq 0x1a1dd
movl $0x0, 0x2c(%rbp)
movq %r15, %rdi
xorl %esi, %esi
movl %ebx, %edx
movl $0x2, %ecx
callq 0x1da17
leaq 0x40(%rbp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, 0x40(%rbp)
movq (%rsp), %rdx
movq 0x50(%rdx), %rcx
movq %rcx, 0x48(%rbp)
movq %rax, (%rcx)
movq %rax, 0x50(%rdx)
movl 0x38(%rbp), %ecx
movl 0x68(%rbp), %eax
movl %ecx, %edx
xorl $0x2, %edx
orl %eax, %edx
jne 0xeff5
movl (%rbp), %edi
movq %r15, %rsi
callq 0x19402
cmpl $-0x1, %eax
movq 0x10(%rsp), %rbx
je 0xf10d
movl 0x28(%rbp), %eax
cmpl 0x2c(%rbp), %eax
jne 0xf021
movq %r15, %rdi
callq 0x1d5f9
jmp 0xf021
movl %r15d, 0x38(%rbp)
jmp 0xed79
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xefe2
movl $0x3, %edi
leaq 0x14274(%rip), %rsi     # 0x2323c
leaq 0x14366(%rip), %rdx     # 0x23335
movl $0x154, %ecx            # imm = 0x154
leaq 0x137b1(%rip), %r8      # 0x2278c
xorl %eax, %eax
callq 0x17d92
movq %r15, %rdi
callq 0x1d5f9
movq 0x10(%rsp), %rbx
movq (%rsp), %r15
jmp 0xf06a
cmpl $0x2, %ecx
sete %cl
testl %eax, %eax
setne %al
andb %cl, %al
cmpb $0x1, %al
movq 0x10(%rsp), %rbx
jne 0xf021
movq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0xfef6
cmpl $-0x1, %eax
je 0xf13a
incl 0x8(%rsp)
movq (%rsp), %r15
jmp 0xf0f1
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
movq %r12, %rbx
movq %r15, %r12
movq (%rsp), %r15
jl 0xf06a
movl $0x3, %edi
leaq 0x141ec(%rip), %rsi     # 0x2323c
leaq 0x142de(%rip), %rdx     # 0x23335
movl $0x137, %ecx            # imm = 0x137
leaq 0x13dc7(%rip), %r8      # 0x22e2a
xorl %eax, %eax
callq 0x17d92
leaq 0x20(%rsp), %rdi
callq 0x1a1dd
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf0a6
movl $0x3, %edi
leaq 0x141b0(%rip), %rsi     # 0x2323c
leaq 0x141c3(%rip), %rdx     # 0x23256
movl $0x176, %ecx            # imm = 0x176
leaq 0x14214(%rip), %r8      # 0x232b3
xorl %eax, %eax
callq 0x17d92
movq %rbp, %rdi
callq 0x19891
leaq 0x70(%rbp), %rdi
callq 0x1d5f9
movq %rbp, %rdi
callq 0x3450
xorl %eax, %eax
callq 0x17d59
cmpl $0x4, (%rax)
jl 0xf0f1
movl $0x4, %edi
leaq 0x14165(%rip), %rsi     # 0x2323c
leaq 0x14170(%rip), %rdx     # 0x2324e
movl $0x3a6, %ecx            # imm = 0x3A6
leaq 0x14176(%rip), %r8      # 0x23260
xorl %eax, %eax
callq 0x17d92
incq %r14
movslq 0x4b0(%rbx), %rax
addq $0x88, %r12
cmpq %rax, %r14
jl 0xec36
jmp 0xf17d
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf16c
movl $0x3, %edi
leaq 0x14117(%rip), %rsi     # 0x2323c
leaq 0x1412a(%rip), %rdx     # 0x23256
movl $0x181, %ecx            # imm = 0x181
leaq 0x1419e(%rip), %r8      # 0x232d6
jmp 0xf165
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf16c
movl $0x3, %edi
leaq 0x140ea(%rip), %rsi     # 0x2323c
leaq 0x140fd(%rip), %rdx     # 0x23256
movl $0x18c, %ecx            # imm = 0x18C
leaq 0x14183(%rip), %r8      # 0x232e8
xorl %eax, %eax
callq 0x17d92
movq %r15, %rdi
callq 0x1d5f9
movq (%rsp), %r15
jmp 0xf0bf
xorl %eax, %eax
cmpl $0x0, 0x8(%rsp)
movq 0x40(%rsp), %r14
jne 0xf1e7
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf1bd
leaq 0x1409e(%rip), %rsi     # 0x2323c
leaq 0x140a9(%rip), %rdx     # 0x2324e
leaq 0x140c7(%rip), %r8      # 0x23273
movl $0x3, %edi
movl $0x3ae, %ecx            # imm = 0x3AE
xorl %eax, %eax
callq 0x17d92
movq 0x30(%r15), %rax
movq 0x38(%r15), %rcx
movq %rax, (%rcx)
movq 0x30(%r15), %rax
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
decl 0x68(%rbx)
movq %r15, %rdi
callq 0xf1f6
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq