You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: bsearch.m
    path of file: ./repos/PsPM/src/ext/bsearch
    
    the code of the file until where you have to start completion: % bsearch(x,var)
% Written by A
    
function will behave if there 
% are multiple numbers with same value.
% returns the index values of the searched numbers

function index = bsearch(x,var)

xLen = length(x);
[xRow xCol] = size(x);
if x(1) > x(xLen)	% means x is in descend