// File: /workspace/github_c_makefile_star2_O1/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 $0x90, %edi
callq 0x34b0
testq %rax, %rax
je 0x14166
movq %rax, %rbx
movl $0x90, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x31e0
testl %r14d, %r14d
jle 0x141a5
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 0x1423b
movq %rax, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x32b0
movl %r12d, %r15d
movl %r13d, %r12d
movl 0xc(%rsp), %r13d
jmp 0x141a9
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x142cf
leaq 0xfac0(%rip), %rsi      # 0x23c3f
leaq 0xeb19(%rip), %rdx      # 0x22c9f
leaq 0xf716(%rip), %r8       # 0x238a3
xorl %ebx, %ebx
movl $0x3, %edi
movl $0x10, %ecx
xorl %eax, %eax
callq 0x17d92
jmp 0x142cf
movq %rbp, 0x18(%rbx)
movl %r14d, 0x20(%rbx)
movl $0x20, %edi
callq 0x34b0
testq %rax, %rax
je 0x1420a
movq %rax, %r14
movq %rax, %rdi
callq 0x19b12
testl %eax, %eax
je 0x1426f
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x142bd
leaq 0xfa59(%rip), %rsi      # 0x23c3f
leaq 0xeab2(%rip), %rdx      # 0x22c9f
leaq 0xe3d8(%rip), %r8       # 0x225cc
movl $0x3, %edi
movl $0x2d, %ecx
xorl %eax, %eax
callq 0x17d92
jmp 0x142bd
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x142c5
leaq 0xfa1e(%rip), %rsi      # 0x23c3f
leaq 0xea77(%rip), %rdx      # 0x22c9f
leaq 0xf674(%rip), %r8       # 0x238a3
movl $0x3, %edi
movl $0x27, %ecx
jmp 0x14266
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x142c5
leaq 0xf9f1(%rip), %rsi      # 0x23c3f
leaq 0xea4a(%rip), %rdx      # 0x22c9f
leaq 0xf647(%rip), %r8       # 0x238a3
movl $0x3, %edi
movl $0x19, %ecx
xorl %eax, %eax
callq 0x17d92
jmp 0x142c5
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %r13d, %edx
callq 0x1a7e0
testl %eax, %eax
je 0x142e1
xorl %eax, %eax
callq 0x17d59
cmpl $0x3, (%rax)
jl 0x142b5
leaq 0xf9a9(%rip), %rsi      # 0x23c3f
leaq 0xea02(%rip), %rdx      # 0x22c9f
leaq 0xece5(%rip), %r8       # 0x22f89
movl $0x3, %edi
movl $0x34, %ecx
xorl %eax, %eax
callq 0x17d92
movq %r14, %rdi
callq 0x1a1dd
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 0x19421(%rip), %eax     # 0x2d714
incl %eax
movl %eax, 0x19419(%rip)     # 0x2d714
movl %eax, (%rbx)
jmp 0x142cf