Program: 85324
Project: 85324
Buggy source:
/** 
 * Build a call graph, merge the SCCs and name the contexts.
 */
private void encodeContexts(){
  int i, j;
  int n_reachable=0, n_scc_reachable=0;
  int n_full=0;
  long max_contexts=Long.MIN_VALUE;
  CgEdge p;
  Random rGen=new Random();
  pre_cnt=1;
  max_scc_size=1;
  for (i=0; i < n_func; ++i) {
    vis_cg[i]=0;
    indeg_cg[i]=0;
    max_context_size_block[i]=0;
  }
  queue_cg.clear();
  callGraphDFS(Constants.SUPER_MAIN);
  for (i=0; i < n_func; ++i) {
    if (vis_cg[i] == 0)     continue;
    p=call_graph[i];
    while (p != null) {
      if (rep_cg[i] == rep_cg[p.t]) {
        p.scc_edge=true;
      }
 else {
        p.scc_edge=false;
        ++indeg_cg[rep_cg[p.t]];
      }
      p=p.next;
    }
    ++n_reachable;
    if (rep_cg[i] == i)     ++n_scc_reachable;
  }
  for (i=0; i < n_func; ++i)   if (vis_cg[i] != 0 && rep_cg[i] != i) {
    p=call_graph[i];
    while (p.next != null)     p=p.next;
    p.next=call_graph[rep_cg[i]];
    call_graph[rep_cg[i]]=call_graph[i];
  }
  max_context_size_block[Constants.SUPER_MAIN]=1;
  queue_cg.addLast(Constants.SUPER_MAIN);
  while (!queue_cg.isEmpty()) {
    i=queue_cg.getFirst();
    queue_cg.removeFirst();
    p=call_graph[i];
    while (p != null) {
      if (p.scc_edge == false) {
        j=rep_cg[p.t];
        if (Constants.MAX_CONTEXTS - max_context_size_block[i] < max_context_size_block[j]) {
          long start=rGen.nextLong();
          if (start < 0)           start=-start;
          if (start > Constants.MAX_CONTEXTS - max_context_size_block[i]) {
            start=Constants.MAX_CONTEXTS - max_context_size_block[i];
            max_context_size_block[j]=Constants.MAX_CONTEXTS;
          }
 else {
            if (max_context_size_block[j] < start + max_context_size_block[i])             max_context_size_block[j]=start + max_context_size_block[i];
          }
          p.map_offset=start + 1;
        }
 else {
          p.map_offset=max_context_size_block[j] + 1;
          max_context_size_block[j]+=max_context_size_block[i];
        }
        if (--indeg_cg[j] == 0)         queue_cg.addLast(j);
      }
 else {
        p.map_offset=1;
      }
      p=p.next;
    }
    if (max_context_size_block[i] > max_contexts)     max_contexts=max_context_size_block[i];
  }
  for (i=n_func - 1; i > -1; --i) {
    if (vis_cg[i] == 0)     continue;
    if (rep_cg[i] != i) {
      max_context_size_block[i]=max_context_size_block[rep_cg[i]];
      p=call_graph[i];
      while (p.next.s == i)       p=p.next;
      call_graph[rep_cg[i]]=p.next;
      p.next=null;
    }
    if (max_context_size_block[i] == Constants.MAX_CONTEXTS)     ++n_full;
    context_size[i]=max_context_size_block[i];
    block_num[i]=1;
  }
  if (getOpts().geom_blocking()) {
    for (i=0; i < n_func; ++i) {
      if (vis_cg[i] == 0)       continue;
      p=call_graph[i];
      while (p != null) {
        j=p.t;
        if (j != i && p.scc_edge == true) {
          if (context_size[j] <= Constants.MAX_CONTEXTS - max_context_size_block[i]) {
            p.map_offset=context_size[j] + 1;
            context_size[j]+=max_context_size_block[i];
            ++block_num[j];
          }
 else {
            int iBlock=0;
            if (block_num[j] > 1)             iBlock=rGen.nextInt(block_num[j] - 1) + 1;
            p.map_offset=iBlock * max_context_size_block[j] + 1;
          }
        }
        p=p.next;
      }
    }
  }
  ps.printf("String_Node_Str",n_reachable - 1,n_scc_reachable - 1,n_full);
  ps.printf("String_Node_Str",max_scc_size);
  ps.printf("String_Node_Str",(double)max_contexts);
}

Fixed version (ground truth):
/** 
 * Build a call graph, merge the SCCs and name the contexts. Also permit clients to decide whether to connect the disjoint parts in the call graph or not. 
 */
private void encodeContexts(boolean connectMissedEntries){
  int i, j;
  int n_reachable=0, n_scc_reachable=0;
  int n_full=0;
  long max_contexts=Long.MIN_VALUE;
  Random rGen=new Random();
  pre_cnt=1;
  max_scc_size=1;
  for (i=0; i < n_func; ++i) {
    vis_cg[i]=0;
    indeg_cg[i]=0;
    max_context_size_block[i]=0;
  }
  queue_cg.clear();
  callGraphDFS(Constants.SUPER_MAIN);
  if (connectMissedEntries) {
    for (i=Constants.SUPER_MAIN + 1; i < n_func; ++i)     if (vis_cg[i] == 0)     callGraphDFS(i);
  }
  for (i=0; i < n_func; ++i) {
    if (vis_cg[i] == 0)     continue;
    CgEdge p=call_graph[i];
    while (p != null) {
      if (rep_cg[i] == rep_cg[p.t]) {
        p.scc_edge=true;
      }
 else {
        p.scc_edge=false;
        ++indeg_cg[rep_cg[p.t]];
      }
      p=p.next;
    }
    ++n_reachable;
    if (rep_cg[i] == i)     ++n_scc_reachable;
  }
  if (connectMissedEntries) {
    for (i=Constants.SUPER_MAIN + 1; i < n_func; ++i) {
      int rep_node=rep_cg[i];
      if (indeg_cg[rep_node] == 0) {
        CgEdge p=new CgEdge(Constants.SUPER_MAIN,i,null,call_graph[Constants.SUPER_MAIN]);
        call_graph[Constants.SUPER_MAIN]=p;
        n_calls++;
      }
    }
  }
  for (i=0; i < n_func; ++i)   if (vis_cg[i] != 0 && rep_cg[i] != i) {
    CgEdge p=call_graph[i];
    while (p.next != null)     p=p.next;
    p.next=call_graph[rep_cg[i]];
    call_graph[rep_cg[i]]=call_graph[i];
  }
  max_context_size_block[Constants.SUPER_MAIN]=1;
  queue_cg.addLast(Constants.SUPER_MAIN);
  while (!queue_cg.isEmpty()) {
    i=queue_cg.getFirst();
    queue_cg.removeFirst();
    CgEdge p=call_graph[i];
    while (p != null) {
      if (p.scc_edge == false) {
        j=rep_cg[p.t];
        if (Constants.MAX_CONTEXTS - max_context_size_block[i] < max_context_size_block[j]) {
          long start=rGen.nextLong();
          if (start < 0)           start=-start;
          if (start > Constants.MAX_CONTEXTS - max_context_size_block[i]) {
            start=Constants.MAX_CONTEXTS - max_context_size_block[i];
            max_context_size_block[j]=Constants.MAX_CONTEXTS;
          }
 else {
            if (max_context_size_block[j] < start + max_context_size_block[i])             max_context_size_block[j]=start + max_context_size_block[i];
          }
          p.map_offset=start + 1;
        }
 else {
          p.map_offset=max_context_size_block[j] + 1;
          max_context_size_block[j]+=max_context_size_block[i];
        }
        if (--indeg_cg[j] == 0)         queue_cg.addLast(j);
      }
 else {
        p.map_offset=1;
      }
      p=p.next;
    }
    if (max_context_size_block[i] > max_contexts)     max_contexts=max_context_size_block[i];
  }
  for (i=n_func - 1; i > -1; --i) {
    if (vis_cg[i] == 0)     continue;
    if (rep_cg[i] != i) {
      max_context_size_block[i]=max_context_size_block[rep_cg[i]];
      CgEdge p=call_graph[i];
      while (p.next.s == i)       p=p.next;
      call_graph[rep_cg[i]]=p.next;
      p.next=null;
    }
    if (max_context_size_block[i] == Constants.MAX_CONTEXTS)     ++n_full;
    context_size[i]=max_context_size_block[i];
    block_num[i]=1;
  }
  if (getOpts().geom_blocking()) {
    for (i=0; i < n_func; ++i) {
      if (vis_cg[i] == 0)       continue;
      CgEdge p=call_graph[i];
      while (p != null) {
        j=p.t;
        if (j != i && p.scc_edge == true) {
          if (context_size[j] <= Constants.MAX_CONTEXTS - max_context_size_block[i]) {
            p.map_offset=context_size[j] + 1;
            context_size[j]+=max_context_size_block[i];
            ++block_num[j];
          }
 else {
            int iBlock=0;
            if (block_num[j] > 1)             iBlock=rGen.nextInt(block_num[j] - 1) + 1;
            p.map_offset=iBlock * max_context_size_block[j] + 1;
          }
        }
        p=p.next;
      }
    }
  }
  ps.printf("String_Node_Str",n_reachable - 1,n_scc_reachable - 1,n_full);
  ps.printf("String_Node_Str",max_scc_size);
  ps.printf("String_Node_Str",(double)max_contexts);
}