addec := proc(le, re, c, p)
    local i, cle, cre, lambda, res, x3, y3;
    cle := le mod p;
    cre := re mod p;
    if cle = 0 or cre = 0 then
       res := cle + cre;
    elif cle[1] = cre[1] and cle[2] = -cre[2] mod p then
       res := 0;
    else
       if cle[1] = cre[1] mod p and cle[2] = cre[2] mod p
       then
          lambda := ((3*cle[1]^2+c)/2/cle[2]) mod p;
       else
          lambda := (cre[2]-cle[2])/(cre[1]-cle[1]) mod p;
       fi:
       x3 := (lambda^2-cle[1]-cre[1]) mod p;
       y3 := (lambda*(cle[1]-x3)-cle[2]) mod p;
       res := [x3, y3];
    fi:
    res;
end: