// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%rsp)
movl $0x4c0, %edi            # imm = 0x4C0
callq 0x34b0
testq %rax, %rax
je 0xf52b
movq %rax, %rbx
movl $0x4c0, %edx            # imm = 0x4C0
movq %rax, %rdi
xorl %esi, %esi
callq 0x31e0
movq %r13, (%rbx)
movq %r15, 0x8(%rbx)
movq %r12, 0x10(%rbx)
movl %ebp, 0x18(%rbx)
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rbx)
movq 0x68(%rsp), %rax
movq %rax, 0x28(%rbx)
movq 0x70(%rsp), %rax
movq %rax, 0x50(%rbx)
movl 0x88(%r15), %eax
movl %eax, 0x4b8(%rbx)
movq $0x0, 0x8(%rsp)
testq %r14, %r14
je 0xf568
movq %r14, %rdi
callq 0x3610
leaq 0x1372a(%rip), %rsi     # 0x22a31
leaq 0x8(%rsp), %rdx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x3600
testq %rax, %rax
je 0xf4ca
movq %rax, %r12
leaq 0x70(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x136fc(%rip), %r13     # 0x22a31
leaq 0x8(%rsp), %rbp
leaq 0x141f9(%rip), %r15     # 0x2353a
cmpb $0x0, (%r12)
je 0xf4ca
movq %r12, %rdi
movl $0x3d, %esi
callq 0x3150
testq %rax, %rax
je 0xf4b1
movq %rax, %r14
movb $0x0, (%rax)
incq %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x34e0
testl %eax, %eax
je 0xf3ea
movq %r12, %rdi
leaq 0x13781(%rip), %rsi     # 0x22b05
callq 0x34e0
testl %eax, %eax
je 0xf41e
movq %r12, %rdi
leaq 0x14632(%rip), %rsi     # 0x239cd
callq 0x34e0
testl %eax, %eax
je 0xf435
xorl %eax, %eax
callq 0x17d59
cmpl $0x4, (%rax)
jl 0xf4b1
movq %r14, (%rsp)
movl $0x4, %edi
leaq 0x13e74(%rip), %rsi     # 0x2323c
leaq 0x13683(%rip), %rdx     # 0x22a52
movl $0x3e2, %ecx            # imm = 0x3E2
leaq 0x13819(%rip), %r8      # 0x22bf4
movq %r12, %r9
xorl %eax, %eax
callq 0x17d92
jmp 0xf4b1
movq %r13, %rbp
movq %r15, %r13
movq %r14, %rdi
movq 0x18(%rsp), %rsi
movl $0x8, %edx
movl $0x88, %ecx
leaq 0x13646(%rip), %r8      # 0x22a4f
callq 0x18825
movl %eax, %r15d
testl %eax, %eax
jle 0xf44b
movl %r15d, 0x4b0(%rbx)
jmp 0xf49d
movq %r14, %rdi
leaq 0x123ba(%rip), %rsi     # 0x217e2
callq 0x34e0
movl %eax, 0x4b4(%rbx)
jmp 0xf4b1
cmpb $0x0, (%r14)
je 0xf4b1
movq %r14, %rdi
callq 0x3570
movl %eax, 0x4b8(%rbx)
jmp 0xf4b1
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf493
cmpb $0x0, (%r14)
leaq 0x135ed(%rip), %rax     # 0x22a4f
cmoveq %rax, %r14
movq %r14, (%rsp)
movl $0x3, %edi
leaq 0x13dc6(%rip), %rsi     # 0x2323c
leaq 0x135d5(%rip), %rdx     # 0x22a52
movl $0x3d3, %ecx            # imm = 0x3D3
leaq 0x135d4(%rip), %r8      # 0x22a5d
movq %r12, %r9
xorl %eax, %eax
callq 0x17d92
movq 0x10(%rsp), %rdi
callq 0x3450
testl %r15d, %r15d
movq %r13, %r15
movq %rbp, %r13
leaq 0x8(%rsp), %rbp
jle 0xf568
xorl %edi, %edi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3600
movq %rax, %r12
testq %rax, %rax
jne 0xf341
movq 0x10(%rsp), %rdi
callq 0x3450
cmpl $0x0, 0x4b8(%rbx)
jle 0xf595
movq %rbx, %rax
addq $0x58, %rax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
leaq 0xee(%rip), %rax        # 0xf5e5
movq %rax, 0x30(%rbx)
leaq 0x23b(%rip), %rax       # 0xf73d
movq %rax, 0x38(%rbx)
leaq 0x968(%rip), %rax       # 0xfe75
movq %rax, 0x40(%rbx)
leaq 0x970(%rip), %rax       # 0xfe88
movq %rax, 0x48(%rbx)
movq 0x20(%rsp), %rax
movq %rbx, (%rax)
xorl %ebx, %ebx
jmp 0xf5d4
xorl %eax, %eax
callq 0x17d59
movl $0x3, %ebx
cmpl $0x3, (%rax)
jl 0xf5d4
leaq 0x13cf5(%rip), %rsi     # 0x2323c
leaq 0x13d3a(%rip), %rdx     # 0x23288
leaq 0x1434e(%rip), %r8      # 0x238a3
movl $0x3, %edi
movl $0x400, %ecx            # imm = 0x400
xorl %eax, %eax
callq 0x17d92
jmp 0xf5d4
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf5c7
leaq 0x13cc1(%rip), %rsi     # 0x2323c
leaq 0x13d06(%rip), %rdx     # 0x23288
leaq 0x1344a(%rip), %r8      # 0x229d3
movl $0x3, %edi
movl $0x410, %ecx            # imm = 0x410
jmp 0xf5c0
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0xf5c7
leaq 0x13c94(%rip), %rsi     # 0x2323c
leaq 0x13cd9(%rip), %rdx     # 0x23288
leaq 0x1369c(%rip), %r8      # 0x22c52
movl $0x3, %edi
movl $0x416, %ecx            # imm = 0x416
xorl %eax, %eax
callq 0x17d92
movq %rbx, %rdi
callq 0x3450
movl $0x2, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq