// File: /workspace/github_c_makefile_star2_O0/yakushstanislav[P]EagleMQ/src/handlers.c
// Function: queue_create_command_handler
void queue_create_command_handler(EagleClient *client)
{
	ProtocolRequestQueueCreate *req = (ProtocolRequestQueueCreate*)client->request;
	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_QUEUE_PERM)
		&& !BIT_CHECK(client->perm, EG_USER_QUEUE_CREATE_PERM)) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR_ACCESS);
		return;
	}

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

	if (find_queue_t(server->queues, req->body.name)) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR);
		return;
	}

	if (!req->body.max_msg || req->body.max_msg_size > EG_MAX_MSG_SIZE) {
		add_status_response(client, req->header.cmd, EG_PROTOCOL_STATUS_ERROR_VALUE);
		return;
	}

	queue_t = create_queue_t(req->body.name, req->body.max_msg,
		((req->body.max_msg_size == 0) ? EG_MAX_MSG_SIZE : req->body.max_msg_size), req->body.flags);

	list_add_value_tail(server->queues, queue_t);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x54, 0x20(%rax)
jae 0x7928
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x6980
jmp 0x7a99
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x20, %rax
cmpq $0x0, %rax
jne 0x797b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x797b
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x100000, %rax         # imm = 0x100000
cmpq $0x0, %rax
jne 0x797b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x5, %edx
callq 0x6980
jmp 0x7a99
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movl $0x40, %esi
callq 0x63b0
cmpl $0x0, %eax
jne 0x79ad
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x7, %edx
callq 0x6980
jmp 0x7a99
leaq 0xf8fc(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x170(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0xd500
cmpq $0x0, %rax
je 0x79ec
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x2, %edx
callq 0x6980
jmp 0x7a99
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
je 0x7a03
movq -0x10(%rbp), %rax
cmpl $0x7fffffff, 0x4c(%rax) # imm = 0x7FFFFFFF
jbe 0x7a1b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x7, %edx
callq 0x6980
jmp 0x7a99
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
jne 0x7a45
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x2c(%rbp)
jmp 0x7a4f
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x50(%rax), %ecx
callq 0xcd50
movq %rax, -0x18(%rbp)
leaq 0xf840(%rip), %rax      # 0x172b0
movq (%rax), %rax
movq 0x170(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0xc170
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %esi
movl $0x1, %edx
callq 0x6980
addq $0x30, %rsp
popq %rbp
retq
nop