// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/channel_doh.c
// Function: channel_doh_create
int channel_doh_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_doh_t* ctx;

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

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

	if (ctx->keep_alive < 0) {
		loge("invalid \"keep-alive\"\n");
		free(ctx);
		return CHANNEL_WRONG_ARG;
	}

	/* Compatible with old configuration */
	if (ctx->keep_alive == 1)
		ctx->keep_alive = DEFAULT_HTTP_TIMEOUT;

	ctx->http = http_create(
		proxies,
		proxy_num,
		ctx->keep_alive);
	if (!ctx->http) {
		free(ctx);
		return CHANNEL_ALLOC;
	}

	rbtree_init(&ctx->reqdic, rbcmp);
	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
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 $0x3a0, %edi            # imm = 0x3A0
callq 0x34d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x121f3
jmp 0x121b3
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x121e5
movl $0x3, %edi
leaq 0x24438(%rip), %rsi     # 0x36603
leaq 0x24443(%rip), %rdx     # 0x36615
movl $0x3f6, %ecx            # imm = 0x3F6
leaq 0x24cb9(%rip), %r8      # 0x36e97
movb $0x0, %al
callq 0x243b0
jmp 0x121e7
movl $0x3, -0x4(%rbp)
jmp 0x12464
movq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x3a0, %edx            # imm = 0x3A0
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, 0x13c(%rax)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x12470
cmpl $0x0, %eax
je 0x122c5
jmp 0x1227c
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x122ae
movl $0x3, %edi
leaq 0x2436f(%rip), %rsi     # 0x36603
leaq 0x2437a(%rip), %rdx     # 0x36615
movl $0x406, %ecx            # imm = 0x406
leaq 0x23d02(%rip), %r8      # 0x35fa9
movb $0x0, %al
callq 0x243b0
jmp 0x122b0
movq -0x40(%rbp), %rdi
callq 0x3460
movl $0x2, -0x4(%rbp)
jmp 0x12464
movq -0x40(%rbp), %rax
cmpl $0x0, 0x13c(%rax)
jg 0x1231d
jmp 0x122d4
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x12306
movl $0x3, %edi
leaq 0x24317(%rip), %rsi     # 0x36603
leaq 0x24322(%rip), %rdx     # 0x36615
movl $0x40c, %ecx            # imm = 0x40C
leaq 0x23f29(%rip), %r8      # 0x36228
movb $0x0, %al
callq 0x243b0
jmp 0x12308
movq -0x40(%rbp), %rdi
callq 0x3460
movl $0x2, -0x4(%rbp)
jmp 0x12464
movq -0x40(%rbp), %rax
cmpl $0x0, 0x130(%rax)
jge 0x12375
jmp 0x1232c
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1235e
movl $0x3, %edi
leaq 0x242bf(%rip), %rsi     # 0x36603
leaq 0x242ca(%rip), %rdx     # 0x36615
movl $0x412, %ecx            # imm = 0x412
leaq 0x23ee4(%rip), %r8      # 0x3623b
movb $0x0, %al
callq 0x243b0
jmp 0x12360
movq -0x40(%rbp), %rdi
callq 0x3460
movl $0x2, -0x4(%rbp)
jmp 0x12464
movq -0x40(%rbp), %rax
cmpl $0x1, 0x130(%rax)
jne 0x12390
movq -0x40(%rbp), %rax
movl $0x4b0, 0x130(%rax)     # imm = 0x4B0
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
movq -0x40(%rbp), %rax
movl 0x130(%rax), %edx
callq 0x1fc30
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x80(%rax)
jne 0x123d7
movq -0x40(%rbp), %rdi
callq 0x3460
movl $0x3, -0x4(%rbp)
jmp 0x12464
jmp 0x123d9
movq -0x40(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x40(%rbp), %rax
leaq 0x720(%rip), %rcx       # 0x12b10
movq %rcx, 0x70(%rax)
jmp 0x123f6
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 0x71f(%rip), %rcx       # 0x12b40
movq %rcx, 0x30(%rax)
movq -0x40(%rbp), %rax
leaq 0x760(%rip), %rcx       # 0x12b90
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rax
leaq 0x7d1(%rip), %rcx       # 0x12c10
movq %rcx, 0x40(%rax)
movq -0x40(%rbp), %rax
leaq 0x982(%rip), %rcx       # 0x12dd0
movq %rcx, 0x48(%rax)
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)