// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/handlers.c
// Function: route_list_command_handler
void route_list_command_handler(EagleClient *client)
{
	ProtocolRequestRouteList *req = (ProtocolRequestRouteList*)client->request;
	ProtocolResponseHeader res;
	ListIterator iterator;
	ListNode *node;
	Route_t *route;
	char *list;
	uint32_t keys;
	int i;

	if (client->pos < sizeof(*req)) {
		add_status_response(client, 0, EG_PROTOCOL_STATUS_ERROR_PACKET);
		return;
	}

	if (!BIT_CHECK(client->perm, EG_USER_ADMIN_PERM) && !BIT_CHECK(client->perm, EG_USER_ROUTE_PERM)
		&& !BIT_CHECK(client->perm, EG_USER_ROUTE_LIST_PERM)) {
		add_status_response(client, req->cmd, EG_PROTOCOL_STATUS_ERROR_ACCESS);
		return;
	}

	set_response_header(&res, req->cmd, EG_PROTOCOL_STATUS_SUCCESS,
		EG_LIST_LENGTH(server->routes) * (64 + (sizeof(uint32_t) * 2)));

	list = (char*)xcalloc(sizeof(res) + res.bodylen);

	memcpy(list, &res, sizeof(res));

	i = sizeof(res);
	list_rewind(server->routes, &iterator);
	while ((node = list_next_node(&iterator)) != NULL)
	{
		route = EG_LIST_NODE_VALUE(node);

		keys = EG_KEYLIST_LENGTH(route->keys);

		memcpy(list + i, route->name, strlenz(route->name));
		i += 64;
		memcpy(list + i, &route->flags, sizeof(uint32_t));
		i += sizeof(uint32_t);
		memcpy(list + i, &keys, sizeof(uint32_t));
		i += sizeof(uint32_t);
	}

	add_response(client, list, sizeof(res) + res.bodylen);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x8, 0x20(%rax)
jae 0x9138
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x6980
jmp 0x92bc
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x20, %rax
cmpq $0x0, %rax
jne 0x918f
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0x918f
movq -0x8(%rbp), %rcx
movabsq $0x1000000000, %rax     # imm = 0x1000000000
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
jne 0x918f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x5, %edx
callq 0x6980
jmp 0x92bc
movq -0x10(%rbp), %rax
movb 0x2(%rax), %al
leaq 0xe113(%rip), %rcx      # 0x172b0
movq (%rcx), %rcx
movq 0x178(%rcx), %rcx
movl 0x20(%rcx), %ecx
imulq $0x48, %rcx, %rcx
leaq -0x18(%rbp), %rdi
movl $0x1, %edx
movzbl %al, %esi
callq 0x6c70
movl -0x14(%rbp), %eax
movl %eax, %edi
addq $0x8, %rdi
callq 0x5160
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, (%rax)
movl $0x8, -0x48(%rbp)
leaq 0xe0c6(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x178(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0xc520
leaq -0x28(%rbp), %rdi
callq 0xc450
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x92a6
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x50(%rax), %rax
movl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rax
movslq -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2160
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
callq 0x22c0
movl -0x48(%rbp), %eax
addl $0x40, %eax
movl %eax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movslq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl 0x40(%rdx), %edx
movl %edx, (%rax,%rcx)
movslq -0x48(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl -0x44(%rbp), %edx
movl %edx, (%rax,%rcx)
movslq -0x48(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x48(%rbp)
jmp 0x91fd
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x14(%rbp), %eax
addq $0x8, %rax
movl %eax, %edx
callq 0x6cb0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)