Generate a Python program that has the following intention:

The intention of the program is to find the index of the first occurrence of a given value x in the sorted array arr.

The program uses a recursive function p2 to search for the value x in the array. The function takes two arguments, start and end, which represent the starting and ending indices of a subarray in the array.

The function first calculates the middle index of the subarray using the formula mid = start + (end - start) // 2. If the subarray is empty, then the value x is not present in the array, and the function returns -1.

If the value x is equal to the element at the middle index of the subarray, then the function returns mid. If x is less than the element at the middle index, the function recursively calls itself with start and mid as arguments to search for x in the left half of the subarray. If x is greater than the element at the middle index, the function recursively calls itself with mid + 1 and end as arguments to search for x in the right half of the subarray.

The main function p1 takes two arguments, arr and x, and calls the p2 function to search for x in the array. It returns the index of the first occurrence of x in the array, or -1 if x is not present in the array.