#ifndef __X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H
#define __X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H

#include <x10rt.h>


#define X10_LANG_FINISHSTATE__REMOTEFINISH_H_NODEPS
#include <x10/lang/FinishState__RemoteFinish.h>
#undef X10_LANG_FINISHSTATE__REMOTEFINISH_H_NODEPS
#define X10_LANG_FINISHSTATE__COLLECTINGFINISHSTATE_H_NODEPS
#include <x10/lang/FinishState__CollectingFinishState.h>
#undef X10_LANG_FINISHSTATE__COLLECTINGFINISHSTATE_H_NODEPS
namespace x10 { namespace lang { 
template<class TPMGL(T)> class FinishState__StatefulReducer;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class GlobalRef;
} } 
namespace x10 { namespace lang { 
class FinishState;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class Reducible;
} } 
namespace x10 { namespace lang { 
class Int;
} } 
namespace x10 { namespace util { namespace concurrent { 
class Lock;
} } } 
namespace x10 { namespace util { namespace concurrent { 
class AtomicInteger;
} } } 
namespace x10 { namespace lang { 
class MultipleExceptions;
} } 
namespace x10 { namespace lang { 
class FinishState__RemoteFinishSkeleton;
} } 
namespace x10 { namespace lang { 
class VoidFun_0_0;
} } 
namespace x10 { namespace util { 
template<class TPMGL(T)> class IndexedMemoryChunk;
} } 
namespace x10 { namespace lang { 
class Runtime;
} } 
namespace x10 { namespace lang { 
class Place;
} } 
namespace x10 { namespace lang { 
class FinishState__RootFinish;
} } 
namespace x10 { namespace lang { 
template<class TPMGL(T)> class FinishState__RootCollectingFinish;
} } 
namespace x10 { namespace lang { 
class Throwable;
} } 
namespace x10 { namespace compiler { 
class RemoteInvocation;
} } 
namespace x10 { namespace util { 
template<class TPMGL(T), class TPMGL(U)> class Pair;
} } 
namespace x10 { namespace lang { 

template<class TPMGL(T)> class FinishState__RemoteCollectingFinish;
template <> class FinishState__RemoteCollectingFinish<void>;
template<class TPMGL(T)> class FinishState__RemoteCollectingFinish : public x10::lang::FinishState__RemoteFinish
  {
    public:
    RTT_H_DECLS_CLASS
    
    static x10aux::itable_entry _itables[3];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    static typename x10::lang::FinishState__CollectingFinishState<TPMGL(T)>::template itable<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> > _itable_0;
    
    static x10::lang::Any::itable<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> > _itable_1;
    
    x10aux::ref<x10::lang::FinishState__StatefulReducer<TPMGL(T)> >
      FMGL(sr);
    
    void _constructor(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref,
                      x10aux::ref<x10::lang::Reducible<TPMGL(T)> > reducer);
    
    static x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> > _make(
             x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref,
             x10aux::ref<x10::lang::Reducible<TPMGL(T)> > reducer);
    
    virtual void accept(TPMGL(T) t, x10_int id);
    virtual void notifyActivityTermination();
    virtual x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >
      x10__lang__FinishState__RemoteCollectingFinish____x10__lang__FinishState__RemoteCollectingFinish__this(
      );
    
    // Serialization
    public: static const x10aux::serialization_id_t _serialization_id;
    
    public: virtual 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 FinishState__RemoteCollectingFinish<void> : public x10::lang::FinishState__RemoteFinish
{
    public:
    static x10aux::RuntimeType rtt;
    static const x10aux::RuntimeType* getRTT() { return & rtt; }
    
};

} } 
#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H

namespace x10 { namespace lang { 
template<class TPMGL(T)> class FinishState__RemoteCollectingFinish;
} } 

#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_NODEPS
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_NODEPS
#include <x10/lang/FinishState__RemoteFinish.h>
#include <x10/lang/FinishState__CollectingFinishState.h>
#include <x10/lang/FinishState__StatefulReducer.h>
#include <x10/lang/GlobalRef.h>
#include <x10/lang/FinishState.h>
#include <x10/lang/Reducible.h>
#include <x10/lang/Int.h>
#include <x10/util/concurrent/Lock.h>
#include <x10/util/concurrent/AtomicInteger.h>
#include <x10/lang/MultipleExceptions.h>
#include <x10/lang/FinishState__RemoteFinishSkeleton.h>
#include <x10/lang/VoidFun_0_0.h>
#include <x10/util/IndexedMemoryChunk.h>
#include <x10/lang/Runtime.h>
#include <x10/lang/Place.h>
#include <x10/lang/FinishState__RootFinish.h>
#include <x10/lang/FinishState__RootCollectingFinish.h>
#include <x10/lang/Throwable.h>
#include <x10/compiler/RemoteInvocation.h>
#include <x10/util/Pair.h>
#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_GENERICS
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_GENERICS
#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_GENERICS
#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_IMPLEMENTATION
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_IMPLEMENTATION
#include <x10/lang/FinishState__RemoteCollectingFinish.h>

#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__16_CLOSURE
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__16_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_FinishState__RemoteCollectingFinish__closure__16 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 675 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        x10aux::nullCheck(x10::lang::FinishState::template deref<x10aux::ref<x10::lang::FinishState__RootCollectingFinish<TPMGL(T)> > >(
                            ref))->notify(message, x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Throwable> >(t));
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref;
    x10::util::IndexedMemoryChunk<x10_int > message;
    x10aux::ref<x10::lang::MultipleExceptions> t;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->ref);
        buf.write(this->message);
        buf.write(this->t);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >* storage = x10aux::alloc<x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > that_ref = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > >();
        x10::util::IndexedMemoryChunk<x10_int > that_message = buf.read<x10::util::IndexedMemoryChunk<x10_int > >();
        x10aux::ref<x10::lang::MultipleExceptions> that_t = buf.read<x10aux::ref<x10::lang::MultipleExceptions> >();
        x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) > > this_ = new (storage) x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >(that_ref, that_message, that_t);
        return this_;
    }
    
    x10_lang_FinishState__RemoteCollectingFinish__closure__16(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref, x10::util::IndexedMemoryChunk<x10_int > message, x10aux::ref<x10::lang::MultipleExceptions> t) : ref(ref), message(message), t(t) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10:675";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) > >x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >::__apply, &x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_GENERAL_ASYNC);

#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__16_CLOSURE
#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__17_CLOSURE
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__17_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_FinishState__RemoteCollectingFinish__closure__17 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 677 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        x10aux::nullCheck(x10::lang::FinishState::template deref<x10aux::ref<x10::lang::FinishState__RootCollectingFinish<TPMGL(T)> > >(
                            ref))->notifyValue(message, result);
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref;
    x10::util::IndexedMemoryChunk<x10_int > message;
    TPMGL(T) result;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->ref);
        buf.write(this->message);
        buf.write(this->result);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >* storage = x10aux::alloc<x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > that_ref = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > >();
        x10::util::IndexedMemoryChunk<x10_int > that_message = buf.read<x10::util::IndexedMemoryChunk<x10_int > >();
        TPMGL(T) that_result = buf.read<TPMGL(T)>();
        x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) > > this_ = new (storage) x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >(that_ref, that_message, that_result);
        return this_;
    }
    
    x10_lang_FinishState__RemoteCollectingFinish__closure__17(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref, x10::util::IndexedMemoryChunk<x10_int > message, TPMGL(T) result) : ref(ref), message(message), result(result) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10:677";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) > >x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >::__apply, &x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_GENERAL_ASYNC);

#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__17_CLOSURE
#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__18_CLOSURE
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__18_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_FinishState__RemoteCollectingFinish__closure__18 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 685 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        x10aux::nullCheck(x10::lang::FinishState::template deref<x10aux::ref<x10::lang::FinishState__RootCollectingFinish<TPMGL(T)> > >(
                            ref))->notify(message, x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Throwable> >(t));
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref;
    x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message;
    x10aux::ref<x10::lang::MultipleExceptions> t;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->ref);
        buf.write(this->message);
        buf.write(this->t);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >* storage = x10aux::alloc<x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > that_ref = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > >();
        x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > that_message = buf.read<x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > >();
        x10aux::ref<x10::lang::MultipleExceptions> that_t = buf.read<x10aux::ref<x10::lang::MultipleExceptions> >();
        x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) > > this_ = new (storage) x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >(that_ref, that_message, that_t);
        return this_;
    }
    
    x10_lang_FinishState__RemoteCollectingFinish__closure__18(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref, x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message, x10aux::ref<x10::lang::MultipleExceptions> t) : ref(ref), message(message), t(t) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10:685";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) > >x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >::__apply, &x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_GENERAL_ASYNC);

#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__18_CLOSURE
#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__19_CLOSURE
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__19_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_FinishState__RemoteCollectingFinish__closure__19 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 687 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        x10aux::nullCheck(x10::lang::FinishState::template deref<x10aux::ref<x10::lang::FinishState__RootCollectingFinish<TPMGL(T)> > >(
                            ref))->notifyValue(message, result);
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref;
    x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message;
    TPMGL(T) result;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->ref);
        buf.write(this->message);
        buf.write(this->result);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >* storage = x10aux::alloc<x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > that_ref = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > >();
        x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > that_message = buf.read<x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > >();
        TPMGL(T) that_result = buf.read<TPMGL(T)>();
        x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) > > this_ = new (storage) x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >(that_ref, that_message, that_result);
        return this_;
    }
    
    x10_lang_FinishState__RemoteCollectingFinish__closure__19(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref, x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message, TPMGL(T) result) : ref(ref), message(message), result(result) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10:687";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) > >x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >::__apply, &x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_GENERAL_ASYNC);

#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__19_CLOSURE
#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__20_CLOSURE
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__20_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_FinishState__RemoteCollectingFinish__closure__20 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 696 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        x10aux::nullCheck(x10::lang::FinishState::template deref<x10aux::ref<x10::lang::FinishState__RootCollectingFinish<TPMGL(T)> > >(
                            ref))->notify(message, x10aux::class_cast_unchecked<x10aux::ref<x10::lang::Throwable> >(t));
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref;
    x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message;
    x10aux::ref<x10::lang::MultipleExceptions> t;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->ref);
        buf.write(this->message);
        buf.write(this->t);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >* storage = x10aux::alloc<x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > that_ref = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > >();
        x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > that_message = buf.read<x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > >();
        x10aux::ref<x10::lang::MultipleExceptions> that_t = buf.read<x10aux::ref<x10::lang::MultipleExceptions> >();
        x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) > > this_ = new (storage) x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >(that_ref, that_message, that_t);
        return this_;
    }
    
    x10_lang_FinishState__RemoteCollectingFinish__closure__20(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref, x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message, x10aux::ref<x10::lang::MultipleExceptions> t) : ref(ref), message(message), t(t) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10:696";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) > >x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >::__apply, &x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_GENERAL_ASYNC);

#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__20_CLOSURE
#ifndef X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__21_CLOSURE
#define X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__21_CLOSURE
#include <x10/lang/Closure.h>
#include <x10/lang/VoidFun_0_0.h>
template<class TPMGL(T)> class x10_lang_FinishState__RemoteCollectingFinish__closure__21 : public x10::lang::Closure {
    public:
    
    static typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) > > _itable;
    static x10aux::itable_entry _itables[2];
    
    virtual x10aux::itable_entry* _getITables() { return _itables; }
    
    // closure body
    void __apply() {
        
        //#line 698 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        x10aux::nullCheck(x10::lang::FinishState::template deref<x10aux::ref<x10::lang::FinishState__RootCollectingFinish<TPMGL(T)> > >(
                            ref))->notifyValue(message, result);
    }
    
    // captured environment
    x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref;
    x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message;
    TPMGL(T) result;
    
    x10aux::serialization_id_t _get_serialization_id() {
        return _serialization_id;
    }
    
    void _serialize_body(x10aux::serialization_buffer &buf) {
        buf.write(this->ref);
        buf.write(this->message);
        buf.write(this->result);
    }
    
    template<class __T> static x10aux::ref<__T> _deserialize(x10aux::deserialization_buffer &buf) {
        x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >* storage = x10aux::alloc<x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) > >();
        buf.record_reference(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) > >(storage));
        x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > that_ref = buf.read<x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > >();
        x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > that_message = buf.read<x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > >();
        TPMGL(T) that_result = buf.read<TPMGL(T)>();
        x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) > > this_ = new (storage) x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >(that_ref, that_message, that_result);
        return this_;
    }
    
    x10_lang_FinishState__RemoteCollectingFinish__closure__21(x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref, x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message, TPMGL(T) result) : ref(ref), message(message), result(result) { }
    
    static const x10aux::serialization_id_t _serialization_id;
    
    static const x10aux::RuntimeType* getRTT() { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    virtual const x10aux::RuntimeType *_type() const { return x10aux::getRTT<x10::lang::VoidFun_0_0>(); }
    
    x10aux::ref<x10::lang::String> toString() {
        return x10aux::string_utils::lit(this->toNativeString());
    }
    
    const char* toNativeString() {
        return "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10:698";
    }

};

template<class TPMGL(T)> typename x10::lang::VoidFun_0_0::template itable <x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) > >x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >::_itable(&x10::lang::Reference::equals, &x10::lang::Closure::hashCode, &x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >::__apply, &x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >::toString, &x10::lang::Closure::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >::_itables[2] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::VoidFun_0_0>, &x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >::_itable),x10aux::itable_entry(NULL, NULL)};

template<class TPMGL(T)> const x10aux::serialization_id_t x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) >::template _deserialize<x10::lang::Reference>,x10aux::CLOSURE_KIND_GENERAL_ASYNC);

#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH__CLOSURE__21_CLOSURE
template<class TPMGL(T)> typename x10::lang::FinishState__CollectingFinishState<TPMGL(T)>::template itable<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >  x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_itable_0(&x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::accept, &x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::equals, &x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::hashCode, &x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::toString, &x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::typeName);
template<class TPMGL(T)> x10::lang::Any::itable<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >  x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_itable_1(&x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::equals, &x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::hashCode, &x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::toString, &x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::typeName);
template<class TPMGL(T)> x10aux::itable_entry x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_itables[3] = {x10aux::itable_entry(&x10aux::getRTT<x10::lang::FinishState__CollectingFinishState<TPMGL(T)> >, &_itable_0), x10aux::itable_entry(&x10aux::getRTT<x10::lang::Any>, &_itable_1), x10aux::itable_entry(NULL, (void*)x10aux::getRTT<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >())};

//#line 648 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10FieldDecl_c

//#line 649 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10ConstructorDecl_c
template<class TPMGL(T)> void x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_constructor(
                           x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref,
                           x10aux::ref<x10::lang::Reducible<TPMGL(T)> > reducer) {
    
    //#line 650 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10ConstructorCall_c
    (this)->::x10::lang::FinishState__RemoteFinish::_constructor(
      ref);
    
    //#line 649 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.AssignPropertyCall_c
    
    //#line 651 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
      FMGL(sr) = x10::lang::FinishState__StatefulReducer<TPMGL(T)>::_make(reducer);
}
template<class TPMGL(T)> x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> > x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_make(
                           x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref,
                           x10aux::ref<x10::lang::Reducible<TPMGL(T)> > reducer)
{
    x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> > this_ = new (memset(x10aux::alloc<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >(), 0, sizeof(x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>))) x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>();
    this_->_constructor(ref, reducer);
    return this_;
}



//#line 653 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::accept(
  TPMGL(T) t, x10_int id) {
    
    //#line 654 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
    x10aux::nullCheck(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                        FMGL(sr))->accept(t, id);
}

//#line 656 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> void x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::notifyActivityTermination(
  ) {
    
    //#line 657 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
    x10aux::nullCheck(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                        FMGL(lock))->lock();
    
    //#line 658 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> > x43918 =
      ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this);
    
    //#line 658 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": polyglot.ast.Empty_c
    ;
    
    //#line 658 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10FieldAssign_c
    x10aux::nullCheck(x43918)->FMGL(count) = ((x10_int) ((x10aux::nullCheck(x43918)->
                                                            FMGL(count)) - (((x10_int)1))));
    
    //#line 659 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
    if (((((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
            FMGL(local)->x10::util::concurrent::AtomicInteger::decrementAndGet()) > (((x10_int)0))))
    {
        
        //#line 660 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        x10aux::nullCheck(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                            FMGL(lock))->unlock();
        
        //#line 661 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10Return_c
        return;
    }
    
    //#line 663 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::lang::MultipleExceptions> t = x10::lang::MultipleExceptions::make(
                                                     ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                       FMGL(exceptions));
    
    //#line 664 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
    x10::lang::GlobalRef<x10aux::ref<x10::lang::FinishState> > ref =
      ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->ref();
    
    //#line 665 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
    x10aux::ref<x10::lang::VoidFun_0_0> closure;
    
    //#line 666 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
    x10aux::nullCheck(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                        FMGL(sr))->placeMerge();
    
    //#line 667 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
    TPMGL(T) result = x10aux::nullCheck(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                          FMGL(sr))->result();
    
    //#line 668 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
    x10aux::nullCheck(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                        FMGL(sr))->reset();
    
    //#line 669 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
    if ((!x10aux::struct_equals((((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                   FMGL(counts))->length(),
                                ((x10_int)0)))) {
        
        //#line 670 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        (((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
           FMGL(counts))->__set(x10aux::here, ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                FMGL(count));
        
        //#line 671 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
        if (((((x10_int) ((((x10_int)2)) * (((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                              FMGL(length))))) > (x10aux::num_hosts)))
        {
            
            //#line 672 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
            x10::util::IndexedMemoryChunk<x10_int > message =
              x10::util::IndexedMemoryChunk<void>::allocate<x10_int >((((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                         FMGL(counts))->length(), 8, false, false);
            
            //#line 673 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
            x10::util::IndexedMemoryChunk<void>::copy<x10_int >(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                  FMGL(counts),((x10_int)0),message,((x10_int)0),(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                                                                    FMGL(counts))->length());
            
            //#line 674 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
            if ((!x10aux::struct_equals(X10_NULL, t))) {
                
                //#line 675 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
                closure = x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T)>)))x10_lang_FinishState__RemoteCollectingFinish__closure__16<TPMGL(T)>(ref, message, t)));
            } else {
                
                //#line 677 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
                closure = x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T)>)))x10_lang_FinishState__RemoteCollectingFinish__closure__17<TPMGL(T)>(ref, message, result)));
            }
            
        } else {
            
            //#line 680 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
            x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message =
              x10::util::IndexedMemoryChunk<void>::allocate<x10::util::Pair<x10_int, x10_int> >(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                                                  FMGL(length), 8, false, false);
            
            //#line 681 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
            x10_int i43797min43914 = ((x10_int)0);
            
            //#line 681 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
            x10_int i43797max43915 = ((x10_int) ((((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                    FMGL(length)) - (((x10_int)1))));
            
            //#line 681 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": polyglot.ast.For_c
            {
                x10_int i43916;
                for (
                     //#line 681 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
                     i43916 = i43797min43914; ((i43916) <= (i43797max43915));
                     
                     //#line 681 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
                     i43916 = ((x10_int) ((i43916) + (((x10_int)1)))))
                {
                    
                    //#line 681 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
                    x10_int i43917 = i43916;
                    
                    //#line 682 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
                    (message)->__set(i43917, x10::util::Pair<x10_int, x10_int>::_make((((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                                         FMGL(places))->__apply(i43917),
                                                                                      (((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                                         FMGL(counts))->__apply((((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                                                                   FMGL(places))->__apply(i43917))));
                }
            }
            
            //#line 684 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
            if ((!x10aux::struct_equals(X10_NULL, t))) {
                
                //#line 685 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
                closure = x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T)>)))x10_lang_FinishState__RemoteCollectingFinish__closure__18<TPMGL(T)>(ref, message, t)));
            } else {
                
                //#line 687 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
                closure = x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T)>)))x10_lang_FinishState__RemoteCollectingFinish__closure__19<TPMGL(T)>(ref, message, result)));
            }
            
        }
        
        //#line 690 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        (((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
           FMGL(counts))->clear(((x10_int)0), (((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                 FMGL(counts))->length());
        
        //#line 691 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10FieldAssign_c
        ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
          FMGL(length) = ((x10_int)1);
    } else {
        
        //#line 693 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10LocalDecl_c
        x10::util::IndexedMemoryChunk<x10::util::Pair<x10_int, x10_int> > message =
          x10::util::IndexedMemoryChunk<void>::allocate<x10::util::Pair<x10_int, x10_int> >(((x10_int)1), 8, false, false);
        
        //#line 694 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
        (message)->__set(((x10_int)0), x10::util::Pair<x10_int, x10_int>::_make(x10aux::here,
                                                                                ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                                                                                  FMGL(count)));
        
        //#line 695 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10If_c
        if ((!x10aux::struct_equals(X10_NULL, t))) {
            
            //#line 696 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
            closure = x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T)>)))x10_lang_FinishState__RemoteCollectingFinish__closure__20<TPMGL(T)>(ref, message, t)));
        } else {
            
            //#line 698 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10LocalAssign_c
            closure = x10aux::ref<x10::lang::VoidFun_0_0>(x10aux::ref<x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T) > >(new (x10aux::alloc<x10::lang::VoidFun_0_0>(sizeof(x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T)>)))x10_lang_FinishState__RemoteCollectingFinish__closure__21<TPMGL(T)>(ref, message, result)));
        }
        
    }
    
    //#line 701 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
      FMGL(count) = ((x10_int)0);
    
    //#line 702 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10FieldAssign_c
    ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
      FMGL(exceptions) = X10_NULL;
    
    //#line 703 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
    x10aux::nullCheck(((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this)->
                        FMGL(lock))->unlock();
    
    //#line 704 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
    x10aux::run_closure_at(x10::lang::Place::place((ref)->location)->
                             FMGL(id), closure);
    
    //#line 705 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": Eval of x10.ast.X10Call_c
    x10aux::dealloc(closure.operator->());
}

//#line 647 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10MethodDecl_c
template<class TPMGL(T)> x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >
  x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::x10__lang__FinishState__RemoteCollectingFinish____x10__lang__FinishState__RemoteCollectingFinish__this(
  ) {
    
    //#line 647 "/wrkdirs/usr/ports/lang/x10/work/x10.runtime/src-x10/x10/lang/FinishState.x10": x10.ast.X10Return_c
    return ((x10aux::ref<x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)> >)this);
    
}
template<class TPMGL(T)> const x10aux::serialization_id_t x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_serialization_id = 
    x10aux::DeserializationDispatcher::addDeserializer(x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_deserializer, x10aux::CLOSURE_KIND_NOT_ASYNC);

template<class TPMGL(T)> void x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_serialize_body(x10aux::serialization_buffer& buf) {
    x10::lang::FinishState__RemoteFinish::_serialize_body(buf);
    buf.write(this->FMGL(sr));
    
}

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

template<class TPMGL(T)> void x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_deserialize_body(x10aux::deserialization_buffer& buf) {
    x10::lang::FinishState__RemoteFinish::_deserialize_body(buf);
    FMGL(sr) = buf.read<x10aux::ref<x10::lang::FinishState__StatefulReducer<TPMGL(T)> > >();
}

template<class TPMGL(T)> x10aux::RuntimeType x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::rtt;
template<class TPMGL(T)> void x10::lang::FinishState__RemoteCollectingFinish<TPMGL(T)>::_initRTT() {
    const x10aux::RuntimeType *canonical = x10aux::getRTT<x10::lang::FinishState__RemoteCollectingFinish<void> >();
    if (rtt.initStageOne(canonical)) return;
    const x10aux::RuntimeType* parents[2] = { x10aux::getRTT<x10::lang::FinishState__RemoteFinish>(), x10aux::getRTT<x10::lang::FinishState__CollectingFinishState<TPMGL(T)> >()};
    const x10aux::RuntimeType* params[1] = { x10aux::getRTT<TPMGL(T)>()};
    x10aux::RuntimeType::Variance variances[1] = { x10aux::RuntimeType::invariant};
    const char *baseName = "x10.lang.FinishState.RemoteCollectingFinish";
    rtt.initStageTwo(baseName, x10aux::RuntimeType::class_kind, 2, parents, 1, params, variances);
}
#endif // X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_IMPLEMENTATION
#endif // __X10_LANG_FINISHSTATE__REMOTECOLLECTINGFINISH_H_NODEPS
