Rectoanal inhibitory reflex
The rectoanal inhibitory reflex (RAIR) (also known as the anal sampling mechanism, anal sampling reflex, rectosphincteric reflex,  or anorectal sampling reflex) is a reflex characterized by a transient involuntary relaxation of the internal anal sphincter in response to distention of the rectum. The RAIR provides the upper anal canal with the ability to discriminate between flatus and fecal material. The ability of the rectum to discriminate between gaseous, liquid and solid contents is essential to the ability to voluntarily control defecation. The RAIR allows for voluntary flatulation to occur without also eliminating solid waste, irrespective of the presence of fecal material in the anal canal. Reflex arc
The physiological basis for the RAIR is poorly understood, but it is thought to involve a coordinated response by the internal anal sphincter to rectal distention with recovery of anal pressure from the distal to the proximal sphincter. Mediated by the autonomic nervous system, the afferent limb of this reflex depends upon an intact network of interstitial cells of Cajal in the internal anal sphincter. These cells, which are mediated at least in part by nitric oxide, provide inhibitory innervation of the internal anal sphincter. Clinical significance
Impairment of this reflex can result in fecal incontinence. The absence of a RAIR is pathognomonic for Hirschsprung's disease. See also 
External anal sphincter
Levator ani

References 

Rectum
Excretion