#ifndef __X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H
#define __X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H

#include <x10rt.h>


#define X10_LANG_OBJECT_H_NODEPS
#include <x10/lang/Object.h>
#undef X10_LANG_OBJECT_H_NODEPS
#define X10_IO_CUSTOMSERIALIZATION_H_NODEPS
#include <x10/io/CustomSerialization.h>
#undef X10_IO_CUSTOMSERIALIZATION_H_NODEPS
#define X10_UTIL_INDEXEDMEMORYCHUNK_H_NODEPS
#include <x10/util/IndexedMemoryChunk.h>
#undef X10_UTIL_INDEXEDMEMORYCHUNK_H_NODEPS
#define X10_LANG_INT_H_NODEPS
#include <x10/lang/Int.h>
#undef X10_LANG_INT_H_NODEPS
namespace x10 { namespace util { 
template<class TPMGL(T)> class IndexedMemoryChunk;
} } 
namespace x10 { namespace lang { 
class Int;
} } 
namespace x10 { namespace io { 
class SerialData;
} } 
namespace x10 { namespace lang { 
class Any;
} } 
namespace x10 { namespace compiler { 
class CompilerFlags;
} } 
namespace x10 { namespace compiler { 
class Inline;
} } 
namespace x10 { namespace array { 
template<class TPMGL(T)> class Array;
} } 
namespace x10 { namespace lang { 
class Math;
} } 
namespace x10 { namespace lang { 
class ArrayIndexOutOfBoundsException;
} } 
namespace x10 { namespace lang { 
class String;
} } 
namespace x10 { namespace compiler { 
class NoInline;
} } 
namespace x10 { namespace compiler { 
class NoReturn;
} } 
namespace x10 { namespace lang { 
class UnsupportedOperationException;
} } 
namespace x10 { namespace lang { 
class Zero;
} } 
namespace x10 { namespace util { 

template<class TPMGL(T)> class GrowableIndexedMemoryChunk;
template <> class GrowableIndexedMemoryChunk<void>;
template<class TPMGL(T)> class GrowableIndexedMemoryChunk : public x10::lang::Object
  {
    public:
    RTT_H_DECLS_CLASS
    
    static x10aux::itable_entry _itables[3];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    static x10::io::CustomSerialization::itable<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > _itable_0;
    
    static x10::lang::Any::itable<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > _itable_1;
    
    x10::util::IndexedMemoryChunk<TPMGL(T) > FMGL(imc);
    
    x10_int FMGL(length);
    
    void _constructor();
    
    static x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > _make(
             );
    
    void _constructor(x10_int cap);
    
    static x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > _make(
             x10_int cap);
    
    void _constructor(x10aux::ref<x10::io::SerialData> sd);
    
    static x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > _make(
             x10aux::ref<x10::io::SerialData> sd);
    
    virtual x10aux::ref<x10::io::SerialData> serialize();
    virtual void add(TPMGL(T) v);
    virtual void insert(x10_int p, x10::util::IndexedMemoryChunk<TPMGL(T) > items);
    virtual TPMGL(T) __apply(x10_int idx);
    virtual void __set(x10_int idx, TPMGL(T) v);
    virtual x10_int length();
    virtual x10_int capacity();
    virtual void removeLast();
    virtual void clear();
    virtual x10::util::IndexedMemoryChunk<TPMGL(T) > moveSectionToIndexedMemoryChunk(
      x10_int i, x10_int j);
    virtual x10aux::ref<x10::array::Array<TPMGL(T)> > moveSectionToArray(
      x10_int i, x10_int j);
    virtual x10::util::IndexedMemoryChunk<TPMGL(T) > toIndexedMemoryChunk(
      );
    virtual x10aux::ref<x10::array::Array<TPMGL(T)> > toArray(
      );
    virtual void grow(x10_int newCapacity);
    virtual void shrink(x10_int newCapacity);
    virtual x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >
      x10__util__GrowableIndexedMemoryChunk____x10__util__GrowableIndexedMemoryChunk__this(
      );
    void __fieldInitializers46680();
    
    // Serialization
    public: static const x10aux::serialization_id_t _serialization_id;
    
    public: x10aux::serialization_id_t _get_serialization_id() {
         return _serialization_id;
    }
    
    public: virtual void _serialize_body(x10aux::serialization_buffer& buf);
    
    public: static x10aux::ref<x10::lang::Reference> _deserializer(x10aux::deserialization_buffer& buf);
    
    public: void _deserialize_body(x10aux::deserialization_buffer& buf);
    
};
template <> class GrowableIndexedMemoryChunk<void> : public x10::lang::Object
{
    public:
    static x10aux::RuntimeType rtt;
    static const x10aux::RuntimeType* getRTT() { return & rtt; }
    static void raiseIndexOutOfBounds(x10_int idx, x10_int length) X10_PRAGMA_NORETURN ;
    
    static void illegalGap(x10_int idx, x10_int length) X10_PRAGMA_NORETURN ;
    
    
};

} } 
#endif // X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H

namespace x10 { namespace util { 
template<class TPMGL(T)> class GrowableIndexedMemoryChunk;
} } 

#ifndef X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_NODEPS
#define X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_NODEPS
#include <x10/lang/Object.h>
#include <x10/io/CustomSerialization.h>
#include <x10/util/IndexedMemoryChunk.h>
#include <x10/lang/Int.h>
#include <x10/io/SerialData.h>
#include <x10/lang/Any.h>
#include <x10/compiler/CompilerFlags.h>
#include <x10/compiler/Inline.h>
#include <x10/array/Array.h>
#include <x10/lang/Math.h>
#include <x10/lang/ArrayIndexOutOfBoundsException.h>
#include <x10/lang/String.h>
#include <x10/compiler/NoInline.h>
#include <x10/compiler/NoReturn.h>
#include <x10/lang/UnsupportedOperationException.h>
#include <x10/lang/Zero.h>
#ifndef X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_GENERICS
#define X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_GENERICS
#endif // X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_GENERICS
#ifndef X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_IMPLEMENTATION
#define X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_IMPLEMENTATION
#include <x10/util/GrowableIndexedMemoryChunk.h>

template<class TPMGL(T)> x10::io::CustomSerialization::itable<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_itable_0(&x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::equals, &x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::hashCode, &x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::serialize, &x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::toString, &x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::typeName);
template<class TPMGL(T)> x10::lang::Any::itable<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_itable_1(&x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::equals, &x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::hashCode, &x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::toString, &x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_itables[3] = {x10aux::itable_entry(&x10aux::getRTT<x10::io::CustomSerialization>, &_itable_0), x10aux::itable_entry(&x10aux::getRTT<x10::lang::Any>, &_itable_1), x10aux::itable_entry(NULL, (void*)x10aux::getRTT<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >())};

//#line 32 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10FieldDecl_c

//#line 41 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10FieldDecl_c
/**
    * Elements 0..length-1 have valid entries of type T.
    * Elements length..imc.length-1 may not be valid 
    * values of type T.  
    * It is an invariant of this class, that such elements
    * will never be accessed.
    */

//#line 47 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_constructor(
                           ) {
    
    //#line 48 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_constructor(
      ((x10_int)0));
    
}
template<class TPMGL(T)> x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_make(
                           ) {
    x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >(), 0, sizeof(x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>))) x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>();
    this_->_constructor();
    return this_;
}



//#line 55 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_constructor(
                           x10_int cap) {
    
    //#line 55 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::lang::Object::_constructor();
    
    //#line 55 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.AssignPropertyCall_c
    
    //#line 31 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::__fieldInitializers46680();
    
    //#line 56 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(imc) = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(cap, 8, false, true);
    
    //#line 57 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(length) = ((x10_int)0);
}
template<class TPMGL(T)> x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_make(
                           x10_int cap) {
    x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >(), 0, sizeof(x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>))) x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>();
    this_->_constructor(cap);
    return this_;
}



//#line 60 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_constructor(
                           x10aux::ref<x10::io::SerialData> sd) {
    
    //#line 60 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::lang::Object::_constructor();
    
    //#line 60 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.AssignPropertyCall_c
    
    //#line 31 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::__fieldInitializers46680();
    
    //#line 61 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10::util::IndexedMemoryChunk<TPMGL(T) > data = x10aux::class_cast<x10::util::IndexedMemoryChunk<TPMGL(T) > >(x10aux::nullCheck(sd)->
                                                                                                                    FMGL(data));
    
    //#line 62 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(imc) = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >((data)->length(), 8, false, false);
    
    //#line 63 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(data,((x10_int)0),((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                             FMGL(imc),((x10_int)0),(data)->length());
    
    //#line 64 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(length) = (data)->length();
}
template<class TPMGL(T)> x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_make(
                           x10aux::ref<x10::io::SerialData> sd)
{
    x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >(), 0, sizeof(x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>))) x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>();
    this_->_constructor(sd);
    return this_;
}



//#line 67 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::io::SerialData>
  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::serialize(
  ) {
    
    //#line 68 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10::util::IndexedMemoryChunk<TPMGL(T) > data = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                               FMGL(length), 8, false, false);
    
    //#line 69 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                           FMGL(imc),((x10_int)0),data,((x10_int)0),((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                      FMGL(length));
    
    //#line 70 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return x10::io::SerialData::_make(x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Any> >(data),
                                      x10aux::class_cast_unchecked<x10aux::ref<x10::io::SerialData> >(X10_NULL));
    
}

//#line 76 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::add(
  TPMGL(T) v) {
    
    //#line 77 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (((((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                         FMGL(length)) + (((x10_int)1))))) > (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::capacity())))
    {
        
        //#line 77 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::grow(
          ((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                         FMGL(length)) + (((x10_int)1)))));
    }
    
    //#line 78 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
       FMGL(imc))->__set(((x10_int) (((__extension__ ({
        
        //#line 78 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
        x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > x47037 =
          ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this);
        
        //#line 78 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": polyglot.ast.Empty_c
        ;
        x10aux::nullCheck(x47037)->FMGL(length) = ((x10_int) ((x10aux::nullCheck(x47037)->
                                                                 FMGL(length)) + (((x10_int)1))));
    }))
    ) - (((x10_int)1)))), v);
}

//#line 90 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::insert(
  x10_int p, x10::util::IndexedMemoryChunk<TPMGL(T) > items) {
    
    //#line 91 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10_int addLen = (items)->length();
    
    //#line 92 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10_int newLen = ((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                    FMGL(length)) + (addLen)));
    
    //#line 93 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10_int movLen = ((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                    FMGL(length)) - (p)));
    
    //#line 94 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (BOUNDS_CHECK_BOOL && ((movLen) < (((x10_int)0))))
    {
        
        //#line 94 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        x10::util::GrowableIndexedMemoryChunk<void>::illegalGap(
          p, ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
               FMGL(length));
    }
    
    //#line 95 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (((newLen) > (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::capacity())))
    {
        
        //#line 95 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::grow(
          newLen);
    }
    
    //#line 96 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (((movLen) > (((x10_int)0)))) {
        
        //#line 97 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                               FMGL(imc),p,((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                             FMGL(imc),((x10_int) ((p) + (addLen))),movLen);
    }
    
    //#line 99 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(items,((x10_int)0),((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                              FMGL(imc),p,(items)->length());
    
    //#line 100 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(length) = newLen;
}

//#line 103 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> TPMGL(T) x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::__apply(
  x10_int idx) {
    
    //#line 104 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (BOUNDS_CHECK_BOOL && ((idx) >= (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                          FMGL(length))))
    {
        
        //#line 104 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        x10::util::GrowableIndexedMemoryChunk<void>::raiseIndexOutOfBounds(
          idx, ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                 FMGL(length));
    }
    
    //#line 105 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
              FMGL(imc))->__apply(idx);
    
}

//#line 108 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::__set(
  x10_int idx, TPMGL(T) v) {
    
    //#line 109 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (BOUNDS_CHECK_BOOL && ((idx) > (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                         FMGL(length)))) {
        
        //#line 109 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        x10::util::GrowableIndexedMemoryChunk<void>::illegalGap(
          idx, ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                 FMGL(length));
    }
    
    //#line 110 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if ((x10aux::struct_equals(idx, ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                      FMGL(length)))) {
        
        //#line 111 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::add(
          v);
    } else {
        
        //#line 113 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
        (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
           FMGL(imc))->__set(idx, v);
    }
    
}

//#line 121 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10_int x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::length(
  ) {
    
    //#line 121 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
             FMGL(length);
    
}

//#line 126 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10_int x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::capacity(
  ) {
    
    //#line 126 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
              FMGL(imc))->length();
    
}

//#line 131 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::removeLast(
  ) {
    
    //#line 132 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
       FMGL(imc))->clear(((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                        FMGL(length)) - (((x10_int)1)))), ((x10_int)1));
    
    //#line 133 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(length) = ((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                    FMGL(length)) - (((x10_int)1))));
    
    //#line 134 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::shrink(
      ((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                     FMGL(length)) + (((x10_int)1)))));
}

//#line 140 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::clear(
  ) {
    
    //#line 141 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
       FMGL(imc))->clear(((x10_int)0), ((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                      FMGL(length)) - (((x10_int)1)))));
    
    //#line 142 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(length) = ((x10_int)0);
}

//#line 153 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10::util::IndexedMemoryChunk<TPMGL(T) >
  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::moveSectionToIndexedMemoryChunk(
  x10_int i, x10_int j) {
    
    //#line 154 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10_int len = ((x10_int) ((((x10_int) ((j) - (i)))) + (((x10_int)1))));
    
    //#line 155 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (((len) < (((x10_int)1)))) {
        
        //#line 155 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
        return x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(((x10_int)0), 8, false, false);
        
    }
    
    //#line 156 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10::util::IndexedMemoryChunk<TPMGL(T) > tmp = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(len, 8, false, false);
    
    //#line 157 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                           FMGL(imc),i,tmp,((x10_int)0),len);
    
    //#line 158 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                           FMGL(imc),((x10_int) ((j) + (((x10_int)1)))),((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                          FMGL(imc),i,((x10_int) ((((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                                                                  FMGL(length)) - (j)))) - (((x10_int)1)))));
    
    //#line 159 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
       FMGL(imc))->clear(((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                        FMGL(length)) - (len))), len);
    
    //#line 160 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > x47041 =
      ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this);
    
    //#line 160 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10_int y47042 = len;
    
    //#line 160 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    x10aux::nullCheck(x47041)->FMGL(length) = ((x10_int) ((x10aux::nullCheck(x47041)->
                                                             FMGL(length)) - (y47042)));
    
    //#line 161 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::shrink(
      ((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                     FMGL(length)) + (((x10_int)1)))));
    
    //#line 162 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return tmp;
    
}

//#line 165 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::array::Array<TPMGL(T)> >
  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::moveSectionToArray(
  x10_int i, x10_int j) {
    
    //#line 166 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return x10::array::Array<TPMGL(T)>::_make(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::moveSectionToIndexedMemoryChunk(
                                                i, j));
    
}

//#line 172 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10::util::IndexedMemoryChunk<TPMGL(T) >
  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::toIndexedMemoryChunk(
  ) {
    
    //#line 173 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10::util::IndexedMemoryChunk<TPMGL(T) > ans = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                              FMGL(length), 8, false, false);
    
    //#line 174 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                           FMGL(imc),((x10_int)0),ans,((x10_int)0),((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                     FMGL(length));
    
    //#line 175 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return ans;
    
}

//#line 181 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::array::Array<TPMGL(T)> >
  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::toArray(
  ) {
    
    //#line 182 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return x10::array::Array<TPMGL(T)>::_make(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::toIndexedMemoryChunk());
    
}

//#line 185 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::grow(
  x10_int newCapacity) {
    
    //#line 186 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10_int oldCapacity = ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::capacity();
    
    //#line 187 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (((newCapacity) < (((x10_int) ((oldCapacity) * (((x10_int)2)))))))
    {
        
        //#line 188 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10LocalAssign_c
        newCapacity = ((x10_int) ((oldCapacity) * (((x10_int)2))));
    }
    
    //#line 190 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (((newCapacity) < (((x10_int)8)))) {
        
        //#line 191 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10LocalAssign_c
        newCapacity = ((x10_int)8);
    }
    
    //#line 194 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10::util::IndexedMemoryChunk<TPMGL(T) > tmp = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(newCapacity, 8, false, false);
    
    //#line 195 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                           FMGL(imc),((x10_int)0),tmp,((x10_int)0),((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                     FMGL(length));
    
    //#line 196 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (tmp)->clear(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                   FMGL(length), ((x10_int) ((newCapacity) - (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                FMGL(length)))));
    
    //#line 197 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
       FMGL(imc))->deallocate();
    
    //#line 198 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(imc) = tmp;
}

//#line 201 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::shrink(
  x10_int newCapacity) {
    
    //#line 202 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10If_c
    if (((newCapacity) > (((x10_int) ((((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::capacity()) / x10aux::zeroCheck(((x10_int)4)))))) ||
        ((newCapacity) < (((x10_int)8)))) {
        
        //#line 203 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
        return;
    }
    
    //#line 204 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10LocalAssign_c
    newCapacity = x10::lang::Math::max(newCapacity, ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                      FMGL(length));
    
    //#line 205 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10LocalAssign_c
    newCapacity = x10::lang::Math::max(newCapacity, ((x10_int)8));
    
    //#line 206 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10LocalDecl_c
    x10::util::IndexedMemoryChunk<TPMGL(T) > tmp = x10::util::IndexedMemoryChunk<void>::allocate<TPMGL(T) >(newCapacity, 8, false, false);
    
    //#line 207 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    x10::util::IndexedMemoryChunk<void>::copy<TPMGL(T) >(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                           FMGL(imc),((x10_int)0),tmp,((x10_int)0),((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                                                     FMGL(length));
    
    //#line 208 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (tmp)->clear(((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                   FMGL(length), ((x10_int) ((newCapacity) - (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
                                                                FMGL(length)))));
    
    //#line 209 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10Call_c
    (((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
       FMGL(imc))->deallocate();
    
    //#line 210 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(imc) = tmp;
}

//#line 213 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c

//#line 217 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c

//#line 31 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >
  x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::x10__util__GrowableIndexedMemoryChunk____x10__util__GrowableIndexedMemoryChunk__this(
  ) {
    
    //#line 31 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this);
    
}

//#line 31 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::__fieldInitializers46680(
  ) {
    
    //#line 31 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(imc) = x10aux::zeroValue<x10::util::IndexedMemoryChunk<TPMGL(T) > >();
    
    //#line 31 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/util/GrowableIndexedMemoryChunk.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >)this)->
      FMGL(length) = ((x10_int)0);
}
template<class TPMGL(T)> const x10aux::serialization_id_t x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_deserializer, x10aux::CLOSURE_KIND_NOT_ASYNC);

template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_serialize_body(x10aux::serialization_buffer& buf) {
    /* NOTE: Implements x10.io.CustomSerialization */
    buf.write(this->serialize());
    
}

template<class TPMGL(T)> x10aux::ref<x10::lang::Reference> x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_deserializer(x10aux::deserialization_buffer& buf) {
    x10aux::ref<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::util::GrowableIndexedMemoryChunk<TPMGL(T)> >(), 0, sizeof(x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>))) x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>();
    buf.record_reference(this_);
    this_->_deserialize_body(buf);
    return this_;
}

template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_deserialize_body(x10aux::deserialization_buffer& buf) {
    /* NOTE: Implements x10.io.CustomSerialization */
    x10aux::ref<x10::io::SerialData>val_ = buf.read<x10aux::ref<x10::io::SerialData> >();
    _constructor(val_);
    
}

template<class TPMGL(T)> x10aux::RuntimeType x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::rtt;
template<class TPMGL(T)> void x10::util::GrowableIndexedMemoryChunk<TPMGL(T)>::_initRTT() {
    const x10aux::RuntimeType *canonical = x10aux::getRTT<x10::util::GrowableIndexedMemoryChunk<void> >();
    if (rtt.initStageOne(canonical)) return;
    const x10aux::RuntimeType* parents[2] = { x10aux::getRTT<x10::lang::Object>(), x10aux::getRTT<x10::io::CustomSerialization>()};
    const x10aux::RuntimeType* params[1] = { x10aux::getRTT<TPMGL(T)>()};
    x10aux::RuntimeType::Variance variances[1] = { x10aux::RuntimeType::invariant};
    const char *baseName = "x10.util.GrowableIndexedMemoryChunk";
    rtt.initStageTwo(baseName, x10aux::RuntimeType::class_kind, 2, parents, 1, params, variances);
}
#endif // X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_IMPLEMENTATION
#endif // __X10_UTIL_GROWABLEINDEXEDMEMORYCHUNK_H_NODEPS
