Program: 21785
Project: 21785
Buggy source:
private static void chemicalReaction(World world,Entity entity,int x,int y,int z,ChemicalFluidReactionRule rule,boolean popFlowingFluid){
  ChemicalFluidReactionOutput output=reactionRules.get(rule);
  if (output == null) {
    return;
  }
  if (output.explosionLevel != Float.NaN) {
    world.createExplosion(null,x,y,z,output.explosionLevel,true);
  }
  int halfSpace=FLUIDS_GENERATE_SPACE / 2;
  List[] availableSpaces=new List[FLUIDS_GENERATE_SPACE];
  for (int i=0; i < availableSpaces.length; i++) {
    availableSpaces[i]=findAvailableSpacesAtCrossSection(world,x,y - halfSpace + i,z,1);
  }
  Iterator<MinechemChemicalType> it=output.outputs.iterator();
  while (it.hasNext()) {
    MinechemChemicalType chemical=it.next();
    boolean hasFlowingStatus=chemical.roomState().getQuanta() > 2;
    CoordTuple coords=null;
    if (!(!hasFlowingStatus && popFlowingFluid)) {
      boolean isGas=chemical.roomState().isGas();
      if (isGas) {
        for (int i=availableSpaces.length - 1; i > -1; i--) {
          if (!availableSpaces[i].isEmpty()) {
            coords=(CoordTuple)availableSpaces[i].remove(availableSpaces[i].size() - 1);
            break;
          }
        }
      }
 else {
        for (int i=0; i < availableSpaces.length; i++) {
          if (!availableSpaces[i].isEmpty()) {
            coords=(CoordTuple)availableSpaces[i].remove(availableSpaces[i].size() - 1);
            break;
          }
        }
      }
    }
    if (coords == null) {
      if (!popFlowingFluid) {
        ItemStack itemStack=MinechemUtil.createItemStack(chemical,8);
        MinechemUtil.throwItemStack(world,itemStack,x,y,z);
      }
    }
 else     if (!(popFlowingFluid && !hasFlowingStatus)) {
      int px=coords.getX();
      int py=coords.getY();
      int pz=coords.getZ();
      world.func_147480_a(px,py,pz,true);
      world.setBlockToAir(px,py,pz);
      Block fluidBlock=null;
      if (chemical instanceof ElementEnum) {
        fluidBlock=FluidHelper.elementsBlocks.get(FluidHelper.elements.get(chemical));
      }
 else       if (chemical instanceof MoleculeEnum) {
        fluidBlock=FluidHelper.moleculeBlocks.get(FluidHelper.molecules.get(chemical));
      }
      if (fluidBlock != null) {
        world.setBlock(px,py,pz,fluidBlock,popFlowingFluid ? 1 : 0,3);
      }
    }
  }
}

Fixed version (ground truth):
private static void chemicalReaction(World world,Entity entity,int x,int y,int z,ChemicalFluidReactionRule rule,boolean popFlowingFluid){
  ChemicalFluidReactionOutput output=reactionRules.get(rule);
  if (output == null) {
    return;
  }
  if (!Float.isNaN(output.explosionLevel)) {
    world.createExplosion(null,x,y,z,output.explosionLevel,true);
  }
  int halfSpace=FLUIDS_GENERATE_SPACE / 2;
  List[] availableSpaces=new List[FLUIDS_GENERATE_SPACE];
  for (int i=0; i < availableSpaces.length; i++) {
    availableSpaces[i]=findAvailableSpacesAtCrossSection(world,x,y - halfSpace + i,z,1);
  }
  Iterator<MinechemChemicalType> it=output.outputs.iterator();
  while (it.hasNext()) {
    MinechemChemicalType chemical=it.next();
    boolean hasFlowingStatus=chemical.roomState().getQuanta() > 2;
    CoordTuple coords=null;
    if (!(!hasFlowingStatus && popFlowingFluid)) {
      boolean isGas=chemical.roomState().isGas();
      if (isGas) {
        for (int i=availableSpaces.length - 1; i > -1; i--) {
          if (!availableSpaces[i].isEmpty()) {
            coords=(CoordTuple)availableSpaces[i].remove(availableSpaces[i].size() - 1);
            break;
          }
        }
      }
 else {
        for (int i=0; i < availableSpaces.length; i++) {
          if (!availableSpaces[i].isEmpty()) {
            coords=(CoordTuple)availableSpaces[i].remove(availableSpaces[i].size() - 1);
            break;
          }
        }
      }
    }
    if (coords == null) {
      if (!popFlowingFluid) {
        ItemStack itemStack=MinechemUtil.createItemStack(chemical,8);
        MinechemUtil.throwItemStack(world,itemStack,x,y,z);
      }
    }
 else     if (!(popFlowingFluid && !hasFlowingStatus)) {
      int px=coords.getX();
      int py=coords.getY();
      int pz=coords.getZ();
      world.func_147480_a(px,py,pz,true);
      world.setBlockToAir(px,py,pz);
      Block fluidBlock=null;
      if (chemical instanceof ElementEnum) {
        fluidBlock=FluidHelper.elementsBlocks.get(FluidHelper.elements.get(chemical));
      }
 else       if (chemical instanceof MoleculeEnum) {
        fluidBlock=FluidHelper.moleculeBlocks.get(FluidHelper.molecules.get(chemical));
      }
      if (fluidBlock != null) {
        world.setBlock(px,py,pz,fluidBlock,popFlowingFluid ? 1 : 0,3);
      }
    }
  }
}