comefrom: <awangdev>Closest Number in Sorted Array_1.java
code: public int closestNumber(int[] A, int target) {
          if (A == null || A.length == 0) {
              return -1;
          }
          int start = 0;
          int end = A.length - 1;
          int mid;
          while (start + 1 < end) {
              mid = start + (end - start) / 2;
              if (A[mid] == target) {
                  return mid;
              } else if (mid - 1 >= 0 && A[mid - 1] <= target && target < A[mid]) {
                  return (target - A[mid - 1]) < (A[mid] - target) ? (mid - 1) : mid; 
              } else if (mid + 1 < A.length && A[mid] < target && target <= A[mid + 1]) {
                  return (target - A[mid]) < (A[mid + 1] - target) ? mid : mid + 1;
              } else if (A[mid] < target) {
                  start = mid;
              } else {
                  end = mid;
              }
          }
          return (target - A[start]) < (A[end] - target) ? start : end;
      }
masked: public int sample_funcname ( int [ ] var_0 , int var_1 ) {
    if ( var_0 == null || var_0 . length == 0 ) {
      return - 1 ;
    }
    int var_6 = 0 ;
    int var_7 = var_0 . length - 1 ;
    int var_8 ;
    while ( var_6 + 1 < var_7 ) {
      var_8 = var_6 + ( var_7 - var_6 ) / 2 ;
      if ( var_0 [ var_8 ] == var_1 ) {
        return var_8 ;
      }
      else if ( var_8 - 1 >= 0 && var_0 [ var_8 - 1 ] <= var_1 && var_1 < var_0 [ var_8 ] ) {
        return ( var_1 - var_0 [ var_8 - 1 ] ) < ( var_0 [ var_8 ] - var_1 ) ? ( var_8 - 1 ) : var_8 ;
      }
      else if ( var_8 + 1 < var_0 . length && var_0 [ var_8 ] < var_1 && var_1 <= var_0 [ var_8 + 1 ] ) {
        return ( var_1 - var_0 [ var_8 ] ) < ( var_0 [ var_8 + 1 ] - var_1 ) ? var_8 : var_8 + 1 ;
      }
      else if ( var_0 [ var_8 ] < var_1 ) {
        var_6 = var_8 ;
      }
      else {
        var_7 = var_8 ;
      }
    }
    return ( var_1 - var_0 [ var_6 ] ) < ( var_0 [ var_7 ] - var_1 ) ? var_6 : var_7 ;
  }
  