Generate a Python program that has the following intention:

The intention of the program below is to implement a binary search algorithm to find the index of a target value (x) in an input sorted array (arr). The binary search algorithm is one of the most efficient searching algorithms, with a time complexity of O(log n) in the worst case.

The function p1 takes two arguments: an input sorted array (arr) and the target value (x) to search for. It then defines an internal function p2, which is the actual binary search function.

The p2 function takes two arguments: the start and end indices of the search range in the input array. It initializes the mid index as the average of the start and end indices. If the target value (x) is found at the mid index, it returns the index. If the target value is not found at the mid index, it checks whether x is smaller than the mid element. If so, it recursively calls p2 with the start index as the new mid index; otherwise, it recursively calls p2 with the mid index + 1 as the new start index.

The main p1 function returns the result of the p2 function, which is the index of the target value (x) in the input array (arr), or -1 if the target value is not found in the array. Provide two versions of response separated with exactly 6 asterisk symbols: ******.
user