/* Generated automatically from libarray.scm.  DO NOT EDIT */
#define LIBGAUCHE_BODY 
#include <gauche.h>
#include <gauche/code.h>
#include "gauche/priv/arrayP.h"




static ScmObj* complete_ixs(ScmObj* ixs,int* pixcount,ScmObj ixlist);
static ScmSmallInt index_vector_TOpos(const ScmArrayBase* array,ScmSmallInt rank,ScmObj* ixs);
static ScmSmallInt index_array_TOpos(const ScmArrayBase* array,ScmSmallInt rank,const ScmArrayBase* iarray);
static void bad_index(ScmObj* ixs,int ixcount);
static void index_mismatch(ScmSmallInt rank,ScmObj* ixs,int ixcount);
static ScmSmallInt index_args_TOpos(const ScmArrayBase* array,ScmSmallInt rank,ScmObj* ixs,ScmSmallInt ixcount);
static ScmObj libarrayarray_rank(ScmObj*, int, void*);
static SCM_DEFINE_SUBRX(libarrayarray_rank__STUB, 1, 0,0, SCM_FALSE,SCM_SUBR_IMMEDIATE_ARG, libarrayarray_rank, NULL, NULL);

/* debug info of %toplevel */
static unsigned char uvector__00001[] = {
 0u, 3u, 134u, 6u, 8u, 2u, 1u, 128u, 160u, 34u, 71u, 9u, 12u, 9u, 1u,
17u, 193u, 195u, 2u, 96u, 56u, 71u, 2u, 12u, 9u, 128u, 225u, 28u, 0u,
48u, 38u, 3u, 132u, 128u,};
static ScmObj libarrayarray_ref(ScmObj*, int, void*);
static SCM_DEFINE_SUBR(libarrayarray_ref__STUB, 1, 11,SCM_FALSE,libarrayarray_ref, NULL, NULL);

static ScmObj libarrayarray_setX(ScmObj*, int, void*);
static SCM_DEFINE_SUBR(libarrayarray_setX__STUB, 1, 12,SCM_FALSE,libarrayarray_setX, NULL, NULL);

/* debug info of %toplevel */
static unsigned char uvector__00002[] = {
 0u, 3u, 134u, 6u, 8u, 2u, 1u, 128u, 224u, 50u, 71u, 9u, 12u, 9u, 1u,
145u, 193u, 195u, 2u, 96u, 56u, 71u, 2u, 12u, 9u, 128u, 225u, 28u, 0u,
48u, 38u, 3u, 132u, 128u,};
/* debug info of %toplevel */
static unsigned char uvector__00003[] = {
 0u, 3u, 134u, 6u, 8u, 2u, 1u, 129u, 32u, 66u, 71u, 9u, 12u, 9u, 2u,
17u, 193u, 195u, 2u, 96u, 56u, 71u, 2u, 12u, 9u, 128u, 225u, 28u, 0u,
48u, 38u, 3u, 132u, 128u,};
static ScmObj SCM_debug_info_const_vector();
#if defined(__CYGWIN__) || defined(GAUCHE_WINDOWS)
#define SCM_CGEN_CONST /*empty*/
#else
#define SCM_CGEN_CONST const
#endif
static SCM_CGEN_CONST struct scm__scRec {
  ScmString d1949[22];
} scm__sc SCM_UNUSED = {
  {   /* ScmString d1949 */
      SCM_STRING_CONST_INITIALIZER("array-rank", 10, 10),
      SCM_STRING_CONST_INITIALIZER("array", 5, 5),
      SCM_STRING_CONST_INITIALIZER("source-info", 11, 11),
      SCM_STRING_CONST_INITIALIZER("libarray.scm", 12, 12),
      SCM_STRING_CONST_INITIALIZER("bind-info", 9, 9),
      SCM_STRING_CONST_INITIALIZER("gauche.internal", 15, 15),
      SCM_STRING_CONST_INITIALIZER("<array-base>", 12, 12),
      SCM_STRING_CONST_INITIALIZER("->", 2, 2),
      SCM_STRING_CONST_INITIALIZER("<fixnum>", 8, 8),
      SCM_STRING_CONST_INITIALIZER("%expression-name-mark-key", 25, 25),
      SCM_STRING_CONST_INITIALIZER("%toplevel", 9, 9),
      SCM_STRING_CONST_INITIALIZER("array-ref", 9, 9),
      SCM_STRING_CONST_INITIALIZER("rest", 4, 4),
      SCM_STRING_CONST_INITIALIZER("ixlist", 6, 6),
      SCM_STRING_CONST_INITIALIZER("optarray", 8, 8),
      SCM_STRING_CONST_INITIALIZER("ixs", 3, 3),
      SCM_STRING_CONST_INITIALIZER("*", 1, 1),
      SCM_STRING_CONST_INITIALIZER("<top>", 5, 5),
      SCM_STRING_CONST_INITIALIZER("array-set!", 10, 10),
      SCM_STRING_CONST_INITIALIZER("<void>", 6, 6),
      SCM_STRING_CONST_INITIALIZER("define-in-module", 16, 16),
      SCM_STRING_CONST_INITIALIZER("gauche", 6, 6),
  },
};
static struct scm__rcRec {
  ScmUVector d1954[3];
  ScmCompiledCode d1953[3];
  ScmWord d1952[45];
  ScmPair d1951[31] SCM_ALIGN_PAIR;
  ScmObj d1950[65];
} scm__rc SCM_UNUSED = {
  {   /* ScmUVector d1954 */
      SCM_UVECTOR_INITIALIZER(Scm_U8VectorClass, 34, uvector__00001, 0, NULL),
      SCM_UVECTOR_INITIALIZER(Scm_U8VectorClass, 34, uvector__00002, 0, NULL),
      SCM_UVECTOR_INITIALIZER(Scm_U8VectorClass, 34, uvector__00003, 0, NULL),
  },
  {   /* ScmCompiledCode d1953 */
        SCM_COMPILED_CODE_CONST_INITIALIZER(  /* %toplevel */
            (ScmWord*)(SCM_OBJ(&scm__rc.d1952[0])), 15,
            10, 0, 0, SCM_FALSE, SCM_NIL, SCM_FALSE,
            SCM_FALSE, SCM_FALSE),
        SCM_COMPILED_CODE_CONST_INITIALIZER(  /* %toplevel */
            (ScmWord*)(SCM_OBJ(&scm__rc.d1952[15])), 15,
            10, 0, 0, SCM_FALSE, SCM_NIL, SCM_FALSE,
            SCM_FALSE, SCM_FALSE),
        SCM_COMPILED_CODE_CONST_INITIALIZER(  /* %toplevel */
            (ScmWord*)(SCM_OBJ(&scm__rc.d1952[30])), 15,
            10, 0, 0, SCM_FALSE, SCM_NIL, SCM_FALSE,
            SCM_FALSE, SCM_FALSE),
  },
  {   /* ScmWord d1952 */
    /* %toplevel */
    0x0000000e    /*   0 (PRE-CALL 0) */,
    SCM_WORD((ScmWord*)SCM_OBJ(&scm__rc.d1952[0]) + 4),
    0x0000005f    /*   2 (GREF-CALL 0) */,
    SCM_WORD(SCM_UNDEFINED) /* %expression-name-mark-key */,
    0x0000000d    /*   4 (PUSH) */,
    0x00000001    /*   5 (CONST) */,
    SCM_WORD(SCM_UNDEFINED) /* array-rank */,
    0x000000ee    /*   7 (EXTEND-DENV) */,
    SCM_WORD((ScmWord*)SCM_OBJ(&scm__rc.d1952[0]) + 12),
    0x0000005d    /*   9 (GREF) */,
    SCM_WORD(SCM_UNDEFINED) /* array-rank */,
    0x00000014    /*  11 (RET) */,
    0x00000015    /*  12 (DEFINE 0) */,
    SCM_WORD(SCM_UNDEFINED) /* array-rank */,
    0x00000014    /*  14 (RET) */,
    /* %toplevel */
    0x0000000e    /*   0 (PRE-CALL 0) */,
    SCM_WORD((ScmWord*)SCM_OBJ(&scm__rc.d1952[15]) + 4),
    0x0000005f    /*   2 (GREF-CALL 0) */,
    SCM_WORD(SCM_UNDEFINED) /* %expression-name-mark-key */,
    0x0000000d    /*   4 (PUSH) */,
    0x00000001    /*   5 (CONST) */,
    SCM_WORD(SCM_UNDEFINED) /* array-ref */,
    0x000000ee    /*   7 (EXTEND-DENV) */,
    SCM_WORD((ScmWord*)SCM_OBJ(&scm__rc.d1952[15]) + 12),
    0x0000005d    /*   9 (GREF) */,
    SCM_WORD(SCM_UNDEFINED) /* array-ref */,
    0x00000014    /*  11 (RET) */,
    0x00000015    /*  12 (DEFINE 0) */,
    SCM_WORD(SCM_UNDEFINED) /* array-ref */,
    0x00000014    /*  14 (RET) */,
    /* %toplevel */
    0x0000000e    /*   0 (PRE-CALL 0) */,
    SCM_WORD((ScmWord*)SCM_OBJ(&scm__rc.d1952[30]) + 4),
    0x0000005f    /*   2 (GREF-CALL 0) */,
    SCM_WORD(SCM_UNDEFINED) /* %expression-name-mark-key */,
    0x0000000d    /*   4 (PUSH) */,
    0x00000001    /*   5 (CONST) */,
    SCM_WORD(SCM_UNDEFINED) /* array-set! */,
    0x000000ee    /*   7 (EXTEND-DENV) */,
    SCM_WORD((ScmWord*)SCM_OBJ(&scm__rc.d1952[30]) + 12),
    0x0000005d    /*   9 (GREF) */,
    SCM_WORD(SCM_UNDEFINED) /* array-set! */,
    0x00000014    /*  11 (RET) */,
    0x00000015    /*  12 (DEFINE 0) */,
    SCM_WORD(SCM_UNDEFINED) /* array-set! */,
    0x00000014    /*  14 (RET) */,
  },
  {   /* ScmPair d1951 */
       { SCM_NIL, SCM_NIL },
       { SCM_UNDEFINED, SCM_NIL},
       { SCM_MAKE_INT(228U), SCM_NIL},
       { SCM_OBJ(&scm__sc.d1949[3]), SCM_OBJ(&scm__rc.d1951[2])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[3])},
       { SCM_UNDEFINED, SCM_NIL},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[5])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[6])},
       { SCM_OBJ(&scm__rc.d1951[7]), SCM_NIL},
       { SCM_OBJ(&scm__rc.d1951[4]), SCM_OBJ(&scm__rc.d1951[8])},
       { SCM_UNDEFINED, SCM_NIL},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[10])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[11])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[12])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[13])},
       { SCM_MAKE_INT(233U), SCM_NIL},
       { SCM_OBJ(&scm__sc.d1949[3]), SCM_OBJ(&scm__rc.d1951[15])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[16])},
       { SCM_UNDEFINED, SCM_NIL},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[18])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[19])},
       { SCM_OBJ(&scm__rc.d1951[20]), SCM_NIL},
       { SCM_OBJ(&scm__rc.d1951[17]), SCM_OBJ(&scm__rc.d1951[21])},
       { SCM_MAKE_INT(251U), SCM_NIL},
       { SCM_OBJ(&scm__sc.d1949[3]), SCM_OBJ(&scm__rc.d1951[23])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[24])},
       { SCM_UNDEFINED, SCM_NIL},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[26])},
       { SCM_UNDEFINED, SCM_OBJ(&scm__rc.d1951[27])},
       { SCM_OBJ(&scm__rc.d1951[28]), SCM_NIL},
       { SCM_OBJ(&scm__rc.d1951[25]), SCM_OBJ(&scm__rc.d1951[29])},
  },
  {   /* ScmObj d1950 */
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_OBJ(SCM_CLASS_STATIC_TAG(Scm_VectorClass)) /* <vector> */,
    SCM_VECTOR_SIZE_SLOT_INITIALIZER(5, FALSE),
    SCM_MAKE_INT(1U),
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_OBJ(SCM_CLASS_STATIC_TAG(Scm_VectorClass)) /* <vector> */,
    SCM_VECTOR_SIZE_SLOT_INITIALIZER(6, FALSE),
    SCM_MAKE_INT(1U),
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_OBJ(SCM_CLASS_STATIC_TAG(Scm_VectorClass)) /* <vector> */,
    SCM_VECTOR_SIZE_SLOT_INITIALIZER(6, FALSE),
    SCM_MAKE_INT(1U),
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNDEFINED,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_UNBOUND,
    SCM_OBJ(SCM_CLASS_STATIC_TAG(Scm_VectorClass)) /* <vector> */,
    SCM_VECTOR_SIZE_SLOT_INITIALIZER(5, FALSE),
    SCM_FALSE,
    SCM_FALSE,
    SCM_FALSE,
    SCM_FALSE,
    SCM_FALSE,
    SCM_UNBOUND,
    SCM_UNBOUND,
  },
};
typedef struct ScmArrayBaseRec {  SCM_INSTANCE_HEADER; ScmObj start_vector; ScmObj end_vector; ScmObj coefficient_vector; ScmObj offset; ScmObj backing_storage; } ScmArrayBase;
static ScmObj Scm_ArrayBaseClass_ALLOCATE(ScmClass *klass SCM_UNUSED, ScmObj initargs SCM_UNUSED)
{

#line 92 "libarray.scm"
{ScmArrayBase* z=SCM_NEW_INSTANCE(ScmArrayBase,klass);
(z)->start_vector=(SCM_UNDEFINED);
(z)->end_vector=(SCM_UNDEFINED);
(z)->coefficient_vector=(SCM_UNDEFINED);
(z)->offset=(SCM_MAKE_INT(0));
(z)->backing_storage=(SCM_UNDEFINED);
return (SCM_OBJ(z));}
}

SCM_DEFINE_BASE_CLASS(Scm_ArrayBaseClass, ScmArrayBase, NULL, NULL, NULL, Scm_ArrayBaseClass_ALLOCATE, SCM_CLASS_OBJECT_CPL);

static ScmObj Scm_ArrayBaseClass_start_vector_GET(ScmObj OBJARG)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  return SCM_OBJ_SAFE(obj->start_vector);
}

static void Scm_ArrayBaseClass_start_vector_SET(ScmObj OBJARG, ScmObj value)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  obj->start_vector = (value);
}

static ScmObj Scm_ArrayBaseClass_end_vector_GET(ScmObj OBJARG)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  return SCM_OBJ_SAFE(obj->end_vector);
}

static void Scm_ArrayBaseClass_end_vector_SET(ScmObj OBJARG, ScmObj value)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  obj->end_vector = (value);
}

static ScmObj Scm_ArrayBaseClass_coefficient_vector_GET(ScmObj OBJARG)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  return SCM_OBJ_SAFE(obj->coefficient_vector);
}

static void Scm_ArrayBaseClass_coefficient_vector_SET(ScmObj OBJARG, ScmObj value)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  obj->coefficient_vector = (value);
}

static ScmObj Scm_ArrayBaseClass_offset_GET(ScmObj OBJARG)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  return SCM_OBJ_SAFE(obj->offset);
}

static void Scm_ArrayBaseClass_offset_SET(ScmObj OBJARG, ScmObj value)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  obj->offset = (value);
}

static ScmObj Scm_ArrayBaseClass_backing_storage_GET(ScmObj OBJARG)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  return SCM_OBJ_SAFE(obj->backing_storage);
}

static void Scm_ArrayBaseClass_backing_storage_SET(ScmObj OBJARG, ScmObj value)
{
  ScmArrayBase* obj = SCM_ARRAY_BASE(OBJARG);
  obj->backing_storage = (value);
}

static ScmClassStaticSlotSpec Scm_ArrayBaseClass__SLOTS[] = {
  SCM_CLASS_SLOT_SPEC("start-vector", Scm_ArrayBaseClass_start_vector_GET, Scm_ArrayBaseClass_start_vector_SET),
  SCM_CLASS_SLOT_SPEC("end-vector", Scm_ArrayBaseClass_end_vector_GET, Scm_ArrayBaseClass_end_vector_SET),
  SCM_CLASS_SLOT_SPEC("coefficient-vector", Scm_ArrayBaseClass_coefficient_vector_GET, Scm_ArrayBaseClass_coefficient_vector_SET),
  SCM_CLASS_SLOT_SPEC("offset", Scm_ArrayBaseClass_offset_GET, Scm_ArrayBaseClass_offset_SET),
  SCM_CLASS_SLOT_SPEC("backing-storage", Scm_ArrayBaseClass_backing_storage_GET, Scm_ArrayBaseClass_backing_storage_SET),
  SCM_CLASS_SLOT_SPEC_END()
};

#define ARRAY_FAST_RANK (10)

#define ARRAY_FAST_RANK1 ((ARRAY_FAST_RANK)+(1))

 ScmSmallInt Scm_ArrayRank(const ScmArrayBase* array){{
#line 113 "libarray.scm"
if (!(SCM_UVECTORP((array)->start_vector))){{Scm_Error("Encountered an uninitialized array.");}}
return (SCM_UVECTOR_SIZE((array)->start_vector));}}
static ScmObj* complete_ixs(ScmObj* ixs,int* pixcount,ScmObj ixlist){ScmObj cise__1946;{
#line 124 "libarray.scm"
if (SCM_NULLP(ixlist)){
return (ixs);} else {
{ScmSmallInt len=(*(pixcount))+(Scm_Length(ixlist));ScmObj* ixs2=
SCM_NEW_ARRAY(ScmObj,len);int i=0;
#line 129 "libarray.scm"
for (; (i)<(*(pixcount)); (i)++){
(ixs2)[i]=((ixs)[i]);}
SCM_FOR_EACH(cise__1946,ixlist) {{ScmObj v=SCM_CAR(cise__1946);(ixs2)[i]=(v);}}
*(pixcount)=(i);
return (ixs2);}}}}
static ScmSmallInt index_vector_TOpos(const ScmArrayBase* array,ScmSmallInt rank,ScmObj* ixs){{
#line 141 "libarray.scm"
{int32_t* Vb=SCM_S32VECTOR_ELEMENTS((array)->start_vector);int32_t* Ve=
SCM_S32VECTOR_ELEMENTS((array)->end_vector);int32_t* Vc=
SCM_S32VECTOR_ELEMENTS((array)->coefficient_vector);ScmSmallInt pos=
SCM_INT_VALUE((array)->offset);
{int i=0;int cise__1947=rank;for (; (i)<(cise__1947); (i)++){
if (!(SCM_INTP((ixs)[i]))){{
Scm_Error("Bad array index: %S",(ixs)[i]);}}
{ScmSmallInt ix=SCM_INT_VALUE((ixs)[i]);
if (!(((ix)>=((Vb)[i]))&&(
(ix)<((Ve)[i])))){{
Scm_Error("Array index out of range: %d",ix);}}
pos=((pos)+(((ix)-((Vb)[i]))*((Vc)[i])));}}}
SCM_ASSERT((0)<=(pos));
return (pos);}}}
static ScmSmallInt index_array_TOpos(const ScmArrayBase* array,ScmSmallInt rank,const ScmArrayBase* iarray){{
#line 164 "libarray.scm"
if (!(SCM_VECTORP((iarray)->backing_storage))){{
Scm_Error("Only <array> can be used as an index object: %S",iarray);}}
{int32_t* iVb=SCM_S32VECTOR_ELEMENTS((iarray)->start_vector);int32_t* iVc=
SCM_S32VECTOR_ELEMENTS((iarray)->coefficient_vector);ScmSmallInt ioff=
SCM_INT_VALUE((iarray)->offset);ScmVector* ibs=
SCM_VECTOR((iarray)->backing_storage);ScmObj ixs[rank];
#line 171 "libarray.scm"
{int i=0;int cise__1948=rank;for (; (i)<(cise__1948); (i)++){
{ScmSmallInt ipos=(((iVc)[0])*((i)+((iVb)[0])))+(ioff);
SCM_ASSERT(((0)<=(ipos))&&(
(ipos)<(SCM_VECTOR_SIZE(ibs))));
(ixs)[i]=((SCM_VECTOR_ELEMENTS(ibs))[ipos]);}}}
return (index_vector_TOpos(array,rank,ixs));}}}
static void bad_index(ScmObj* ixs,int ixcount){{
#line 181 "libarray.scm"
Scm_Error("Bad array index: %S",Scm_ArrayToList(ixs,ixcount));}}
static void index_mismatch(ScmSmallInt rank,ScmObj* ixs,int ixcount){{
#line 185 "libarray.scm"
Scm_Error("Index %S does not match array's rank %ld",
Scm_ArrayToList(ixs,ixcount),rank);}}
static ScmSmallInt index_args_TOpos(const ScmArrayBase* array,ScmSmallInt rank,ScmObj* ixs,ScmSmallInt ixcount){{
#line 196 "libarray.scm"
if (
(ixcount)==(0)){
if (!((rank)==(0))){{index_mismatch(rank,ixs,ixcount);}}
return (SCM_INT_VALUE((array)->offset));}else if(
SCM_VECTORP((ixs)[0])){
if (!((ixcount)==(1))){{bad_index(ixs,ixcount);}}
if (!((rank)==(SCM_VECTOR_SIZE((ixs)[0])))){{
index_mismatch(rank,ixs,ixcount);}}
return (index_vector_TOpos(array,rank,SCM_VECTOR_ELEMENTS((ixs)[0])));}else if(
SCM_ARRAY_BASE_P((ixs)[0])){
if (!((ixcount)==(1))){{bad_index(ixs,ixcount);}}
{const ScmArrayBase* iarr=SCM_ARRAY_BASE((ixs)[0]);ScmObj bv=
(iarr)->backing_storage;
if (!(SCM_VECTORP(bv))){{bad_index(ixs,ixcount);}}
if (!((Scm_ArrayRank(iarr))==(1))){{bad_index(ixs,ixcount);}}
if (!((((SCM_S32VECTOR_ELEMENTS((iarr)->end_vector))[0])-(
(SCM_S32VECTOR_ELEMENTS((iarr)->start_vector))[0]))==(rank))){{
#line 214 "libarray.scm"
index_mismatch(rank,ixs,1);}}
return (index_array_TOpos(array,rank,iarr));}}else if(
SCM_INTP((ixs)[0])){
if (!((ixcount)==(rank))){{index_mismatch(rank,ixs,ixcount);}}
return (index_vector_TOpos(array,rank,ixs));} else {
bad_index(ixs,ixcount);return (0);}}}

static ScmObj libarrayarray_rank(ScmObj *SCM_FP SCM_UNUSED, int SCM_ARGCNT SCM_UNUSED, void *data_ SCM_UNUSED)
{
  ScmObj array_scm;
  ScmArrayBase* array;
  ScmObj SCM_SUBRARGS[1];
  SCM_ENTER_SUBR("array-rank");
  for (int SCM_i=0; SCM_i<1; SCM_i++) {
    SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
  }
  array_scm = SCM_SUBRARGS[0];
  if (!SCM_ARRAY_BASE_P(array_scm)) Scm_TypeError("array", "<array-base>", array_scm);
  array = SCM_ARRAY_BASE(array_scm);
  {
{
ScmSmallInt SCM_RESULT;
ScmObj SCM_RESULT_s;
SCM_RESULT = Scm_ArrayRank(array);
SCM_RESULT_s = SCM_MAKE_INT(SCM_RESULT);
goto SCM_STUB_RETURN_BOXED;
goto SCM_STUB_RETURN;
SCM_STUB_RETURN:
SCM_RESULT_s = SCM_MAKE_INT(SCM_RESULT);
goto SCM_STUB_RETURN_BOXED;
SCM_STUB_RETURN_BOXED:
SCM_RETURN(SCM_RESULT_s);
}
  }
}


static ScmObj libarrayarray_ref(ScmObj *SCM_FP SCM_UNUSED, int SCM_ARGCNT SCM_UNUSED, void *data_ SCM_UNUSED)
{
  ScmObj array_scm;
  ScmArrayBase* array;
  ScmObj* ixs;
  int ixcount;
  ScmObj ixlist_scm;
  ScmObj ixlist;
  ScmObj SCM_SUBRARGS[12];
  SCM_ENTER_SUBR("array-ref");
  for (int SCM_i=0; SCM_i<12; SCM_i++) {
    SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
  }
  array_scm = SCM_SUBRARGS[0];
  if (!SCM_ARRAY_BASE_P(array_scm)) Scm_TypeError("array", "<array-base>", array_scm);
  array = SCM_ARRAY_BASE(array_scm);
  ixs = &SCM_SUBRARGS[1];
  ixcount = SCM_ARGCNT-1-1;
  ixlist_scm = SCM_SUBRARGS[SCM_ARGCNT-1];
  if (!SCM_LISTP(ixlist_scm)) Scm_TypeError("ixlist", "list", ixlist_scm);
  ixlist = (ixlist_scm);
  {
{
ScmObj SCM_RESULT;
ScmObj SCM_RESULT_s;

#line 236 "libarray.scm"
if (!(SCM_UVECTORP((array)->start_vector))){{Scm_Error("Encountered an uninitialized array.");}}

#line 237 "libarray.scm"
{ScmSmallInt rank=SCM_UVECTOR_SIZE((array)->start_vector);ScmObj* ixs2=
complete_ixs(ixs,&(ixcount),ixlist);ScmSmallInt pos=
index_args_TOpos(array,rank,ixs2,ixcount);ScmObj bv=
(array)->backing_storage;
if (
SCM_VECTORP(bv)){
SCM_ASSERT((pos)<(SCM_VECTOR_SIZE(bv)));
SCM_RESULT = 
#line 244 "libarray.scm"
SCM_VECTOR_ELEMENT(bv,pos);
SCM_RESULT_s = SCM_OBJ_SAFE(SCM_RESULT);
goto SCM_STUB_RETURN_BOXED;}else if(
SCM_UVECTORP(bv)){
SCM_RESULT = 
#line 246 "libarray.scm"
Scm_VMUVectorRef(SCM_UVECTOR(bv),SCM_UVECTOR_GENERIC,pos,SCM_UNBOUND);
SCM_RESULT_s = SCM_OBJ_SAFE(SCM_RESULT);
goto SCM_STUB_RETURN_BOXED;} else {
#line 248 "libarray.scm"
Scm_Panic("Invalid array");
SCM_RESULT = SCM_UNDEFINED;
SCM_RESULT_s = SCM_OBJ_SAFE(SCM_RESULT);
goto SCM_STUB_RETURN_BOXED;}}
goto SCM_STUB_RETURN;
SCM_STUB_RETURN:
SCM_RESULT_s = SCM_OBJ_SAFE(SCM_RESULT);
goto SCM_STUB_RETURN_BOXED;
SCM_STUB_RETURN_BOXED:
SCM_RETURN(SCM_RESULT_s);
}
  }
}


static ScmObj libarrayarray_setX(ScmObj *SCM_FP SCM_UNUSED, int SCM_ARGCNT SCM_UNUSED, void *data_ SCM_UNUSED)
{
  ScmObj array_scm;
  ScmArrayBase* array;
  ScmObj* ixs;
  int ixcount;
  ScmObj ixlist_scm;
  ScmObj ixlist;
  ScmObj SCM_SUBRARGS[13];
  SCM_ENTER_SUBR("array-set!");
  for (int SCM_i=0; SCM_i<13; SCM_i++) {
    SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
  }
  array_scm = SCM_SUBRARGS[0];
  if (!SCM_ARRAY_BASE_P(array_scm)) Scm_TypeError("array", "<array-base>", array_scm);
  array = SCM_ARRAY_BASE(array_scm);
  ixs = &SCM_SUBRARGS[1];
  ixcount = SCM_ARGCNT-1-1;
  ixlist_scm = SCM_SUBRARGS[SCM_ARGCNT-1];
  if (!SCM_LISTP(ixlist_scm)) Scm_TypeError("ixlist", "list", ixlist_scm);
  ixlist = (ixlist_scm);
  {

#line 255 "libarray.scm"
if (!(SCM_UVECTORP((array)->start_vector))){{Scm_Error("Encountered an uninitialized array.");}}

#line 256 "libarray.scm"
if (!((ixcount)>=(1))){{
Scm_AssertionError(SCM_LIST1(SCM_OBJ(array)),"Wrong number of arguments for array-set!");}}

#line 259 "libarray.scm"
{ScmSmallInt rank=SCM_UVECTOR_SIZE((array)->start_vector);ScmObj* ixs2=
complete_ixs(ixs,&(ixcount),ixlist);ScmSmallInt pos=
index_args_TOpos(array,rank,ixs2,(ixcount)-(1));ScmObj val=
(ixs2)[(ixcount)-(1)];ScmObj bv=
(array)->backing_storage;
if (
SCM_VECTORP(bv)){
SCM_ASSERT((pos)<(SCM_VECTOR_SIZE(bv)));
SCM_VECTOR_ELEMENT(bv,pos)=(val);}else if(
SCM_UVECTORP(bv)){
Scm_UVectorSet(SCM_UVECTOR(bv),SCM_UVECTOR_GENERIC,pos,val,SCM_CLAMP_ERROR);} else {
#line 271 "libarray.scm"
Scm_Panic("Invalid array");}}
goto SCM_STUB_RETURN;
SCM_STUB_RETURN:
SCM_RETURN(SCM_UNDEFINED);
  }
}

static ScmCompiledCode *toplevels[] = {
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[0])),
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[1])),
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[2])),
 NULL /*termination*/
};
ScmObj SCM_debug_info_const_vector()
{
  static _Bool initialized = FALSE;
  if (!initialized) {
    int i = 0;
    SCM_VECTOR_ELEMENT(SCM_OBJ(&scm__rc.d1950[56]), i++) = scm__rc.d1950[63];
    SCM_VECTOR_ELEMENT(SCM_OBJ(&scm__rc.d1950[56]), i++) = scm__rc.d1950[64];
    SCM_VECTOR_ELEMENT(SCM_OBJ(&scm__rc.d1950[56]), i++) = scm__rc.d1950[0];
    SCM_VECTOR_ELEMENT(SCM_OBJ(&scm__rc.d1950[56]), i++) = scm__rc.d1950[23];
    SCM_VECTOR_ELEMENT(SCM_OBJ(&scm__rc.d1950[56]), i++) = scm__rc.d1950[39];
    initialized = TRUE;
  }
  return SCM_OBJ(&scm__rc.d1950[56]);
}
void Scm_Init_libarray() {
   Scm_SelectModule(SCM_MODULE(SCM_OBJ(Scm_GaucheModule())));
   Scm_SelectModule(SCM_MODULE(SCM_OBJ(Scm_GaucheInternalModule())));
  Scm_InitStaticClassWithMeta(&Scm_ArrayBaseClass, "<array-base>", SCM_MODULE(SCM_OBJ(Scm_GaucheInternalModule())), NULL, SCM_FALSE, Scm_ArrayBaseClass__SLOTS, 0);
  scm__rc.d1950[0] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[0])),TRUE); /* array-rank */
  scm__rc.d1950[1] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[1])),TRUE); /* array */
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[1]), scm__rc.d1950[1]);
  scm__rc.d1950[2] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[2])),TRUE); /* source-info */
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[4]), scm__rc.d1950[2]);
  scm__rc.d1950[3] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[4])),TRUE); /* bind-info */
  scm__rc.d1950[4] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[5])),TRUE); /* gauche.internal */
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[5]), scm__rc.d1950[0]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[6]), scm__rc.d1950[4]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[7]), scm__rc.d1950[3]);
  scm__rc.d1950[5] = Scm_MakeExtendedPair(scm__rc.d1950[0], SCM_OBJ(&scm__rc.d1951[1]), SCM_OBJ(&scm__rc.d1951[9]));
  scm__rc.d1950[6] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[6])),TRUE); /* <array-base> */
  scm__rc.d1950[7] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[7])),TRUE); /* -> */
  scm__rc.d1950[8] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[8])),TRUE); /* <fixnum> */
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[9]))[3] = scm__rc.d1950[4];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[9]))[4] = scm__rc.d1950[6];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[9]))[5] = scm__rc.d1950[7];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[9]))[6] = scm__rc.d1950[8];
  Scm_MakeBinding(SCM_MODULE(SCM_OBJ(Scm_GaucheInternalModule())), SCM_SYMBOL(SCM_INTERN("array-rank")), SCM_OBJ(&libarrayarray_rank__STUB), 0);
  libarrayarray_rank__STUB.common.info = scm__rc.d1950[5];
  libarrayarray_rank__STUB.common.typeHint = SCM_OBJ(&scm__rc.d1950[9]);
  scm__rc.d1950[17] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[9])),TRUE); /* %expression-name-mark-key */
  scm__rc.d1950[16] = Scm_MakeIdentifier(scm__rc.d1950[17], SCM_MODULE(Scm_GaucheInternalModule()), SCM_NIL); /* gauche.internal#%expression-name-mark-key */
  scm__rc.d1950[19] = SCM_OBJ(Scm_FindModule(SCM_SYMBOL(scm__rc.d1950[4]), SCM_FIND_MODULE_CREATE|SCM_FIND_MODULE_PLACEHOLDING)); /* module gauche.internal */
  scm__rc.d1950[18] = Scm_MakeIdentifier(scm__rc.d1950[0], SCM_MODULE(scm__rc.d1950[19]), SCM_NIL); /* gauche.internal#array-rank */
  scm__rc.d1950[20] = Scm_MakeIdentifier(scm__rc.d1950[0], SCM_MODULE(Scm_GaucheModule()), SCM_NIL); /* gauche#array-rank */
  scm__rc.d1950[21] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[10])),TRUE); /* %toplevel */
  scm__rc.d1950[22] = Scm_MakePackedDebugInfo(SCM_U8VECTOR(SCM_OBJ(&scm__rc.d1954[0])),SCM_debug_info_const_vector);
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[0]))->name = scm__rc.d1950[21];/* %toplevel */
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[0]))->debugInfo = scm__rc.d1950[22];
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[0]))[3] = SCM_WORD(scm__rc.d1950[16]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[0]))[6] = SCM_WORD(scm__rc.d1950[0]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[0]))[10] = SCM_WORD(scm__rc.d1950[18]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[0]))[13] = SCM_WORD(scm__rc.d1950[20]);
  scm__rc.d1950[23] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[11])),TRUE); /* array-ref */
  scm__rc.d1950[24] = Scm_MakeKeyword(SCM_STRING(SCM_OBJ(&scm__sc.d1949[12]))); /* :rest */
  scm__rc.d1950[25] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[13])),TRUE); /* ixlist */
  scm__rc.d1950[26] = Scm_MakeKeyword(SCM_STRING(SCM_OBJ(&scm__sc.d1949[14]))); /* :optarray */
  scm__rc.d1950[27] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[15])),TRUE); /* ixs */
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[10]), scm__rc.d1950[27]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[11]), scm__rc.d1950[26]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[12]), scm__rc.d1950[25]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[13]), scm__rc.d1950[24]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[14]), scm__rc.d1950[1]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[17]), scm__rc.d1950[2]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[18]), scm__rc.d1950[23]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[19]), scm__rc.d1950[4]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[20]), scm__rc.d1950[3]);
  scm__rc.d1950[28] = Scm_MakeExtendedPair(scm__rc.d1950[23], SCM_OBJ(&scm__rc.d1951[14]), SCM_OBJ(&scm__rc.d1951[22]));
  scm__rc.d1950[29] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[16])),TRUE); /* * */
  scm__rc.d1950[30] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[17])),TRUE); /* <top> */
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[31]))[3] = scm__rc.d1950[4];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[31]))[4] = scm__rc.d1950[6];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[31]))[5] = scm__rc.d1950[29];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[31]))[6] = scm__rc.d1950[7];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[31]))[7] = scm__rc.d1950[30];
  Scm_MakeBinding(SCM_MODULE(SCM_OBJ(Scm_GaucheInternalModule())), SCM_SYMBOL(SCM_INTERN("array-ref")), SCM_OBJ(&libarrayarray_ref__STUB), 0);
  libarrayarray_ref__STUB.common.info = scm__rc.d1950[28];
  libarrayarray_ref__STUB.common.typeHint = SCM_OBJ(&scm__rc.d1950[31]);
  scm__rc.d1950[39] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[18])),TRUE); /* array-set! */
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[25]), scm__rc.d1950[2]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[26]), scm__rc.d1950[39]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[27]), scm__rc.d1950[4]);
  SCM_SET_CAR(SCM_OBJ(&scm__rc.d1951[28]), scm__rc.d1950[3]);
  scm__rc.d1950[40] = Scm_MakeExtendedPair(scm__rc.d1950[39], SCM_OBJ(&scm__rc.d1951[14]), SCM_OBJ(&scm__rc.d1951[30]));
  scm__rc.d1950[41] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[19])),TRUE); /* <void> */
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[42]))[3] = scm__rc.d1950[4];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[42]))[4] = scm__rc.d1950[6];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[42]))[5] = scm__rc.d1950[29];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[42]))[6] = scm__rc.d1950[7];
  ((ScmObj*)SCM_OBJ(&scm__rc.d1950[42]))[7] = scm__rc.d1950[41];
  Scm_MakeBinding(SCM_MODULE(SCM_OBJ(Scm_GaucheInternalModule())), SCM_SYMBOL(SCM_INTERN("array-set!")), SCM_OBJ(&libarrayarray_setX__STUB), 0);
  libarrayarray_setX__STUB.common.info = scm__rc.d1950[40];
  libarrayarray_setX__STUB.common.typeHint = SCM_OBJ(&scm__rc.d1950[42]);
  scm__rc.d1950[50] = Scm_MakeIdentifier(scm__rc.d1950[23], SCM_MODULE(scm__rc.d1950[19]), SCM_NIL); /* gauche.internal#array-ref */
  scm__rc.d1950[51] = Scm_MakeIdentifier(scm__rc.d1950[23], SCM_MODULE(Scm_GaucheModule()), SCM_NIL); /* gauche#array-ref */
  scm__rc.d1950[52] = Scm_MakePackedDebugInfo(SCM_U8VECTOR(SCM_OBJ(&scm__rc.d1954[1])),SCM_debug_info_const_vector);
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[1]))->name = scm__rc.d1950[21];/* %toplevel */
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[1]))->debugInfo = scm__rc.d1950[52];
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[15]))[3] = SCM_WORD(scm__rc.d1950[16]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[15]))[6] = SCM_WORD(scm__rc.d1950[23]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[15]))[10] = SCM_WORD(scm__rc.d1950[50]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[15]))[13] = SCM_WORD(scm__rc.d1950[51]);
  scm__rc.d1950[53] = Scm_MakeIdentifier(scm__rc.d1950[39], SCM_MODULE(scm__rc.d1950[19]), SCM_NIL); /* gauche.internal#array-set! */
  scm__rc.d1950[54] = Scm_MakeIdentifier(scm__rc.d1950[39], SCM_MODULE(Scm_GaucheModule()), SCM_NIL); /* gauche#array-set! */
  scm__rc.d1950[55] = Scm_MakePackedDebugInfo(SCM_U8VECTOR(SCM_OBJ(&scm__rc.d1954[2])),SCM_debug_info_const_vector);
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[2]))->name = scm__rc.d1950[21];/* %toplevel */
  SCM_COMPILED_CODE(SCM_OBJ(&scm__rc.d1953[2]))->debugInfo = scm__rc.d1950[55];
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[30]))[3] = SCM_WORD(scm__rc.d1950[16]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[30]))[6] = SCM_WORD(scm__rc.d1950[39]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[30]))[10] = SCM_WORD(scm__rc.d1950[53]);
  ((ScmWord*)SCM_OBJ(&scm__rc.d1952[30]))[13] = SCM_WORD(scm__rc.d1950[54]);
  Scm_VMExecuteToplevels(toplevels);
  scm__rc.d1950[63] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[20])),TRUE); /* define-in-module */
  scm__rc.d1950[64] = Scm_MakeSymbol(SCM_STRING(SCM_OBJ(&scm__sc.d1949[21])),TRUE); /* gauche */
}
