int quotient_(int x, int y) {
  int x_type;
  int y_type;
  arenumbersvectors(x, y);
  x_type = MgetVecSubtype(x);
  y_type = MgetVecSubtype(y);
  if ((x_type == INTEGERSUBTYPE) && (y_type == INTEGERSUBTYPE))
    return
      make_integer(
        get_integer_val(x) /
        get_integer_val(y));
  else {
    not_integer();
    return 0; // return not reached
  }
}

int scheme_style_mod(int x, int y) {
  int ret;
  ret = abs(x) % abs(y);
  if (x < 0)
    ret= -ret;
  return ret;
}

int remainder_(int x, int y) {
  int x_type;
  int y_type;
  arenumbersvectors(x, y);
  x_type = MgetVecSubtype(x);
  y_type = MgetVecSubtype(y);
  if ((x_type == INTEGERSUBTYPE) && (y_type == INTEGERSUBTYPE))
    return
      make_integer(
        scheme_style_mod(get_integer_val(x),
                         get_integer_val(y)));
  else {
    not_integer();
    return 0; // return not reached
  }
}

int modulo_(int x, int y) {
  int x_type;
  int y_type;
  int i;
  int j;
  int return_;
  arenumbersvectors(x, y);
  x_type = MgetVecSubtype(x);
  y_type = MgetVecSubtype(y);
  if ((x_type == INTEGERSUBTYPE) && (y_type == INTEGERSUBTYPE)) {
    i = get_integer_val(x);
    j = get_integer_val(y);
    return_ = scheme_style_mod(i, j);
    if (return_ * j < 0) {
      j = abs(j);
      if (return_ > 0)
        return_ = return_ - j;
      else
        return_ = return_ + j;
    }
    return make_integer(return_);
  }
  else {
    not_integer();
    return 0; // return not reached
  }
}

int arithmeticshift(int x, int y) {
  int x_type;
  int y_type;
  int value;
  arenumbersvectors(x, y);
  x_type = MgetVecSubtype(x);
  y_type = MgetVecSubtype(y);
  if ((x_type == INTEGERSUBTYPE) && (y_type == INTEGERSUBTYPE)) {
    value = get_integer_val(y);
    if (value < 0)
      return
        make_integer(
          get_integer_val(x) >>
          -value);
    else
      return
        make_integer(
          get_integer_val(x) <<
          value);
  }
  else {
    not_integer();
    return 0; // return not reached
  }
}

int bitwiseand(int x, int y) {
  int x_type;
  int y_type;
  arenumbersvectors(x, y);
  x_type = MgetVecSubtype(x);
  y_type = MgetVecSubtype(y);
  if (x_type == INTEGERSUBTYPE && y_type == INTEGERSUBTYPE)
    return
      make_integer(
        get_integer_val(x) &
        get_integer_val(y));
  else {
    not_integer();
    return 0; // return not reached
  }
}

int bitwiseor(int x, int y) {
  int x_type;
  int y_type;
  arenumbersvectors(x, y);
  x_type = MgetVecSubtype(x);
  y_type = MgetVecSubtype(y);
  if (x_type == INTEGERSUBTYPE && y_type == INTEGERSUBTYPE)
    return
      make_integer(
        get_integer_val(x) |
        get_integer_val(y));
  else {
    not_integer();
    return 0; // return not reached
  }
}

int bitwisexor(int x, int y) {
  int x_type;
  int y_type;
  arenumbersvectors(x, y);
  x_type = MgetVecSubtype(x);
  y_type = MgetVecSubtype(y);
  if (x_type == INTEGERSUBTYPE && y_type == INTEGERSUBTYPE)
    return
      make_integer(
        get_integer_val(x) ^
        get_integer_val(y));
  else {
    not_integer();
    return 0; // return not reached
  }
}
