/* Automatically generated by chibi-ffi; version: 0.4 */

#include <chibi/eval.h>

#include "stdint.h"

static int16_t sexp_swap_s16(int16_t n) {
  return (n << 8) | ((n >> 8) & 0xFF);
}
static uint16_t sexp_swap_u16(uint16_t n) {
  return (n >> 8) | ((n & 0xFF) << 8);
}
static int32_t sexp_swap_s32(int32_t n) {
  n = ((n << 8) & 0xFF00FF00) | ((n >> 8) & 0xFF00FF);
  return (n << 16) | ((n >> 16) & 0xFFFF);
}
static uint32_t sexp_swap_u32(uint32_t n) {
  return ((n>>24)&0xff)  | ((n<<8)&0xff0000) |
         ((n>>8)&0xff00) | ((n<<24)&0xff000000);
}
static int64_t sexp_swap_s64(int64_t n) {
  n = ((n << 8) & 0xFF00FF00FF00FF00ULL) | ((n >> 8) & 0x00FF00FF00FF00FFULL);
  n = ((n << 16) & 0xFFFF0000FFFF0000ULL) | ((n >> 16) & 0x0000FFFF0000FFFFULL);
  return (n << 32) | ((n >> 32) & 0xFFFFFFFFULL);
}
static uint64_t sexp_swap_u64(uint64_t n) {
  n = ((n << 8) & 0xFF00FF00FF00FF00ULL) | ((n >> 8) & 0x00FF00FF00FF00FFULL);
  n = ((n << 16) & 0xFFFF0000FFFF0000ULL ) | ((n >> 16) & 0x0000FFFF0000FFFFULL);
  return (n << 32) | (n >> 32);
}
static float sexp_swap_float(const float x) {
  float y;
  const uint32_t* xs = (const uint32_t*) &x;
  uint32_t* ys = (uint32_t*) &y;
  *ys = sexp_swap_u32(*xs);
  return y;
}
static double sexp_swap_double(const double x) {
  double y;
  const uint64_t* xs = (const uint64_t*) &x;
  uint64_t* ys = (uint64_t*) &y;
  *ys = sexp_swap_u64(*xs);
  return y;
}

sexp_sint_t decode_utf8(unsigned char* p, int ch_len) {
  if (ch_len <= 1)
    return *p;
  else if (ch_len == 2)
    return ((p[0]&0x3F)<<6) + (p[1]&0x3F);
  else if (ch_len == 3)
    return ((p[0]&0x1F)<<12) + ((p[1]&0x3F)<<6) + (p[2]&0x3F);
  else
    return ((p[0]&0x0F)<<18) + ((p[1]&0x3F)<<12) + ((p[2]&0x3F)<<6) + (p[3]&0x3F);
}

sexp str2utf16(sexp ctx, char* s, int len, sexp endianness) {
  unsigned char *p = (unsigned char*) s, *q;
  uint16_t *utf16, hi, lo;
  sexp_sint_t utf16_len, ch_len, ch, i;
  sexp res;
  q = p + len;
  for (utf16_len=0; p<q; ++utf16_len) {
    ch_len = sexp_utf8_initial_byte_count(*p);
    if (ch_len == 4) ++utf16_len;   /* surrogate */
    p += ch_len;
  }
  res = sexp_make_bytes(ctx, sexp_make_fixnum(utf16_len*2), SEXP_VOID);
  if (!sexp_bytesp(res)) return res;
  utf16 = (uint16_t*)sexp_bytes_data(res);
  for (p=(unsigned char*)s; p<q; ) {
    ch_len = sexp_utf8_initial_byte_count(*p);
    ch = decode_utf8(p, ch_len);
    if (ch_len == 4) {
      hi = (0xD800 - (0x10000 >> 10) + ((ch) >> 10));
      lo = (0xDC00 + ((ch) & 0x3FF));
      (*utf16++) = hi;
      (*utf16++) = lo;
    } else {
      (*utf16++) = (uint16_t)ch;
    }
    p += ch_len;
  }
  if (endianness != sexp_global(ctx, SEXP_G_ENDIANNESS)) {
    utf16 = (uint16_t*)sexp_bytes_data(res);
    for (i=0; i<utf16_len; ++i) {
      utf16[i] = sexp_swap_u16(utf16[i]);
    }
  }
  return res;
}

sexp str2utf32(sexp ctx, char* s, int len, int utf32_len, sexp endianness) {
  unsigned char *p = (unsigned char*) s, *q;
  uint32_t *utf32;
  sexp_sint_t ch_len, i;
  sexp res;
  q = p + len;
  res = sexp_make_bytes(ctx, sexp_make_fixnum(utf32_len*4), SEXP_VOID);
  if (!sexp_bytesp(res)) return res;
  utf32 = (uint32_t*)sexp_bytes_data(res);
  while (p<q) {
    ch_len = sexp_utf8_initial_byte_count(*p);
    (*utf32++) = (uint32_t)decode_utf8(p, ch_len);
    p += ch_len;
  }
  if (endianness != sexp_global(ctx, SEXP_G_ENDIANNESS)) {
    utf32 = (uint32_t*)sexp_bytes_data(res);
    for (i=0; i<utf32_len; ++i) {
      utf32[i] = sexp_swap_u32(utf32[i]);
    }
  }
  return res;
}

static int utf8_char_byte_count(int c) {
  if (c < 0x80) return 1;
  if (c < 0x800) return 2;
  if (c < 0x10000) return 3;
  return 4;
}

static void utf8_encode_char(unsigned char* p, int len, int c) {
  switch (len) {
  case 4:  *p++ = (0xF0 + ((c)>>18)); *p++ = (0x80 + ((c>>12)&0x3F));
    *p++ = (0x80 + ((c>>6)&0x3F));    *p = (0x80 + (c&0x3F)); break;
  case 3:  *p++ = (0xE0 + ((c)>>12)); *p++ = (0x80 + ((c>>6)&0x3F));
    *p = (0x80 + (c&0x3F)); break;
  case 2:  *p++ = (0xC0 + ((c)>>6));  *p = (0x80 + (c&0x3F)); break;
  default: *p = c; break;
  }
}

sexp utf16_2_str(sexp ctx, char* bv, int len, sexp endianness, int endianness_mandatory) {
  int swap = endianness != sexp_global(ctx, SEXP_G_ENDIANNESS);
  uint16_t ch, ch2;
  sexp_sint_t i, ch_len, utf8_len=0, start=0;
  sexp res;
  unsigned char* dst;
  if (!endianness_mandatory && len>1) {
    ch = *(uint16_t*)(bv);
    if (ch == 0xFFFE) {
      swap = 1;
      start = 2;
    } else if (ch == 0xFEFF) {
      start = 2;
    }
  }
  for (i=start; i+1<len; i+=2) {
    ch = swap ? sexp_swap_u16(*((uint16_t*)(bv+i))) : *((uint16_t*)(bv+i));
    if (0xd800 <= ch && ch <= 0xdbff && i+3<len) {
      ch2 = swap ? sexp_swap_u16(*((uint16_t*)(bv+i+2))) : *((uint16_t*)(bv+i+2));
      if (0xdc00 <= ch2 && ch2 <= 0xdfff) {
        ch = 0x10000 + (((ch - 0xd800) << 10) | (ch2 - 0xdc00));
        i += 2;
      }
    }
    utf8_len += utf8_char_byte_count(ch);
  }
  res = sexp_make_string(ctx, sexp_make_fixnum(utf8_len), SEXP_VOID);
  if (!(res && sexp_stringp(res))) return res;
  dst = (unsigned char*) sexp_string_data(res);
  for (i=start; i+1<len; i+=2) {
    ch = swap ? sexp_swap_u16(*((uint16_t*)(bv+i))) : *((uint16_t*)(bv+i));
    if (0xd800 <= ch && ch <= 0xdbff && i+3<len) {
      ch2 = swap ? sexp_swap_u16(*((uint16_t*)(bv+i+2))) : *((uint16_t*)(bv+i+2));
      if (0xdc00 <= ch2 && ch2 <= 0xdfff) {
        ch = 0x10000 + (((ch - 0xd800) << 10) | (ch2 - 0xdc00));
        i += 2;
      }
    }
    ch_len = utf8_char_byte_count(ch);
    utf8_encode_char(dst, ch_len, ch);
    dst += ch_len;
  }
  return res;
}

sexp utf32_2_str(sexp ctx, char* bv, int len, sexp endianness, int endianness_mandatory) {
  int swap = endianness != sexp_global(ctx, SEXP_G_ENDIANNESS);
  uint32_t ch;
  sexp_sint_t i, ch_len, utf8_len=0, start=0;
  sexp res;
  unsigned char* dst;
  if (!endianness_mandatory && len>3) {
    ch = *(uint32_t*)(bv);
    if (ch == 0xFFFE0000) {
      swap = 1;
      start = 4;
    } else if (ch == 0xFEFF) {
      start = 4;
    }
  }
  for (i=start; i+3<len; i+=4) {
    ch = swap ? sexp_swap_u32(*((uint32_t*)(bv+i))) : *((uint32_t*)(bv+i));
    utf8_len += utf8_char_byte_count(ch);
  }
  res = sexp_make_string(ctx, sexp_make_fixnum(utf8_len), SEXP_VOID);
  if (!(res && sexp_stringp(res))) return res;
  dst = (unsigned char*) sexp_string_data(res);
  for (i=start; i+3<len; i+=4) {
    ch = swap ? sexp_swap_u32(*((uint32_t*)(bv+i))) : *((uint32_t*)(bv+i));
    ch_len = utf8_char_byte_count(ch);
    utf8_encode_char(dst, ch_len, ch);
    dst += ch_len;
  }
  return res;
}

/*
types: ()
enums: ()
*/

sexp sexp_25_utf32_3e_string_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  res = utf32_2_str(ctx, sexp_bytes_data(arg1), sexp_bytes_length(arg1), arg3, sexp_truep(arg4));
  return res;
}

sexp sexp_25_utf16_3e_string_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  res = utf16_2_str(ctx, sexp_bytes_data(arg1), sexp_bytes_length(arg1), arg3, sexp_truep(arg4));
  return res;
}

sexp sexp_25_string_3e_utf32_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg4) {
  sexp res;
  if (! sexp_stringp(arg1))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg1);
  res = str2utf32(ctx, sexp_string_data(arg1), sexp_string_size(arg1), sexp_string_length(arg1), arg4);
  return res;
}

sexp sexp_25_string_3e_utf16_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg3) {
  sexp res;
  if (! sexp_stringp(arg1))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg1);
  res = str2utf16(ctx, sexp_string_data(arg1), sexp_string_size(arg1), arg3);
  return res;
}

static void bytevector_ieee_double_set_x(sexp arg0, char* arg1, int arg2, double arg3, sexp arg4) {
   *((double*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_double(arg3));
}
sexp sexp_bytevector_ieee_double_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_flonump(arg3))
    return sexp_type_exception(ctx, self, SEXP_FLONUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_ieee_double_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_flonum_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static double bytevector_ieee_double_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((double*)(arg1+arg2)) : sexp_swap_double(*(double*)(arg1+arg2)));
}
sexp sexp_bytevector_ieee_double_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_flonum(ctx, bytevector_ieee_double_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_ieee_double_native_set_x(char* arg0, int arg1, double arg2) {
   *((double*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_ieee_double_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_flonump(arg2))
    return sexp_type_exception(ctx, self, SEXP_FLONUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_ieee_double_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_flonum_value(arg2))), SEXP_VOID);
  return res;
}

static double bytevector_ieee_double_native_ref(char* arg0, int arg1) {
   return *((double*)(arg0+arg1));
}
sexp sexp_bytevector_ieee_double_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_flonum(ctx, bytevector_ieee_double_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_ieee_single_set_x(sexp arg0, char* arg1, int arg2, float arg3, sexp arg4) {
   *((float*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_float(arg3));
}
sexp sexp_bytevector_ieee_single_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_flonump(arg3))
    return sexp_type_exception(ctx, self, SEXP_FLONUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_ieee_single_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_flonum_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static float bytevector_ieee_single_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((float*)(arg1+arg2)) : sexp_swap_float(*(float*)(arg1+arg2)));
}
sexp sexp_bytevector_ieee_single_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_flonum(ctx, bytevector_ieee_single_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_ieee_single_native_set_x(char* arg0, int arg1, float arg2) {
   *((float*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_ieee_single_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_flonump(arg2))
    return sexp_type_exception(ctx, self, SEXP_FLONUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_ieee_single_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_flonum_value(arg2))), SEXP_VOID);
  return res;
}

static float bytevector_ieee_single_native_ref(char* arg0, int arg1) {
   return *((float*)(arg0+arg1));
}
sexp sexp_bytevector_ieee_single_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_flonum(ctx, bytevector_ieee_single_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_u64_set_x(sexp arg0, char* arg1, int arg2, uint64_t arg3, sexp arg4) {
   *((uint64_t*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_u64(arg3));
}
sexp sexp_bytevector_u64_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_exact_integerp(arg3))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_u64_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_sint_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static uint64_t bytevector_u64_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((uint64_t*)(arg1+arg2)) : sexp_swap_u64(*((uint64_t*)(arg1+arg2))));
}
sexp sexp_bytevector_u64_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_unsigned_integer(ctx, bytevector_u64_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_u64_native_set_x(char* arg0, int arg1, uint64_t arg2) {
   *((uint64_t*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_u64_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_u64_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_VOID);
  return res;
}

static uint64_t bytevector_u64_native_ref(char* arg0, int arg1) {
   return *((uint64_t*)(arg0+arg1));
}
sexp sexp_bytevector_u64_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_unsigned_integer(ctx, bytevector_u64_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_u32_set_x(sexp arg0, char* arg1, int arg2, uint32_t arg3, sexp arg4) {
   *((uint32_t*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_u32(arg3));
}
sexp sexp_bytevector_u32_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_exact_integerp(arg3))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_u32_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_sint_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static uint32_t bytevector_u32_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((uint32_t*)(arg1+arg2)) : sexp_swap_u32(*((uint32_t*)(arg1+arg2))));
}
sexp sexp_bytevector_u32_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_unsigned_integer(ctx, bytevector_u32_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_u32_native_set_x(char* arg0, int arg1, uint32_t arg2) {
   *((uint32_t*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_u32_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_u32_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_VOID);
  return res;
}

static uint32_t bytevector_u32_native_ref(char* arg0, int arg1) {
   return *((uint32_t*)(arg0+arg1));
}
sexp sexp_bytevector_u32_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_unsigned_integer(ctx, bytevector_u32_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_u16_set_x(sexp arg0, char* arg1, int arg2, uint16_t arg3, sexp arg4) {
   *((uint16_t*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_u16(arg3));
}
sexp sexp_bytevector_u16_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_exact_integerp(arg3))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_u16_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_sint_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static uint16_t bytevector_u16_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((uint16_t*)(arg1+arg2)) : sexp_swap_u16(*((uint16_t*)(arg1+arg2))));
}
sexp sexp_bytevector_u16_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_unsigned_integer(ctx, bytevector_u16_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_u16_native_set_x(char* arg0, int arg1, uint16_t arg2) {
   *((uint16_t*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_u16_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_u16_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_VOID);
  return res;
}

static uint16_t bytevector_u16_native_ref(char* arg0, int arg1) {
   return *((uint16_t*)(arg0+arg1));
}
sexp sexp_bytevector_u16_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_unsigned_integer(ctx, bytevector_u16_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_s64_set_x(sexp arg0, char* arg1, int arg2, int64_t arg3, sexp arg4) {
   *((int64_t*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_s64(arg3));
}
sexp sexp_bytevector_s64_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_exact_integerp(arg3))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_s64_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_sint_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static int64_t bytevector_s64_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((int64_t*)(arg1+arg2)) : sexp_swap_s64(*((int64_t*)(arg1+arg2))));
}
sexp sexp_bytevector_s64_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_integer(ctx, bytevector_s64_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_s64_native_set_x(char* arg0, int arg1, int64_t arg2) {
   *((int64_t*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_s64_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_s64_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_VOID);
  return res;
}

static int64_t bytevector_s64_native_ref(char* arg0, int arg1) {
   return *((int64_t*)(arg0+arg1));
}
sexp sexp_bytevector_s64_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_integer(ctx, bytevector_s64_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_s32_set_x(sexp arg0, char* arg1, int arg2, int32_t arg3, sexp arg4) {
   *((int32_t*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_s32(arg3));
}
sexp sexp_bytevector_s32_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_exact_integerp(arg3))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_s32_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_sint_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static int32_t bytevector_s32_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((int32_t*)(arg1+arg2)) : sexp_swap_s32(*((int32_t*)(arg1+arg2))));
}
sexp sexp_bytevector_s32_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_integer(ctx, bytevector_s32_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_s32_native_set_x(char* arg0, int arg1, int32_t arg2) {
   *((int32_t*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_s32_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_s32_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_VOID);
  return res;
}

static int32_t bytevector_s32_native_ref(char* arg0, int arg1) {
   return *((int32_t*)(arg0+arg1));
}
sexp sexp_bytevector_s32_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_integer(ctx, bytevector_s32_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_s16_set_x(sexp arg0, char* arg1, int arg2, int16_t arg3, sexp arg4) {
   *((int16_t*)(arg1+arg2)) = (arg4 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? arg3 : sexp_swap_s16(arg3));
}
sexp sexp_bytevector_s16_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3, sexp arg4) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (! sexp_exact_integerp(arg3))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg3);
  if (!((-1 < sexp_unbox_fixnum(arg2)) && (sexp_unbox_fixnum(arg2) < sexp_bytes_length(arg1)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg2 (bytevector-length arg1))", SEXP_NULL);
  }
  res = ((bytevector_s16_set_x(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), sexp_sint_value(arg3), arg4)), SEXP_VOID);
  return res;
}

static int16_t bytevector_s16_ref(sexp arg0, char* arg1, int arg2, sexp arg3) {
   return (arg3 == sexp_global(arg0, SEXP_G_ENDIANNESS) ? *((int16_t*)(arg1+arg2)) : sexp_swap_s16(*((int16_t*)(arg1+arg2))));
}
sexp sexp_bytevector_s16_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg1, sexp arg2, sexp arg3) {
  sexp res;
  if (! sexp_bytesp(arg1))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_integer(ctx, bytevector_s16_ref(ctx, sexp_bytes_data(arg1), sexp_sint_value(arg2), arg3));
  return res;
}

static void bytevector_s16_native_set_x(char* arg0, int arg1, int16_t arg2) {
   *((int16_t*)(arg0+arg1)) = arg2;
}
sexp sexp_bytevector_s16_native_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_s16_native_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_VOID);
  return res;
}

static int16_t bytevector_s16_native_ref(char* arg0, int arg1) {
   return *((int16_t*)(arg0+arg1));
}
sexp sexp_bytevector_s16_native_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_integer(ctx, bytevector_s16_native_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}

static void bytevector_s8_set_x(char* arg0, int arg1, int8_t arg2) {
   ((int8_t*)arg0)[arg1] = arg2;
}
sexp sexp_bytevector_s8_set_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  if (!((-1 < sexp_unbox_fixnum(arg1)) && (sexp_unbox_fixnum(arg1) < sexp_bytes_length(arg0)))) {
    return sexp_user_exception(ctx, self, "assertion failed: " "(< -1 arg1 (bytevector-length arg0))", SEXP_NULL);
  }
  res = ((bytevector_s8_set_x(sexp_bytes_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_VOID);
  return res;
}

static int8_t bytevector_s8_ref(char* arg0, int arg1) {
   return ((int8_t*)arg0)[arg1];
}
sexp sexp_bytevector_s8_ref_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_bytesp(arg0))
    return sexp_type_exception(ctx, self, SEXP_BYTES, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_integer(ctx, bytevector_s8_ref(sexp_bytes_data(arg0), sexp_sint_value(arg1)));
  return res;
}


sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env, const char* version, const sexp_abi_identifier_t abi) {
  sexp_gc_var3(name, tmp, op);
  if (!(sexp_version_compatible(ctx, version, sexp_version)
        && sexp_abi_compatible(ctx, abi, SEXP_ABI_IDENTIFIER)))
    return SEXP_ABI_ERROR;
  sexp_gc_preserve3(ctx, name, tmp, op);
  op = sexp_define_foreign_opt(ctx, env, "%utf32->string", 3, sexp_25_utf32_3e_string_stub, sexp_make_boolean(SEXP_FALSE));
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_OBJECT);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ONE, sexp_make_fixnum(SEXP_BOOLEAN));
  }
  op = sexp_define_foreign_opt(ctx, env, "%utf16->string", 3, sexp_25_utf16_3e_string_stub, sexp_make_boolean(SEXP_FALSE));
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_OBJECT);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ONE, sexp_make_fixnum(SEXP_BOOLEAN));
  }
  op = sexp_define_foreign_opt(ctx, env, "%string->utf32", 2, sexp_25_string_3e_utf32_stub, sexp_global(ctx, SEXP_G_ENDIANNESS));
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_OBJECT);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_STRING);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FIXNUM));
  }
  op = sexp_define_foreign_opt(ctx, env, "%string->utf16", 2, sexp_25_string_3e_utf16_stub, sexp_global(ctx, SEXP_G_ENDIANNESS));
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_OBJECT);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_STRING);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-double-set!", 4, sexp_bytevector_ieee_double_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FLONUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-double-ref", 3, sexp_bytevector_ieee_double_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FLONUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-double-native-set!", 3, sexp_bytevector_ieee_double_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FLONUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-double-native-ref", 2, sexp_bytevector_ieee_double_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FLONUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-single-set!", 4, sexp_bytevector_ieee_single_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FLONUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-single-ref", 3, sexp_bytevector_ieee_single_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FLONUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-single-native-set!", 3, sexp_bytevector_ieee_single_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FLONUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-ieee-single-native-ref", 2, sexp_bytevector_ieee_single_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FLONUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u64-set!", 4, sexp_bytevector_u64_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FIXNUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u64-ref", 3, sexp_bytevector_u64_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u64-native-set!", 3, sexp_bytevector_u64_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u64-native-ref", 2, sexp_bytevector_u64_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u32-set!", 4, sexp_bytevector_u32_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FIXNUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u32-ref", 3, sexp_bytevector_u32_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u32-native-set!", 3, sexp_bytevector_u32_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u32-native-ref", 2, sexp_bytevector_u32_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u16-set!", 4, sexp_bytevector_u16_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FIXNUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u16-ref", 3, sexp_bytevector_u16_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u16-native-set!", 3, sexp_bytevector_u16_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-u16-native-ref", 2, sexp_bytevector_u16_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s64-set!", 4, sexp_bytevector_s64_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FIXNUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s64-ref", 3, sexp_bytevector_s64_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s64-native-set!", 3, sexp_bytevector_s64_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s64-native-ref", 2, sexp_bytevector_s64_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s32-set!", 4, sexp_bytevector_s32_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FIXNUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s32-ref", 3, sexp_bytevector_s32_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s32-native-set!", 3, sexp_bytevector_s32_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s32-native-ref", 2, sexp_bytevector_s32_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s16-set!", 4, sexp_bytevector_s16_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_argn_type(op) = sexp_make_vector(ctx, SEXP_TWO, sexp_make_fixnum(SEXP_OBJECT));
    sexp_vector_set(sexp_opcode_argn_type(op), SEXP_ZERO, sexp_make_fixnum(SEXP_FIXNUM));
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s16-ref", 3, sexp_bytevector_s16_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s16-native-set!", 3, sexp_bytevector_s16_native_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s16-native-ref", 2, sexp_bytevector_s16_native_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s8-set!", 3, sexp_bytevector_s8_set_x_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = SEXP_VOID;
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg3_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  op = sexp_define_foreign(ctx, env, "bytevector-s8-ref", 2, sexp_bytevector_s8_ref_stub);
  if (sexp_opcodep(op)) {
    sexp_opcode_return_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
    sexp_opcode_arg1_type(op) = sexp_make_fixnum(SEXP_BYTES);
    sexp_opcode_arg2_type(op) = sexp_make_fixnum(SEXP_FIXNUM);
  }
  sexp_gc_release3(ctx);
  return SEXP_VOID;
}

