// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/handlers.c
// Function: route_unbind_command_handler
void route_unbind_command_handler(EagleClient *client)
{
	ProtocolRequestRouteUnbind *req = (ProtocolRequestRouteUnbind*)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_UNBIND_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;
	}

	if (unbind_route_t(route, queue_t, req->body.key) == EG_STATUS_ERR) {
		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 $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 0x98eb
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x6980
jmp 0x9a85
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x20, %rax
cmpq $0x0, %rax
jne 0x9942
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x2, %rax
cmpq $0x0, %rax
jne 0x9942
movq -0x8(%rbp), %rcx
movabsq $0x10000000000, %rax    # imm = 0x10000000000
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
jne 0x9942
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x5, %edx
callq 0x6980
jmp 0x9a85
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x40, %esi
callq 0x63b0
cmpl $0x0, %eax
je 0x9992
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
addq $0x40, %rdi
movl $0x40, %esi
callq 0x63b0
cmpl $0x0, %eax
je 0x9992
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
addq $0x80, %rdi
movl $0x20, %esi
callq 0x62a0
cmpl $0x0, %eax
jne 0x99ad
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x7, %edx
callq 0x6980
jmp 0x9a85
leaq 0xd8fc(%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 0x99f1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x9, %edx
callq 0x6980
jmp 0x9a85
leaq 0xd8b8(%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 0x9a36
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x9, %edx
callq 0x6980
jmp 0x9a85
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
addq $0x80, %rdx
callq 0xdf10
cmpl $-0x1, %eax
jne 0x9a6f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x2, %edx
callq 0x6980
jmp 0x9a85
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)