Glycolysis is the process of breakdown of glucose or similar hexose sugar into two molecules of pyruvic acid through a series of enzyme mediated reactions, releasing energy (ATP) and reducing power $(NADH_2)$. It is the first step of respiration, which occurs inside the cytoplasm and is independent of $O_2$. In glycolysis, two molecules of ATP are consumed during double phosphorylation of glucose to form fructose 1, 6 diphosphate. Four molecules of ATP are produced in the conversion of 1, 3-diphosphoglycerate to 3-phosphoglycerate and phosphenol pyruvate to pyruvate whereas, two molecules of $NADH_2$ are formed during oxidation of glyceraldehyde 3-phosphate to 1, 3-diphosphoglycerate. Since, each NADH is equivalent to 3 ATP, so net gain in glycolysis is 8 ATP.