// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movl $0xc20, %edi            # imm = 0xC20
callq 0x34d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xe0f3
jmp 0xe0b3
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0xe0e5
movl $0x3, %edi
leaq 0x27eb3(%rip), %rsi     # 0x35f7e
leaq 0x27ec1(%rip), %rdx     # 0x35f93
movl $0x50a, %ecx            # imm = 0x50A
leaq 0x28db9(%rip), %r8      # 0x36e97
movb $0x0, %al
callq 0x243b0
jmp 0xe0e7
movl $0x3, -0x4(%rbp)
jmp 0xe3a0
movq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0xc20, %edx            # imm = 0xC20
callq 0x3200
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x18(%rax)
movq 0x10(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movq 0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x28(%rax)
movq 0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x28(%rbp), %rax
movl 0x88(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x4fc(%rax)
movq -0x28(%rbp), %rax
movl 0x88(%rax), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0xacc(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0x4f0(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0xac0(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0x648(%rax)
movq -0x40(%rbp), %rax
movl $0x1, 0xc18(%rax)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xe3b0
cmpl $0x0, %eax
je 0xe211
jmp 0xe1c8
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0xe1fa
movl $0x3, %edi
leaq 0x27d9e(%rip), %rsi     # 0x35f7e
leaq 0x27dac(%rip), %rdx     # 0x35f93
movl $0x520, %ecx            # imm = 0x520
leaq 0x27db6(%rip), %r8      # 0x35fa9
movb $0x0, %al
callq 0x243b0
jmp 0xe1fc
movq -0x40(%rbp), %rdi
callq 0x3460
movl $0x2, -0x4(%rbp)
jmp 0xe3a0
movq -0x40(%rbp), %rdi
callq 0xee30
cmpl $0x0, %eax
je 0xe234
movq -0x40(%rbp), %rdi
callq 0x3460
movl $0x2, -0x4(%rbp)
jmp 0xe3a0
jmp 0xe236
movq -0x40(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x40(%rbp), %rax
leaq 0xc63(%rip), %rcx       # 0xeeb0
movq %rcx, 0x70(%rax)
jmp 0xe253
movq -0x40(%rbp), %rcx
addq $0x58, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x40(%rbp), %rcx
addq $0x58, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x40(%rbp), %rax
leaq 0xc62(%rip), %rcx       # 0xeee0
movq %rcx, 0x30(%rax)
movq -0x40(%rbp), %rax
leaq 0xe33(%rip), %rcx       # 0xf0c0
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rax
leaq 0x1014(%rip), %rcx      # 0xf2b0
movq %rcx, 0x40(%rax)
movq -0x40(%rbp), %rax
leaq 0x11c5(%rip), %rcx      # 0xf470
movq %rcx, 0x48(%rax)
movq -0x40(%rbp), %rax
cmpl $0x0, 0x630(%rax)
je 0xe320
movq -0x40(%rbp), %rdi
addq $0x80, %rdi
movq -0x40(%rbp), %rsi
callq 0xf720
cmpl $0x0, %eax
je 0xe320
jmp 0xe2d7
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0xe309
movl $0x3, %edi
leaq 0x27c8f(%rip), %rsi     # 0x35f7e
leaq 0x27c9d(%rip), %rdx     # 0x35f93
movl $0x533, %ecx            # imm = 0x533
leaq 0x27cbb(%rip), %r8      # 0x35fbd
movb $0x0, %al
callq 0x243b0
jmp 0xe30b
movq -0x40(%rbp), %rdi
callq 0xf470
movl $0x5, -0x4(%rbp)
jmp 0xe3a0
movq -0x40(%rbp), %rax
cmpl $0x0, 0xc00(%rax)
je 0xe38e
movq -0x40(%rbp), %rdi
addq $0x650, %rdi            # imm = 0x650
movq -0x40(%rbp), %rsi
callq 0xf720
cmpl $0x0, %eax
je 0xe38e
jmp 0xe348
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0xe37a
movl $0x3, %edi
leaq 0x27c1e(%rip), %rsi     # 0x35f7e
leaq 0x27c2c(%rip), %rdx     # 0x35f93
movl $0x539, %ecx            # imm = 0x539
leaq 0x27c6f(%rip), %r8      # 0x35fe2
movb $0x0, %al
callq 0x243b0
jmp 0xe37c
movq -0x40(%rbp), %rdi
callq 0xf470
movl $0x5, -0x4(%rbp)
jmp 0xe3a0
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)