// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movl %r9d, %ebp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, 0x18(%rsp)
movq %rsi, %r12
movq %rdi, %r13
movl $0x3a0, %edi            # imm = 0x3A0
callq 0x34b0
testq %rax, %rax
je 0xcb37
movq %rax, %r14
movq %r13, 0x60(%rsp)
movq 0xa0(%rsp), %r13
movl $0x3a0, %edx            # imm = 0x3A0
movq %rax, %rdi
xorl %esi, %esi
callq 0x31e0
movq %r12, (%r14)
movq %r15, 0x8(%r14)
movq %rbx, 0x10(%r14)
movl %ebp, 0x24(%rsp)
movl %ebp, 0x18(%r14)
movq %r13, 0x20(%r14)
movq 0xa8(%rsp), %rax
movq %rax, 0x28(%r14)
movq 0xb0(%rsp), %rax
movq %rax, 0x50(%r14)
movl 0x88(%r15), %eax
movq %r14, 0x28(%rsp)
movl %eax, 0x13c(%r14)
movq $0x0, 0x30(%rsp)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xcd08
movq %rbx, 0x58(%rsp)
callq 0x3610
leaq 0x162db(%rip), %rsi     # 0x22a31
leaq 0x30(%rsp), %rdx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x3600
testq %rax, %rax
movq 0x28(%rsp), %rbx
je 0xcb77
movq %rax, %rbp
leaq 0x308(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x1d8(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x270(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x140(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0x90(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x16275(%rip), %r14     # 0x22a31
leaq 0x30(%rsp), %r15
cmpb $0x0, (%rbp)
je 0xcb77
movq %rbp, %rdi
movl $0x3d, %esi
callq 0x3150
testq %rax, %rax
je 0xca07
movq %rax, %r13
movb $0x0, (%rax)
leaq 0x1(%rax), %r12
movq %rbp, %rdi
leaq 0x16245(%rip), %rsi     # 0x22a3a
callq 0x34e0
testl %eax, %eax
je 0xc941
movq %rbp, %rdi
leaq 0x15a1f(%rip), %rsi     # 0x2222b
callq 0x34e0
testl %eax, %eax
je 0xc96f
movq %rbp, %rdi
leaq 0x15a44(%rip), %rsi     # 0x22267
callq 0x34e0
testl %eax, %eax
je 0xc9a3
movq %rbp, %rdi
leaq 0x162b3(%rip), %rsi     # 0x22aed
callq 0x34e0
testl %eax, %eax
je 0xc9b4
movq %rbp, %rdi
leaq 0x16278(%rip), %rsi     # 0x22ac9
callq 0x34e0
testl %eax, %eax
je 0xca25
movq %rbp, %rdi
leaq 0x1629d(%rip), %rsi     # 0x22b05
callq 0x34e0
testl %eax, %eax
je 0xca35
movq %rbp, %rdi
leaq 0x162a0(%rip), %rsi     # 0x22b1f
callq 0x34e0
testl %eax, %eax
je 0xca4c
movq %rbp, %rdi
leaq 0x17137(%rip), %rsi     # 0x239cd
callq 0x34e0
testl %eax, %eax
je 0xca63
movq %rbp, %rdi
leaq 0x16779(%rip), %rsi     # 0x23026
callq 0x34e0
testl %eax, %eax
je 0xca73
movq %rbp, %rdi
leaq 0x1678a(%rip), %rsi     # 0x2304e
callq 0x34e0
testl %eax, %eax
je 0xca94
movq %rbp, %rdi
leaq 0x1679b(%rip), %rsi     # 0x23076
callq 0x34e0
testl %eax, %eax
je 0xcab9
movq %rbp, %rdi
leaq 0x167b0(%rip), %rsi     # 0x230a2
callq 0x34e0
testl %eax, %eax
je 0xcade
xorl %eax, %eax
callq 0x17d59
cmpl $0x4, (%rax)
jl 0xca07
movq %r12, (%rsp)
movl $0x4, %edi
leaq 0x166e2(%rip), %rsi     # 0x23001
leaq 0x1612c(%rip), %rdx     # 0x22a52
movl $0x3df, %ecx            # imm = 0x3DF
leaq 0x162c2(%rip), %r8      # 0x22bf4
movq %rbp, %r9
xorl %eax, %eax
callq 0x17d92
jmp 0xca07
cmpb $0x5b, (%r12)
jne 0xc983
addq $0x2, %r13
movq %r13, %rdi
movl $0x5d, %esi
callq 0x3150
testq %rax, %rax
je 0xc9ce
movq %rax, %rbp
movb $0x0, (%rax)
cmpb $0x3a, 0x1(%rax)
je 0xc9d2
incq %rbp
jmp 0xc9d6
movq %r12, %rdi
callq 0x3610
movq %rax, 0x120(%rbx)
jmp 0xca07
movq %r12, %rdi
movl $0x3a, %esi
callq 0x3150
testq %rax, %rax
je 0xc9cb
movq %rax, %rbp
movb $0x0, (%rax)
incq %rbp
movq %r12, %r13
jmp 0xc9d6
movq %r12, %rdi
callq 0x3610
movq %rax, 0x128(%rbx)
jmp 0xca07
movq %r12, %rdi
leaq 0x14e24(%rip), %rsi     # 0x217e2
callq 0x34e0
movl %eax, 0x88(%rbx)
jmp 0xca07
movq %r12, %r13
xorl %ebp, %ebp
jmp 0xc9d6
addq $0x2, %rbp
leaq 0x1606e(%rip), %rdx     # 0x22a4b
testq %rbp, %rbp
je 0xc9f2
cmpb $0x0, (%rbp)
leaq 0x1605e(%rip), %rdx     # 0x22a4b
je 0xc9f2
movq %rbp, %rdx
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x1829a
testl %eax, %eax
je 0xcca5
xorl %edi, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3600
movq %rax, %rbp
testq %rax, %rax
jne 0xc7c1
jmp 0xcb77
movq %r12, %rdi
callq 0x3570
movl %eax, 0x130(%rbx)
jmp 0xca07
movq %r12, %rdi
leaq 0x14da3(%rip), %rsi     # 0x217e2
callq 0x34e0
movl %eax, 0x134(%rbx)
jmp 0xca07
movq %r12, %rdi
leaq 0x14d8c(%rip), %rsi     # 0x217e2
callq 0x34e0
movl %eax, 0x138(%rbx)
jmp 0xca07
movq %r12, %rdi
callq 0x3570
movl %eax, 0x13c(%rbx)
jmp 0xca07
cmpb $0x0, (%r12)
je 0xca07
movq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0xd1c3
testl %eax, %eax
je 0xca07
jmp 0xcd5a
cmpb $0x0, (%r12)
je 0xca07
movq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0xd1c3
testl %eax, %eax
je 0xca07
jmp 0xcd8c
cmpb $0x0, (%r12)
je 0xca07
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0xd1c3
testl %eax, %eax
je 0xca07
jmp 0xcdc2
cmpb $0x0, (%r12)
je 0xca07
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0xd1c3
testl %eax, %eax
je 0xca07
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
movq 0x10(%rsp), %r14
jl 0xcd00
leaq 0x164e7(%rip), %rsi     # 0x23001
leaq 0x15f31(%rip), %rdx     # 0x22a52
leaq 0x16586(%rip), %r8      # 0x230ae
movl $0x3, %edi
movl $0x3d9, %ecx            # imm = 0x3D9
jmp 0xcdf6
xorl %eax, %eax
callq 0x17d59
movl $0x3, %ebx
cmpl $0x3, (%rax)
jl 0xcd49
leaq 0x164ae(%rip), %rsi     # 0x23001
leaq 0x164b9(%rip), %rdx     # 0x23013
leaq 0x16d42(%rip), %r8      # 0x238a3
movl $0x3, %edi
movl $0x3f6, %ecx            # imm = 0x3F6
xorl %eax, %eax
callq 0x17d92
jmp 0xcd49
movq 0x10(%rsp), %rdi
callq 0x3450
cmpl $0x0, 0x13c(%rbx)
jle 0xcc2c
movl 0x130(%rbx), %eax
testl %eax, %eax
js 0xcc59
cmpl $0x1, %eax
jne 0xcbab
movl $0x4b0, 0x130(%rbx)     # imm = 0x4B0
movl 0x130(%rbx), %edx
movq 0x58(%rsp), %rdi
movl 0x24(%rsp), %esi
callq 0x1534b
movq %rax, 0x80(%rbx)
testq %rax, %rax
movq 0x60(%rsp), %rcx
je 0xcc93
movq $0x0, 0x68(%rbx)
leaq 0x21b(%rip), %rax       # 0xcdfe
movq %rax, 0x70(%rbx)
movq %rbx, %rax
addq $0x58, %rax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
leaq 0x20a(%rip), %rax       # 0xce07
movq %rax, 0x30(%rbx)
leaq 0x20b(%rip), %rax       # 0xce13
movq %rax, 0x38(%rbx)
leaq 0x3d6(%rip), %rax       # 0xcfe9
movq %rax, 0x40(%rbx)
leaq 0x4e3(%rip), %rax       # 0xd101
movq %rax, 0x48(%rbx)
movq %rbx, (%rcx)
xorl %ebx, %ebx
jmp 0xcd49
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xcc8b
leaq 0x163c2(%rip), %rsi     # 0x23001
leaq 0x163cd(%rip), %rdx     # 0x23013
leaq 0x16005(%rip), %r8      # 0x22c52
movl $0x3, %edi
movl $0x40c, %ecx            # imm = 0x40C
jmp 0xcc84
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xcc8b
leaq 0x16395(%rip), %rsi     # 0x23001
leaq 0x163a0(%rip), %rdx     # 0x23013
leaq 0x15feb(%rip), %r8      # 0x22c65
movl $0x3, %edi
movl $0x412, %ecx            # imm = 0x412
xorl %eax, %eax
callq 0x17d92
movq %rbx, %rdi
jmp 0xcd3f
movq %rbx, %rdi
callq 0x3450
movl $0x3, %ebx
jmp 0xcd49
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
movq 0x10(%rsp), %r14
jl 0xcd00
testq %rbp, %rbp
je 0xcccc
cmpb $0x0, (%rbp)
leaq 0x15d85(%rip), %rax     # 0x22a4b
cmovneq %rbp, %rax
jmp 0xccd3
leaq 0x15d78(%rip), %rax     # 0x22a4b
movq %rax, (%rsp)
leaq 0x16323(%rip), %rsi     # 0x23001
leaq 0x15d6d(%rip), %rdx     # 0x22a52
leaq 0x15d71(%rip), %r8      # 0x22a5d
movl $0x3, %edi
movl $0x3a8, %ecx            # imm = 0x3A8
movq %r13, %r9
xorl %eax, %eax
callq 0x17d92
movq %r14, %rdi
callq 0x3450
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xcd3a
leaq 0x162e6(%rip), %rsi     # 0x23001
leaq 0x162f1(%rip), %rdx     # 0x23013
leaq 0x15caa(%rip), %r8      # 0x229d3
movl $0x3, %edi
movl $0x406, %ecx            # imm = 0x406
xorl %eax, %eax
callq 0x17d92
movq 0x28(%rsp), %rdi
callq 0x3450
movl $0x2, %ebx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
movq 0x10(%rsp), %r14
jl 0xcd00
leaq 0x1628f(%rip), %rsi     # 0x23001
leaq 0x15cd9(%rip), %rdx     # 0x22a52
leaq 0x162b0(%rip), %r8      # 0x23030
movl $0x3, %edi
movl $0x3c4, %ecx            # imm = 0x3C4
jmp 0xcdf6
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
movq 0x10(%rsp), %r14
jl 0xcd00
leaq 0x16259(%rip), %rsi     # 0x23001
leaq 0x15ca3(%rip), %rdx     # 0x22a52
leaq 0x162a2(%rip), %r8      # 0x23058
movl $0x3, %edi
movl $0x3cb, %ecx            # imm = 0x3CB
jmp 0xcdf6
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
movq 0x10(%rsp), %r14
jl 0xcd00
leaq 0x16223(%rip), %rsi     # 0x23001
leaq 0x15c6d(%rip), %rdx     # 0x22a52
leaq 0x16296(%rip), %r8      # 0x23082
movl $0x3, %edi
movl $0x3d2, %ecx            # imm = 0x3D2
movq %r12, %r9
jmp 0xccf9