To make the flavoring paste, cut off the brown bottom and green top of each lemongrass stalk, leaving a pale 5-inch piece. Discard the 2 outer layers of each piece, then cut crosswise into 1/4-inch slices.
Place the lemongrass, shallots, garlic, turmeric, galangal (if using) and chilies in a food processor. Puree to a paste the consistency of cooked oatmeal. If it will not blend, scrape down the sides, add 1 tablespoon water and pulse again. Repeat as needed.
Cut the whole chicken into 16 skin-on, bone-in pieces (2 wing pieces, 4 leg pieces, 4 thigh pieces and 6 breast pieces), using a cleaver to cut through the leg and thigh bones (or ask your butcher to cut it them for you). Discard the remaining carcass and excess skin and fat. Rinse the chicken to remove any bone shards and pat dry.
Heat the oil in a 12-inch nonstick skillet over a medium-low flame. Add the cinnamon, star anise and cardamom and saute until fragrant, about 2 minutes. Raise the heat to medium and, when the oil is hot enough (a drop of paste placed in the oil should sizzle), add the paste and saute, stirring to prevent scorching, until the garlic no longer smells raw, 5 to 7 minutes.
Add the coconut milk, asam gelugor (if using), sugar, lime leaves and salt. Stir to combine and bring to a gentle boil, then reduce heat to medium-low and simmer, uncovered, at a slow, steady bubble, stirring every 5 minutes, until the liquid is the consistency of a thick pea soup, about 20 minutes.
Add the chicken to the coconut milk and stir well to coat. Continue to gently simmer, uncovered, for 1 to 1 1/2 hours, or until the liquid is nearly gone. Stir every 10 minutes to prevent the chicken from sticking to the pan. (Again, it may take more time depending on the thickness of the coconut milk used.) Season with salt to taste. If there is more than 1/3 cup oil in the pan, skim off the excess.
Slowly brown the chicken in the rendered fat. Stir every 5 minutes, careful not to break apart the chicken. Continue sauteing until the meat is a golden toffee brown, about 25 minutes more. Transfer the chicken to a serving dish and let rest at least 10 minutes before serving. Discard the whole spice, asam gelugor and lime leaves, if you like. Serve at room temperature.