// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_chndoh.c
// Function: create_upstream_chctx
static int create_upstream_chctx(doh_server_t* doh, channel_chndoh_t* c)
{
	if (doh->channel == CH_UDP) {
		char args[2048];
		int n;
		n = snprintf(args, sizeof(args),
			"upstream=%s&proxy=%d&timeout=%d",
			doh->addrstr,
			doh->use_proxy,
			doh->timeout);
		if (n <= 0 || n >= sizeof(args))
			return -1;
		doh->query = channel_udp_query;
		return channel_udp_create(&doh->chctx,
			"udp", args,
			c->conf,
			c->proxies,
			c->proxy_num,
			c->chnr,
			c->blacklist,
			doh);
	}
	else if (doh->channel == CH_TCP) {
		char args[2048];
		int n;
		n = snprintf(args, sizeof(args),
			"upstream=%s&proxy=%d&timeout=%d",
			doh->addrstr,
			doh->use_proxy,
			doh->timeout);
		if (n <= 0 || n >= sizeof(args))
			return -1;
		doh->query = channel_tcp_query;
		return channel_tcp_create(&doh->chctx,
			"tcp", args,
			c->conf,
			c->proxies,
			c->proxy_num,
			c->chnr,
			c->blacklist,
			doh);
	}
	else if (doh->channel == CH_DOH) {
		doh->http = http_create(
			c->proxies,
			c->proxy_num,
			doh->keep_alive);
		if (!doh->http)
			return -1;
		return 0;
	}
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1050, %rsp           # imm = 0x1050
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, 0x5b0(%rax)
jne 0xf81b
leaq -0x820(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x458(%rax), %rcx
movq -0x10(%rbp), %rax
movl 0x474(%rax), %r8d
movq -0x10(%rbp), %rax
movl 0x47c(%rax), %r9d
movl $0x800, %esi            # imm = 0x800
leaq 0x26e6b(%rip), %rdx     # 0x365e3
movb $0x0, %al
callq 0x35a0
movl %eax, -0x824(%rbp)
cmpl $0x0, -0x824(%rbp)
jle 0xf79d
movslq -0x824(%rbp), %rax
cmpq $0x800, %rax            # imm = 0x800
jb 0xf7a9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf964
movq -0x10(%rbp), %rax
leaq 0x948c(%rip), %rcx      # 0x18c40
movq %rcx, 0x5c0(%rax)
movq -0x10(%rbp), %rdi
addq $0x5b8, %rdi            # imm = 0x5B8
leaq -0x820(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %r8
movq -0x18(%rbp), %rax
movl 0x18(%rax), %r9d
movq -0x18(%rbp), %rax
movq 0x20(%rax), %r11
movq -0x18(%rbp), %rax
movq 0x28(%rax), %r10
movq -0x10(%rbp), %rax
leaq 0x263dd(%rip), %rsi     # 0x35bdd
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x19290
movl %eax, -0x4(%rbp)
jmp 0xf964
movq -0x10(%rbp), %rax
cmpl $0x3, 0x5b0(%rax)
jne 0xf900
leaq -0x1030(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x458(%rax), %rcx
movq -0x10(%rbp), %rax
movl 0x474(%rax), %r8d
movq -0x10(%rbp), %rax
movl 0x47c(%rax), %r9d
movl $0x800, %esi            # imm = 0x800
leaq 0x26d83(%rip), %rdx     # 0x365e3
movb $0x0, %al
callq 0x35a0
movl %eax, -0x1034(%rbp)
cmpl $0x0, -0x1034(%rbp)
jle 0xf885
movslq -0x1034(%rbp), %rax
cmpq $0x800, %rax            # imm = 0x800
jb 0xf891
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf964
movq -0x10(%rbp), %rax
leaq 0x5d84(%rip), %rcx      # 0x15620
movq %rcx, 0x5c0(%rax)
movq -0x10(%rbp), %rdi
addq $0x5b8, %rdi            # imm = 0x5B8
leaq -0x1030(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %r8
movq -0x18(%rbp), %rax
movl 0x18(%rax), %r9d
movq -0x18(%rbp), %rax
movq 0x20(%rax), %r11
movq -0x18(%rbp), %rax
movq 0x28(%rax), %r10
movq -0x10(%rbp), %rax
leaq 0x262f9(%rip), %rsi     # 0x35be1
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x15cc0
movl %eax, -0x4(%rbp)
jmp 0xf964
movq -0x10(%rbp), %rax
cmpl $0x1, 0x5b0(%rax)
jne 0xf959
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x18(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x470(%rax), %edx
callq 0x1fc30
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x5b8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x5b8(%rax)
jne 0xf950
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xf964
movl $0x0, -0x4(%rbp)
jmp 0xf964
jmp 0xf95b
jmp 0xf95d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x1050, %rsp           # imm = 0x1050
popq %rbp
retq