// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/channel_doh.c
// Function: channel_doh_create
int channel_doh_create(
	channel_t** pctx,
	const char* name,
	const char* args,
	const config_t* conf,
	const proxy_t* proxies,
	const int proxy_num,
	const chnroute_ctx chnr,
	const chnroute_ctx blacklist,
	void* data)
{
	channel_doh_t* ctx;

	ctx = (channel_doh_t*)malloc(sizeof(channel_doh_t));
	if (!ctx) {
		loge("alloc\n");
		return CHANNEL_ALLOC;
	}

	memset(ctx, 0, sizeof(channel_doh_t));

	ctx->name = name;
	ctx->conf = conf;
	ctx->proxies = proxies;
	ctx->proxy_num = proxy_num;
	ctx->chnr = chnr;
	ctx->blacklist = blacklist;
	ctx->data = data;
	ctx->timeout = conf->timeout;

	if (parse_args(ctx, args)) {
		loge("parse_args() error\n");
		free(ctx);
		return CHANNEL_WRONG_ARG;
	}

	if (ctx->timeout <= 0) {
		loge("invalid \"timeout\"\n");
		free(ctx);
		return CHANNEL_WRONG_ARG;
	}

	if (ctx->keep_alive < 0) {
		loge("invalid \"keep-alive\"\n");
		free(ctx);
		return CHANNEL_WRONG_ARG;
	}

	/* Compatible with old configuration */
	if (ctx->keep_alive == 1)
		ctx->keep_alive = DEFAULT_HTTP_TIMEOUT;

	ctx->http = http_create(
		proxies,
		proxy_num,
		ctx->keep_alive);
	if (!ctx->http) {
		free(ctx);
		return CHANNEL_ALLOC;
	}

	rbtree_init(&ctx->reqdic, rbcmp);
	dllist_init(&ctx->reqs);

	ctx->fdset = fdset;
	ctx->step = step;
	ctx->query = query;
	ctx->destroy = destroy;

	*pctx = (channel_t*)ctx;

	return CHANNEL_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r9d, %ebp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r13
movl $0x1, %edi
movl $0x3a0, %esi            # imm = 0x3A0
callq 0x3240
testq %rax, %rax
je 0xc73d
movq 0xa0(%rsp), %rsi
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %rdx
movq %r12, (%rax)
movq %r15, 0x8(%rax)
movq %rbx, 0x10(%rax)
movl %ebp, 0x18(%rax)
movq %rdx, 0x20(%rax)
movq %rcx, 0x28(%rax)
movq %rsi, 0x50(%rax)
movl 0x88(%r15), %ecx
movq %rax, %r15
movl %ecx, 0x13c(%rax)
movq $0x0, 0x18(%rsp)
testq %r14, %r14
je 0xc831
movq %rbx, 0x40(%rsp)
movl %ebp, 0x14(%rsp)
movq %r13, 0x48(%rsp)
movq %r14, %rdi
callq 0x3610
leaq 0x166e0(%rip), %rsi     # 0x22a39
leaq 0x18(%rsp), %rdx
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x3600
testq %rax, %rax
movq %r15, %rbx
je 0xc77d
movq %rax, %rbp
leaq 0x308(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x1d8(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0x270(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x140(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x90(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0x18(%rsp), %r15
cmpb $0x0, (%rbp)
je 0xc77d
movq %rbp, %rdi
movl $0x3d, %esi
callq 0x3150
testq %rax, %rax
je 0xc609
movq %rax, %r13
movb $0x0, (%rax)
leaq 0x1(%rax), %r12
movq %rbp, %rdi
leaq 0x16653(%rip), %rsi     # 0x22a42
callq 0x34e0
testl %eax, %eax
je 0xc53b
movq %rbp, %rdi
leaq 0x15e05(%rip), %rsi     # 0x2220b
callq 0x34e0
testl %eax, %eax
je 0xc569
movq %rbp, %rdi
leaq 0x15e2a(%rip), %rsi     # 0x22247
callq 0x34e0
testl %eax, %eax
je 0xc59d
movq %rbp, %rdi
leaq 0x166c1(%rip), %rsi     # 0x22af5
callq 0x34e0
testl %eax, %eax
je 0xc5ae
movq %rbp, %rdi
leaq 0x16686(%rip), %rsi     # 0x22ad1
callq 0x34e0
testl %eax, %eax
je 0xc62b
movq %rbp, %rdi
leaq 0x166ab(%rip), %rsi     # 0x22b0d
callq 0x34e0
testl %eax, %eax
je 0xc63b
movq %rbp, %rdi
leaq 0x166ae(%rip), %rsi     # 0x22b27
callq 0x34e0
testl %eax, %eax
je 0xc652
movq %rbp, %rdi
leaq 0x1754d(%rip), %rsi     # 0x239dd
callq 0x34e0
testl %eax, %eax
je 0xc669
movq %rbp, %rdi
leaq 0x16b87(%rip), %rsi     # 0x2302e
callq 0x34e0
testl %eax, %eax
je 0xc679
movq %rbp, %rdi
leaq 0x16b98(%rip), %rsi     # 0x23056
callq 0x34e0
testl %eax, %eax
je 0xc69a
movq %rbp, %rdi
leaq 0x16ba9(%rip), %rsi     # 0x2307e
callq 0x34e0
testl %eax, %eax
je 0xc6bf
movq %rbp, %rdi
leaq 0x16bbe(%rip), %rsi     # 0x230aa
callq 0x34e0
testl %eax, %eax
je 0xc6e4
xorl %eax, %eax
callq 0x176e5
cmpl $0x4, (%rax)
jl 0xc609
movq %r12, (%rsp)
movl $0x4, %edi
leaq 0x16af0(%rip), %rsi     # 0x23009
leaq 0x1653a(%rip), %rdx     # 0x22a5a
movl $0x3df, %ecx            # imm = 0x3DF
leaq 0x166d0(%rip), %r8      # 0x22bfc
movq %rbp, %r9
xorl %eax, %eax
callq 0x1771e
jmp 0xc609
cmpb $0x5b, (%r12)
jne 0xc57d
addq $0x2, %r13
movq %r13, %rdi
movl $0x5d, %esi
callq 0x3150
testq %rax, %rax
je 0xc5c5
movq %rax, %rbp
movb $0x0, (%rax)
cmpb $0x3a, 0x1(%rax)
je 0xc5dd
incq %rbp
jmp 0xc5e1
movq %r12, %rdi
callq 0x3610
movq %rax, 0x120(%rbx)
jmp 0xc609
movq %r12, %rdi
movl $0x3a, %esi
callq 0x3150
testq %rax, %rax
je 0xc5cc
movq %rax, %rbp
movb $0x0, (%rax)
incq %rbp
movq %r12, %r13
jmp 0xc5e1
movq %r12, %rdi
callq 0x3610
movq %rax, 0x128(%rbx)
jmp 0xc609
movq %r12, %rdi
leaq 0x1520a(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x88(%rbx)
jmp 0xc609
movb $0x1, %r14b
xorl %ebp, %ebp
jmp 0xc5d4
movb $0x1, %r14b
xorl %ebp, %ebp
movq %r12, %r13
leaq 0x16478(%rip), %rdx     # 0x22a53
jmp 0xc5f4
addq $0x2, %rbp
cmpb $0x0, (%rbp)
leaq 0x16467(%rip), %rdx     # 0x22a53
je 0xc5f1
movq %rbp, %rdx
xorl %r14d, %r14d
movq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x17c36
testl %eax, %eax
je 0xc8f1
xorl %edi, %edi
leaq 0x16427(%rip), %rsi     # 0x22a39
movq %r15, %rdx
callq 0x3600
movq %rax, %rbp
testq %rax, %rax
jne 0xc3bb
jmp 0xc77d
movq %r12, %rdi
callq 0x3570
movl %eax, 0x130(%rbx)
jmp 0xc609
movq %r12, %rdi
leaq 0x1517d(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x134(%rbx)
jmp 0xc609
movq %r12, %rdi
leaq 0x15166(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x138(%rbx)
jmp 0xc609
movq %r12, %rdi
callq 0x3570
movl %eax, 0x13c(%rbx)
jmp 0xc609
cmpb $0x0, (%r12)
je 0xc609
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0xcdb4
testl %eax, %eax
je 0xc609
jmp 0xc959
cmpb $0x0, (%r12)
je 0xc609
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0xcdb4
testl %eax, %eax
je 0xc609
jmp 0xc98b
cmpb $0x0, (%r12)
je 0xc609
movq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0xcdb4
testl %eax, %eax
je 0xc609
jmp 0xc9bd
cmpb $0x0, (%r12)
je 0xc609
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0xcdb4
testl %eax, %eax
je 0xc609
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r15
jl 0xc94c
leaq 0x168e9(%rip), %rsi     # 0x23009
leaq 0x16333(%rip), %rdx     # 0x22a5a
leaq 0x16988(%rip), %r8      # 0x230b6
movl $0x3, %edi
movl $0x3d9, %ecx            # imm = 0x3D9
jmp 0xc9f1
xorl %eax, %eax
callq 0x176e5
movl $0x3, %ebx
cmpl $0x3, (%rax)
jl 0xc8d1
leaq 0x168b0(%rip), %rsi     # 0x23009
leaq 0x168bb(%rip), %rdx     # 0x2301b
leaq 0x1714c(%rip), %r8      # 0x238b3
movl $0x3, %edi
movl $0x3f6, %ecx            # imm = 0x3F6
xorl %eax, %eax
callq 0x1771e
jmp 0xc8d1
movq 0x8(%rsp), %rdi
callq 0x3450
cmpl $0x0, 0x13c(%rbx)
jle 0xc865
movl 0x130(%rbx), %edx
testl %edx, %edx
js 0xc892
cmpl $0x1, %edx
jne 0xc7b6
movl $0x4b0, 0x130(%rbx)     # imm = 0x4B0
movl $0x4b0, %edx            # imm = 0x4B0
movq 0x40(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x14db7
movq %rax, 0x80(%rbx)
testq %rax, %rax
movq 0x48(%rsp), %rcx
je 0xc8e2
movq $0x0, 0x68(%rbx)
leaq 0x211(%rip), %rax       # 0xc9f9
movq %rax, 0x70(%rbx)
movq %rbx, %rax
addq $0x58, %rax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
leaq 0x200(%rip), %rax       # 0xca02
movq %rax, 0x30(%rbx)
leaq 0x201(%rip), %rax       # 0xca0e
movq %rax, 0x38(%rbx)
leaq 0x3c8(%rip), %rax       # 0xcbe0
movq %rax, 0x40(%rbx)
leaq 0x4d1(%rip), %rax       # 0xccf4
movq %rax, 0x48(%rbx)
movq %rbx, (%rcx)
xorl %ebx, %ebx
jmp 0xc8d1
movq %r15, %rbx
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xc8c4
leaq 0x167be(%rip), %rsi     # 0x23009
leaq 0x167c9(%rip), %rdx     # 0x2301b
leaq 0x16182(%rip), %r8      # 0x229db
movl $0x3, %edi
movl $0x406, %ecx            # imm = 0x406
jmp 0xc8bd
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xc8c4
leaq 0x16791(%rip), %rsi     # 0x23009
leaq 0x1679c(%rip), %rdx     # 0x2301b
leaq 0x163d4(%rip), %r8      # 0x22c5a
movl $0x3, %edi
movl $0x40c, %ecx            # imm = 0x40C
jmp 0xc8bd
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xc8c4
leaq 0x16764(%rip), %rsi     # 0x23009
leaq 0x1676f(%rip), %rdx     # 0x2301b
leaq 0x163ba(%rip), %r8      # 0x22c6d
movl $0x3, %edi
movl $0x412, %ecx            # imm = 0x412
xorl %eax, %eax
callq 0x1771e
movq %rbx, %rdi
callq 0x3450
movl $0x2, %ebx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x3450
movl $0x3, %ebx
jmp 0xc8d1
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r15
jl 0xc94c
testb %r14b, %r14b
je 0xc910
leaq 0x16145(%rip), %rax     # 0x22a53
jmp 0xc91f
cmpb $0x0, (%rbp)
leaq 0x16138(%rip), %rax     # 0x22a53
cmovneq %rbp, %rax
movq %rax, (%rsp)
leaq 0x166df(%rip), %rsi     # 0x23009
leaq 0x16129(%rip), %rdx     # 0x22a5a
leaq 0x1612d(%rip), %r8      # 0x22a65
movl $0x3, %edi
movl $0x3a8, %ecx            # imm = 0x3A8
movq %r13, %r9
xorl %eax, %eax
callq 0x1771e
movq %r15, %rdi
callq 0x3450
jmp 0xc834
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r15
jl 0xc94c
leaq 0x16698(%rip), %rsi     # 0x23009
leaq 0x160e2(%rip), %rdx     # 0x22a5a
leaq 0x166b9(%rip), %r8      # 0x23038
movl $0x3, %edi
movl $0x3c4, %ecx            # imm = 0x3C4
jmp 0xc9f1
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r15
jl 0xc94c
leaq 0x16666(%rip), %rsi     # 0x23009
leaq 0x160b0(%rip), %rdx     # 0x22a5a
leaq 0x166af(%rip), %r8      # 0x23060
movl $0x3, %edi
movl $0x3cb, %ecx            # imm = 0x3CB
jmp 0xc9f1
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r15
jl 0xc94c
leaq 0x16630(%rip), %rsi     # 0x23009
leaq 0x1607a(%rip), %rdx     # 0x22a5a
leaq 0x166a3(%rip), %r8      # 0x2308a
movl $0x3, %edi
movl $0x3d2, %ecx            # imm = 0x3D2
movq %r12, %r9
jmp 0xc945