// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movl $0x90, %edi
callq 0x34d0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1e106
jmp 0x1e0c5
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1e0f7
movl $0x3, %edi
leaq 0x192de(%rip), %rsi     # 0x373bb
leaq 0x18191(%rip), %rdx     # 0x36275
movl $0x10, %ecx
leaq 0x18da7(%rip), %r8      # 0x36e97
movb $0x0, %al
callq 0x243b0
jmp 0x1e0f9
movq $0x0, -0x8(%rbp)
jmp 0x1e333
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x90, %edx
callq 0x3200
cmpl $0x0, -0x24(%rbp)
jle 0x1e1ac
movslq -0x24(%rbp), %rdi
callq 0x34d0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x1e18b
jmp 0x1e141
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1e173
movl $0x3, %edi
leaq 0x19262(%rip), %rsi     # 0x373bb
leaq 0x18115(%rip), %rdx     # 0x36275
movl $0x19, %ecx
leaq 0x18d2b(%rip), %r8      # 0x36e97
movb $0x0, %al
callq 0x243b0
jmp 0x1e175
movq -0x30(%rbp), %rdi
callq 0x3460
movq $0x0, -0x8(%rbp)
jmp 0x1e333
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
movslq -0x24(%rbp), %rdx
callq 0x32d0
movl -0x24(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x1e1c2
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x24(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x20(%rax)
movl $0x20, %edi
callq 0x34d0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1e223
jmp 0x1e1d9
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1e20b
movl $0x3, %edi
leaq 0x191ca(%rip), %rsi     # 0x373bb
leaq 0x1807d(%rip), %rdx     # 0x36275
movl $0x27, %ecx
leaq 0x18c93(%rip), %r8      # 0x36e97
movb $0x0, %al
callq 0x243b0
jmp 0x1e20d
movq -0x30(%rbp), %rdi
callq 0x3460
movq $0x0, -0x8(%rbp)
jmp 0x1e333
movq -0x38(%rbp), %rdi
callq 0x270f0
cmpl $0x0, %eax
je 0x1e286
jmp 0x1e233
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1e265
movl $0x3, %edi
leaq 0x19170(%rip), %rsi     # 0x373bb
leaq 0x18023(%rip), %rdx     # 0x36275
movl $0x2d, %ecx
leaq 0x17944(%rip), %r8      # 0x35ba2
movb $0x0, %al
callq 0x243b0
jmp 0x1e267
movq -0x38(%rbp), %rdi
callq 0x3460
movq -0x30(%rbp), %rdi
callq 0x3460
movq $0x0, -0x8(%rbp)
jmp 0x1e333
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x284b0
cmpl $0x0, %eax
je 0x1e2f6
jmp 0x1e29d
movb $0x0, %al
callq 0x242d0
cmpl $0x3, (%rax)
jl 0x1e2cf
movl $0x3, %edi
leaq 0x19106(%rip), %rsi     # 0x373bb
leaq 0x17fb9(%rip), %rdx     # 0x36275
movl $0x34, %ecx
leaq 0x182c3(%rip), %r8      # 0x3658b
movb $0x0, %al
callq 0x243b0
jmp 0x1e2d1
movq -0x38(%rbp), %rdi
callq 0x27870
movq -0x38(%rbp), %rdi
callq 0x3460
movq -0x30(%rbp), %rdi
callq 0x3460
movq $0x0, -0x8(%rbp)
jmp 0x1e333
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x18(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x28(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x24(%rax)
movl 0x238e8(%rip), %ecx     # 0x41c04
addl $0x1, %ecx
movl %ecx, 0x238df(%rip)     # 0x41c04
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)