Language: C

#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct priority_queue{
	size_t __nmemb;
	size_t __size;
	int (*__compar) (const void*, const void*);
	size_t length;
	void *heap;
	void *temp;
	int (*push)(struct priority_queue*, int);
	int (*pop)(struct priority_queue*);
	void (*clear)(struct priority_queue*);
	void (*dispose)(struct priority_queue*);
};

int priority_queue_push(struct priority_queue *p, int value){
	if(p->length == p->__nmemb){
		return -1;
	}
	void *heap = p->heap - p->__size;
	p->length++;
	memcpy(heap+(p->length*p->__size), (void*)&value, p->__size);

	size_t node = p->length;
	void *pnt = heap+node*p->__size;
	void *pnt2 = heap+(node/2)*p->__size;
	while(node!=1 && p->__compar(pnt, pnt2)<0){
		memcpy(p->temp, pnt, p->__size);
		memcpy(pnt, pnt2, p->__size);
		memcpy(pnt2, p->temp, p->__size);
		node/=2;
		*pnt = heap+node*p->__size;
		*pnt2 = heap+(node/2)*p->__size;
	}
	return 0;
}

int priority_queue_pop(struct priority_queue *p){
	if(p->length == 0){
		return 0;
	}
	int ret;
	size_t node, downto;
	size_t left, right;
	char f;
	void *heap = p->heap - p->__size;
	
	ret = *((int*)(heap+p->__size));
	
	memcpy(heap+p->__size, heap+(p->length*p->__size), p->__size);
	p->length--;
	node = 1;
	while(1) {
		downto = node;
		left = node<<1;
		right = left+1;
		if (left<=p->length && p->__compar(heap+downto*p->__size, heap+left*p->__size)>0){
			downto=left;
		}
		if (right<=p->length && p->__compar(heap+downto*p->__size, heap+right*p->__size)>0){
			downto = right;
		}
		if(downto==node){
			break;
		}
		memcpy(p->temp, heap+node*p->__size, p->__size);
		memcpy(heap+node*p->__size, heap+downto*p->__size, p->__size);
		memcpy(heap+downto*p->__size, p->temp, p->__size);
		node = downto;
	}
    return ret;
}

void priority_queue_clear(struct priority_queue *p){;
	p->length = 0;
}

void priority_queue_dispose(struct priority_queue *p){
	free(p->heap);
}

int create_priority_queue(struct priority_queue *p, size_t __nmemb, /*size_t __size, */int (*__compar) (const void*, const void*)){
	size_t __size = sizeof(int);
	if((p->heap = malloc(__nmemb * __size)) == NULL){
		return -1;
	}
	if((p->temp = malloc(__size)) == NULL){
		free(p->heap);
		return -1;
	}
	p->__nmemb = __nmemb;
	p->__size = __size;
	p->__compar = __compar;
	p->length = 0;
	p->push = priority_queue_push;
	p->pop = priority_queue_pop;
	p->clear = priority_queue_clear;
	p->dispose = priority_queue_dispose;
	return 0;
}

int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}

struct priority_queue A;
int N, M, a, i;
long sum;

int main(void){
	scanf("%d%d", &N, &M);
	create_priority_queue(&A, N, compare_int);
	for(i=0; i<N; i++){
		scanf("%d", &a);
		sum += a;
		A.push(&A, a);
	}
	for(i=0; i<M; i++){
		a = A.pop(&A);
		sum -= (a+1)>>1;
		A.push(&A, a>>1);
	}
	printf("%ld\n", sum);
}



Compiler output:
main.c: In function 'priority_queue_push':
main.c:35:17: warning: dereferencing 'void *' pointer
   35 |                 *pnt = heap+node*p->__size;
      |                 ^~~~
main.c:35:22: error: invalid use of void expression
   35 |                 *pnt = heap+node*p->__size;
      |                      ^
main.c:36:17: warning: dereferencing 'void *' pointer
   36 |                 *pnt2 = heap+(node/2)*p->__size;
      |                 ^~~~~
main.c:36:23: error: invalid use of void expression
   36 |                 *pnt2 = heap+(node/2)*p->__size;
      |                       ^