// File: /workspace/github_c_makefile_star2_O0/GangZhuo[P]dohclient/src/main.c
// Function: req_add_new
static req_t* req_add_new(const char* data, int datalen,
	int listen,
	void* from, int fromlen, int fromtcp)
{
	req_t* req;
	const char* key;

	req = req_new(data, datalen, listen, from, fromlen, fromtcp);
	if (!req) {
		return NULL;
	}

	if (loglevel > LOG_DEBUG) {
		req_print(req);
	}

	if (!msg_check(req->msg)) {
		req_destroy(req);
		return NULL;
	}

	key = req_key(req);

	if (loglevel >= LOG_INFO) {
		logi("query %s from %s by %s\n",
			key,
			req->fromtcp
			? get_sockname(((peer_t*)req->from)->conn.sock)
			: get_addrname((struct sockaddr*)req->from),
			req->fromtcp ? "tcp" : "udp");
	}

	if (!reqdic_add(req, key)) {
		req_destroy(req);
		return NULL;
	}

	/* add to peer's request list */
	if (fromtcp) {
		peer_t* peer = from;
		dllist_add(&peer->reqs, &req->entry_peer);
	}

	/* add to global request list */
	dllist_add(&reqs, &req->entry);

	/* set expire */
	req->expire = time(NULL) + conf.timeout;

	logd("request added (id:%d) - %s\n",
		req->id,
		key);

	return req;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %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)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movq -0x20(%rbp), %rcx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
callq 0x1e090
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x321c1
movq $0x0, -0x8(%rbp)
jmp 0x323f3
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jle 0x321e8
jmp 0x321cf
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jl 0x321e4
movq -0x30(%rbp), %rdi
callq 0x1e3a0
jmp 0x321e6
jmp 0x321e8
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x32580
cmpl $0x0, %eax
jne 0x32210
movq -0x30(%rbp), %rdi
callq 0x1e340
movq $0x0, -0x8(%rbp)
jmp 0x323f3
movq -0x30(%rbp), %rdi
callq 0x32700
movq %rax, -0x38(%rbp)
movb $0x0, %al
callq 0x242d0
cmpl $0x6, (%rax)
jl 0x322ce
jmp 0x3222f
movb $0x0, %al
callq 0x242d0
cmpl $0x6, (%rax)
jl 0x322ca
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x32266
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %edi
callq 0x25120
movq %rax, -0x50(%rbp)
jmp 0x32277
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x25020
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %r9
movq -0x50(%rbp), %r10
movq -0x30(%rbp), %rax
movl 0x24(%rax), %edx
leaq 0x3950(%rip), %rax      # 0x35bdd
leaq 0x394d(%rip), %rcx      # 0x35be1
cmpl $0x0, %edx
cmovneq %rcx, %rax
movl $0x6, %edi
leaq 0x691b(%rip), %rsi      # 0x38bc2
leaq 0x7775(%rip), %rdx      # 0x39a23
movl $0x130, %ecx            # imm = 0x130
leaq 0x7775(%rip), %r8       # 0x39a2f
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x322cc
jmp 0x322ce
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x32720
cmpl $0x0, %eax
jne 0x322f6
movq -0x30(%rbp), %rdi
callq 0x1e340
movq $0x0, -0x8(%rbp)
jmp 0x323f3
cmpl $0x0, -0x28(%rbp)
je 0x32349
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
addq $0x70, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x40(%rbp), %rax
movq 0x78(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movq -0x40(%rbp), %rax
movq 0x78(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
addq $0x68, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x78(%rax)
jmp 0x32349
jmp 0x3234b
movq -0x30(%rbp), %rax
leaq 0xf882(%rip), %rcx      # 0x41bd8
movq %rcx, 0x58(%rax)
movq 0xf87f(%rip), %rcx      # 0x41be0
movq -0x30(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x30(%rbp), %rcx
addq $0x58, %rcx
movq 0xf868(%rip), %rax      # 0x41be0
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
addq $0x58, %rax
movq %rax, 0xf856(%rip)      # 0x41be0
xorl %eax, %eax
movl %eax, %edi
callq 0x3330
movq %rax, %rcx
movslq 0xf813(%rip), %rax      # 0x41bb0
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movb $0x0, %al
callq 0x242d0
cmpl $0x7, (%rax)
jl 0x323e9
movq -0x30(%rbp), %rax
movl (%rax), %r9d
movq -0x38(%rbp), %rax
movl $0x7, %edi
leaq 0x67f7(%rip), %rsi      # 0x38bc2
leaq 0x7651(%rip), %rdx      # 0x39a23
movl $0x146, %ecx            # imm = 0x146
leaq 0x7669(%rip), %r8       # 0x39a47
movq %rax, (%rsp)
movb $0x0, %al
callq 0x243b0
jmp 0x323eb
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)