// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/channel_chndoh.c
// Function: channel_chndoh_create
int channel_chndoh_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_chndoh_t* ctx;

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

	memset(ctx, 0, sizeof(channel_chndoh_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->chndoh.timeout = conf->timeout;
	ctx->frndoh.timeout = conf->timeout;
	ctx->chndoh.keep_alive = TRUE;
	ctx->frndoh.keep_alive = TRUE;
	ctx->chndoh.auto_resolve_host = TRUE;
	ctx->frndoh.auto_resolve_host = TRUE;

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

	if (check_ctx(ctx)) {
		free(ctx);
		return CHANNEL_WRONG_ARG;
	}

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

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

	if (ctx->chndoh.channel != CH_NONE && create_upstream_chctx(&ctx->chndoh, ctx)) {
		loge("create_upstream_chctx(chndoh) error\n");
		destroy((channel_t*)ctx);
		return CHANNEL_ERROR;
	}

	if (ctx->frndoh.channel != CH_NONE && create_upstream_chctx(&ctx->frndoh, ctx)) {
		loge("create_upstream_chctx(frndoh) error\n");
		destroy((channel_t*)ctx);
		return CHANNEL_ERROR;
	}

	*pctx = (channel_t*)ctx;

	return CHANNEL_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %ebp
movq %r8, %r12
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, 0x40(%rsp)
movl $0x1, %edi
movl $0xc20, %esi            # imm = 0xC20
callq 0x3240
testq %rax, %rax
je 0xa0d0
movq %rax, %rbx
movq 0x90(%rsp), %rax
movq 0x88(%rsp), %rcx
movq 0x80(%rsp), %rdx
movq %r13, (%rbx)
movq %r15, 0x8(%rbx)
movq %r12, 0x10(%rbx)
movl %ebp, 0x18(%rbx)
movq %rdx, 0x20(%rbx)
movq %rcx, 0x28(%rbx)
movq %rax, 0x50(%rbx)
movl 0x88(%r15), %eax
movl %eax, 0x4fc(%rbx)
movl %eax, 0xacc(%rbx)
movl $0x1, %eax
movl %eax, 0x4f0(%rbx)
movl %eax, 0xac0(%rbx)
movl %eax, 0x648(%rbx)
movl %eax, 0xc18(%rbx)
movq $0x0, 0x28(%rsp)
testq %r14, %r14
je 0xa2af
leaq 0x80(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x650(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x3610
leaq 0x18f29(%rip), %rsi     # 0x22a39
leaq 0x28(%rsp), %rdx
movq %rax, 0x20(%rsp)
movq %rax, %rdi
callq 0x3600
testq %rax, %rax
je 0xa110
movq %rax, %r15
leaq 0x518(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x480(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x18eec(%rip), %rbp     # 0x22a39
leaq 0x28(%rsp), %r12
cmpb $0x0, (%r15)
je 0xa110
movq %r15, %rdi
movl $0x3d, %esi
callq 0x3150
testq %rax, %rax
je 0x9ec9
movq %rax, %r14
movb $0x0, (%rax)
incq %r14
movq %r15, %rdi
leaq 0x18eb6(%rip), %rsi     # 0x22a3b
callq 0x34e0
testl %eax, %eax
je 0x9e1d
movq %r15, %rdi
leaq 0x18eab(%rip), %rsi     # 0x22a47
callq 0x34e0
testl %eax, %eax
je 0x9e24
movq %r15, %rdi
leaq 0x18ecf(%rip), %rsi     # 0x22a82
callq 0x34e0
testl %eax, %eax
je 0x9e86
movq %r15, %rdi
leaq 0x18ec4(%rip), %rsi     # 0x22a8e
callq 0x34e0
testl %eax, %eax
je 0x9eb3
movq %r15, %rdi
leaq 0x18eb9(%rip), %rsi     # 0x22a9a
callq 0x34e0
movl %eax, %r13d
testl %eax, %eax
je 0x9e8e
movq %r15, %rdi
leaq 0x18eab(%rip), %rsi     # 0x22aa6
callq 0x34e0
testl %eax, %eax
je 0x9e8e
movq %r15, %rdi
leaq 0x18ea0(%rip), %rsi     # 0x22ab2
callq 0x34e0
testl %eax, %eax
je 0x9ee7
movq %r15, %rdi
leaq 0x18e95(%rip), %rsi     # 0x22abe
callq 0x34e0
testl %eax, %eax
je 0x9eef
movq %r15, %rdi
leaq 0x18e8a(%rip), %rsi     # 0x22aca
callq 0x34e0
testl %eax, %eax
je 0x9f07
movq %r15, %rdi
leaq 0x18e85(%rip), %rsi     # 0x22adc
callq 0x34e0
testl %eax, %eax
je 0x9f0f
movq %r15, %rdi
leaq 0x18e80(%rip), %rsi     # 0x22aee
callq 0x34e0
testl %eax, %eax
je 0x9f27
movq %r15, %rdi
leaq 0x18e75(%rip), %rsi     # 0x22afa
callq 0x34e0
testl %eax, %eax
je 0x9f2f
movq %r15, %rdi
leaq 0x18e6a(%rip), %rsi     # 0x22b06
callq 0x34e0
testl %eax, %eax
je 0x9f51
movq %r15, %rdi
leaq 0x18e60(%rip), %rsi     # 0x22b13
callq 0x34e0
testl %eax, %eax
je 0x9f59
movq %r15, %rdi
leaq 0x18e56(%rip), %rsi     # 0x22b20
callq 0x34e0
testl %eax, %eax
je 0x9f7b
movq %r15, %rdi
leaq 0x18e4a(%rip), %rsi     # 0x22b2b
callq 0x34e0
testl %eax, %eax
je 0x9f83
movq %r15, %rdi
leaq 0x18e3e(%rip), %rsi     # 0x22b36
callq 0x34e0
testl %eax, %eax
je 0x9fa5
movq %r15, %rdi
leaq 0x18e32(%rip), %rsi     # 0x22b41
callq 0x34e0
testl %eax, %eax
je 0x9fac
movq %r15, %rdi
leaq 0x18e3d(%rip), %rsi     # 0x22b63
callq 0x34e0
testl %eax, %eax
je 0x9fd5
movq %r15, %rdi
leaq 0x18e32(%rip), %rsi     # 0x22b6f
callq 0x34e0
testl %eax, %eax
je 0x9fdc
movq %r15, %rdi
leaq 0x18e27(%rip), %rsi     # 0x22b7b
callq 0x34e0
testl %eax, %eax
je 0xa005
movq %r15, %rdi
leaq 0x18e1f(%rip), %rsi     # 0x22b8a
callq 0x34e0
testl %eax, %eax
je 0xa00d
movq %r15, %rdi
leaq 0x18e3e(%rip), %rsi     # 0x22bc0
callq 0x34e0
testl %eax, %eax
je 0xa072
movq %r15, %rdi
leaq 0x18e36(%rip), %rsi     # 0x22bcf
callq 0x34e0
testl %eax, %eax
je 0xa08b
movq %r15, %rdi
leaq 0x18e2e(%rip), %rsi     # 0x22bde
callq 0x34e0
testl %eax, %eax
je 0xa0ad
movq %r15, %rdi
leaq 0x18e26(%rip), %rsi     # 0x22bed
callq 0x34e0
testl %eax, %eax
je 0xa0b5
xorl %eax, %eax
callq 0x176e5
cmpl $0x4, (%rax)
leaq 0x18c54(%rip), %rbp     # 0x22a39
jl 0x9ec9
movq %r14, (%rsp)
movl $0x4, %edi
leaq 0x18bb5(%rip), %rsi     # 0x229b0
leaq 0x18c58(%rip), %rdx     # 0x22a5a
movl $0x490, %ecx            # imm = 0x490
leaq 0x18dee(%rip), %r8      # 0x22bfc
movq %r15, %r9
xorl %eax, %eax
callq 0x1771e
jmp 0x9ec9
movl $0x80, %ebp
jmp 0x9e29
movl $0x650, %ebp            # imm = 0x650
leaq (%rbx,%rbp), %r13
movq %r14, %rdi
callq 0x3610
movq %rax, 0x458(%rbx,%rbp)
cmpl $0x1, 0x5b0(%rbx,%rbp)
leaq 0x8(%rbx,%rbp), %rsi
leaq 0x18c06(%rip), %r8      # 0x22a57
leaq 0x18bfb(%rip), %rax     # 0x22a53
cmoveq %rax, %r8
movq %r14, %rdi
movl $0x8, %edx
movl $0x88, %ecx
callq 0x181bf
testl %eax, %eax
jle 0xa252
movl %eax, 0x448(%r13)
leaq 0x18bb5(%rip), %rbp     # 0x22a39
jmp 0x9ec9
movl $0x80, %r15d
jmp 0x9eb9
cmpb $0x0, (%r14)
je 0x9ec9
movq %r14, %rdi
callq 0x3610
testl %r13d, %r13d
movq 0x10(%rsp), %rcx
cmoveq 0x18(%rsp), %rcx
movq %rax, 0x460(%rcx)
jmp 0x9ec9
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
callq 0x3610
movq %rax, 0x450(%rbx,%r15)
xorl %edi, %edi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x3600
movq %rax, %r15
testq %rax, %rax
jne 0x9b52
jmp 0xa110
movl $0x80, %r15d
jmp 0x9ef5
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
callq 0x3610
movq %rax, 0x468(%rbx,%r15)
jmp 0x9ec9
movl $0x80, %r15d
jmp 0x9f15
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
callq 0x3570
movl %eax, 0x470(%rbx,%r15)
jmp 0x9ec9
movl $0x80, %r15d
jmp 0x9f35
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
leaq 0x17883(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x44c(%rbx,%r15)
jmp 0x9ec9
movl $0x80, %r15d
jmp 0x9f5f
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
leaq 0x17859(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x474(%rbx,%r15)
jmp 0x9ec9
movl $0x80, %r15d
jmp 0x9f89
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
leaq 0x1782f(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x478(%rbx,%r15)
jmp 0x9ec9
movl $0x80, %edi
jmp 0x9fb1
movl $0x650, %edi            # imm = 0x650
cmpb $0x0, (%r14)
je 0x9ec9
addq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0xa955
testl %eax, %eax
je 0x9ec9
jmp 0xa2ff
movl $0x80, %edi
jmp 0x9fe1
movl $0x650, %edi            # imm = 0x650
cmpb $0x0, (%r14)
je 0x9ec9
addq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0xa955
testl %eax, %eax
je 0x9ec9
jmp 0xa333
movl $0x80, %r13d
jmp 0xa013
movl $0x650, %r13d           # imm = 0x650
movq %r14, %rdi
leaq 0x185ca(%rip), %rsi     # 0x225e7
callq 0x34e0
testl %eax, %eax
je 0xa061
movq %r14, %rdi
leaq 0x185bb(%rip), %rsi     # 0x225eb
callq 0x34e0
testl %eax, %eax
je 0xa07a
movq %r14, %rdi
leaq 0x185ac(%rip), %rsi     # 0x225ef
callq 0x34e0
testl %eax, %eax
jne 0xa36b
movl $0x1, 0x5b0(%rbx,%r13)
jmp 0x9e7d
movl $0x2, 0x5b0(%rbx,%r13)
jmp 0x9e7d
movl $0x80, %r15d
jmp 0xa091
movl $0x3, 0x5b0(%rbx,%r13)
jmp 0x9e7d
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
leaq 0x17727(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x5c8(%rbx,%r15)
jmp 0x9e7d
movl $0x80, %r15d
jmp 0xa0bb
movl $0x650, %r15d           # imm = 0x650
movq %r14, %rdi
callq 0x3570
movl %eax, 0x47c(%rbx,%r15)
jmp 0x9e7d
xorl %eax, %eax
callq 0x176e5
movl $0x3, %ebx
cmpl $0x3, (%rax)
jl 0xa2ee
leaq 0x188c4(%rip), %rsi     # 0x229b0
leaq 0x188d2(%rip), %rdx     # 0x229c5
leaq 0x197b9(%rip), %r8      # 0x238b3
movl $0x3, %edi
movl $0x50a, %ecx            # imm = 0x50A
xorl %eax, %eax
callq 0x1771e
jmp 0xa2ee
movq 0x20(%rsp), %rdi
callq 0x3450
cmpl $0x0, 0x630(%rbx)
je 0xa135
movq 0x18(%rsp), %rdi
callq 0xa9d7
testl %eax, %eax
jne 0xa2e1
cmpl $0x0, 0xc00(%rbx)
je 0xa150
movq 0x10(%rsp), %rdi
callq 0xa9d7
testl %eax, %eax
jne 0xa2e1
movq $0x0, 0x68(%rbx)
leaq 0x244(%rip), %rax       # 0xa3a3
movq %rax, 0x70(%rbx)
movq %rbx, %rax
addq $0x58, %rax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
leaq 0x233(%rip), %rax       # 0xa3ac
movq %rax, 0x30(%rbx)
leaq 0x2d0(%rip), %rax       # 0xa454
movq %rax, 0x38(%rbx)
leaq 0x3e5(%rip), %rax       # 0xa574
movq %rax, 0x40(%rbx)
leaq 0x4ee(%rip), %rax       # 0xa688
movq %rax, 0x48(%rbx)
cmpl $0x0, 0x630(%rbx)
je 0xa1e5
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0xa7da
testl %eax, %eax
je 0xa1e5
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xa231
leaq 0x187e5(%rip), %rsi     # 0x229b0
leaq 0x187f3(%rip), %rdx     # 0x229c5
leaq 0x18816(%rip), %r8      # 0x229ef
movl $0x3, %edi
movl $0x533, %ecx            # imm = 0x533
jmp 0xa22a
cmpl $0x0, 0xc00(%rbx)
je 0xa243
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xa7da
testl %eax, %eax
je 0xa243
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xa231
leaq 0x1879e(%rip), %rsi     # 0x229b0
leaq 0x187ac(%rip), %rdx     # 0x229c5
leaq 0x187f4(%rip), %r8      # 0x22a14
movl $0x3, %edi
movl $0x539, %ecx            # imm = 0x539
xorl %eax, %eax
callq 0x1771e
movq %rbx, %rdi
callq 0xa688
movl $0x5, %ebx
jmp 0xa2ee
movq 0x40(%rsp), %rax
movq %rbx, (%rax)
xorl %ebx, %ebx
jmp 0xa2ee
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xa2a5
cmpl $0x1, 0x5b0(%r13)
leaq 0x187ea(%rip), %rax     # 0x22a57
leaq 0x187df(%rip), %rcx     # 0x22a53
cmoveq %rcx, %rax
movq %rax, (%rsp)
leaq 0x1872d(%rip), %rsi     # 0x229b0
leaq 0x187d0(%rip), %rdx     # 0x22a5a
leaq 0x187d4(%rip), %r8      # 0x22a65
movl $0x3, %edi
movl $0x448, %ecx            # imm = 0x448
movq %r15, %r9
xorl %eax, %eax
callq 0x1771e
movq 0x20(%rsp), %rdi
callq 0x3450
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xa2e1
leaq 0x186ee(%rip), %rsi     # 0x229b0
leaq 0x186fc(%rip), %rdx     # 0x229c5
leaq 0x1870b(%rip), %r8      # 0x229db
movl $0x3, %edi
movl $0x520, %ecx            # imm = 0x520
xorl %eax, %eax
callq 0x1771e
movq %rbx, %rdi
callq 0x3450
movl $0x2, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xa2a5
movq %r14, (%rsp)
leaq 0x1869a(%rip), %rsi     # 0x229b0
leaq 0x1873d(%rip), %rdx     # 0x22a5a
leaq 0x18828(%rip), %r8      # 0x22b4c
movl $0x3, %edi
movl $0x46f, %ecx            # imm = 0x46F
jmp 0xa29b
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xa2a5
movq %r14, (%rsp)
leaq 0x18662(%rip), %rsi     # 0x229b0
leaq 0x18705(%rip), %rdx     # 0x22a5a
leaq 0x187f0(%rip), %r8      # 0x22b4c
movl $0x3, %edi
movl $0x477, %ecx            # imm = 0x477
jmp 0xa29b
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xa2a5
movq %r14, (%rsp)
leaq 0x1862a(%rip), %rsi     # 0x229b0
leaq 0x186cd(%rip), %rdx     # 0x22a5a
leaq 0x18805(%rip), %r8      # 0x22b99
movl $0x3, %edi
movl $0x482, %ecx            # imm = 0x482
jmp 0xa29b