TODO: refactor this weak code!!!
504507
private static ImmutableTerm tryToExtractIRITemplateString(ImmutableTerm term) {
        if (term instanceof ImmutableFunctionalTerm) {
            ImmutableFunctionalTerm functionalTerm = (ImmutableFunctionalTerm) term;
            return functionalTerm.getArity() > 0
                    ? tryToExtractIRITemplateString(functionalTerm.getTerm(0))
                    : term;
        }
        return term;
    }
1357303
function stringifyValue(value, replacer, space, indent) {
  // boolean, null, number, string, or date
  if (typeof value === 'boolean' || value instanceof Boolean ||
      value === null ||
      typeof value === 'number' || value instanceof Number ||
      typeof value === 'string' || value instanceof String ||
      value instanceof Date) {
    return JSON.stringify(value);
  }

  // lossless number, the secret ingredient :)
  if (value && value.isLosslessNumber) {
    return value.value;
  }

  // array
  if (Array.isArray(value)) {
    return stringifyArray(value, replacer, space, indent);
  }

  // object (test lastly!)
  if (value && typeof value === 'object') {
    return stringifyObject(value, replacer, space, indent);
  }

  return undefined;
}
1042336
private final String eval(final String str) throws InvalidExpression {
		if (str == null)
			return null;
		return new MapExpression(str, null, mapper, false).eval().get();
	}
419765
function updateSourceCode(code, changes) {
  // Summary:
  //  This must be called before code is changed some places else rather than ast

  changes.sort((c1, c2) => c2.start - c1.start);
  // Remove same or overlapped changes
  const newChanges = _.reduce(
    changes,
    (cleanChanges, curr) => {
      const last = _.last(cleanChanges);

      if (!cleanChanges.length || last.start > curr.end) {
        cleanChanges.push(curr);
      } else if (last.start === last.end && last.end === curr.start && curr.start === curr.end) {
        // insert code at the same position, merge them
        last.replacement += curr.replacement;
      }
      return cleanChanges;
    },
    [],
  );

  const chars = code.split('');
  newChanges.forEach(c => {
    // Special case: after the change, two empty lines occurs, should delete one line
    if (
      c.replacement === '' &&
      (c.start === 0 || chars[c.start - 1] === '\n') &&
      chars[c.end] === '\n'
    ) {
      c.end += 1;
    }
    chars.splice(c.start, c.end - c.start, c.replacement);
  });
  return chars.join('');
}
207130
function minValue(bound, formatError) {
        'use strict';
        return function (value) {
            if (value || !isNaN(parseFloat(value))) {
                var intValue = Number(value);
                if (!isNaN(intValue) && intValue < bound) {
                    return formatError(intValue);
                }
            }
            return '';
        };
    }
798157
function(iscount, type, code){ // type = 0:違う 1:numより小さい 2:numより大きい
		for(var c=0;c<this.board.cell.length;c++){
			var cell = this.board.cell[c];
			if(!cell.isValidNum()){ continue;}
			var num = cell.getNum(), count=cell.countDir4Cell(iscount);
			if((type===0 && num===count) || (type===1 && num<=count) || (type===2 && num>=count)){ continue;}
			
			this.failcode.add(code);
			if(this.checkOnly){ break;}
			cell.seterr(1);
		}
	}
18680
function (data) {
            if (!data) {
                return;
            }

            return _.union.apply(null, _.map(_.values(data), _.keys));
        }
1280089
function (mode, code, tokens, flags, scope, parseMode) {
    var index = code.index,
        length = code.length;

    if ( /* <!-- */
        code.codePointAt(index) === 0x003c &&
        code.codePointAt(++index) === 0x0021 &&
        code.codePointAt(++index) === 0x002d &&
        code.codePointAt(++index) === 0x002d
    ) {
        index++;

        for (; index < length; index++) {
            if ( /* --> */
                code.codePointAt(index) === 0x002d &&
                code.codePointAt(index + 1) === 0x002d &&
                code.codePointAt(index + 2) === 0x003e
            ) {
                index += 3;
                code.index = index;

                return true;
            }
        }

        throw code.makeError(
            code.index, code.index + 4,
            'Unclosed Comment: Expected "-->" to fallow "<!--".'
        );
    }

    return null;
}
1160883
function baseFlatten(input, shallow, strict, output) {
  output = output || [];
  var idx = output.length;
  for (var i = 0, length = getLength(input); i < length; i++) {
    var value = input[i];
    if (isArrayLike(value) && (isArray(value) || isArguments(value))) {
      // flatten current level of array or arguments object
      if (shallow) {
        var j = 0,
          len = value.length;
        while (j < len) {
          output[idx++] = value[j++];
        }
      } else {
        baseFlatten(value, shallow, strict, output);
        idx = output.length;
      }
    } else if (!strict) {
      output[idx++] = value;
    }
  }

  return output;
}
801371
function dedupeJSONStringify(jsonValue: mixed): string {
  // Clone the object to convert references to the same object instance into
  // copies. This is needed for the WeakMap/Map to recognize them as duplicates.
  // $FlowFixMe(>=0.95.0) JSON.stringify can return undefined
  jsonValue = JSON.parse(JSON.stringify(jsonValue));
  const metadataForHash = new Map();
  const metadataForVal = new WeakMap();
  const varDefs = [];
  collectMetadata(jsonValue);
  collectDuplicates(jsonValue);
  const code = printJSCode(false, '', jsonValue);
  return varDefs.length === 0
    ? code
    : `(function(){\nvar ${varDefs.join(',\n')};\nreturn ${code};\n})()`;

  // Collect common metadata for each object in the value tree, ensuring that
  // equivalent values have the *same reference* to the same metadata. Note that
  // the hashes generated are not exactly JSON, but still identify equivalent
  // values. Runs in linear time due to hashing in a bottom-up recursion.
  function collectMetadata(value) {
    if (value == null || typeof value !== 'object') {
      return JSON.stringify(value);
    }
    let hash;
    if (Array.isArray(value)) {
      hash = '[';
      for (let i = 0; i < value.length; i++) {
        hash += collectMetadata(value[i]) + ',';
      }
    } else {
      hash = '{';
      for (const k in value) {
        if (value.hasOwnProperty(k) && value[k] !== undefined) {
          hash += k + ':' + collectMetadata(value[k]) + ',';
        }
      }
    }
    let metadata = metadataForHash.get(hash);
    if (!metadata) {
      metadata = {value, hash, isDuplicate: false};
      metadataForHash.set(hash, metadata);
    }
    metadataForVal.set(value, metadata);
    return hash;
  }

  // Using top-down recursion, linearly scan the JSON tree to determine which
  // values should be deduplicated.
  function collectDuplicates(value) {
    if (value == null || typeof value !== 'object') {
      return;
    }
    const metadata = metadataForVal.get(value);
    // Only consider duplicates with hashes longer than 2 (excludes [] and {}).
    if (metadata && metadata.value !== value && metadata.hash.length > 2) {
      metadata.isDuplicate = true;
      return;
    }
    if (Array.isArray(value)) {
      for (let i = 0; i < value.length; i++) {
        collectDuplicates(value[i]);
      }
    } else {
      for (const k in value) {
        if (value.hasOwnProperty(k) && value[k] !== undefined) {
          collectDuplicates(value[k]);
        }
      }
    }
  }

  // Stringify JS, replacing duplicates with variable references.
  function printJSCode(isDupedVar, depth, value) {
    if (value == null || typeof value !== 'object') {
      return JSON.stringify(value);
    }
    // Only use variable references at depth beyond the top level.
    if (depth !== '') {
      const metadata = metadataForVal.get(value);
      if (metadata && metadata.isDuplicate) {
        if (!metadata.varName) {
          const refCode = printJSCode(true, '', value);
          metadata.varName = 'v' + varDefs.length;
          varDefs.push(metadata.varName + ' = ' + refCode);
        }
        return '(' + metadata.varName + '/*: any*/)';
      }
    }
    let str;
    let isEmpty = true;
    const depth2 = depth + '  ';
    if (Array.isArray(value)) {
      // Empty arrays can only have one inferred flow type and then conflict if
      // used in different places, this is unsound if we would write to them but
      // this whole module is based on the idea of a read only JSON tree.
      if (isDupedVar && value.length === 0) {
        return '([]/*: any*/)';
      }
      str = '[';
      for (let i = 0; i < value.length; i++) {
        str +=
          (isEmpty ? '\n' : ',\n') +
          depth2 +
          printJSCode(isDupedVar, depth2, value[i]);
        isEmpty = false;
      }
      str += isEmpty ? ']' : `\n${depth}]`;
    } else {
      str = '{';
      for (const k in value) {
        if (value.hasOwnProperty(k) && value[k] !== undefined) {
          str +=
            (isEmpty ? '\n' : ',\n') +
            depth2 +
            JSON.stringify(k) +
            ': ' +
            printJSCode(isDupedVar, depth2, value[k]);
          isEmpty = false;
        }
      }
      str += isEmpty ? '}' : `\n${depth}}`;
    }
    return str;
  }
}
623312
function replaceDefine(code) {
    var defineList = getDefineBlock(code);
    var segments = [];
    var index = 0;
    defineList.forEach(function (block) {

        if (block.type === 'function') {
            segments.push(code.slice(index, block.defineRange[0]));
            index = block.factoryRange[0] + 1;

            block.returnRange.forEach(function (range) {
                segments.push(code.slice(index, range[0]));
                segments.push('module.exports =');
                segments.push(code.slice(range[0] + 6, range[1]));
                index = range[1];
            });
            segments.push(code.slice(index, block.factoryRange[1] - 1));

            index = block.defineRange[1];
        }
        else if (block.type === 'object') {
            segments.push(code.slice(index, block.defineRange[0]));
            segments.push('module.exports = ');
            segments.push(code.slice(block.factoryRange[0], block.factoryRange[1]) + ';');
            index = block.defineRange[1];
        }
    });

    segments.push(code.slice(index));

    code = segments.join('');

    return code;
}
895805
function(json) {

    var resArray = [];

    var emitArrayOfObjects = function(json, res) {

        var printValue = function(v) {
            var result = null;
            if (typeof(v) === "function") {
                result = "<![CDATA[";
                result = result + v.toString();
                result = result + "]]>";
            } else {
                result = v;
                if (typeof(v) !== "string") {
                    if (v !== null && typeof(v) !== 'undefined') {
                        result = v.toString();
                    } else {
                        result = "";
                    }
                }
                result = result.replace(/[&]/g, "&amp;");
                result = result.replace(/[<]/g, "&lt;");
                result = result.replace(/[>]/g, "&gt;");
            }
            return result;
        };

        var emitSimple = function(elemName, value, res) {
            res.push(`<${elemName}>`);
            res.push(printValue(value));
            res.push(`</${elemName}>`);
        };

        var emitElement = function(elemName, subElemList, res) {
            if (Array.isArray(subElemList)) {
                subElemList.forEach(function(subElem) {
                    emitElement(elemName, subElem, res);
                });
            } else if (typeof subElemList === 'object' && subElemList !== null) {
                var attrs = [];
                var textValue = "";
                if (subElemList._attrs) {
                    for (var attrName in subElemList._attrs) {
                        if (subElemList._attrs.hasOwnProperty(attrName)) {
                            attrs.push(`${attrName}='${subElemList._attrs[attrName]}'`);
                        }
                    }
                }
                if (subElemList._text) {
                    textValue = subElemList._text;
                } else if (subElemList._cdata) {
                    textValue = `<![CDATA[${subElemList._cdata}]]>`;
                } else if (subElemList.text) {
                    textValue = subElemList.text;
                }
                var attrString = attrs.length > 0 ? attrs.join(" ") : "";
                res.push(attrs.length > 0 ? `<${elemName} ${attrString}>` : `<${elemName}>`);
                emitArrayOfObjects(subElemList, res);
                res.push(textValue);
                res.push(`</${elemName}>`);

            } else {
                emitSimple(elemName, subElemList, res);
            }
        };

        for (var key in json) {
            if (json.hasOwnProperty(key) && key !== '_attrs' && key !== '_cdata' && key !== '_text' && key !== 'text') {
                emitElement(key, json[key], res);
            }
        }
    };

    emitArrayOfObjects(json, resArray);
    return resArray.join("");
}
66717
function itSucks (report) {
    if (report.pass) {
        console.log(`Your code looks good. Wanna cookie or something? This is what's supposed to happen!`);
    }
    else {
        for (let analysis of report.analyses) {
            if (!analysis.pass) {
                console.warn(`Your code in ${analysis.target} sucks!`);
                console.warn(analysis.errors
                    .map((error, index) => `Reason #${index + 1} it sucks: ${error.message} (line ${error.line})`)
                    .join('\n'));
            }
        }
    }
}
112368
private int dedup(Tag[] src, int ss, Tag[] dst, int ds, int len) {
    if (len == 0) {
      return ds;
    } else {
      dst[ds] = src[ss];
      String k = src[ss].key();
      int j = ds;
      final int e = ss + len;
      for (int i = ss + 1; i < e; ++i) {
        if (k.equals(src[i].key())) {
          dst[j] = src[i];
        } else {
          k = src[i].key();
          dst[++j] = src[i];
        }
      }
      return j + 1;
    }
  }
1348783
function (target, source) {
        'use strict';
        var keys = Object.keys(source),
            len = keys.length,
            i = 0,
            prop,
            isA, isB;
        while (i < len) {
            prop = keys[i];
            isA = isObj(target[prop]);
            isB = isObj(source[prop]);
            if (isA && isB) {
                deepMerge(target[prop], source[prop]);
            } else if (!isA && isB) {
                target[prop] = JSON.parse(JSON.stringify(source[prop]));
            } else {
                target[prop] = source[prop];
            }
            i += 1;
        }
    }
1143353
function(array, fun) {
      return _.cat.apply(null, _.map(array, fun));
    }
238600
function(){
			var rect, obj, i;
            for (i=0, l=changed_objs.length; i<l; i++){
            	obj = changed_objs[i];
            	rect = obj._mbr || obj;
            	if (obj.staleRect == null)
            			obj.staleRect = {}
        		obj.staleRect._x = rect._x;
				obj.staleRect._y = rect._y;
				obj.staleRect._w = rect._w;
				obj.staleRect._h = rect._h;

				obj._changed = false
            }
            changed_objs.length = 0;
            dirty_rects.length = 0

		}