Program: 24144
Project: 24144
Buggy source:
public Profile generate(ProfileDefn profile,String id,String html,Calendar genDate) throws Exception {
  if (profile.getSource() != null)   return profile.getSource();
  Profile p=new Profile();
  p.setUrl("String_Node_Str" + id);
  p.setName(profile.metadata("String_Node_Str"));
  p.setPublisher(profile.metadata("String_Node_Str"));
  if (profile.hasMetadata("String_Node_Str"))   p.getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL,profile.metadata("String_Node_Str")));
  if (profile.hasMetadata("String_Node_Str"))   p.setDescription(profile.metadata("String_Node_Str"));
  if (profile.hasMetadata("String_Node_Str"))   p.setRequirements(profile.metadata("String_Node_Str"));
  if (profile.hasMetadata("String_Node_Str"))   p.setDateElement(Factory.newDateTime(profile.metadata("String_Node_Str").substring(0,10)));
 else   p.setDate(new DateAndTime(genDate));
  if (profile.hasMetadata("String_Node_Str"))   p.setStatus(Profile.ResourceProfileStatus.fromCode(profile.metadata("String_Node_Str")));
  for (  String s : profile.getMetadata().get("String_Node_Str"))   p.getCode().add(Factory.makeCoding(s));
  Set<String> containedSlices=new HashSet<String>();
  for (  ResourceDefn resource : profile.getResources()) {
    Profile.ProfileStructureComponent c=new Profile.ProfileStructureComponent();
    p.getStructure().add(c);
    c.setPublish(resource.isPublishedInProfile());
    c.setType(resource.getRoot().getName());
    c.setName(resource.getRoot().getName());
    c.setBase("String_Node_Str" + c.getType());
    if (!"String_Node_Str".equals(resource.getRoot().getProfileName()))     c.setName(resource.getRoot().getProfileName());
    c.setDifferential(new ConstraintComponent());
    defineElement(profile,p,c.getDifferential(),resource.getRoot(),resource.getName(),containedSlices,new ArrayList<ProfileGenerator.SliceHandle>(),SnapShotMode.None);
    List<String> names=new ArrayList<String>();
    names.addAll(resource.getSearchParams().keySet());
    Collections.sort(names);
    for (    String pn : names) {
      SearchParameter param=resource.getSearchParams().get(pn);
      makeSearchParam(p,c,resource.getName(),param);
    }
    reset();
    ProfileStructureComponent base=definitions.getSnapShotForType(c.getType());
    new ProfileUtilities(context).generateSnapshot(base,c,"String_Node_Str" + c.getType(),p.getName());
    reset();
  }
  for (  ExtensionDefn ex : profile.getExtensions())   p.getExtensionDefn().add(generateExtensionDefn(ex,p));
  XhtmlNode div=new XhtmlNode(NodeType.Element,"String_Node_Str");
  div.addText("String_Node_Str");
  p.setText(new Narrative());
  p.getText().setStatus(NarrativeStatus.GENERATED);
  p.getText().setDiv(div);
  return p;
}

Fixed version (ground truth):
public Profile generate(ProfileDefn profile,String id,String html,Calendar genDate) throws Exception {
  if (profile.getSource() != null)   return profile.getSource();
  Profile p=new Profile();
  p.setUrl("String_Node_Str" + id);
  p.setName(profile.metadata("String_Node_Str"));
  p.setPublisher(profile.metadata("String_Node_Str"));
  if (profile.hasMetadata("String_Node_Str"))   p.getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL,profile.metadata("String_Node_Str")));
  if (profile.hasMetadata("String_Node_Str"))   p.setDescription(profile.metadata("String_Node_Str"));
  if (profile.hasMetadata("String_Node_Str"))   p.setRequirements(profile.metadata("String_Node_Str"));
  if (profile.hasMetadata("String_Node_Str"))   p.setDateElement(Factory.newDateTime(profile.metadata("String_Node_Str").substring(0,10)));
 else   p.setDate(new DateAndTime(genDate));
  if (profile.hasMetadata("String_Node_Str"))   p.setStatus(Profile.ResourceProfileStatus.fromCode(profile.metadata("String_Node_Str")));
  for (  String s : profile.getMetadata().get("String_Node_Str"))   if (!Utilities.noString(s))   p.getCode().add(Factory.makeCoding(s));
  Set<String> containedSlices=new HashSet<String>();
  for (  ResourceDefn resource : profile.getResources()) {
    Profile.ProfileStructureComponent c=new Profile.ProfileStructureComponent();
    p.getStructure().add(c);
    c.setPublish(resource.isPublishedInProfile());
    c.setType(resource.getRoot().getName());
    c.setName(resource.getRoot().getName());
    c.setBase("String_Node_Str" + c.getType());
    if (!"String_Node_Str".equals(resource.getRoot().getProfileName()))     c.setName(resource.getRoot().getProfileName());
    c.setDifferential(new ConstraintComponent());
    defineElement(profile,p,c.getDifferential(),resource.getRoot(),resource.getName(),containedSlices,new ArrayList<ProfileGenerator.SliceHandle>(),SnapShotMode.None);
    List<String> names=new ArrayList<String>();
    names.addAll(resource.getSearchParams().keySet());
    Collections.sort(names);
    for (    String pn : names) {
      SearchParameter param=resource.getSearchParams().get(pn);
      makeSearchParam(p,c,resource.getName(),param);
    }
    reset();
    ProfileStructureComponent base=definitions.getSnapShotForType(c.getType());
    new ProfileUtilities(context).generateSnapshot(base,c,"String_Node_Str" + c.getType(),p.getName());
    reset();
  }
  for (  ExtensionDefn ex : profile.getExtensions())   p.getExtensionDefn().add(generateExtensionDefn(ex,p));
  XhtmlNode div=new XhtmlNode(NodeType.Element,"String_Node_Str");
  div.addText("String_Node_Str");
  p.setText(new Narrative());
  p.getText().setStatus(NarrativeStatus.GENERATED);
  p.getText().setDiv(div);
  return p;
}