// File: /workspace/github_c_makefile_star2_O3/GangZhuo[P]dohclient/src/dns_request.c
// Function: req_new
req_t* req_new(const char* data, int datalen,
	int listen,
	void* from, int fromlen, int fromtcp)
{
	req_t* req;
	ns_msg_t *msg;

	req = (req_t*)malloc(sizeof(req_t));
	if (!req) {
		loge("alloc\n");
		return NULL;
	}

	memset(req, 0, sizeof(req_t));

	if (fromlen > 0) {
		req->from = malloc(fromlen);
		if (!req->from) {
			loge("alloc\n");
			free(req);
			return NULL;
		}
		memcpy(req->from, from, fromlen);
		req->fromlen = fromlen;
	}
	else {
		req->from = from;
		req->fromlen = fromlen;
	}

	msg = (ns_msg_t*)malloc(sizeof(ns_msg_t));
	if (!msg) {
		loge("alloc\n");
		free(req);
		return NULL;
	}

	if (init_ns_msg(msg)) {
		loge("init_ns_msg() error\n");
		free(msg);
		free(req);
		return NULL;
	}

	if (ns_parse(msg, (const uint8_t*)data, datalen)) {
		loge("ns_parse() error\n");
		ns_msg_free(msg);
		free(msg);
		free(req);
		return NULL;
	}

	req->msg = msg;
	req->listen = listen;
	req->fromtcp = fromtcp;
	req->id = ++_req_id;

	return req;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %r15d
movl %r8d, %r14d
movq %rcx, %rbp
movl %edx, %r12d
movl %esi, %r13d
movq %rdi, 0x10(%rsp)
movl $0x1, %edi
movl $0x90, %esi
callq 0x3240
testq %rax, %rax
je 0x13c84
movq %rax, %rbx
testl %r14d, %r14d
jle 0x13cc3
movl %r13d, 0xc(%rsp)
movl %r12d, %r13d
movl %r15d, %r12d
movl %r14d, %r15d
movq %r15, %rdi
callq 0x34b0
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x13d59
movq %rax, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x32b0
movl %r12d, %r15d
movl %r13d, %r12d
movl 0xc(%rsp), %r13d
jmp 0x13cc7
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x13ded
leaq 0xffae(%rip), %rsi      # 0x23c4b
leaq 0xf003(%rip), %rdx      # 0x22ca7
leaq 0xfc08(%rip), %r8       # 0x238b3
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x10, %ecx
xorl %eax, %eax
callq 0x1771e
jmp 0x13ded
movq %rbp, 0x18(%rbx)
movl %r14d, 0x20(%rbx)
movl $0x20, %edi
callq 0x34b0
testq %rax, %rax
je 0x13d28
movq %rax, %r14
movq %rax, %rdi
callq 0x19496
testl %eax, %eax
je 0x13d8d
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x13ddb
leaq 0xff47(%rip), %rsi      # 0x23c4b
leaq 0xef9c(%rip), %rdx      # 0x22ca7
leaq 0xe89a(%rip), %r8       # 0x225ac
movl $0x3, %edi
movl $0x2d, %ecx
xorl %eax, %eax
callq 0x1771e
jmp 0x13ddb
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x13de3
leaq 0xff0c(%rip), %rsi      # 0x23c4b
leaq 0xef61(%rip), %rdx      # 0x22ca7
leaq 0xfb66(%rip), %r8       # 0x238b3
movl $0x3, %edi
movl $0x27, %ecx
jmp 0x13d84
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x13de3
leaq 0xfedf(%rip), %rsi      # 0x23c4b
leaq 0xef34(%rip), %rdx      # 0x22ca7
leaq 0xfb39(%rip), %r8       # 0x238b3
movl $0x3, %edi
movl $0x19, %ecx
xorl %eax, %eax
callq 0x1771e
jmp 0x13de3
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %r13d, %edx
callq 0x1a0ca
testl %eax, %eax
je 0x13dff
xorl %eax, %eax
callq 0x176e5
cmpl $0x3, (%rax)
jl 0x13dd3
leaq 0xfe97(%rip), %rsi      # 0x23c4b
leaq 0xeeec(%rip), %rdx      # 0x22ca7
leaq 0xf1cf(%rip), %r8       # 0x22f91
movl $0x3, %edi
movl $0x34, %ecx
xorl %eax, %eax
callq 0x1771e
movq %r14, %rdi
callq 0x19ae0
movq %r14, %rdi
callq 0x3450
movq %rbx, %rdi
callq 0x3450
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x8(%rbx)
movl %r12d, 0x10(%rbx)
movl %r15d, 0x24(%rbx)
movl 0x19903(%rip), %eax     # 0x2d714
incl %eax
movl %eax, 0x198fb(%rip)     # 0x2d714
movl %eax, (%rbx)
jmp 0x13ded