// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x1
popq %rdi
movl $0x90, %esi
callq 0x3250
testq %rax, %rax
je 0x1306e
movq %rax, %rbx
testl %r14d, %r14d
jle 0x130a9
movl %r13d, 0xc(%rsp)
movl %r12d, %r13d
movl %r15d, %r12d
movl %r14d, %r15d
movq %r15, %rdi
callq 0x34c0
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x13134
movq %rax, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x32c0
movl %r12d, %r15d
movl %r13d, %r12d
movl 0xc(%rsp), %r13d
jmp 0x130ad
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x131c0
leaq 0xebc4(%rip), %rsi      # 0x21c4b
leaq 0xdc19(%rip), %rdx      # 0x20ca7
leaq 0xe81e(%rip), %r8       # 0x218b3
xorl %ebx, %ebx
pushq $0x3
popq %rdi
pushq $0x10
popq %rcx
xorl %eax, %eax
callq 0x1662e
jmp 0x131c0
movq %rbp, 0x18(%rbx)
movl %r14d, 0x20(%rbx)
pushq $0x20
popq %rdi
callq 0x34c0
testq %rax, %rax
je 0x13108
movq %rax, %r14
movq %rax, %rdi
callq 0x18296
testl %eax, %eax
je 0x13164
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x131ae
leaq 0xeb63(%rip), %rsi      # 0x21c4b
leaq 0xdbb8(%rip), %rdx      # 0x20ca7
leaq 0xd4b6(%rip), %r8       # 0x205ac
pushq $0x3
popq %rdi
pushq $0x2d
popq %rcx
xorl %eax, %eax
callq 0x1662e
jmp 0x131ae
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x131b6
leaq 0xeb2c(%rip), %rsi      # 0x21c4b
leaq 0xdb81(%rip), %rdx      # 0x20ca7
leaq 0xe786(%rip), %r8       # 0x218b3
pushq $0x3
popq %rdi
pushq $0x27
jmp 0x1315a
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x131b6
leaq 0xeb04(%rip), %rsi      # 0x21c4b
leaq 0xdb59(%rip), %rdx      # 0x20ca7
leaq 0xe75e(%rip), %r8       # 0x218b3
pushq $0x3
popq %rdi
pushq $0x19
popq %rcx
xorl %eax, %eax
callq 0x1662e
jmp 0x131b6
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %r13d, %edx
callq 0x18e8f
testl %eax, %eax
je 0x131d2
xorl %eax, %eax
callq 0x165f5
cmpl $0x3, (%rax)
jl 0x131a6
leaq 0xeac0(%rip), %rsi      # 0x21c4b
leaq 0xdb15(%rip), %rdx      # 0x20ca7
leaq 0xddf8(%rip), %r8       # 0x20f91
pushq $0x3
popq %rdi
pushq $0x34
popq %rcx
xorl %eax, %eax
callq 0x1662e
movq %r14, %rdi
callq 0x188ce
movq %r14, %rdi
callq 0x3460
movq %rbx, %rdi
callq 0x3460
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 0x1b540(%rip), %eax     # 0x2e724
incl %eax
movl %eax, 0x1b538(%rip)     # 0x2e724
movl %eax, (%rbx)
jmp 0x131c0