Require that the input array to be non-empty and x is an non-zero index into the array. Return the index of the first element that is strictly larger than m, the maximum element in the first x elements, or return the last index. Ensure the returned index is larger than or equal to x. Ensure the ghost variable represents the largest element in the first x elements of the array (DO NOT use max).