An air-filled sac lying above the alimentary canal in bony fish that regulates the buoyancy of the animal. Air enters or leaves the bladder either via a pneumatic duct opening into the oesophagus or stomach or via capillary blood vessels, so that the specific gravity of the fish always matches the depth at which it is swimming. This makes the fish weightless, so less energy is required for locomotion. In lungfish it also has a respiratory function. The lungs of tetrapods are homologous with the swim bladder, and it is now thought that the latter evolved from the lungs of air-breathing ancestral fishes and developed its hydrostatic function by specialization.