function [vtable_out,index,new_entry] = BR_vtable(vtable,L1,L2,L3,c,op)
% BR_vtable - add a avariable to the variable table
% On input:
%     vtable (kx5 array): initial variable table
%     L1 (int): literal 1
%     L2 (int): literal 2
%     L3 (int): literal 3
%     c (?): 
%     op (?):
% On output:
%     vtable_out (px5 array): table with new variable
%     index (int): ?
%     new_entry (?): ?
% Call:
%     [vt,ind,ne] = BR_table(vtable,L1,L2,L3,c,op);
% Author:
%     T. Henderson
%     UU
%     Summer 2018
%

vtable_out = vtable;
new_entry = 0;
if L2==0
    p = (L1>1);
elseif L3==0
    p = 2*(L1>0) + (L2>0);
else
    p = 4*(L1>0) + 2*(L2>0) + (L3>0);
end
if c<0
    index = find(vtable(:,1)==L1&vtable(:,2)==L2&vtable(:,3)==L3...
        &vtable(:,5)==p&vtable(:,7)==op);
else
    index = find(vtable(:,1)==L1&vtable(:,2)==L2&vtable(:,3)==L3...
        &vtable(:,4)==c&vtable(:,5)==p&vtable(:,7)==op);
end
if isempty(index)
    len_vtable = length(vtable(:,1));
    vtable_out(len_vtable+1,1:7) = [L1,L2,L3,c,p,len_vtable+1,op];
    index = len_vtable + 1;
    new_entry = 1;
end
