// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/handlers.c
// Function: route_bind_command_handler
void route_bind_command_handler(EagleClient *client)
{
	ProtocolRequestRouteBind *req = (ProtocolRequestRouteBind*)client->request;
	Route_t *route;
	Queue_t *queue_t;

	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_BIND_PERM)) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR_ACCESS);
		return;
	}

	if (!check_input_buffer2(req->body.name, 64) || !check_input_buffer2(req->body.queue, 64)
		|| !check_input_buffer1(req->body.key, 32)) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR_VALUE);
		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;
	}

	queue_t = find_queue_t(server->queues, req->body.queue);
	if (!queue_t) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR_NOT_FOUND);
		return;
	}

	bind_route_t(route, queue_t, req->body.key);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0xa8, 0x20(%rax)
jae 0x972b
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x6980
jmp 0x98a5
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x20, %rax
cmpq $0x0, %rax
jne 0x9782
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0x9782
movq -0x8(%rbp), %rcx
movabsq $0x8000000000, %rax     # imm = 0x8000000000
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
jne 0x9782
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x5, %edx
callq 0x6980
jmp 0x98a5
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x40, %esi
callq 0x63b0
cmpl $0x0, %eax
je 0x97d2
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
addq $0x40, %rdi
movl $0x40, %esi
callq 0x63b0
cmpl $0x0, %eax
je 0x97d2
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
addq $0x80, %rdi
movl $0x20, %esi
callq 0x62a0
cmpl $0x0, %eax
jne 0x97ed
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x7, %edx
callq 0x6980
jmp 0x98a5
leaq 0xdabc(%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 0x982e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x9, %edx
callq 0x6980
jmp 0x98a5
leaq 0xda7b(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x170(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
addq $0x40, %rsi
callq 0xd500
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x9873
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x9, %edx
callq 0x6980
jmp 0x98a5
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
addq $0x80, %rdx
callq 0xde50
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x1, %edx
callq 0x6980
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)