// File: /workspace/github_c_makefile_star2_O2/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, %r13
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, 0x40(%rsp)
pushq $0x1
popq %rdi
movl $0x3a0, %esi            # imm = 0x3A0
callq 0x3250
testq %rax, %rax
je 0xc148
movq %rax, %rbx
movq 0xa0(%rsp), %rax
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %rdx
movq %r12, (%rbx)
movq %r15, 0x8(%rbx)
movq %r13, 0x10(%rbx)
movl %ebp, 0x18(%rbx)
movq %rdx, 0x20(%rbx)
movq %rcx, 0x28(%rbx)
movq %rax, 0x50(%rbx)
movl 0x88(%r15), %eax
movl %eax, 0x13c(%rbx)
andq $0x0, 0x50(%rsp)
testq %r14, %r14
je 0xc309
movq %r13, 0x38(%rsp)
movl %ebp, 0x14(%rsp)
movq %r14, %rdi
callq 0x3620
leaq 0x14cb8(%rip), %rsi     # 0x20a39
leaq 0x50(%rsp), %r14
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r14, %rdx
callq 0x3610
movq %rax, %r12
leaq 0x308(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x1d8(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x270(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0x140(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x90(%rbx), %rax
movq %rax, 0x48(%rsp)
testq %r12, %r12
je 0xc183
cmpb $0x0, (%r12)
je 0xc183
movq %r12, %rdi
pushq $0x3d
popq %rsi
callq 0x3150
testq %rax, %rax
je 0xc027
movq %rax, %r15
movb $0x0, (%rax)
leaq 0x1(%rax), %rbp
movq %r12, %rdi
leaq 0x14c31(%rip), %rsi     # 0x20a42
callq 0x34f0
testl %eax, %eax
je 0xbf5b
movq %r12, %rdi
leaq 0x143e3(%rip), %rsi     # 0x2020b
callq 0x34f0
testl %eax, %eax
je 0xbf86
movq %r12, %rdi
leaq 0x14408(%rip), %rsi     # 0x20247
callq 0x34f0
testl %eax, %eax
je 0xbfb8
movq %r12, %rdi
leaq 0x14c9f(%rip), %rsi     # 0x20af5
callq 0x34f0
testl %eax, %eax
je 0xbfc9
movq %r12, %rdi
leaq 0x14c64(%rip), %rsi     # 0x20ad1
callq 0x34f0
testl %eax, %eax
je 0xc040
movq %r12, %rdi
leaq 0x14c89(%rip), %rsi     # 0x20b0d
callq 0x34f0
testl %eax, %eax
je 0xc050
movq %r12, %rdi
leaq 0x14c8c(%rip), %rsi     # 0x20b27
callq 0x34f0
testl %eax, %eax
je 0xc067
movq %r12, %rdi
leaq 0x15b2b(%rip), %rsi     # 0x219dd
callq 0x34f0
testl %eax, %eax
je 0xc07e
movq %r12, %rdi
leaq 0x15165(%rip), %rsi     # 0x2102e
callq 0x34f0
testl %eax, %eax
je 0xc08e
movq %r12, %rdi
leaq 0x15176(%rip), %rsi     # 0x21056
callq 0x34f0
testl %eax, %eax
je 0xc0aa
movq %r12, %rdi
leaq 0x15187(%rip), %rsi     # 0x2107e
callq 0x34f0
testl %eax, %eax
je 0xc0ce
movq %r12, %rdi
leaq 0x1519c(%rip), %rsi     # 0x210aa
callq 0x34f0
testl %eax, %eax
je 0xc0f2
xorl %eax, %eax
callq 0x165f5
cmpl $0x4, (%rax)
jl 0xc027
movq %rbp, (%rsp)
pushq $0x4
popq %rdi
leaq 0x150d0(%rip), %rsi     # 0x21009
leaq 0x14b1a(%rip), %rdx     # 0x20a5a
movl $0x3df, %ecx            # imm = 0x3DF
leaq 0x14cb0(%rip), %r8      # 0x20bfc
movq %r12, %r9
xorl %eax, %eax
callq 0x1662e
jmp 0xc027
cmpb $0x5b, (%rbp)
jne 0xbf9a
addq $0x2, %r15
movq %r15, %rdi
pushq $0x5d
popq %rsi
callq 0x3150
testq %rax, %rax
je 0xbfe0
movq %rax, %r12
movb $0x0, (%rax)
cmpb $0x3a, 0x1(%rax)
je 0xbffa
incq %r12
jmp 0xbffe
movq %rbp, %rdi
callq 0x3620
movq %rax, 0x120(%rbx)
jmp 0xc027
movq %rbp, %rdi
pushq $0x3a
popq %rsi
callq 0x3150
testq %rax, %rax
je 0xbfe8
movq %rax, %r12
movb $0x0, (%rax)
incq %r12
movq %rbp, %r15
jmp 0xbffe
movq %rbp, %rdi
callq 0x3620
movq %rax, 0x128(%rbx)
jmp 0xc027
movq %rbp, %rdi
leaq 0x137ef(%rip), %rsi     # 0x1f7c2
callq 0x34f0
movl %eax, 0x88(%rbx)
jmp 0xc027
movb $0x1, %r13b
xorl %r12d, %r12d
jmp 0xbff1
movb $0x1, %r13b
xorl %r12d, %r12d
movq %rbp, %r15
leaq 0x14a5b(%rip), %rdx     # 0x20a53
jmp 0xc012
addq $0x2, %r12
cmpb $0x0, (%r12)
leaq 0x14a49(%rip), %rdx     # 0x20a53
je 0xc00f
movq %r12, %rdx
xorl %r13d, %r13d
movq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x16b72
testl %eax, %eax
je 0xc2a7
xorl %edi, %edi
leaq 0x14a09(%rip), %rsi     # 0x20a39
movq %r14, %rdx
callq 0x3610
movq %rax, %r12
jmp 0xbdd5
movq %rbp, %rdi
callq 0x3580
movl %eax, 0x130(%rbx)
jmp 0xc027
movq %rbp, %rdi
leaq 0x13768(%rip), %rsi     # 0x1f7c2
callq 0x34f0
movl %eax, 0x134(%rbx)
jmp 0xc027
movq %rbp, %rdi
leaq 0x13751(%rip), %rsi     # 0x1f7c2
callq 0x34f0
movl %eax, 0x138(%rbx)
jmp 0xc027
movq %rbp, %rdi
callq 0x3580
movl %eax, 0x13c(%rbx)
jmp 0xc027
cmpb $0x0, (%rbp)
je 0xc027
movq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0xc79d
testl %eax, %eax
je 0xc027
jmp 0xc355
cmpb $0x0, (%rbp)
je 0xc027
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0xc79d
testl %eax, %eax
je 0xc027
jmp 0xc385
cmpb $0x0, (%rbp)
je 0xc027
movq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0xc79d
testl %eax, %eax
je 0xc027
jmp 0xc3b9
cmpb $0x0, (%rbp)
je 0xc027
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0xc79d
testl %eax, %eax
je 0xc027
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r14
jl 0xc301
leaq 0x14edc(%rip), %rsi     # 0x21009
leaq 0x14926(%rip), %rdx     # 0x20a5a
leaq 0x14f7b(%rip), %r8      # 0x210b6
pushq $0x3
popq %rdi
movl $0x3d9, %ecx            # imm = 0x3D9
jmp 0xc3eb
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xc2a0
leaq 0x14eaa(%rip), %rsi     # 0x21009
leaq 0x14eb5(%rip), %rdx     # 0x2101b
leaq 0x15746(%rip), %r8      # 0x218b3
pushq $0x3
popq %rbx
movl %ebx, %edi
movl $0x3f6, %ecx            # imm = 0x3F6
xorl %eax, %eax
callq 0x1662e
jmp 0xc344
movq 0x8(%rsp), %rdi
callq 0x3460
cmpl $0x0, 0x13c(%rbx)
jle 0xc234
movl 0x130(%rbx), %edx
testl %edx, %edx
js 0xc266
cmpl $0x1, %edx
jne 0xc1bc
movl $0x4b0, 0x130(%rbx)     # imm = 0x4B0
movl $0x4b0, %edx            # imm = 0x4B0
movq 0x38(%rsp), %rdi
movl 0x14(%rsp), %esi
callq 0x1405f
movq %rax, 0x80(%rbx)
testq %rax, %rax
je 0xc298
andq $0x0, 0x68(%rbx)
leaq 0x20d(%rip), %rax       # 0xc3f3
movq %rax, 0x70(%rbx)
movq %rbx, %rax
addq $0x58, %rax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
leaq 0x1fc(%rip), %rax       # 0xc3fc
movq %rax, 0x30(%rbx)
leaq 0x1fd(%rip), %rax       # 0xc408
movq %rax, 0x38(%rbx)
leaq 0x3bf(%rip), %rax       # 0xc5d5
movq %rax, 0x40(%rbx)
leaq 0x4c0(%rip), %rax       # 0xc6e1
movq %rax, 0x48(%rbx)
movq 0x40(%rsp), %rax
movq %rbx, (%rax)
xorl %ebx, %ebx
jmp 0xc344
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xc339
leaq 0x14dbe(%rip), %rsi     # 0x21009
leaq 0x14dc9(%rip), %rdx     # 0x2101b
leaq 0x14a01(%rip), %r8      # 0x20c5a
pushq $0x3
popq %rdi
movl $0x40c, %ecx            # imm = 0x40C
jmp 0xc332
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xc339
leaq 0x14d8c(%rip), %rsi     # 0x21009
leaq 0x14d97(%rip), %rdx     # 0x2101b
leaq 0x149e2(%rip), %r8      # 0x20c6d
pushq $0x3
popq %rdi
movl $0x412, %ecx            # imm = 0x412
jmp 0xc332
movq %rbx, %rdi
callq 0x3460
pushq $0x3
jmp 0xc343
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r14
jl 0xc301
testb %r13b, %r13b
je 0xc2c6
leaq 0x1478f(%rip), %rax     # 0x20a53
jmp 0xc2d6
cmpb $0x0, (%r12)
leaq 0x14781(%rip), %rax     # 0x20a53
cmovneq %r12, %rax
movq %rax, (%rsp)
leaq 0x14d28(%rip), %rsi     # 0x21009
leaq 0x14772(%rip), %rdx     # 0x20a5a
leaq 0x14776(%rip), %r8      # 0x20a65
pushq $0x3
popq %rdi
movl $0x3a8, %ecx            # imm = 0x3A8
movq %r15, %r9
xorl %eax, %eax
callq 0x1662e
movq %r14, %rdi
callq 0x3460
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xc339
leaq 0x14ced(%rip), %rsi     # 0x21009
leaq 0x14cf8(%rip), %rdx     # 0x2101b
leaq 0x146b1(%rip), %r8      # 0x209db
pushq $0x3
popq %rdi
movl $0x406, %ecx            # imm = 0x406
xorl %eax, %eax
callq 0x1662e
movq %rbx, %rdi
callq 0x3460
pushq $0x2
popq %rbx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r14
jl 0xc301
leaq 0x14c9c(%rip), %rsi     # 0x21009
leaq 0x146e6(%rip), %rdx     # 0x20a5a
leaq 0x14cbd(%rip), %r8      # 0x21038
pushq $0x3
popq %rdi
movl $0x3c4, %ecx            # imm = 0x3C4
jmp 0xc3eb
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r14
jl 0xc301
leaq 0x14c68(%rip), %rsi     # 0x21009
leaq 0x146b2(%rip), %rdx     # 0x20a5a
leaq 0x14cb1(%rip), %r8      # 0x21060
pushq $0x3
popq %rdi
movl $0x3cb, %ecx            # imm = 0x3CB
jmp 0xc3eb
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
movq 0x8(%rsp), %r14
jl 0xc301
leaq 0x14c34(%rip), %rsi     # 0x21009
leaq 0x1467e(%rip), %rdx     # 0x20a5a
leaq 0x14ca7(%rip), %r8      # 0x2108a
pushq $0x3
popq %rdi
movl $0x3d2, %ecx            # imm = 0x3D2
movq %rbp, %r9
jmp 0xc2fa