Program: 35607
Project: 35607
Buggy source:
private void processMessages(Response response,boolean isFromTheFuture){
  if (response.code() == 200) {
    boolean shouldForceFuture=false;
    if (globalLastKnownFutureMessageId == -1) {
      shouldForceFuture=true;
    }
    ChatOverall chatOverall=(ChatOverall)response.body();
    List<ChatMessage> chatMessageList=chatOverall.getOcs().getData();
    if (!isFromTheFuture) {
      for (int i=0; i < chatMessageList.size(); i++) {
        chatMessageList.get(i).setBaseUrl(currentUser.getBaseUrl());
        if (globalLastKnownPastMessageId == -1 || chatMessageList.get(i).getJsonMessageId() < globalLastKnownPastMessageId) {
          globalLastKnownPastMessageId=chatMessageList.get(i).getJsonMessageId();
        }
        if (shouldForceFuture) {
          if (chatMessageList.get(i).getJsonMessageId() > globalLastKnownFutureMessageId) {
            globalLastKnownFutureMessageId=chatMessageList.get(i).getJsonMessageId();
          }
        }
      }
      adapter.addToEnd(chatMessageList,false);
    }
 else {
      LinearLayoutManager layoutManager=(LinearLayoutManager)messagesList.getLayoutManager();
      for (int i=0; i < chatMessageList.size(); i++) {
        chatMessageList.get(i).setBaseUrl(currentUser.getBaseUrl());
        adapter.addToStart(chatMessageList.get(i),layoutManager.findLastVisibleItemPosition() <= adapter.getItemCount() - 3);
      }
      globalLastKnownFutureMessageId=Integer.parseInt(response.headers().get("String_Node_Str"));
    }
    if (shouldForceFuture) {
      pullChatMessages(1);
    }
  }
 else   if (response.code() == 304 && !isFromTheFuture) {
    historyRead=true;
  }
}

Fixed version (ground truth):
private void processMessages(Response response,boolean isFromTheFuture){
  if (response.code() == 200) {
    boolean shouldForceFuture=false;
    if (globalLastKnownFutureMessageId == -1) {
      shouldForceFuture=true;
    }
    ChatOverall chatOverall=(ChatOverall)response.body();
    List<ChatMessage> chatMessageList=chatOverall.getOcs().getData();
    if (!isFromTheFuture) {
      for (int i=0; i < chatMessageList.size(); i++) {
        chatMessageList.get(i).setBaseUrl(currentUser.getBaseUrl());
        if (globalLastKnownPastMessageId == -1 || chatMessageList.get(i).getJsonMessageId() < globalLastKnownPastMessageId) {
          globalLastKnownPastMessageId=chatMessageList.get(i).getJsonMessageId();
        }
        if (shouldForceFuture) {
          if (chatMessageList.get(i).getJsonMessageId() > globalLastKnownFutureMessageId) {
            globalLastKnownFutureMessageId=chatMessageList.get(i).getJsonMessageId();
          }
        }
      }
      adapter.addToEnd(chatMessageList,false);
    }
 else {
      LinearLayoutManager layoutManager=(LinearLayoutManager)messagesList.getLayoutManager();
      for (int i=0; i < chatMessageList.size(); i++) {
        chatMessageList.get(i).setBaseUrl(currentUser.getBaseUrl());
        adapter.addToStart(chatMessageList.get(i),layoutManager.findLastVisibleItemPosition() <= adapter.getItemCount() - 10);
      }
      globalLastKnownFutureMessageId=Integer.parseInt(response.headers().get("String_Node_Str"));
    }
    if (shouldForceFuture) {
      pullChatMessages(1);
    }
  }
 else   if (response.code() == 304 && !isFromTheFuture) {
    historyRead=true;
  }
}