Recursive Merge Sort Implementation

Known to many as the best sorting algorithm for worst case time complexity merge sort runs in O(nLogn) The recursive implementation is given below :
#include<stdio.h>
/* takes two arrays and merges them */
void merge(int a[],int p,int q,int r){
		int i,j=0,k=0,n1,n2;
		n1 = r - p + 1 ;
		n2 = q - r ;
		int l[n1+1],m[n2+1];

		for(i=0;i<n1;i++) l[i]=a[p+i];
		l[i]=9999;
		for(i=0;i<n2;i++) m[i]=a[r+i+1];
		m[i]=9999;

		for(i=p;i<=q;i++){
			if(l[j] < m[k]){
				a[i] = l[j];
				j++;
			}else{
				a[i] = m[k];
				k++;	
			}
		}	
}

void merge_sort(int ar[],int p,int q){
	if(p < q){
		int mid = (p + q)/2 ;
		merge_sort(ar,p,mid);
		merge_sort(ar,mid+1,q);
		merge(ar,p,q,mid);
	}
}

int main(){
	int i,len,ar[] = {49,2,1,57,3,126,98};
	len = sizeof(ar)/sizeof(ar[0]) ;
	merge_sort(ar,0,len-1);
	for(i=0;i<len;i++)printf("%d ",ar[i]);
	return 0;
}