// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/handlers.c
// Function: queue_push_command_handler
void queue_push_command_handler(EagleClient *client)
{
	ProtocolRequestHeader *req = (ProtocolRequestHeader*)client->request;
	Queue_t *queue_t;
	Object *msg;
	char *queue_name, *msg_data;
	uint32_t expire;
	size_t msg_size;

	if (client->pos < (sizeof(*req) + 69)) {
		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_PUSH_PERM)) {
		add_status_response(client, req->cmd, EG_PROTOCOL_STATUS_ERROR_ACCESS);
		return;
	}

	queue_name = client->request + sizeof(*req);

	if (!check_input_buffer2(queue_name, 64)) {
		add_status_response(client, req->cmd, EG_PROTOCOL_STATUS_ERROR_VALUE);
		return;
	}

	if (server->nomemory) {
		add_status_response(client, req->cmd, EG_PROTOCOL_STATUS_ERROR_MEMORY);
		return;
	}

	queue_t = find_queue_t(client->declared_queues, queue_name);
	if (!queue_t) {
		add_status_response(client, req->cmd, EG_PROTOCOL_STATUS_ERROR_NOT_DECLARED);
		return;
	}

	msg_data = client->request + sizeof(*req) + 64 + sizeof(uint32_t);
	msg_size = client->pos - (sizeof(*req) + 64 + sizeof(uint32_t));
	expire = *((uint32_t*)(client->request + sizeof(*req) + 64));

	if (expire) {
		expire += server->now_timems;
	}

	msg = create_dup_object(msg_data, msg_size);

	if (push_message_queue_t(queue_t, msg, expire) == EG_STATUS_ERR) {
		add_status_response(client, req->cmd, EG_PROTOCOL_STATUS_ERROR);
		return;
	}

	add_status_response(client, req->cmd, EG_PROTOCOL_STATUS_SUCCESS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x4d, 0x20(%rax)
jae 0x82a8
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x6980
jmp 0x8448
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x20, %rax
cmpq $0x0, %rax
jne 0x82fb
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x82fb
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x4000000, %rax        # imm = 0x4000000
cmpq $0x0, %rax
jne 0x82fb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x5, %edx
callq 0x6980
jmp 0x8448
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x40, %esi
callq 0x63b0
cmpl $0x0, %eax
jne 0x8339
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x7, %edx
callq 0x6980
jmp 0x8448
leaq 0xef70(%rip), %rax      # 0x172b0
movq (%rax), %rax
cmpl $0x0, 0x1b0(%rax)
je 0x8367
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x6, %edx
callq 0x6980
jmp 0x8448
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0xd500
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x839e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x8, %edx
callq 0x6980
jmp 0x8448
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x8, %rax
addq $0x40, %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
subq $0x4c, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x48(%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x83f4
leaq 0xeecf(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x190(%rax), %rcx
movl -0x34(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x6760
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x34(%rbp), %edx
callq 0xd150
cmpl $-0x1, %eax
jne 0x8432
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x2, %edx
callq 0x6980
jmp 0x8448
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x1, %edx
callq 0x6980
addq $0x40, %rsp
popq %rbp
retq
nop