Language: C++

#include<bits/stdc++.h>
using namespace std;
void msort(void *a, size_t len, size_t size, int (*comp)(const void*, const void*), void *b){
    void *m[2] = {a, b};
    size_t i, j;
    void *t, *l, *r, *ll, *rr;
    size_t s;
    for(i=0, j=1; j<len; i++, j*=2){
        s = j*size;
        t = m[(i+1)&1];
        rr = m[i&1];
        size_t k;
        for(k=0; k<len-j*2; k+=j*2){
            l=rr; r=ll=rr+s; rr=ll+s;
            while(l<ll && r<rr){
                if(comp(r, l) >= 0){
                    memcpy(t, l, size); t+=size; l+=size;
                }else{
                    memcpy(t, r, size); t+=size; r+=size;
                }
            }
            memcpy(t, l, ll-l); t+=ll-l;
            memcpy(t, r, rr-r); t+=rr-r;
        }
        if(k+j < len){
            l=rr; r=ll=rr+s; rr=ll+(len-k-j)*size;
            while(l<ll && r<rr){
                if(comp(r, l) >= 0){
                    memcpy(t, l, size); t+=size; l+=size;
                }else{
                    memcpy(t, r, size); t+=size; r+=size;
                }
            }
            memcpy(t, l, ll-l); t+=ll-l;
            memcpy(t, r, rr-r); t+=rr-r;
        }
    }
    if(i&1){
        memcpy(a, b, len*size);
    }
}
int comp_int(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}
int main(){
 int N, K; cin >> N >> K;
 int h[N], t[N];
  for(int i=0; i<N; i++) cin >> h[i];
  msort(h, N, sizeof(int), comp_int, t);
  int ans = 0;
  while(ans<N && h[ans] <= K) ans++;
  cout << ans << endl;
 return 0; 
}

Compiler output:
a.cc: In function 'void msort(void*, size_t, size_t, int (*)(const void*, const void*), void*)':
a.cc:14:26: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   14 |             l=rr; r=ll=rr+s; rr=ll+s;
      |                        ~~^~
a.cc:14:35: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   14 |             l=rr; r=ll=rr+s; rr=ll+s;
      |                                 ~~^~
a.cc:17:42: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   17 |                     memcpy(t, l, size); t+=size; l+=size;
      |                                         ~^~~~~~
a.cc:17:51: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   17 |                     memcpy(t, l, size); t+=size; l+=size;
      |                                                  ~^~~~~~
a.cc:19:42: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   19 |                     memcpy(t, r, size); t+=size; r+=size;
      |                                         ~^~~~~~
a.cc:19:51: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   19 |                     memcpy(t, r, size); t+=size; r+=size;
      |                                                  ~^~~~~~
a.cc:22:29: error: invalid use of 'void'
   22 |             memcpy(t, l, ll-l); t+=ll-l;
      |                             ^
a.cc:22:39: error: invalid use of 'void'
   22 |             memcpy(t, l, ll-l); t+=ll-l;
      |                                       ^
a.cc:23:29: error: invalid use of 'void'
   23 |             memcpy(t, r, rr-r); t+=rr-r;
      |                             ^
a.cc:23:39: error: invalid use of 'void'
   23 |             memcpy(t, r, rr-r); t+=rr-r;
      |                                       ^
a.cc:26:26: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   26 |             l=rr; r=ll=rr+s; rr=ll+(len-k-j)*size;
      |                        ~~^~
a.cc:26:35: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   26 |             l=rr; r=ll=rr+s; rr=ll+(len-k-j)*size;
      |                                 ~~^~~~~~~~~~~~~~~
a.cc:29:42: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   29 |                     memcpy(t, l, size); t+=size; l+=size;
      |                                         ~^~~~~~
a.cc:29:51: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   29 |                     memcpy(t, l, size); t+=size; l+=size;
      |                                                  ~^~~~~~
a.cc:31:42: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   31 |                     memcpy(t, r, size); t+=size; r+=size;
      |                                         ~^~~~~~
a.cc:31:51: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   31 |                     memcpy(t, r, size); t+=size; r+=size;
      |                                                  ~^~~~~~
a.cc:34:29: error: invalid use of 'void'
   34 |             memcpy(t, l, ll-l); t+=ll-l;
      |                             ^
a.cc:34:39: error: invalid use of 'void'
   34 |             memcpy(t, l, ll-l); t+=ll-l;
      |                                       ^
a.cc:35:29: error: invalid use of 'void'
   35 |             memcpy(t, r, rr-r); t+=rr-r;
      |                             ^
a.cc:35:39: error: invalid use of 'void'
   35 |             memcpy(t, r, rr-r); t+=rr-r;
      |                                       ^