// File: /workspace/github_c_makefile_star2_O2/GangZhuo[P]dohclient/src/channel_tcp.c
// Function: channel_tcp_create
int channel_tcp_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_tcp_t* ctx;

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

	memset(ctx, 0, sizeof(channel_tcp_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;
	}

	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 $0x28, %rsp
movl %r9d, %ebp
movq %r8, %r12
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
pushq $0x1
popq %rdi
movl $0x4c0, %esi            # imm = 0x4C0
callq 0x3250
testq %rax, %rax
je 0xe7bf
movq %rax, %rbx
movq 0x70(%rsp), %rax
movq 0x68(%rsp), %rcx
movq 0x60(%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, 0x4b8(%rbx)
andq $0x0, 0x20(%rsp)
testq %r14, %r14
je 0xe8de
movq %r14, %rdi
callq 0x3620
leaq 0x123bd(%rip), %r13     # 0x20a39
leaq 0x20(%rsp), %rbp
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3610
movq %rax, %r14
leaq 0x70(%rbx), %rax
movq %rax, 0x18(%rsp)
pushq $0x3d
popq %r15
testq %r14, %r14
je 0xe7fa
cmpb $0x0, (%r14)
je 0xe7fa
movq %r14, %rdi
movl %r15d, %esi
callq 0x3150
testq %rax, %rax
je 0xe7aa
movq %rax, %r12
movb $0x0, (%rax)
incq %r12
movq %r14, %rdi
leaq 0x12e6c(%rip), %rsi     # 0x2154a
callq 0x34f0
testl %eax, %eax
je 0xe752
movq %r14, %rdi
leaq 0x1241c(%rip), %rsi     # 0x20b0d
callq 0x34f0
testl %eax, %eax
je 0xe77e
movq %r14, %rdi
leaq 0x132d5(%rip), %rsi     # 0x219dd
callq 0x34f0
testl %eax, %eax
je 0xe795
xorl %eax, %eax
callq 0x165f5
cmpl $0x4, (%rax)
jl 0xe7aa
movq %r12, (%rsp)
pushq $0x4
popq %rdi
leaq 0x12b19(%rip), %rsi     # 0x2124c
leaq 0x12320(%rip), %rdx     # 0x20a5a
movl $0x3e2, %ecx            # imm = 0x3E2
leaq 0x124b6(%rip), %r8      # 0x20bfc
movq %r14, %r9
xorl %eax, %eax
callq 0x1662e
jmp 0xe7aa
movq %r12, %rdi
movq 0x18(%rsp), %rsi
pushq $0x8
popq %rdx
movl $0x88, %ecx
leaq 0x122ee(%rip), %r8      # 0x20a57
callq 0x170aa
testl %eax, %eax
jle 0xe88d
movl %eax, 0x4b0(%rbx)
jmp 0xe7aa
movq %r12, %rdi
leaq 0x1103a(%rip), %rsi     # 0x1f7c2
callq 0x34f0
movl %eax, 0x4b4(%rbx)
jmp 0xe7aa
cmpb $0x0, (%r12)
je 0xe7aa
movq %r12, %rdi
callq 0x3580
movl %eax, 0x4b8(%rbx)
xorl %edi, %edi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3610
movq %rax, %r14
jmp 0xe6a4
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe857
leaq 0x12a76(%rip), %rsi     # 0x2124c
leaq 0x12abb(%rip), %rdx     # 0x21298
leaq 0x130cf(%rip), %r8      # 0x218b3
pushq $0x3
popq %rbx
movl %ebx, %edi
movl $0x400, %ecx            # imm = 0x400
xorl %eax, %eax
callq 0x1662e
jmp 0xe919
movq 0x8(%rsp), %rdi
callq 0x3460
cmpl $0x0, 0x4b8(%rbx)
jle 0xe85e
movq %rbx, %rax
addq $0x58, %rax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
leaq 0x107(%rip), %rax       # 0xe92a
movq %rax, 0x30(%rbx)
leaq 0x23f(%rip), %rax       # 0xea6d
movq %rax, 0x38(%rbx)
leaq 0x905(%rip), %rax       # 0xf13e
movq %rax, 0x40(%rbx)
leaq 0x90d(%rip), %rax       # 0xf151
movq %rax, 0x48(%rbx)
movq 0x10(%rsp), %rax
movq %rbx, (%rax)
xorl %ebx, %ebx
jmp 0xe919
pushq $0x3
jmp 0xe918
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe90e
leaq 0x129d7(%rip), %rsi     # 0x2124c
leaq 0x12a1c(%rip), %rdx     # 0x21298
leaq 0x123d7(%rip), %r8      # 0x20c5a
pushq $0x3
popq %rdi
movl $0x416, %ecx            # imm = 0x416
jmp 0xe907
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe8d4
cmpb $0x0, (%r12)
leaq 0x121b2(%rip), %rax     # 0x20a57
cmovneq %r12, %rax
movq %rax, (%rsp)
leaq 0x12998(%rip), %rsi     # 0x2124c
leaq 0x1219f(%rip), %rdx     # 0x20a5a
leaq 0x121a3(%rip), %r8      # 0x20a65
pushq $0x3
popq %rdi
movl $0x3d3, %ecx            # imm = 0x3D3
movq %r14, %r9
xorl %eax, %eax
callq 0x1662e
movq 0x8(%rsp), %rdi
callq 0x3460
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0xe90e
leaq 0x1295b(%rip), %rsi     # 0x2124c
leaq 0x129a0(%rip), %rdx     # 0x21298
leaq 0x120dc(%rip), %r8      # 0x209db
pushq $0x3
popq %rdi
movl $0x410, %ecx            # imm = 0x410
xorl %eax, %eax
callq 0x1662e
movq %rbx, %rdi
callq 0x3460
pushq $0x2
popq %rbx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq