code: private final int strcmpMax(String s, int unfoldOffset, int max) {
          int i1, length, c1, c2;
  
          length=s.length();
          max-=length; /* we require length<=max, so no need to decrement max in the loop */
          i1=0;
          do {
              c1=s.charAt(i1++);
              c2=unfold[unfoldOffset++];
              if(c2==0) {
                  return 1; /* reached the end of t but not of s */
              }
              c1-=c2;
              if(c1!=0) {
                  return c1; /* return difference result */
              }
          } while(--length>0);
          /* ends with length==0 */
  
          if(max==0 || unfold[unfoldOffset]==0) {
              return 0; /* equal to length of both strings */
          } else {
              return -max; /* return lengh difference */
          }
      }
docs: /*
  compare s, which has a length, with t=unfold[unfoldOffset..], which has a maximum length or is NUL-terminated
  must be s.length()>0 and max>0 and s.length()<=max