Program: 77674
Project: 77674
Buggy source:
protected void init(){
  assert(content instanceof IImageContent);
  image=(IImageContent)content;
  maxWidth=parent.getMaxAvaWidth();
  Dimension content=getSpecifiedDimension(image);
  IStyle style=image.getComputedStyle();
  root=(ContainerArea)AreaFactory.createInlineContainer(image,true,true);
  int marginWidth=getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_LEFT)) + getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_RIGHT));
  int borderWidth=getDimensionValue(style.getProperty(StyleConstants.STYLE_BORDER_LEFT_WIDTH)) + getDimensionValue(style.getProperty(StyleConstants.STYLE_BORDER_RIGHT_WIDTH));
  IStyle areaStyle=root.getStyle();
  if (marginWidth > maxWidth) {
    areaStyle.setMarginLeft("String_Node_Str");
    areaStyle.setMarginRight("String_Node_Str");
    marginWidth=0;
  }
  int maxContentWidth=maxWidth - marginWidth;
  if (content.getWidth() > maxContentWidth) {
    content.setDimension(maxContentWidth,(int)(maxContentWidth / content.getRatio()));
  }
  if (borderWidth > content.getWidth()) {
    areaStyle.setProperty(IStyle.STYLE_BORDER_LEFT_WIDTH,IStyle.NUMBER_0);
    areaStyle.setProperty(IStyle.STYLE_BORDER_RIGHT_WIDTH,IStyle.NUMBER_0);
    borderWidth=0;
  }
  ImageArea imageArea=(ImageArea)AreaFactory.createImageArea(image,content);
  root.addChild(imageArea);
  imageArea.setPosition(getDimensionValue(areaStyle.getProperty(StyleConstants.STYLE_BORDER_LEFT_WIDTH)),getDimensionValue(areaStyle.getProperty(StyleConstants.STYLE_BORDER_TOP_WIDTH)));
  root.setWidth(content.getWidth());
  root.setHeight(content.getHeight());
  removePadding(areaStyle);
  imageArea.setWidth(root.getContentWidth());
  imageArea.setHeight(root.getContentHeight());
}

Fixed version (ground truth):
protected void init(){
  assert(content instanceof IImageContent);
  image=(IImageContent)content;
  maxWidth=parent.getMaxAvaWidth();
  Dimension content=getSpecifiedDimension(image);
  IStyle style=image.getComputedStyle();
  root=(ContainerArea)AreaFactory.createInlineContainer(image,true,true);
  int marginWidth=getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_LEFT)) + getDimensionValue(style.getProperty(StyleConstants.STYLE_MARGIN_RIGHT));
  int borderWidth=getDimensionValue(style.getProperty(StyleConstants.STYLE_BORDER_LEFT_WIDTH)) + getDimensionValue(style.getProperty(StyleConstants.STYLE_BORDER_RIGHT_WIDTH));
  int paddingWidth=getDimensionValue(style.getProperty(StyleConstants.STYLE_PADDING_LEFT)) + getDimensionValue(style.getProperty(StyleConstants.STYLE_PADDING_RIGHT));
  IStyle areaStyle=root.getStyle();
  if (marginWidth > maxWidth) {
    areaStyle.setMarginLeft("String_Node_Str");
    areaStyle.setMarginRight("String_Node_Str");
    marginWidth=0;
  }
  int maxContentWidthWithBorder=maxWidth - marginWidth;
  if (borderWidth > maxContentWidthWithBorder) {
    areaStyle.setProperty(IStyle.STYLE_BORDER_LEFT_WIDTH,IStyle.NUMBER_0);
    areaStyle.setProperty(IStyle.STYLE_BORDER_RIGHT_WIDTH,IStyle.NUMBER_0);
    borderWidth=0;
  }
  int maxContentWidthWithoutBorder=maxContentWidthWithBorder - borderWidth;
  if (paddingWidth > maxContentWidthWithoutBorder) {
    areaStyle.setProperty(IStyle.STYLE_PADDING_LEFT,IStyle.NUMBER_0);
    areaStyle.setProperty(IStyle.STYLE_PADDING_RIGHT,IStyle.NUMBER_0);
    paddingWidth=0;
  }
  int maxContentWidth=maxContentWidthWithoutBorder - paddingWidth;
  if (content.getWidth() > maxContentWidth) {
    content.setDimension(maxContentWidth,(int)(maxContentWidth / content.getRatio()));
  }
  ImageArea imageArea=(ImageArea)AreaFactory.createImageArea(image,content);
  root.addChild(imageArea);
  int posX=(borderWidth == 0 ? 0 : getDimensionValue(areaStyle.getProperty(StyleConstants.STYLE_BORDER_LEFT_WIDTH))) + (paddingWidth == 0 ? 0 : getDimensionValue(areaStyle.getProperty(StyleConstants.STYLE_PADDING_LEFT)));
  int posY=getDimensionValue(areaStyle.getProperty(StyleConstants.STYLE_BORDER_TOP_WIDTH)) + getDimensionValue(areaStyle.getProperty(StyleConstants.STYLE_PADDING_TOP));
  imageArea.setPosition(posX,posY);
  root.setWidth(content.getWidth() + (borderWidth == 0 ? 0 : (getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_BORDER_LEFT_WIDTH)) + getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_BORDER_RIGHT_WIDTH)))) + (paddingWidth == 0 ? 0 : (getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_PADDING_LEFT)) + getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_PADDING_RIGHT)))));
  root.setHeight(content.getHeight() + getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_BORDER_TOP_WIDTH)) + getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_BORDER_BOTTOM_WIDTH))+ getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_PADDING_TOP))+ getDimensionValue(image.getComputedStyle().getProperty(StyleConstants.STYLE_PADDING_BOTTOM)));
  imageArea.setWidth(content.getWidth());
  imageArea.setHeight(content.getHeight());
}