// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x50(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x15661
movq -0x40(%rbp), %rax
movl 0x4b4(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x15820
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x1568d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x15814
jmp 0x1568f
movq -0x40(%rbp), %rcx
addq $0x58, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x48(%rbp), %rcx
addq $0x30, %rcx
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
addq $0x30, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x40(%rbp), %rax
movl 0x68(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x68(%rax)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x4b0(%rcx), %eax
jge 0x1576b
movq -0x48(%rbp), %rdi
movl -0x4c(%rbp), %esi
movl -0x1c(%rbp), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
movq -0x28(%rbp), %rcx
callq 0x15960
cmpl $0x0, %eax
je 0x15752
jmp 0x1571c
movb $0x0, %al
callq 0x242d0
cmpl $0x4, (%rax)
jl 0x1574e
movl $0x4, %edi
leaq 0x210fc(%rip), %rsi     # 0x36830
leaq 0x21107(%rip), %rdx     # 0x36842
movl $0x3a6, %ecx            # imm = 0x3A6
leaq 0x2110d(%rip), %r8      # 0x36854
movb $0x0, %al
callq 0x243b0
jmp 0x15750
jmp 0x1575b
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1575d
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x156e6
cmpl $0x0, -0x50(%rbp)
jne 0x1580d
jmp 0x15777
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x157a9
movl $0x3, %edi
leaq 0x210a1(%rip), %rsi     # 0x36830
leaq 0x210ac(%rip), %rdx     # 0x36842
movl $0x3ae, %ecx            # imm = 0x3AE
leaq 0x210c5(%rip), %r8      # 0x36867
movb $0x0, %al
callq 0x243b0
jmp 0x157ab
jmp 0x157ad
jmp 0x157af
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x40(%rbp), %rax
movl 0x68(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x68(%rax)
movq -0x48(%rbp), %rdi
callq 0x15bd0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x15814
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)