dsolve2(c_,y_,x_,-1):= if(isfree(c,y),d(c,x), dsolve(d(replace(c,y,y(x)),x)-y));
dsolve2(a_*b_,y_,x_,-1):= if(hasnot(a,y) and hasnot(b,x), solve(d(1/b,y)=d(a,x)+C_1,y), 
	if(hasnot(b,y) and hasnot(a,x), solve(d(1/a,y)=d(b,x)+C_1,y)  ));

dsolve2(b_,y_,x_,2):= if(hasnot(b,y), int(b,x,2)+c_1+c_2*x, if(hasnot(b,x), int(1/sqrt(2int(b,y)),y)=C_1+x ));

dsolve2(b_,y_,x_,1):= if(has(b,y/x), int(1/(replace(b,y/x,zz)-zz),zz,1,y/x)=C_1+log(x),
	if(hasnot(b,y), int(b,x)+c_1, if(hasnot(b,x),int(1/b,y)=C_1+x )));
dsolve2(a_*b_,y_,x_,1):= if(hasnot(a,y) and hasnot(b,x), block(f:=int(1/b,y)=int(a,x)+C_1,g:=solve(f,y),if(hasnot(g,y),g,f)), 
	if(hasnot(b,y) and hasnot(a,x), block(f:=int(1/a,y)=int(b,x)+C_1,g:=solve(f,y),if(hasnot(g,y),g,f)) ));
dsolve2(a_*b_*c_,y_,x_,1):= if(hasnot(a,y) and hasnot(b,c,x), block(f:=int(1/b/c,y)=int(a,x)+C_1,g:=solve(f,y),if(hasnot(g,y),g,f)), 
	if(hasnot(b,y) and hasnot(a,c,x), block(f:=int(1/a/c,y)=int(b,x)+C_1,g:=solve(f,y),if(hasnot(g,y),g,f)) ));


#2;
dsolve2(a_+b_,y_,x_,p_):= if(p>1 and has(b,y), if(p<=2 and hasnot(a,b,x), int(1/sqrt(C_2+2int(a+b,y)),y,p-1)=C_1+x,
	if(has(a,x),block(k:=dsolve(expand(a+b),y), if(hasnot(k,y) and hasnot(d(k,x,round(p-0.6)),x), k, 
	if(hasnot(k,y) and has(k,C_1) and hasnot(d(replace(k,C_1,0),x,round(p-0.6)),x), replace(k,C_1,0)
	))))));
dsolve2(a_+z_, y_,x_,2) := if(hasnot(a+z,x), int(1/sqrt(C_2+2int(a+z,y)),y)=C_1+x );
dsolve2(a_+z_, y_,x_,1) := if(has(a+z,exp(y)), log(dsolve(y*replace(a+z,exp(y),y),y,x,1)) );

dsolve2(a_+b_*y_, y_,x_,q_) := if(hasnot(a,y), gsolution(b,y,x,q)+psolution(b,a,y,x,q),
	if(q==2 and hasnot(a,b,x), int(1/sqrt(2int(a+b*y,y)),y)=C_1+x ));
dsolve2(a_+y_, y_,x_,q_) := if(hasnot(a,y), gsolution(1,y,x,q)+psolution(1,a,y,x,q),
	if(q==2 and hasnot(a,x), int(1/sqrt(2int(a+y,y)),y)=C_1+x ));


#3;
dsolve2(x_+xx_+z_,y_,x_,p_):=if(has(z,y) and hasnot(xx,y), block(f:=solve(z+x,y),if(d(f,x,p)==xx,f)), 
	if(has(xx,y) and hasnot(z,y), block(f:=solve(xx+x,y),if(d(f,x,p)==z,f))
	));
dsolve2(c_*x_+xx_+z_,y_,x_,p_):=	if(has(z,y) and hasnot(xx,y), block(f:=solve(z+c*x,y),if(d(f,x,p)==xx,f)), 
	if(has(xx,y) and hasnot(z,y), block(f:=solve(xx+c*x,y),if(d(f,x,p)==z,f))
	));
dsolve2(a_+x_+z_,y_,x_,p_):=	if(has(z,y) and hasnot(a,y), block(f:=solve(z+x,y),if(d(f,x,p)==a,f)),
	if(has(a,y) and hasnot(z,y), block(f:=solve(a+x,y),if(d(f,x,p)==z,f))
	));
dsolve2(a_+c_*x_+z_,y_,x_,p_):=	if(has(z,y) and hasnot(a,y) and isconstant(c), block(f:=solve(z+c*x,y),if(d(f,x,p)==a,f)), 
	if(has(a,y) and hasnot(z,y), block(f:=solve(a+c*x,y),if(d(f,x,p)==z,f))
	));
dsolve2(a_+b_+x_,y_,x_,p_):=if(has(a,y) and hasnot(b,y), block(f:=solve(a+x,y),if(d(f,x,p)==b,f)),
	if(has(b,y) and hasnot(a,y), if(hasnot(a,x), replace(dsolve(b+x,y,x,p),x,a+x), block(f:=solve(b+x,y),if(d(f,x,p)==a,f)) 
	)));
dsolve2(a_+b_+c_*x_,y_,x_,p_):=if(has(a,y) and hasnot(b,y), block(f:=solve(a+c*x,y),if(d(f,x,p)==b,f)),
	if(has(b,y) and hasnot(a,y) and isconstant(c), if(hasnot(a,x), replace(dsolve(b+c*x,y,x,p),x,a/c+x), block(f:=solve(b+c*x,y),if(d(f,x,p)==a,f))
	)));