// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/handlers.c
// Function: route_push_command_handler
void route_push_command_handler(EagleClient *client)
{
	ProtocolRequestRoutePush *req = (ProtocolRequestRoutePush*)client->request;
	Route_t *route;
	Object *msg;
	char *msg_data;
	uint32_t expire;
	size_t msg_size;

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

	if (!check_input_buffer2(req->body.name, 64) || !check_input_buffer1(req->body.key, 32)) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR_VALUE);
		return;
	}

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

	route = find_route_t(server->routes, req->body.name);
	if (!route) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR_NOT_FOUND);
		return;
	}

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

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

	msg = create_dup_object(msg_data, msg_size);
	EG_OBJECT_RESET_REFCOUNT(msg);

	if (push_message_route_t(route, req->body.key, msg, expire) != EG_STATUS_OK) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR);
		return;
	}

	add_status_response(client, req->header.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 $0x6d, 0x20(%rax)
jae 0x9ac8
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x6980
jmp 0x9c9b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x20, %rax
cmpq $0x0, %rax
jne 0x9b1f
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0x9b1f
movq -0x8(%rbp), %rcx
movabsq $0x20000000000, %rax    # imm = 0x20000000000
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
jne 0x9b1f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x5, %edx
callq 0x6980
jmp 0x9c9b
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x40, %esi
callq 0x63b0
cmpl $0x0, %eax
je 0x9b51
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
addq $0x40, %rdi
movl $0x20, %esi
callq 0x62a0
cmpl $0x0, %eax
jne 0x9b6c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x7, %edx
callq 0x6980
jmp 0x9c9b
leaq 0xd73d(%rip), %rax      # 0x172b0
movq (%rax), %rax
cmpl $0x0, 0x1b0(%rax)
je 0x9b9a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x6, %edx
callq 0x6980
jmp 0x9c9b
leaq 0xd70f(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x178(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0xdfe0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x9bde
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x9, %edx
callq 0x6980
jmp 0x9c9b
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x68, %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
subq $0x6c, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x68(%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x9c30
leaq 0xd693(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x190(%rax), %rcx
movl -0x2c(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6760
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
addq $0x40, %rsi
movq -0x20(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0xdd50
cmpl $0x0, %eax
je 0x9c85
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x2, %edx
callq 0x6980
jmp 0x9c9b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x1, %edx
callq 0x6980
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)