// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/handlers.c
// Function: queue_list_command_handler
void queue_list_command_handler(EagleClient *client)
{
	ProtocolRequestQueueList *req = (ProtocolRequestQueueList*)client->request;
	ProtocolResponseHeader res;
	ListIterator iterator;
	ListNode *node;
	Queue_t *queue_t;
	uint32_t queue_size, declared_clients, subscribed_clients;
	char *list;
	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_QUEUE_PERM)
		&& !BIT_CHECK(client->perm, EG_USER_QUEUE_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->queues) * (64 + (sizeof(uint32_t) * 6)));

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

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

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

		queue_size = get_size_queue_t(queue_t);
		declared_clients = get_declared_clients_queue_t(queue_t);
		subscribed_clients = get_subscribed_clients_queue_t(queue_t);

		memcpy(list + i, queue_t->name, strlenz(queue_t->name));
		i += 64;
		memcpy(list + i, &queue_t->max_msg, sizeof(uint32_t));
		i += sizeof(uint32_t);
		memcpy(list + i, &queue_t->max_msg_size, sizeof(uint32_t));
		i += sizeof(uint32_t);
		memcpy(list + i, &queue_t->flags, sizeof(uint32_t));
		i += sizeof(uint32_t);
		memcpy(list + i, &queue_size, sizeof(uint32_t));
		i += sizeof(uint32_t);
		memcpy(list + i, &declared_clients, sizeof(uint32_t));
		i += sizeof(uint32_t);
		memcpy(list + i, &subscribed_clients, sizeof(uint32_t));
		i += sizeof(uint32_t);
	}

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %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 0x7d78
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x6980
jmp 0x7f7a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x20, %rax
cmpq $0x0, %rax
jne 0x7dcb
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x7dcb
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x800000, %rax         # imm = 0x800000
cmpq $0x0, %rax
jne 0x7dcb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x5, %edx
callq 0x6980
jmp 0x7f7a
movq -0x10(%rbp), %rax
movb 0x2(%rax), %al
leaq 0xf4d7(%rip), %rcx      # 0x172b0
movq (%rcx), %rcx
movq 0x170(%rcx), %rcx
movl 0x20(%rcx), %ecx
imulq $0x58, %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, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, (%rax)
movl $0x8, -0x54(%rbp)
leaq 0xf48a(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x170(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0xc520
leaq -0x28(%rbp), %rdi
callq 0xc450
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x7f64
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0xd610
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rdi
callq 0xd5c0
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0xd5e0
movl %eax, -0x44(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
callq 0x2160
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
callq 0x22c0
movl -0x54(%rbp), %eax
addl $0x40, %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl 0x40(%rdx), %edx
movl %edx, (%rax,%rcx)
movslq -0x54(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl 0x44(%rdx), %edx
movl %edx, (%rax,%rcx)
movslq -0x54(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl 0x48(%rdx), %edx
movl %edx, (%rax,%rcx)
movslq -0x54(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl -0x3c(%rbp), %edx
movl %edx, (%rax,%rcx)
movslq -0x54(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl -0x40(%rbp), %edx
movl %edx, (%rax,%rcx)
movslq -0x54(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl -0x44(%rbp), %edx
movl %edx, (%rax,%rcx)
movslq -0x54(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x54(%rbp)
jmp 0x7e39
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x14(%rbp), %eax
addq $0x8, %rax
movl %eax, %edx
callq 0x6cb0
addq $0x70, %rsp
popq %rbp
retq