Program: 59877
Project: 59877
Buggy source:
public IIcon getIcon(IBlockAccess world,int x,int y,int z,int side){
  int metadata=world.getBlockMetadata(x,y,z);
  if (metadata < 0 || metadata > 15)   metadata=0;
  CarvableVariation variation=map[metadata];
  if (variation == null)   return GeneralClient.getMissingIcon();
switch (variation.kind) {
case NORMAL:
case TOPSIDE:
case TOPBOTSIDE:
    return getIcon(side,metadata);
case CTM3:
  int tex=CTM.getTexture(world,x,y,z,side);
int row=tex / 16;
int col=tex % 16;
return variation.ctm.seams[col / 4].icons[col % 4 + row * 4];
case CTMV:
{
if (side < 2) return variation.iconTop;
Block block=world.getBlock(x,y,z);
boolean topConnected=CTM.isConnected(world,x,y + 1,z,side,block,metadata);
boolean botConnected=CTM.isConnected(world,x,y - 1,z,side,block,metadata);
if (topConnected && botConnected) return variation.seamsCtmVert.icons[2];
if (topConnected && !botConnected) return variation.seamsCtmVert.icons[3];
if (!topConnected && botConnected) return variation.seamsCtmVert.icons[1];
return variation.seamsCtmVert.icons[0];
}
case CTMH:
if (side < 2) return variation.iconTop;
Block block=CTM.getBlockOrFacade(world,x,y,z,side);
boolean p;
boolean n;
boolean reverse=side == 2 || side == 4;
if (side < 4) {
p=CTM.isConnected(world,x - 1,y,z,side,block,metadata);
n=CTM.isConnected(world,x + 1,y,z,side,block,metadata);
}
 else {
p=CTM.isConnected(world,x,y,z - 1,side,block,metadata);
n=CTM.isConnected(world,x,y,z + 1,side,block,metadata);
}
if (p && n) return variation.seamsCtmVert.icons[1];
 else if (p) return variation.seamsCtmVert.icons[reverse ? 2 : 3];
 else if (n) return variation.seamsCtmVert.icons[reverse ? 3 : 2];
return variation.seamsCtmVert.icons[0];
case V9:
case V4:
int variationSize=(variation.kind == V9) ? 3 : 2;
int xModulus=x % variationSize;
int zModulus=z % variationSize;
int textureX=(xModulus < 0) ? (xModulus + variationSize) : xModulus;
int textureZ=(zModulus < 0) ? (zModulus + variationSize) : zModulus;
int textureY=(variationSize - (y % variationSize) - 1);
if (side == 2 || side == 5) {
textureX=(variationSize - textureX - 1);
textureZ=(variationSize - textureZ - 1);
}
int index;
if (side == 0 || side == 1) {
index=textureX + textureZ * variationSize;
}
 else if (side == 2 || side == 3) {
index=textureX + textureY * variationSize;
}
 else {
index=textureZ + textureY * variationSize;
}
return variation.variations9.icons[index];
case CTMX:
return variation.icon;
case R16:
case R9:
case R4:
int indexRan=x + y + z;
if ((side == 2) || (side == 5)) {
indexRan=-indexRan;
}
while (indexRan < 0) {
indexRan=indexRan + 10000;
}
return variation.variations9.icons[indexRan % ((variation.kind == R9) ? 9 : 4)];
}
return GeneralClient.getMissingIcon();
}

Fixed version (ground truth):
public IIcon getIcon(IBlockAccess world,int x,int y,int z,int side){
  int metadata=world.getBlockMetadata(x,y,z);
  if (metadata < 0 || metadata > 15)   metadata=0;
  CarvableVariation variation=map[metadata];
  if (variation == null)   return GeneralClient.getMissingIcon();
switch (variation.kind) {
case NORMAL:
case TOPSIDE:
case TOPBOTSIDE:
    return getIcon(side,metadata);
case CTM3:
  int tex=CTM.getTexture(world,x,y,z,side);
int row=tex / 16;
int col=tex % 16;
return variation.ctm.seams[col / 4].icons[col % 4 + row * 4];
case CTMV:
{
if (side < 2) return variation.iconTop;
Block block=world.getBlock(x,y,z);
boolean topConnected=CTM.isConnected(world,x,y + 1,z,side,block,metadata);
boolean botConnected=CTM.isConnected(world,x,y - 1,z,side,block,metadata);
if (topConnected && botConnected) return variation.seamsCtmVert.icons[2];
if (topConnected && !botConnected) return variation.seamsCtmVert.icons[3];
if (!topConnected && botConnected) return variation.seamsCtmVert.icons[1];
return variation.seamsCtmVert.icons[0];
}
case CTMH:
if (side < 2) return variation.iconTop;
Block block=CTM.getBlockOrFacade(world,x,y,z,side);
boolean p;
boolean n;
boolean reverse=side == 2 || side == 5;
if (side < 4) {
p=CTM.isConnected(world,x - 1,y,z,side,block,metadata);
n=CTM.isConnected(world,x + 1,y,z,side,block,metadata);
}
 else {
p=CTM.isConnected(world,x,y,z - 1,side,block,metadata);
n=CTM.isConnected(world,x,y,z + 1,side,block,metadata);
}
if (p && n) return variation.seamsCtmVert.icons[1];
 else if (p) return variation.seamsCtmVert.icons[reverse ? 2 : 3];
 else if (n) return variation.seamsCtmVert.icons[reverse ? 3 : 2];
return variation.seamsCtmVert.icons[0];
case V9:
case V4:
int variationSize=(variation.kind == V9) ? 3 : 2;
int xModulus=x % variationSize;
int zModulus=z % variationSize;
int textureX=(xModulus < 0) ? (xModulus + variationSize) : xModulus;
int textureZ=(zModulus < 0) ? (zModulus + variationSize) : zModulus;
int textureY=(variationSize - (y % variationSize) - 1);
if (side == 2 || side == 5) {
textureX=(variationSize - textureX - 1);
textureZ=(variationSize - textureZ - 1);
}
int index;
if (side == 0 || side == 1) {
index=textureX + textureZ * variationSize;
}
 else if (side == 2 || side == 3) {
index=textureX + textureY * variationSize;
}
 else {
index=textureZ + textureY * variationSize;
}
return variation.variations9.icons[index];
case CTMX:
return variation.icon;
case R16:
case R9:
case R4:
int indexRan=x + y + z;
if ((side == 2) || (side == 5)) {
indexRan=-indexRan;
}
while (indexRan < 0) {
indexRan=indexRan + 10000;
}
return variation.variations9.icons[indexRan % ((variation.kind == R9) ? 9 : 4)];
}
return GeneralClient.getMissingIcon();
}