// File: /workspace/github_c_makefile_star2_O3/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 $0x1, %edi
movl $0x4c0, %esi            # imm = 0x4C0
callq 0x3240
testq %rax, %rax
je 0xefe4
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), %r15d
movl %r15d, 0x4b8(%rbx)
movq $0x0, 0x10(%rsp)
testq %r14, %r14
je 0xf0a8
movq %r14, %rdi
callq 0x3610
movq %rax, %r14
leaq 0x13c0e(%rip), %rsi     # 0x22a39
leaq 0x10(%rsp), %rdx
movq %rax, %rdi
callq 0x3600
testq %rax, %rax
je 0xef89
movq %rax, %rbp
movq %r14, 0x8(%rsp)
leaq 0x70(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x13be0(%rip), %r14     # 0x22a39
leaq 0x10(%rsp), %r15
leaq 0x146e5(%rip), %r12     # 0x2354a
cmpb $0x0, (%rbp)
je 0xef7d
movq %rbp, %rdi
movl $0x3d, %esi
callq 0x3150
testq %rax, %rax
je 0xef64
movq %rax, %r13
movb $0x0, (%rax)
incq %r13
movq %rbp, %rdi
movq %r12, %rsi
callq 0x34e0
testl %eax, %eax
je 0xef0a
movq %rbp, %rdi
leaq 0x13c66(%rip), %rsi     # 0x22b0d
callq 0x34e0
testl %eax, %eax
je 0xef38
movq %rbp, %rdi
leaq 0x14b1f(%rip), %rsi     # 0x239dd
callq 0x34e0
testl %eax, %eax
je 0xef4f
xorl %eax, %eax
callq 0x176e5
cmpl $0x4, (%rax)
jl 0xef64
movq %r13, (%rsp)
movl $0x4, %edi
leaq 0x14361(%rip), %rsi     # 0x2324c
leaq 0x13b68(%rip), %rdx     # 0x22a5a
movl $0x3e2, %ecx            # imm = 0x3E2
leaq 0x13cfe(%rip), %r8      # 0x22bfc
movq %rbp, %r9
xorl %eax, %eax
callq 0x1771e
jmp 0xef64
movq %r13, %rdi
movq 0x18(%rsp), %rsi
movl $0x8, %edx
movl $0x88, %ecx
leaq 0x13b34(%rip), %r8      # 0x22a57
callq 0x181bf
testl %eax, %eax
jle 0xf055
movl %eax, 0x4b0(%rbx)
jmp 0xef64
movq %r13, %rdi
leaq 0x12880(%rip), %rsi     # 0x217c2
callq 0x34e0
movl %eax, 0x4b4(%rbx)
jmp 0xef64
cmpb $0x0, (%r13)
je 0xef64
movq %r13, %rdi
callq 0x3570
movl %eax, 0x4b8(%rbx)
xorl %edi, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3600
movq %rax, %rbp
testq %rax, %rax
jne 0xee65
movl 0x4b8(%rbx), %r15d
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x3450
testl %r15d, %r15d
jle 0xf024
movq %rbx, %rax
addq $0x58, %rax
movq %rax, 0x58(%rbx)
movq %rax, 0x60(%rbx)
leaq 0x148(%rip), %rax       # 0xf0f8
movq %rax, 0x30(%rbx)
leaq 0x295(%rip), %rax       # 0xf250
movq %rax, 0x38(%rbx)
leaq 0x9d7(%rip), %rax       # 0xf99d
movq %rax, 0x40(%rbx)
leaq 0x9df(%rip), %rax       # 0xf9b0
movq %rax, 0x48(%rbx)
movq 0x20(%rsp), %rax
movq %rbx, (%rax)
xorl %ebx, %ebx
jmp 0xf0e7
xorl %eax, %eax
callq 0x176e5
movl $0x3, %ebx
cmpl $0x3, (%rax)
jl 0xf0e7
leaq 0x1424c(%rip), %rsi     # 0x2324c
leaq 0x14291(%rip), %rdx     # 0x23298
leaq 0x148a5(%rip), %r8      # 0x238b3
movl $0x3, %edi
movl $0x400, %ecx            # imm = 0x400
xorl %eax, %eax
callq 0x1771e
jmp 0xf0e7
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xf0da
leaq 0x14211(%rip), %rsi     # 0x2324c
leaq 0x14256(%rip), %rdx     # 0x23298
leaq 0x13c11(%rip), %r8      # 0x22c5a
movl $0x3, %edi
movl $0x416, %ecx            # imm = 0x416
jmp 0xf0d3
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xf09e
cmpb $0x0, (%r13)
leaq 0x139ea(%rip), %rax     # 0x22a57
cmovneq %r13, %rax
movq %rax, (%rsp)
leaq 0x141d0(%rip), %rsi     # 0x2324c
leaq 0x139d7(%rip), %rdx     # 0x22a5a
leaq 0x139db(%rip), %r8      # 0x22a65
movl $0x3, %edi
movl $0x3d3, %ecx            # imm = 0x3D3
movq %rbp, %r9
xorl %eax, %eax
callq 0x1771e
movq 0x8(%rsp), %rdi
callq 0x3450
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0xf0da
leaq 0x14191(%rip), %rsi     # 0x2324c
leaq 0x141d6(%rip), %rdx     # 0x23298
leaq 0x13912(%rip), %r8      # 0x229db
movl $0x3, %edi
movl $0x410, %ecx            # imm = 0x410
xorl %eax, %eax
callq 0x1771e
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