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: adimat_min22.m
    path of file: ./repos/d2d/arFramework3/ThirdParty/StrucID/adimat/runtime
    
    the code of the file until where you have to start completion: % function adj = adimat_min22(val1, val2, adj)
%
% This determines the adjoint of val2 in z = min(val1, val2), where
% the adjoint of z is given as parameter adj.
%
% see also a_mean
%
% This file is part of the ADiMat runtime environmen
    
function adj = adimat_min22(val1, val2, adj)
%
% This determines the adjoint of val2 in z = min(val1, val2), where
% the adjoint of z is given as parameter adj.
%
% see also a_mean
%
% This file is part of the ADiMat runtime environment
%
% Copyright 2010-2013 Johannes Willkomm, Institute for Scientific Computing   
%                     TU Darmstadt
function adj = adimat_min22(val1, val2, adj)
  m = min(val1, val2);
  where = m == val2;
  ties = where & (m == val1);
  adj(~where) = a_zeros(0);
  if any(ties(:))
     warning('adimat:min:ties', 'There are %d ties in the min(x, y) evaluation.', sum(ties(:)));
     adj(ties) = adj(ties) .* 0.5;
  end