/* Generated by Cython 0.14 on Thu May  5 01:44:45 2011 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif

#ifndef PySet_CheckExact
#  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject PyLongObject
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API__dcmt__pyrandom
#include "stdlib.h"
#include "limits.h"
#include "string.h"
#include "inttypes.h"
#include "dc.h"
#include "common.h"

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "common.pxi",
  "pyrandom.pyx",
};

/* Type declarations */

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":8
 * 
 * 
 * cdef class RandomContainer:             # <<<<<<<<<<<<<<
 * 
 * 	cdef mt_struct *mt
 */

struct __pyx_obj_4dcmt_8pyrandom_RandomContainer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer *__pyx_vtab;
  mt_struct *mt;
};


struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer {
  void (*initWithStruct)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *, mt_struct *);
  void (*initWithParams)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *, int, int, int, uint32_t);
  PyObject *(*seed)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *, uint32_t);
  PyObject *(*random)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *);
  PyObject *(*random_raw)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *);
};
static struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer *__pyx_vtabptr_4dcmt_8pyrandom_RandomContainer;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
  end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */


static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
    }
    return r;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname); /*proto*/

#define __pyx_binding_PyCFunctionType_USED 1

typedef struct {
    PyCFunctionObject func;
} __pyx_binding_PyCFunctionType_object;

PyTypeObject __pyx_binding_PyCFunctionType_type;
PyTypeObject *__pyx_binding_PyCFunctionType = NULL;

PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module); /* proto */
#define __pyx_binding_PyCFunctionType_New(ml, self) __pyx_binding_PyCFunctionType_NewEx(ml, self, NULL)

int __pyx_binding_PyCFunctionType_init(void); /* proto */

#include "descrobject.h"
static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t);

static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject *);

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from libc.stdlib */

/* Module declarations from libc.limits */

/* Module declarations from dcmt.pyrandom */

static PyTypeObject *__pyx_ptype_4dcmt_8pyrandom_RandomContainer = 0;
static uint32_t __pyx_f_4dcmt_8pyrandom_get_seed(PyObject *); /*proto*/
static void __pyx_f_4dcmt_8pyrandom_validate_parameters(PyObject *, PyObject *, PyObject *, PyObject *, int *, int *, int *, int *); /*proto*/
static PyObject *__pyx_f_4dcmt_8pyrandom_create_mt_range(PyObject *, PyObject *, PyObject *, PyObject *, mt_struct ***, int *); /*proto*/
#define __Pyx_MODULE_NAME "dcmt.pyrandom"
int __pyx_module_is_main_dcmt__pyrandom = 0;

/* Implementation of dcmt.pyrandom */
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_MemoryError;
static char __pyx_k_2[] = "Seed must be an integer or hashable type";
static char __pyx_k_4[] = "Starting ID must be equal to or lower than maximum ID";
static char __pyx_k_6[] = "All IDs must lie between 0 and 65535";
static char __pyx_k_8[] = "Known bug: cannot create RNG for wordlen=31, exponent=521, id=9";
static char __pyx_k_10[] = "Word length must be equal to 31 or 32";
static char __pyx_k_12[] = "Mersenne exponent is incorrect or not from a supported set";
static char __pyx_k_14[] = "range expected 1 or 2 positional arguments";
static char __pyx_k_16[] = "dcmt internal error: could not create all requested RNGs";
static char __pyx_k_18[] = "Failed to create RNG";
static char __pyx_k_20[] = "jumpahead requires an integer, not ";
static char __pyx_k_21[] = "number of bits must be greater than zero";
static char __pyx_k_23[] = "State version ";
static char __pyx_k_24[] = " is not supported";
static char __pyx_k_25[] = "dcmt.exceptions";
static char __pyx_k_26[] = "dcmt.pyrandom";
static char __pyx_k__a[] = "a";
static char __pyx_k__i[] = "i";
static char __pyx_k__k[] = "k";
static char __pyx_k__n[] = "n";
static char __pyx_k__id[] = "id";
static char __pyx_k__mm[] = "mm";
static char __pyx_k__mt[] = "mt";
static char __pyx_k__nn[] = "nn";
static char __pyx_k__os[] = "os";
static char __pyx_k__rc[] = "rc";
static char __pyx_k__rr[] = "rr";
static char __pyx_k__ww[] = "ww";
static char __pyx_k__aaa[] = "aaa";
static char __pyx_k__cls[] = "cls";
static char __pyx_k__seed[] = "seed";
static char __pyx_k__self[] = "self";
static char __pyx_k__time[] = "time";
static char __pyx_k__lmask[] = "lmask";
static char __pyx_k__maskB[] = "maskB";
static char __pyx_k__maskC[] = "maskC";
static char __pyx_k__range[] = "range";
static char __pyx_k__state[] = "state";
static char __pyx_k__umask[] = "umask";
static char __pyx_k__wmask[] = "wmask";
static char __pyx_k__Random[] = "Random";
static char __pyx_k__append[] = "append";
static char __pyx_k__random[] = "random";
static char __pyx_k__shift0[] = "shift0";
static char __pyx_k__shift1[] = "shift1";
static char __pyx_k__shiftB[] = "shiftB";
static char __pyx_k__shiftC[] = "shiftC";
static char __pyx_k____new__[] = "__new__";
static char __pyx_k__hexlify[] = "hexlify";
static char __pyx_k__urandom[] = "urandom";
static char __pyx_k__wordlen[] = "wordlen";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k___hexlify[] = "_hexlify";
static char __pyx_k___urandom[] = "_urandom";
static char __pyx_k__binascii[] = "binascii";
static char __pyx_k__exponent[] = "exponent";
static char __pyx_k__gen_seed[] = "gen_seed";
static char __pyx_k__getstate[] = "getstate";
static char __pyx_k__setstate[] = "setstate";
static char __pyx_k__DcmtError[] = "DcmtError";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k__jumpahead[] = "jumpahead";
static char __pyx_k__DcmtRandom[] = "DcmtRandom";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__random_raw[] = "random_raw";
static char __pyx_k__MemoryError[] = "MemoryError";
static char __pyx_k__getrandbits[] = "getrandbits";
static char __pyx_k__initWithParams[] = "initWithParams";
static char __pyx_k__initWithStruct[] = "initWithStruct";
static char __pyx_k__DcmtParameterError[] = "DcmtParameterError";
static char __pyx_k__NotImplementedError[] = "NotImplementedError";
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_kp_s_18;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_20;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_kp_s_24;
static PyObject *__pyx_n_s_25;
static PyObject *__pyx_n_s_26;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_n_s__DcmtError;
static PyObject *__pyx_n_s__DcmtParameterError;
static PyObject *__pyx_n_s__DcmtRandom;
static PyObject *__pyx_n_s__MemoryError;
static PyObject *__pyx_n_s__NotImplementedError;
static PyObject *__pyx_n_s__Random;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____new__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___hexlify;
static PyObject *__pyx_n_s___urandom;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__aaa;
static PyObject *__pyx_n_s__append;
static PyObject *__pyx_n_s__binascii;
static PyObject *__pyx_n_s__cls;
static PyObject *__pyx_n_s__exponent;
static PyObject *__pyx_n_s__gen_seed;
static PyObject *__pyx_n_s__getrandbits;
static PyObject *__pyx_n_s__getstate;
static PyObject *__pyx_n_s__hexlify;
static PyObject *__pyx_n_s__i;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__initWithParams;
static PyObject *__pyx_n_s__initWithStruct;
static PyObject *__pyx_n_s__jumpahead;
static PyObject *__pyx_n_s__k;
static PyObject *__pyx_n_s__lmask;
static PyObject *__pyx_n_s__maskB;
static PyObject *__pyx_n_s__maskC;
static PyObject *__pyx_n_s__mm;
static PyObject *__pyx_n_s__mt;
static PyObject *__pyx_n_s__n;
static PyObject *__pyx_n_s__nn;
static PyObject *__pyx_n_s__os;
static PyObject *__pyx_n_s__random;
static PyObject *__pyx_n_s__random_raw;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__rc;
static PyObject *__pyx_n_s__rr;
static PyObject *__pyx_n_s__seed;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__setstate;
static PyObject *__pyx_n_s__shift0;
static PyObject *__pyx_n_s__shift1;
static PyObject *__pyx_n_s__shiftB;
static PyObject *__pyx_n_s__shiftC;
static PyObject *__pyx_n_s__state;
static PyObject *__pyx_n_s__time;
static PyObject *__pyx_n_s__umask;
static PyObject *__pyx_n_s__urandom;
static PyObject *__pyx_n_s__wmask;
static PyObject *__pyx_n_s__wordlen;
static PyObject *__pyx_n_s__ww;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_16;
static PyObject *__pyx_int_32;
static PyObject *__pyx_int_256;
static PyObject *__pyx_int_521;
static PyObject *__pyx_k_tuple_1;
static PyObject *__pyx_k_tuple_3;
static PyObject *__pyx_k_tuple_5;
static PyObject *__pyx_k_tuple_7;
static PyObject *__pyx_k_tuple_9;
static PyObject *__pyx_k_tuple_11;
static PyObject *__pyx_k_tuple_13;
static PyObject *__pyx_k_tuple_15;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_19;
static PyObject *__pyx_k_tuple_22;

/* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":50
 * 
 * 
 * cdef uint32_t get_seed(object seed) except? -1:             # <<<<<<<<<<<<<<
 * 	"""
 * 	Return valid seed or raise an exception
 */

static  uint32_t __pyx_f_4dcmt_8pyrandom_get_seed(PyObject *__pyx_v_seed) {
  uint32_t __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  long __pyx_t_10;
  __Pyx_RefNannySetupContext("get_seed");
  __Pyx_INCREF(__pyx_v_seed);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":59
 * 	"""
 * 
 * 	if seed is None:             # <<<<<<<<<<<<<<
 * 		try:
 * 			seed = long(_hexlify(_urandom(16)), 16)
 */
  __pyx_t_1 = (__pyx_v_seed == Py_None);
  if (__pyx_t_1) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":60
 * 
 * 	if seed is None:
 * 		try:             # <<<<<<<<<<<<<<
 * 			seed = long(_hexlify(_urandom(16)), 16)
 * 		except NotImplementedError:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":61
 * 	if seed is None:
 * 		try:
 * 			seed = long(_hexlify(_urandom(16)), 16)             # <<<<<<<<<<<<<<
 * 		except NotImplementedError:
 * 			seed = long(time.time() * 256) # use fractional seconds
 */
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s___hexlify); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___urandom); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_int_16);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_16);
        __Pyx_GIVEREF(__pyx_int_16);
        __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_v_seed);
        __pyx_v_seed = __pyx_t_4;
        __pyx_t_4 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":62
 * 		try:
 * 			seed = long(_hexlify(_urandom(16)), 16)
 * 		except NotImplementedError:             # <<<<<<<<<<<<<<
 * 			seed = long(time.time() * 256) # use fractional seconds
 * 	elif not isinstance(seed, int) and not isinstance(seed, long):
 */
      __pyx_t_5 = PyErr_ExceptionMatches(__pyx_builtin_NotImplementedError);
      if (__pyx_t_5) {
        __Pyx_AddTraceback("dcmt.pyrandom.get_seed");
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_2);

        /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":63
 * 			seed = long(_hexlify(_urandom(16)), 16)
 * 		except NotImplementedError:
 * 			seed = long(time.time() * 256) # use fractional seconds             # <<<<<<<<<<<<<<
 * 	elif not isinstance(seed, int) and not isinstance(seed, long):
 * 		try:
 */
        __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__time); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__time); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyNumber_Multiply(__pyx_t_6, __pyx_int_256); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)(&PyLong_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_v_seed);
        __pyx_v_seed = __pyx_t_7;
        __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L5_exception_handled;
      }
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L11_try_end:;
    }
    goto __pyx_L3;
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":64
 * 		except NotImplementedError:
 * 			seed = long(time.time() * 256) # use fractional seconds
 * 	elif not isinstance(seed, int) and not isinstance(seed, long):             # <<<<<<<<<<<<<<
 * 		try:
 * 			seed = hash(seed)
 */
  __pyx_t_1 = PyInt_Check(__pyx_v_seed); 
  __pyx_t_8 = (!__pyx_t_1);
  if (__pyx_t_8) {
    __pyx_t_1 = PyLong_Check(__pyx_v_seed); 
    __pyx_t_9 = (!__pyx_t_1);
    __pyx_t_1 = __pyx_t_9;
  } else {
    __pyx_t_1 = __pyx_t_8;
  }
  if (__pyx_t_1) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":65
 * 			seed = long(time.time() * 256) # use fractional seconds
 * 	elif not isinstance(seed, int) and not isinstance(seed, long):
 * 		try:             # <<<<<<<<<<<<<<
 * 			seed = hash(seed)
 * 		except TypeError:
 */
    {
      PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
      __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
      __Pyx_XGOTREF(__pyx_save_exc_type);
      __Pyx_XGOTREF(__pyx_save_exc_value);
      __Pyx_XGOTREF(__pyx_save_exc_tb);
      /*try:*/ {

        /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":66
 * 	elif not isinstance(seed, int) and not isinstance(seed, long):
 * 		try:
 * 			seed = hash(seed)             # <<<<<<<<<<<<<<
 * 		except TypeError:
 * 			raise DcmtParameterError("Seed must be an integer or hashable type")
 */
        __pyx_t_10 = PyObject_Hash(__pyx_v_seed); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
        __pyx_t_2 = PyInt_FromLong(__pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_v_seed);
        __pyx_v_seed = __pyx_t_2;
        __pyx_t_2 = 0;
      }
      __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
      __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
      __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
      goto __pyx_L21_try_end;
      __pyx_L14_error:;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":67
 * 		try:
 * 			seed = hash(seed)
 * 		except TypeError:             # <<<<<<<<<<<<<<
 * 			raise DcmtParameterError("Seed must be an integer or hashable type")
 * 
 */
      __pyx_t_5 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
      if (__pyx_t_5) {
        __Pyx_AddTraceback("dcmt.pyrandom.get_seed");
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GOTREF(__pyx_t_4);

        /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":68
 * 			seed = hash(seed)
 * 		except TypeError:
 * 			raise DcmtParameterError("Seed must be an integer or hashable type")             # <<<<<<<<<<<<<<
 * 
 * 	# not checking for overflow now, since we need 4 lower bytes anyway
 */
        __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtParameterError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_Raise(__pyx_t_6, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L15_exception_handled;
      }
      __pyx_L16_except_error:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      goto __pyx_L1_error;
      __pyx_L15_exception_handled:;
      __Pyx_XGIVEREF(__pyx_save_exc_type);
      __Pyx_XGIVEREF(__pyx_save_exc_value);
      __Pyx_XGIVEREF(__pyx_save_exc_tb);
      __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
      __pyx_L21_try_end:;
    }
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":71
 * 
 * 	# not checking for overflow now, since we need 4 lower bytes anyway
 * 	return PyInt_AsUnsignedLongMask(seed)             # <<<<<<<<<<<<<<
 * 
 * cdef void validate_parameters(wordlen, exponent, start_id, max_id,
 */
  __pyx_r = PyInt_AsUnsignedLongMask(__pyx_v_seed);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("dcmt.pyrandom.get_seed");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_seed);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":73
 * 	return PyInt_AsUnsignedLongMask(seed)
 * 
 * cdef void validate_parameters(wordlen, exponent, start_id, max_id,             # <<<<<<<<<<<<<<
 * 		int *c_wordlen, int *c_exponent, int *c_start_id, int *c_max_id) except *:
 * 	"""Return valid parameter or raise an exception"""
 */

static  void __pyx_f_4dcmt_8pyrandom_validate_parameters(PyObject *__pyx_v_wordlen, PyObject *__pyx_v_exponent, PyObject *__pyx_v_start_id, PyObject *__pyx_v_max_id, int *__pyx_v_c_wordlen, int *__pyx_v_c_exponent, int *__pyx_v_c_start_id, int *__pyx_v_c_max_id) {
  int __pyx_v_w;
  int __pyx_v_p;
  int __pyx_v_sid;
  int __pyx_v_mid;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("validate_parameters");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":79
 * 	cdef int w, p, sid, mid
 * 
 * 	w = <int>PyInt_AsLong(wordlen)             # <<<<<<<<<<<<<<
 * 	p = <int>PyInt_AsLong(exponent)
 * 	sid = <int>PyInt_AsLong(start_id)
 */
  __pyx_v_w = ((int)PyInt_AsLong(__pyx_v_wordlen));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":80
 * 
 * 	w = <int>PyInt_AsLong(wordlen)
 * 	p = <int>PyInt_AsLong(exponent)             # <<<<<<<<<<<<<<
 * 	sid = <int>PyInt_AsLong(start_id)
 * 	mid = <int>PyInt_AsLong(max_id)
 */
  __pyx_v_p = ((int)PyInt_AsLong(__pyx_v_exponent));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":81
 * 	w = <int>PyInt_AsLong(wordlen)
 * 	p = <int>PyInt_AsLong(exponent)
 * 	sid = <int>PyInt_AsLong(start_id)             # <<<<<<<<<<<<<<
 * 	mid = <int>PyInt_AsLong(max_id)
 * 
 */
  __pyx_v_sid = ((int)PyInt_AsLong(__pyx_v_start_id));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":82
 * 	p = <int>PyInt_AsLong(exponent)
 * 	sid = <int>PyInt_AsLong(start_id)
 * 	mid = <int>PyInt_AsLong(max_id)             # <<<<<<<<<<<<<<
 * 
 * 	if sid > mid:
 */
  __pyx_v_mid = ((int)PyInt_AsLong(__pyx_v_max_id));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":84
 * 	mid = <int>PyInt_AsLong(max_id)
 * 
 * 	if sid > mid:             # <<<<<<<<<<<<<<
 * 		raise DcmtParameterError("Starting ID must be equal to or lower than maximum ID")
 * 
 */
  __pyx_t_1 = (__pyx_v_sid > __pyx_v_mid);
  if (__pyx_t_1) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":85
 * 
 * 	if sid > mid:
 * 		raise DcmtParameterError("Starting ID must be equal to or lower than maximum ID")             # <<<<<<<<<<<<<<
 * 
 * 	if sid < 0 or mid > 65535:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtParameterError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":87
 * 		raise DcmtParameterError("Starting ID must be equal to or lower than maximum ID")
 * 
 * 	if sid < 0 or mid > 65535:             # <<<<<<<<<<<<<<
 * 		raise DcmtParameterError("All IDs must lie between 0 and 65535")
 * 
 */
  __pyx_t_1 = (__pyx_v_sid < 0);
  if (!__pyx_t_1) {
    __pyx_t_4 = (__pyx_v_mid > 65535);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_1;
  }
  if (__pyx_t_5) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":88
 * 
 * 	if sid < 0 or mid > 65535:
 * 		raise DcmtParameterError("All IDs must lie between 0 and 65535")             # <<<<<<<<<<<<<<
 * 
 * 	if w == 31 and p == 521 and sid <= 9 and mid >= 9:
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtParameterError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":90
 * 		raise DcmtParameterError("All IDs must lie between 0 and 65535")
 * 
 * 	if w == 31 and p == 521 and sid <= 9 and mid >= 9:             # <<<<<<<<<<<<<<
 * 		raise DcmtParameterError("Known bug: cannot create RNG for wordlen=31, exponent=521, id=9")
 * 
 */
  __pyx_t_5 = (__pyx_v_w == 31);
  if (__pyx_t_5) {
    __pyx_t_1 = (__pyx_v_p == 521);
    if (__pyx_t_1) {
      __pyx_t_4 = (__pyx_v_sid <= 9);
      if (__pyx_t_4) {
        __pyx_t_6 = (__pyx_v_mid >= 9);
        __pyx_t_7 = __pyx_t_6;
      } else {
        __pyx_t_7 = __pyx_t_4;
      }
      __pyx_t_4 = __pyx_t_7;
    } else {
      __pyx_t_4 = __pyx_t_1;
    }
    __pyx_t_1 = __pyx_t_4;
  } else {
    __pyx_t_1 = __pyx_t_5;
  }
  if (__pyx_t_1) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":91
 * 
 * 	if w == 31 and p == 521 and sid <= 9 and mid >= 9:
 * 		raise DcmtParameterError("Known bug: cannot create RNG for wordlen=31, exponent=521, id=9")             # <<<<<<<<<<<<<<
 * 
 * 	if w != 31 and w != 32:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtParameterError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":93
 * 		raise DcmtParameterError("Known bug: cannot create RNG for wordlen=31, exponent=521, id=9")
 * 
 * 	if w != 31 and w != 32:             # <<<<<<<<<<<<<<
 * 		raise DcmtParameterError("Word length must be equal to 31 or 32")
 * 
 */
  switch (__pyx_v_w) {
    case 31:
    case 32:
    __pyx_t_1 = 0;
    break;
    default:
    __pyx_t_1 = 1;
    break;
  }
  if (__pyx_t_1) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":94
 * 
 * 	if w != 31 and w != 32:
 * 		raise DcmtParameterError("Word length must be equal to 31 or 32")             # <<<<<<<<<<<<<<
 * 
 * 	if p not in (521, 607, 1279, 2203, 2281, 3217, 4253, 4423,
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtParameterError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":96
 * 		raise DcmtParameterError("Word length must be equal to 31 or 32")
 * 
 * 	if p not in (521, 607, 1279, 2203, 2281, 3217, 4253, 4423,             # <<<<<<<<<<<<<<
 * 			9689, 9941, 11213, 19937, 21701, 23209, 44497):
 * 		raise DcmtParameterError("Mersenne exponent is incorrect or not from a supported set")
 */
  __pyx_t_8 = __pyx_v_p;
  switch (__pyx_v_p) {
    case 521:
    case 607:
    case 1279:
    case 2203:
    case 2281:
    case 3217:
    case 4253:
    case 4423:

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":97
 * 
 * 	if p not in (521, 607, 1279, 2203, 2281, 3217, 4253, 4423,
 * 			9689, 9941, 11213, 19937, 21701, 23209, 44497):             # <<<<<<<<<<<<<<
 * 		raise DcmtParameterError("Mersenne exponent is incorrect or not from a supported set")
 * 
 */
    case 9689:
    case 9941:
    case 11213:
    case 19937:
    case 21701:
    case 23209:
    case 44497:

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":96
 * 		raise DcmtParameterError("Word length must be equal to 31 or 32")
 * 
 * 	if p not in (521, 607, 1279, 2203, 2281, 3217, 4253, 4423,             # <<<<<<<<<<<<<<
 * 			9689, 9941, 11213, 19937, 21701, 23209, 44497):
 * 		raise DcmtParameterError("Mersenne exponent is incorrect or not from a supported set")
 */
    __pyx_t_1 = 0;
    break;
    default:
    __pyx_t_1 = 1;
    break;
  }
  __pyx_t_5 = __pyx_t_1;
  if (__pyx_t_5) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":98
 * 	if p not in (521, 607, 1279, 2203, 2281, 3217, 4253, 4423,
 * 			9689, 9941, 11213, 19937, 21701, 23209, 44497):
 * 		raise DcmtParameterError("Mersenne exponent is incorrect or not from a supported set")             # <<<<<<<<<<<<<<
 * 
 * 	c_wordlen[0] = w
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtParameterError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":100
 * 		raise DcmtParameterError("Mersenne exponent is incorrect or not from a supported set")
 * 
 * 	c_wordlen[0] = w             # <<<<<<<<<<<<<<
 * 	c_exponent[0] = p
 * 	c_start_id[0] = sid
 */
  (__pyx_v_c_wordlen[0]) = __pyx_v_w;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":101
 * 
 * 	c_wordlen[0] = w
 * 	c_exponent[0] = p             # <<<<<<<<<<<<<<
 * 	c_start_id[0] = sid
 * 	c_max_id[0] = mid
 */
  (__pyx_v_c_exponent[0]) = __pyx_v_p;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":102
 * 	c_wordlen[0] = w
 * 	c_exponent[0] = p
 * 	c_start_id[0] = sid             # <<<<<<<<<<<<<<
 * 	c_max_id[0] = mid
 * 
 */
  (__pyx_v_c_start_id[0]) = __pyx_v_sid;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":103
 * 	c_exponent[0] = p
 * 	c_start_id[0] = sid
 * 	c_max_id[0] = mid             # <<<<<<<<<<<<<<
 * 
 * cdef object create_mt_range(args, wordlen, exponent, seed, mt_struct ***mts, int *count):
 */
  (__pyx_v_c_max_id[0]) = __pyx_v_mid;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("dcmt.pyrandom.validate_parameters");
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":105
 * 	c_max_id[0] = mid
 * 
 * cdef object create_mt_range(args, wordlen, exponent, seed, mt_struct ***mts, int *count):             # <<<<<<<<<<<<<<
 * 
 * 	cdef int w, p, mid, sid
 */

static  PyObject *__pyx_f_4dcmt_8pyrandom_create_mt_range(PyObject *__pyx_v_args, PyObject *__pyx_v_wordlen, PyObject *__pyx_v_exponent, PyObject *__pyx_v_seed, mt_struct ***__pyx_v_mts, int *__pyx_v_count) {
  int __pyx_v_w;
  int __pyx_v_p;
  int __pyx_v_mid;
  int __pyx_v_sid;
  PyObject *__pyx_v_start_id;
  PyObject *__pyx_v_max_id;
  uint32_t __pyx_v_s;
  mt_struct **__pyx_v_m;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  uint32_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("create_mt_range");
  __pyx_v_start_id = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_max_id = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":109
 * 	cdef int w, p, mid, sid
 * 
 * 	if len(args) == 1:             # <<<<<<<<<<<<<<
 * 		start_id = 0
 * 		max_id, = args
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 == 1);
  if (__pyx_t_2) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":110
 * 
 * 	if len(args) == 1:
 * 		start_id = 0             # <<<<<<<<<<<<<<
 * 		max_id, = args
 * 	elif len(args) == 2:
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF(__pyx_v_start_id);
    __pyx_v_start_id = __pyx_int_0;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":111
 * 	if len(args) == 1:
 * 		start_id = 0
 * 		max_id, = args             # <<<<<<<<<<<<<<
 * 	elif len(args) == 2:
 * 		start_id, max_id = args
 */
    if (PyTuple_CheckExact(__pyx_v_args) && likely(PyTuple_GET_SIZE(__pyx_v_args) == 1)) {
      PyObject* tuple = __pyx_v_args;
      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_max_id);
      __pyx_v_max_id = __pyx_t_3;
      __pyx_t_3 = 0;
    } else {
      __pyx_t_4 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_EndUnpack(__pyx_t_4, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_v_max_id);
      __pyx_v_max_id = __pyx_t_3;
      __pyx_t_3 = 0;
    }
    goto __pyx_L3;
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":112
 * 		start_id = 0
 * 		max_id, = args
 * 	elif len(args) == 2:             # <<<<<<<<<<<<<<
 * 		start_id, max_id = args
 * 	else:
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 == 2);
  if (__pyx_t_2) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":113
 * 		max_id, = args
 * 	elif len(args) == 2:
 * 		start_id, max_id = args             # <<<<<<<<<<<<<<
 * 	else:
 * 		raise TypeError("range expected 1 or 2 positional arguments")
 */
    if (PyTuple_CheckExact(__pyx_v_args) && likely(PyTuple_GET_SIZE(__pyx_v_args) == 2)) {
      PyObject* tuple = __pyx_v_args;
      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_v_start_id);
      __pyx_v_start_id = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_max_id);
      __pyx_v_max_id = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __pyx_t_5 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_5, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_5, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_EndUnpack(__pyx_t_5, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_v_start_id);
      __pyx_v_start_id = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_max_id);
      __pyx_v_max_id = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":115
 * 		start_id, max_id = args
 * 	else:
 * 		raise TypeError("range expected 1 or 2 positional arguments")             # <<<<<<<<<<<<<<
 * 
 * 	max_id -= 1
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":117
 * 		raise TypeError("range expected 1 or 2 positional arguments")
 * 
 * 	max_id -= 1             # <<<<<<<<<<<<<<
 * 
 * 	if max_id < start_id:
 */
  __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_v_max_id, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_v_max_id);
  __pyx_v_max_id = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":119
 * 	max_id -= 1
 * 
 * 	if max_id < start_id:             # <<<<<<<<<<<<<<
 * 		return []
 * 
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_max_id, __pyx_v_start_id, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":120
 * 
 * 	if max_id < start_id:
 * 		return []             # <<<<<<<<<<<<<<
 * 
 * 	validate_parameters(wordlen, exponent, start_id, max_id, &w, &p, &sid, &mid)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_r = ((PyObject *)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":122
 * 		return []
 * 
 * 	validate_parameters(wordlen, exponent, start_id, max_id, &w, &p, &sid, &mid)             # <<<<<<<<<<<<<<
 * 	cdef uint32_t s = get_seed(seed)
 * 
 */
  __pyx_f_4dcmt_8pyrandom_validate_parameters(__pyx_v_wordlen, __pyx_v_exponent, __pyx_v_start_id, __pyx_v_max_id, (&__pyx_v_w), (&__pyx_v_p), (&__pyx_v_sid), (&__pyx_v_mid)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":123
 * 
 * 	validate_parameters(wordlen, exponent, start_id, max_id, &w, &p, &sid, &mid)
 * 	cdef uint32_t s = get_seed(seed)             # <<<<<<<<<<<<<<
 * 
 * 	cdef mt_struct **m = get_mt_parameters_st(w, p, sid, mid, s, count)
 */
  __pyx_t_6 = __pyx_f_4dcmt_8pyrandom_get_seed(__pyx_v_seed); if (unlikely(__pyx_t_6 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_s = __pyx_t_6;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":125
 * 	cdef uint32_t s = get_seed(seed)
 * 
 * 	cdef mt_struct **m = get_mt_parameters_st(w, p, sid, mid, s, count)             # <<<<<<<<<<<<<<
 * 
 * 	if count[0] < max_id - start_id + 1 or mts == NULL:
 */
  __pyx_v_m = get_mt_parameters_st(__pyx_v_w, __pyx_v_p, __pyx_v_sid, __pyx_v_mid, __pyx_v_s, __pyx_v_count);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":127
 * 	cdef mt_struct **m = get_mt_parameters_st(w, p, sid, mid, s, count)
 * 
 * 	if count[0] < max_id - start_id + 1 or mts == NULL:             # <<<<<<<<<<<<<<
 * 		if mts != NULL:
 * 			free_mt_struct_array(m, count[0])
 */
  __pyx_t_4 = PyInt_FromLong((__pyx_v_count[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_Subtract(__pyx_v_max_id, __pyx_v_start_id); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_2) {
    __pyx_t_7 = (__pyx_v_mts == NULL);
    __pyx_t_8 = __pyx_t_7;
  } else {
    __pyx_t_8 = __pyx_t_2;
  }
  if (__pyx_t_8) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":128
 * 
 * 	if count[0] < max_id - start_id + 1 or mts == NULL:
 * 		if mts != NULL:             # <<<<<<<<<<<<<<
 * 			free_mt_struct_array(m, count[0])
 * 		raise DcmtError("dcmt internal error: could not create all requested RNGs")
 */
    __pyx_t_8 = (__pyx_v_mts != NULL);
    if (__pyx_t_8) {

      /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":129
 * 	if count[0] < max_id - start_id + 1 or mts == NULL:
 * 		if mts != NULL:
 * 			free_mt_struct_array(m, count[0])             # <<<<<<<<<<<<<<
 * 		raise DcmtError("dcmt internal error: could not create all requested RNGs")
 * 
 */
      free_mt_struct_array(__pyx_v_m, (__pyx_v_count[0]));
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":130
 * 		if mts != NULL:
 * 			free_mt_struct_array(m, count[0])
 * 		raise DcmtError("dcmt internal error: could not create all requested RNGs")             # <<<<<<<<<<<<<<
 * 
 * 	mts[0] = m
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":132
 * 		raise DcmtError("dcmt internal error: could not create all requested RNGs")
 * 
 * 	mts[0] = m             # <<<<<<<<<<<<<<
 * 
 * 	return None
 */
  (__pyx_v_mts[0]) = __pyx_v_m;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":134
 * 	mts[0] = m
 * 
 * 	return None             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("dcmt.pyrandom.create_mt_range");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_start_id);
  __Pyx_DECREF(__pyx_v_max_id);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":12
 * 	cdef mt_struct *mt
 * 
 * 	def __init__(self):             # <<<<<<<<<<<<<<
 * 		self.mt = NULL
 * 
 */

static int __pyx_pf_4dcmt_8pyrandom_15RandomContainer_0__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4dcmt_8pyrandom_15RandomContainer_0__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":13
 * 
 * 	def __init__(self):
 * 		self.mt = NULL             # <<<<<<<<<<<<<<
 * 
 * 	cdef void initWithStruct(self, mt_struct *mt):
 */
  ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt = NULL;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":15
 * 		self.mt = NULL
 * 
 * 	cdef void initWithStruct(self, mt_struct *mt):             # <<<<<<<<<<<<<<
 * 		self.mt = mt
 * 
 */

static  void __pyx_f_4dcmt_8pyrandom_15RandomContainer_initWithStruct(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_self, mt_struct *__pyx_v_mt) {
  __Pyx_RefNannySetupContext("initWithStruct");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":16
 * 
 * 	cdef void initWithStruct(self, mt_struct *mt):
 * 		self.mt = mt             # <<<<<<<<<<<<<<
 * 
 * 	cdef void initWithParams(self, int wordlen, int exponent, int id, uint32_t seed) except *:
 */
  __pyx_v_self->mt = __pyx_v_mt;

  __Pyx_RefNannyFinishContext();
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":18
 * 		self.mt = mt
 * 
 * 	cdef void initWithParams(self, int wordlen, int exponent, int id, uint32_t seed) except *:             # <<<<<<<<<<<<<<
 * 		self.mt = get_mt_parameter_id_st(wordlen, exponent, id, seed)
 * 		if self.mt == NULL:
 */

static  void __pyx_f_4dcmt_8pyrandom_15RandomContainer_initWithParams(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_self, int __pyx_v_wordlen, int __pyx_v_exponent, int __pyx_v_id, uint32_t __pyx_v_seed) {
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("initWithParams");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":19
 * 
 * 	cdef void initWithParams(self, int wordlen, int exponent, int id, uint32_t seed) except *:
 * 		self.mt = get_mt_parameter_id_st(wordlen, exponent, id, seed)             # <<<<<<<<<<<<<<
 * 		if self.mt == NULL:
 * 			raise DcmtError("Failed to create RNG")
 */
  __pyx_v_self->mt = get_mt_parameter_id_st(__pyx_v_wordlen, __pyx_v_exponent, __pyx_v_id, __pyx_v_seed);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":20
 * 	cdef void initWithParams(self, int wordlen, int exponent, int id, uint32_t seed) except *:
 * 		self.mt = get_mt_parameter_id_st(wordlen, exponent, id, seed)
 * 		if self.mt == NULL:             # <<<<<<<<<<<<<<
 * 			raise DcmtError("Failed to create RNG")
 * 
 */
  __pyx_t_1 = (__pyx_v_self->mt == NULL);
  if (__pyx_t_1) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":21
 * 		self.mt = get_mt_parameter_id_st(wordlen, exponent, id, seed)
 * 		if self.mt == NULL:
 * 			raise DcmtError("Failed to create RNG")             # <<<<<<<<<<<<<<
 * 
 * 	def __dealloc__(self):
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("dcmt.pyrandom.RandomContainer.initWithParams");
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":23
 * 			raise DcmtError("Failed to create RNG")
 * 
 * 	def __dealloc__(self):             # <<<<<<<<<<<<<<
 * 		if self.mt != NULL:
 * 			free_mt_struct(self.mt)
 */

static void __pyx_pf_4dcmt_8pyrandom_15RandomContainer_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4dcmt_8pyrandom_15RandomContainer_1__dealloc__(PyObject *__pyx_v_self) {
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":24
 * 
 * 	def __dealloc__(self):
 * 		if self.mt != NULL:             # <<<<<<<<<<<<<<
 * 			free_mt_struct(self.mt)
 * 			self.mt = NULL
 */
  __pyx_t_1 = (((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt != NULL);
  if (__pyx_t_1) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":25
 * 	def __dealloc__(self):
 * 		if self.mt != NULL:
 * 			free_mt_struct(self.mt)             # <<<<<<<<<<<<<<
 * 			self.mt = NULL
 * 
 */
    free_mt_struct(((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt);

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":26
 * 		if self.mt != NULL:
 * 			free_mt_struct(self.mt)
 * 			self.mt = NULL             # <<<<<<<<<<<<<<
 * 
 * 	cdef seed(self, uint32_t seed):
 */
    ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt = NULL;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __Pyx_RefNannyFinishContext();
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":28
 * 			self.mt = NULL
 * 
 * 	cdef seed(self, uint32_t seed):             # <<<<<<<<<<<<<<
 * 		sgenrand(seed, self.mt)
 * 
 */

static  PyObject *__pyx_f_4dcmt_8pyrandom_15RandomContainer_seed(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_self, uint32_t __pyx_v_seed) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("seed");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":29
 * 
 * 	cdef seed(self, uint32_t seed):
 * 		sgenrand(seed, self.mt)             # <<<<<<<<<<<<<<
 * 
 * 	cdef random(self):
 */
  sgenrand(__pyx_v_seed, __pyx_v_self->mt);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":31
 * 		sgenrand(seed, self.mt)
 * 
 * 	cdef random(self):             # <<<<<<<<<<<<<<
 * 		return random_float(self.mt)
 * 
 */

static  PyObject *__pyx_f_4dcmt_8pyrandom_15RandomContainer_random(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("random");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":32
 * 
 * 	cdef random(self):
 * 		return random_float(self.mt)             # <<<<<<<<<<<<<<
 * 
 * 	cdef random_raw(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(random_float(__pyx_v_self->mt)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("dcmt.pyrandom.RandomContainer.random");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":34
 * 		return random_float(self.mt)
 * 
 * 	cdef random_raw(self):             # <<<<<<<<<<<<<<
 * 		return random_uint32(self.mt)
 * 
 */

static  PyObject *__pyx_f_4dcmt_8pyrandom_15RandomContainer_random_raw(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("random_raw");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":35
 * 
 * 	cdef random_raw(self):
 * 		return random_uint32(self.mt)             # <<<<<<<<<<<<<<
 * 
 * 	def jumpahead(self, n):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(random_uint32(__pyx_v_self->mt)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("dcmt.pyrandom.RandomContainer.random_raw");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":37
 * 		return random_uint32(self.mt)
 * 
 * 	def jumpahead(self, n):             # <<<<<<<<<<<<<<
 * 
 * 		if type(n) not in (int, long):
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_2jumpahead(PyObject *__pyx_v_self, PyObject *__pyx_v_n); /*proto*/
static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_2jumpahead(PyObject *__pyx_v_self, PyObject *__pyx_v_n) {
  uint32_t *__pyx_v_state;
  uint32_t __pyx_v_i;
  uint32_t __pyx_v_j;
  uint32_t __pyx_v_tmp;
  int __pyx_v_nn;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  uint32_t __pyx_t_6;
  uint32_t __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("jumpahead");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":39
 * 	def jumpahead(self, n):
 * 
 * 		if type(n) not in (int, long):             # <<<<<<<<<<<<<<
 * 			raise TypeError("jumpahead requires an integer, not " + str(type(n)))
 * 
 */
  __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_n)));
  __pyx_t_1 = ((PyObject *)Py_TYPE(__pyx_v_n));
  __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_t_1), ((PyObject *)((PyObject*)(&PyInt_Type))), Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_t_3;
  if (__pyx_t_4) {
    __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_t_1), ((PyObject *)((PyObject*)(&PyLong_Type))), Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __pyx_t_3;
    __pyx_t_3 = __pyx_t_5;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __pyx_t_3;
  if (__pyx_t_4) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":40
 * 
 * 		if type(n) not in (int, long):
 * 			raise TypeError("jumpahead requires an integer, not " + str(type(n)))             # <<<<<<<<<<<<<<
 * 
 * 		cdef uint32_t *state = self.mt.state
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_n)));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(__pyx_v_n)));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_n)));
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_20), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":42
 * 			raise TypeError("jumpahead requires an integer, not " + str(type(n)))
 * 
 * 		cdef uint32_t *state = self.mt.state             # <<<<<<<<<<<<<<
 * 		cdef uint32_t i, j
 * 		cdef uint32_t tmp
 */
  __pyx_v_state = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt->state;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":45
 * 		cdef uint32_t i, j
 * 		cdef uint32_t tmp
 * 		cdef int nn = self.mt.nn             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(nn - 1, 1, -1):
 */
  __pyx_v_nn = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt->nn;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":47
 * 		cdef int nn = self.mt.nn
 * 
 * 		for i in range(nn - 1, 1, -1):             # <<<<<<<<<<<<<<
 * 			j = n % int(i)
 * 			tmp = state[i]
 */
  for (__pyx_t_6 = (__pyx_v_nn - 1); __pyx_t_6 > 1; __pyx_t_6-=1) {
    __pyx_v_i = __pyx_t_6;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":48
 * 
 * 		for i in range(nn - 1, 1, -1):
 * 			j = n % int(i)             # <<<<<<<<<<<<<<
 * 			tmp = state[i]
 * 			state[i] = state[j]
 */
    __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(__pyx_v_n, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_2); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_j = __pyx_t_7;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":49
 * 		for i in range(nn - 1, 1, -1):
 * 			j = n % int(i)
 * 			tmp = state[i]             # <<<<<<<<<<<<<<
 * 			state[i] = state[j]
 * 			state[j] = tmp
 */
    __pyx_v_tmp = (__pyx_v_state[__pyx_v_i]);

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":50
 * 			j = n % int(i)
 * 			tmp = state[i]
 * 			state[i] = state[j]             # <<<<<<<<<<<<<<
 * 			state[j] = tmp
 * 
 */
    (__pyx_v_state[__pyx_v_i]) = (__pyx_v_state[__pyx_v_j]);

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":51
 * 			tmp = state[i]
 * 			state[i] = state[j]
 * 			state[j] = tmp             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(nn):
 */
    (__pyx_v_state[__pyx_v_j]) = __pyx_v_tmp;
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":53
 * 			state[j] = tmp
 * 
 * 		for i in range(nn):             # <<<<<<<<<<<<<<
 * 			state[i] += i + 1
 * 
 */
  __pyx_t_8 = __pyx_v_nn;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_8; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":54
 * 
 * 		for i in range(nn):
 * 			state[i] += i + 1             # <<<<<<<<<<<<<<
 * 
 * 		self.mt.i = nn
 */
    __pyx_t_7 = __pyx_v_i;
    (__pyx_v_state[__pyx_t_7]) = ((__pyx_v_state[__pyx_t_7]) + (__pyx_v_i + 1));
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":56
 * 			state[i] += i + 1
 * 
 * 		self.mt.i = nn             # <<<<<<<<<<<<<<
 * 
 * 	def getrandbits(self, kk):
 */
  ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt->i = __pyx_v_nn;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("dcmt.pyrandom.RandomContainer.jumpahead");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":58
 * 		self.mt.i = nn
 * 
 * 	def getrandbits(self, kk):             # <<<<<<<<<<<<<<
 * 		# WARNING: currently works only for 31 and 32 bit randoms
 * 
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_3getrandbits(PyObject *__pyx_v_self, PyObject *__pyx_v_kk); /*proto*/
static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_3getrandbits(PyObject *__pyx_v_self, PyObject *__pyx_v_kk) {
  int __pyx_v_k;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_bytes;
  uint32_t __pyx_v_r;
  unsigned char *__pyx_v_bytearray;
  int __pyx_v_bytelen;
  int __pyx_v_bitlen;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  long __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("getrandbits");
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":61
 * 		# WARNING: currently works only for 31 and 32 bit randoms
 * 
 * 		cdef int k = <int>kk, i, j, bytes             # <<<<<<<<<<<<<<
 * 		cdef uint32_t r
 * 		cdef unsigned char *bytearray
 */
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_kk); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_k = __pyx_t_1;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":65
 * 		cdef unsigned char *bytearray
 * 
 * 		if k <= 0:             # <<<<<<<<<<<<<<
 * 			raise ValueError("number of bits must be greater than zero")
 * 
 */
  __pyx_t_2 = (__pyx_v_k <= 0);
  if (__pyx_t_2) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":66
 * 
 * 		if k <= 0:
 * 			raise ValueError("number of bits must be greater than zero")             # <<<<<<<<<<<<<<
 * 
 * 		bytes = ((k - 1) / 32 + 1) * 4
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":68
 * 			raise ValueError("number of bits must be greater than zero")
 * 
 * 		bytes = ((k - 1) / 32 + 1) * 4             # <<<<<<<<<<<<<<
 * 		bytearray = <unsigned char *>PyMem_Malloc(bytes);
 * 		if bytearray == NULL:
 */
  __pyx_v_bytes = ((__Pyx_div_long((__pyx_v_k - 1), 32) + 1) * 4);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":69
 * 
 * 		bytes = ((k - 1) / 32 + 1) * 4
 * 		bytearray = <unsigned char *>PyMem_Malloc(bytes);             # <<<<<<<<<<<<<<
 * 		if bytearray == NULL:
 * 			raise MemoryError()
 */
  __pyx_v_bytearray = ((unsigned char *)PyMem_Malloc(__pyx_v_bytes));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":70
 * 		bytes = ((k - 1) / 32 + 1) * 4
 * 		bytearray = <unsigned char *>PyMem_Malloc(bytes);
 * 		if bytearray == NULL:             # <<<<<<<<<<<<<<
 * 			raise MemoryError()
 * 
 */
  __pyx_t_2 = (__pyx_v_bytearray == NULL);
  if (__pyx_t_2) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":71
 * 		bytearray = <unsigned char *>PyMem_Malloc(bytes);
 * 		if bytearray == NULL:
 * 			raise MemoryError()             # <<<<<<<<<<<<<<
 * 
 * 	    # Fill-out whole words, byte-by-byte to avoid endianness issues
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":74
 * 
 * 	    # Fill-out whole words, byte-by-byte to avoid endianness issues
 * 		cdef int bytelen = 4 if self.mt.ww == 32 else 3             # <<<<<<<<<<<<<<
 * 		cdef int bitlen = bytelen * 8
 * 
 */
  if ((((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt->ww == 32)) {
    __pyx_t_4 = 4;
  } else {
    __pyx_t_4 = 3;
  }
  __pyx_v_bytelen = __pyx_t_4;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":75
 * 	    # Fill-out whole words, byte-by-byte to avoid endianness issues
 * 		cdef int bytelen = 4 if self.mt.ww == 32 else 3
 * 		cdef int bitlen = bytelen * 8             # <<<<<<<<<<<<<<
 * 
 * 		for i in range(0, bytes, bytelen):
 */
  __pyx_v_bitlen = (__pyx_v_bytelen * 8);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":77
 * 		cdef int bitlen = bytelen * 8
 * 
 * 		for i in range(0, bytes, bytelen):             # <<<<<<<<<<<<<<
 * 			r = random_uint32(self.mt)
 * 			if k < bitlen:
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_bytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyInt_FromLong(__pyx_v_bytelen); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_3 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_5 = 0; __pyx_t_7 = __pyx_t_6; __Pyx_INCREF(__pyx_t_7);
  } else {
    __pyx_t_5 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_7))) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_7)) break;
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_7))) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
    } else {
      __pyx_t_6 = PyIter_Next(__pyx_t_7);
      if (!__pyx_t_6) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_i = __pyx_t_1;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":78
 * 
 * 		for i in range(0, bytes, bytelen):
 * 			r = random_uint32(self.mt)             # <<<<<<<<<<<<<<
 * 			if k < bitlen:
 * 				r >>= (bitlen - k)
 */
    __pyx_v_r = random_uint32(((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt);

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":79
 * 		for i in range(0, bytes, bytelen):
 * 			r = random_uint32(self.mt)
 * 			if k < bitlen:             # <<<<<<<<<<<<<<
 * 				r >>= (bitlen - k)
 * 
 */
    __pyx_t_2 = (__pyx_v_k < __pyx_v_bitlen);
    if (__pyx_t_2) {

      /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":80
 * 			r = random_uint32(self.mt)
 * 			if k < bitlen:
 * 				r >>= (bitlen - k)             # <<<<<<<<<<<<<<
 * 
 * 			for j in range(bytelen):
 */
      __pyx_v_r = (__pyx_v_r >> (__pyx_v_bitlen - __pyx_v_k));
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":82
 * 				r >>= (bitlen - k)
 * 
 * 			for j in range(bytelen):             # <<<<<<<<<<<<<<
 * 				bytearray[i+j] = <unsigned char>(r >> (8 * j))
 * 
 */
    __pyx_t_1 = __pyx_v_bytelen;
    for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_1; __pyx_t_8+=1) {
      __pyx_v_j = __pyx_t_8;

      /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":83
 * 
 * 			for j in range(bytelen):
 * 				bytearray[i+j] = <unsigned char>(r >> (8 * j))             # <<<<<<<<<<<<<<
 * 
 * 			k -= bitlen
 */
      (__pyx_v_bytearray[(__pyx_v_i + __pyx_v_j)]) = ((unsigned char)(__pyx_v_r >> (8 * __pyx_v_j)));
    }

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":85
 * 				bytearray[i+j] = <unsigned char>(r >> (8 * j))
 * 
 * 			k -= bitlen             # <<<<<<<<<<<<<<
 * 
 * 	    # little endian order to match bytearray assignment order
 */
    __pyx_v_k = (__pyx_v_k - __pyx_v_bitlen);
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":88
 * 
 * 	    # little endian order to match bytearray assignment order
 * 		result = _PyLong_FromByteArray(bytearray, bytes, 1, 0)             # <<<<<<<<<<<<<<
 * 		PyMem_Free(bytearray)
 * 		return result
 */
  __pyx_t_7 = _PyLong_FromByteArray(__pyx_v_bytearray, __pyx_v_bytes, 1, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":89
 * 	    # little endian order to match bytearray assignment order
 * 		result = _PyLong_FromByteArray(bytearray, bytes, 1, 0)
 * 		PyMem_Free(bytearray)             # <<<<<<<<<<<<<<
 * 		return result
 * 
 */
  PyMem_Free(__pyx_v_bytearray);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":90
 * 		result = _PyLong_FromByteArray(bytearray, bytes, 1, 0)
 * 		PyMem_Free(bytearray)
 * 		return result             # <<<<<<<<<<<<<<
 * 
 * 	def getstate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("dcmt.pyrandom.RandomContainer.getrandbits");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":92
 * 		return result
 * 
 * 	def getstate(self):             # <<<<<<<<<<<<<<
 * 		"""Return internal state; can be passed to setstate() later."""
 * 		cdef mt_struct *mt = self.mt
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_4getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4dcmt_8pyrandom_15RandomContainer_4getstate[] = "Return internal state; can be passed to setstate() later.";
static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_4getstate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  mt_struct *__pyx_v_mt;
  PyObject *__pyx_v_state;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  __Pyx_RefNannySetupContext("getstate");
  __pyx_v_state = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":94
 * 	def getstate(self):
 * 		"""Return internal state; can be passed to setstate() later."""
 * 		cdef mt_struct *mt = self.mt             # <<<<<<<<<<<<<<
 * 
 * 		state = []
 */
  __pyx_v_mt = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":96
 * 		cdef mt_struct *mt = self.mt
 * 
 * 		state = []             # <<<<<<<<<<<<<<
 * 		for i in range(self.mt.nn):
 * 			state.append(mt.state[i])
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(((PyObject *)__pyx_v_state));
  __pyx_v_state = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":97
 * 
 * 		state = []
 * 		for i in range(self.mt.nn):             # <<<<<<<<<<<<<<
 * 			state.append(mt.state[i])
 * 
 */
  __pyx_t_2 = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt->nn;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":98
 * 		state = []
 * 		for i in range(self.mt.nn):
 * 			state.append(mt.state[i])             # <<<<<<<<<<<<<<
 * 
 * 		return (1, (mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww,
 */
    if (unlikely(__pyx_v_state == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t((__pyx_v_mt->state[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyList_Append(__pyx_v_state, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":100
 * 			state.append(mt.state[i])
 * 
 * 		return (1, (mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww,             # <<<<<<<<<<<<<<
 * 			mt.wmask, mt.umask, mt.lmask,
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_mt->aaa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyInt_FromLong(__pyx_v_mt->mm); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyInt_FromLong(__pyx_v_mt->nn); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyInt_FromLong(__pyx_v_mt->rr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyInt_FromLong(__pyx_v_mt->ww); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":101
 * 
 * 		return (1, (mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww,
 * 			mt.wmask, mt.umask, mt.lmask,             # <<<<<<<<<<<<<<
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC,
 * 			mt.maskB, mt.maskC, mt.i, tuple(state)))
 */
  __pyx_t_9 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_mt->wmask); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_mt->umask); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_mt->lmask); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":102
 * 		return (1, (mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww,
 * 			mt.wmask, mt.umask, mt.lmask,
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC,             # <<<<<<<<<<<<<<
 * 			mt.maskB, mt.maskC, mt.i, tuple(state)))
 * 
 */
  __pyx_t_12 = PyInt_FromLong(__pyx_v_mt->shift0); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyInt_FromLong(__pyx_v_mt->shift1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyInt_FromLong(__pyx_v_mt->shiftB); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = PyInt_FromLong(__pyx_v_mt->shiftC); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_15);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":103
 * 			mt.wmask, mt.umask, mt.lmask,
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC,
 * 			mt.maskB, mt.maskC, mt.i, tuple(state)))             # <<<<<<<<<<<<<<
 * 
 * 	def setstate(self, state):
 */
  __pyx_t_16 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_mt->maskB); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_mt->maskC); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_18 = PyInt_FromLong(__pyx_v_mt->i); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_18);
  if (unlikely(__pyx_v_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_19 = ((PyObject *)PyList_AsTuple(__pyx_v_state)); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_19));
  __pyx_t_20 = PyTuple_New(16); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_20));
  PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_20, 6, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_20, 7, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_20, 8, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_20, 9, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_20, 10, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_20, 11, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_20, 12, __pyx_t_16);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_20, 13, __pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_20, 14, __pyx_t_18);
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_20, 15, ((PyObject *)__pyx_t_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_19));
  __pyx_t_1 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_t_16 = 0;
  __pyx_t_17 = 0;
  __pyx_t_18 = 0;
  __pyx_t_19 = 0;
  __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_19));
  __Pyx_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_19, 1, ((PyObject *)__pyx_t_20));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_20));
  __pyx_t_20 = 0;
  __pyx_r = ((PyObject *)__pyx_t_19);
  __pyx_t_19 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("dcmt.pyrandom.RandomContainer.getstate");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_state);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":105
 * 			mt.maskB, mt.maskC, mt.i, tuple(state)))
 * 
 * 	def setstate(self, state):             # <<<<<<<<<<<<<<
 * 		"""Restore internal state from object returned by getstate()."""
 * 		version, fields = state
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_5setstate(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static char __pyx_doc_4dcmt_8pyrandom_15RandomContainer_5setstate[] = "Restore internal state from object returned by getstate().";
static PyObject *__pyx_pf_4dcmt_8pyrandom_15RandomContainer_5setstate(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
  PyObject *__pyx_v_version;
  PyObject *__pyx_v_fields;
  mt_struct *__pyx_v_mt;
  PyObject *__pyx_v_state_vec;
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  uint32_t __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  uint32_t __pyx_t_23;
  uint32_t __pyx_t_24;
  uint32_t __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  int __pyx_t_29;
  uint32_t __pyx_t_30;
  uint32_t __pyx_t_31;
  int __pyx_t_32;
  PyObject *__pyx_t_33 = NULL;
  __Pyx_RefNannySetupContext("setstate");
  __pyx_v_version = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_fields = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_state_vec = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":107
 * 	def setstate(self, state):
 * 		"""Restore internal state from object returned by getstate()."""
 * 		version, fields = state             # <<<<<<<<<<<<<<
 * 		if version != 1:
 * 			raise DcmtError("State version " + str(version) + " is not supported")
 */
  if (PyTuple_CheckExact(__pyx_v_state) && likely(PyTuple_GET_SIZE(__pyx_v_state) == 2)) {
    PyObject* tuple = __pyx_v_state;
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_version);
    __pyx_v_version = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_fields);
    __pyx_v_fields = __pyx_t_2;
    __pyx_t_2 = 0;
  } else {
    __pyx_t_3 = PyObject_GetIter(__pyx_v_state); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_3, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_3, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_EndUnpack(__pyx_t_3, 2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_version);
    __pyx_v_version = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_fields);
    __pyx_v_fields = __pyx_t_2;
    __pyx_t_2 = 0;
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":108
 * 		"""Restore internal state from object returned by getstate()."""
 * 		version, fields = state
 * 		if version != 1:             # <<<<<<<<<<<<<<
 * 			raise DcmtError("State version " + str(version) + " is not supported")
 * 
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_version, __pyx_int_1, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":109
 * 		version, fields = state
 * 		if version != 1:
 * 			raise DcmtError("State version " + str(version) + " is not supported")             # <<<<<<<<<<<<<<
 * 
 * 		cdef mt_struct *mt = <mt_struct *>malloc(sizeof(mt_struct))
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__DcmtError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(__pyx_v_version);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_version);
    __Pyx_GIVEREF(__pyx_v_version);
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_kp_s_23), __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_kp_s_24)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":111
 * 			raise DcmtError("State version " + str(version) + " is not supported")
 * 
 * 		cdef mt_struct *mt = <mt_struct *>malloc(sizeof(mt_struct))             # <<<<<<<<<<<<<<
 * 
 * 		mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww, \
 */
  __pyx_v_mt = ((mt_struct *)malloc((sizeof(mt_struct))));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":116
 * 			mt.wmask, mt.umask, mt.lmask, \
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields             # <<<<<<<<<<<<<<
 * 
 * 		mt.state = <uint32_t *>malloc(sizeof(uint32_t) * mt.nn)
 */
  if (PyTuple_CheckExact(__pyx_v_fields) && likely(PyTuple_GET_SIZE(__pyx_v_fields) == 16)) {
    PyObject* tuple = __pyx_v_fields;
    __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":113
 * 		cdef mt_struct *mt = <mt_struct *>malloc(sizeof(mt_struct))
 * 
 * 		mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww, \             # <<<<<<<<<<<<<<
 * 			mt.wmask, mt.umask, mt.lmask, \
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \
 */
    __pyx_t_18 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_18 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
    __pyx_t_19 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_2);
    __pyx_t_20 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_20 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_5);
    __pyx_t_21 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_21 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = PyTuple_GET_ITEM(tuple, 4); __Pyx_INCREF(__pyx_t_6);
    __pyx_t_22 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_22 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = PyTuple_GET_ITEM(tuple, 5); __Pyx_INCREF(__pyx_t_7);
    __pyx_t_23 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_7); if (unlikely((__pyx_t_23 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = PyTuple_GET_ITEM(tuple, 6); __Pyx_INCREF(__pyx_t_8);
    __pyx_t_24 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_24 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = PyTuple_GET_ITEM(tuple, 7); __Pyx_INCREF(__pyx_t_9);
    __pyx_t_25 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_9); if (unlikely((__pyx_t_25 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = PyTuple_GET_ITEM(tuple, 8); __Pyx_INCREF(__pyx_t_10);
    __pyx_t_26 = __Pyx_PyInt_AsInt(__pyx_t_10); if (unlikely((__pyx_t_26 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_11 = PyTuple_GET_ITEM(tuple, 9); __Pyx_INCREF(__pyx_t_11);
    __pyx_t_27 = __Pyx_PyInt_AsInt(__pyx_t_11); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_12 = PyTuple_GET_ITEM(tuple, 10); __Pyx_INCREF(__pyx_t_12);
    __pyx_t_28 = __Pyx_PyInt_AsInt(__pyx_t_12); if (unlikely((__pyx_t_28 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_13 = PyTuple_GET_ITEM(tuple, 11); __Pyx_INCREF(__pyx_t_13);
    __pyx_t_29 = __Pyx_PyInt_AsInt(__pyx_t_13); if (unlikely((__pyx_t_29 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_14 = PyTuple_GET_ITEM(tuple, 12); __Pyx_INCREF(__pyx_t_14);
    __pyx_t_30 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_14); if (unlikely((__pyx_t_30 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_15 = PyTuple_GET_ITEM(tuple, 13); __Pyx_INCREF(__pyx_t_15);
    __pyx_t_31 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_15); if (unlikely((__pyx_t_31 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_16 = PyTuple_GET_ITEM(tuple, 14); __Pyx_INCREF(__pyx_t_16);
    __pyx_t_32 = __Pyx_PyInt_AsInt(__pyx_t_16); if (unlikely((__pyx_t_32 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_17 = PyTuple_GET_ITEM(tuple, 15); __Pyx_INCREF(__pyx_t_17);
    __pyx_v_mt->aaa = __pyx_t_18;
    __pyx_v_mt->mm = __pyx_t_19;
    __pyx_v_mt->nn = __pyx_t_20;
    __pyx_v_mt->rr = __pyx_t_21;
    __pyx_v_mt->ww = __pyx_t_22;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":114
 * 
 * 		mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww, \
 * 			mt.wmask, mt.umask, mt.lmask, \             # <<<<<<<<<<<<<<
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields
 */
    __pyx_v_mt->wmask = __pyx_t_23;
    __pyx_v_mt->umask = __pyx_t_24;
    __pyx_v_mt->lmask = __pyx_t_25;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":115
 * 		mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww, \
 * 			mt.wmask, mt.umask, mt.lmask, \
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \             # <<<<<<<<<<<<<<
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields
 * 
 */
    __pyx_v_mt->shift0 = __pyx_t_26;
    __pyx_v_mt->shift1 = __pyx_t_27;
    __pyx_v_mt->shiftB = __pyx_t_28;
    __pyx_v_mt->shiftC = __pyx_t_29;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":116
 * 			mt.wmask, mt.umask, mt.lmask, \
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields             # <<<<<<<<<<<<<<
 * 
 * 		mt.state = <uint32_t *>malloc(sizeof(uint32_t) * mt.nn)
 */
    __pyx_v_mt->maskB = __pyx_t_30;
    __pyx_v_mt->maskC = __pyx_t_31;
    __pyx_v_mt->i = __pyx_t_32;
    __Pyx_DECREF(__pyx_v_state_vec);
    __pyx_v_state_vec = __pyx_t_17;
    __pyx_t_17 = 0;
  } else {
    __pyx_t_33 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_33)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_33);
    __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_33, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":113
 * 		cdef mt_struct *mt = <mt_struct *>malloc(sizeof(mt_struct))
 * 
 * 		mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww, \             # <<<<<<<<<<<<<<
 * 			mt.wmask, mt.umask, mt.lmask, \
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \
 */
    __pyx_t_31 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_31 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_33, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_32 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_32 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_33, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_29 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_29 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_33, 3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_28 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_28 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_33, 4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_27 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_33, 5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_30 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_7); if (unlikely((__pyx_t_30 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_33, 6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_25 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_25 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = __Pyx_UnpackItem(__pyx_t_33, 7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_24 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_9); if (unlikely((__pyx_t_24 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_33, 8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_26 = __Pyx_PyInt_AsInt(__pyx_t_10); if (unlikely((__pyx_t_26 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_11 = __Pyx_UnpackItem(__pyx_t_33, 9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_22 = __Pyx_PyInt_AsInt(__pyx_t_11); if (unlikely((__pyx_t_22 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_12 = __Pyx_UnpackItem(__pyx_t_33, 10); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_21 = __Pyx_PyInt_AsInt(__pyx_t_12); if (unlikely((__pyx_t_21 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_13 = __Pyx_UnpackItem(__pyx_t_33, 11); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_20 = __Pyx_PyInt_AsInt(__pyx_t_13); if (unlikely((__pyx_t_20 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_14 = __Pyx_UnpackItem(__pyx_t_33, 12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_23 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_14); if (unlikely((__pyx_t_23 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_15 = __Pyx_UnpackItem(__pyx_t_33, 13); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_18 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_15); if (unlikely((__pyx_t_18 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_16 = __Pyx_UnpackItem(__pyx_t_33, 14); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_19 = __Pyx_PyInt_AsInt(__pyx_t_16); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_17 = __Pyx_UnpackItem(__pyx_t_33, 15); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    if (__Pyx_EndUnpack(__pyx_t_33, 16) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
    __pyx_v_mt->aaa = __pyx_t_31;
    __pyx_v_mt->mm = __pyx_t_32;
    __pyx_v_mt->nn = __pyx_t_29;
    __pyx_v_mt->rr = __pyx_t_28;
    __pyx_v_mt->ww = __pyx_t_27;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":114
 * 
 * 		mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww, \
 * 			mt.wmask, mt.umask, mt.lmask, \             # <<<<<<<<<<<<<<
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields
 */
    __pyx_v_mt->wmask = __pyx_t_30;
    __pyx_v_mt->umask = __pyx_t_25;
    __pyx_v_mt->lmask = __pyx_t_24;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":115
 * 		mt.aaa, mt.mm, mt.nn, mt.rr, mt.ww, \
 * 			mt.wmask, mt.umask, mt.lmask, \
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \             # <<<<<<<<<<<<<<
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields
 * 
 */
    __pyx_v_mt->shift0 = __pyx_t_26;
    __pyx_v_mt->shift1 = __pyx_t_22;
    __pyx_v_mt->shiftB = __pyx_t_21;
    __pyx_v_mt->shiftC = __pyx_t_20;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":116
 * 			mt.wmask, mt.umask, mt.lmask, \
 * 			mt.shift0, mt.shift1, mt.shiftB, mt.shiftC, \
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields             # <<<<<<<<<<<<<<
 * 
 * 		mt.state = <uint32_t *>malloc(sizeof(uint32_t) * mt.nn)
 */
    __pyx_v_mt->maskB = __pyx_t_23;
    __pyx_v_mt->maskC = __pyx_t_18;
    __pyx_v_mt->i = __pyx_t_19;
    __Pyx_DECREF(__pyx_v_state_vec);
    __pyx_v_state_vec = __pyx_t_17;
    __pyx_t_17 = 0;
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":118
 * 			mt.maskB, mt.maskC, mt.i, state_vec = fields
 * 
 * 		mt.state = <uint32_t *>malloc(sizeof(uint32_t) * mt.nn)             # <<<<<<<<<<<<<<
 * 		for i in range(mt.nn):
 * 			mt.state[i] = state_vec[i]
 */
  __pyx_v_mt->state = ((uint32_t *)malloc(((sizeof(uint32_t)) * __pyx_v_mt->nn)));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":119
 * 
 * 		mt.state = <uint32_t *>malloc(sizeof(uint32_t) * mt.nn)
 * 		for i in range(mt.nn):             # <<<<<<<<<<<<<<
 * 			mt.state[i] = state_vec[i]
 * 
 */
  __pyx_t_19 = __pyx_v_mt->nn;
  for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
    __pyx_v_i = __pyx_t_20;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":120
 * 		mt.state = <uint32_t *>malloc(sizeof(uint32_t) * mt.nn)
 * 		for i in range(mt.nn):
 * 			mt.state[i] = state_vec[i]             # <<<<<<<<<<<<<<
 * 
 * 		self.mt = mt
 */
    __pyx_t_17 = __Pyx_GetItemInt(__pyx_v_state_vec, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_17) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_18 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_17); if (unlikely((__pyx_t_18 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    (__pyx_v_mt->state[__pyx_v_i]) = __pyx_t_18;
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":122
 * 			mt.state[i] = state_vec[i]
 * 
 * 		self.mt = mt             # <<<<<<<<<<<<<<
 * 
 * 
 */
  ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_v_self)->mt = __pyx_v_mt;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_AddTraceback("dcmt.pyrandom.RandomContainer.setstate");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_version);
  __Pyx_DECREF(__pyx_v_fields);
  __Pyx_DECREF(__pyx_v_state_vec);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":127
 * class DcmtRandom(Random):
 * 
 * 	def __init__(self, *args, wordlen=32, exponent=521, id=0, gen_seed=None):             # <<<<<<<<<<<<<<
 * 		cdef int w, p, mid, sid
 * 		cdef uint32_t s = get_seed(gen_seed)
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_0__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_0__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_0__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_0__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_wordlen = 0;
  PyObject *__pyx_v_exponent = 0;
  PyObject *__pyx_v_id = 0;
  PyObject *__pyx_v_gen_seed = 0;
  PyObject *__pyx_v_args = 0;
  int __pyx_v_w;
  int __pyx_v_p;
  int __pyx_v_mid;
  int __pyx_v_sid;
  uint32_t __pyx_v_s;
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  uint32_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__wordlen,&__pyx_n_s__exponent,&__pyx_n_s__id,&__pyx_n_s__gen_seed,0};
  __Pyx_RefNannySetupContext("__init__");
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
    if (unlikely(!__pyx_v_args)) return NULL;
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_32);
    values[2] = ((PyObject *)__pyx_int_521);
    values[3] = ((PyObject *)__pyx_int_0);
    values[4] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    while (kw_args > 0) {
      PyObject* value;
      value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wordlen);
      if (value) { values[1] = value; if (!(--kw_args)) break; }
      value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exponent);
      if (value) { values[2] = value; if (!(--kw_args)) break; }
      value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__id);
      if (value) { values[3] = value; if (!(--kw_args)) break; }
      value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__gen_seed);
      if (value) { values[4] = value; if (!(--kw_args)) break; }
      break;
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_wordlen = values[1];
    __pyx_v_exponent = values[2];
    __pyx_v_id = values[3];
    __pyx_v_gen_seed = values[4];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_wordlen = ((PyObject *)__pyx_int_32);
    __pyx_v_exponent = ((PyObject *)__pyx_int_521);
    __pyx_v_id = ((PyObject *)__pyx_int_0);
    __pyx_v_gen_seed = ((PyObject *)Py_None);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.__init__");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":129
 * 	def __init__(self, *args, wordlen=32, exponent=521, id=0, gen_seed=None):
 * 		cdef int w, p, mid, sid
 * 		cdef uint32_t s = get_seed(gen_seed)             # <<<<<<<<<<<<<<
 * 
 * 		validate_parameters(wordlen, exponent, id, id, &w, &p, &sid, &mid)
 */
  __pyx_t_1 = __pyx_f_4dcmt_8pyrandom_get_seed(__pyx_v_gen_seed); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_s = __pyx_t_1;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":131
 * 		cdef uint32_t s = get_seed(gen_seed)
 * 
 * 		validate_parameters(wordlen, exponent, id, id, &w, &p, &sid, &mid)             # <<<<<<<<<<<<<<
 * 
 * 		cdef RandomContainer rc = <RandomContainer>RandomContainer()
 */
  __pyx_f_4dcmt_8pyrandom_validate_parameters(__pyx_v_wordlen, __pyx_v_exponent, __pyx_v_id, __pyx_v_id, (&__pyx_v_w), (&__pyx_v_p), (&__pyx_v_sid), (&__pyx_v_mid)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":133
 * 		validate_parameters(wordlen, exponent, id, id, &w, &p, &sid, &mid)
 * 
 * 		cdef RandomContainer rc = <RandomContainer>RandomContainer()             # <<<<<<<<<<<<<<
 * 		rc.initWithParams(w, p, sid, s)
 * 		self.rc = rc
 */
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4dcmt_8pyrandom_RandomContainer)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":134
 * 
 * 		cdef RandomContainer rc = <RandomContainer>RandomContainer()
 * 		rc.initWithParams(w, p, sid, s)             # <<<<<<<<<<<<<<
 * 		self.rc = rc
 * 
 */
  ((struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer *)__pyx_v_rc->__pyx_vtab)->initWithParams(__pyx_v_rc, __pyx_v_w, __pyx_v_p, __pyx_v_sid, __pyx_v_s); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":135
 * 		cdef RandomContainer rc = <RandomContainer>RandomContainer()
 * 		rc.initWithParams(w, p, sid, s)
 * 		self.rc = rc             # <<<<<<<<<<<<<<
 * 
 * 		self.seed(*args)
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__rc, ((PyObject *)__pyx_v_rc)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":137
 * 		self.rc = rc
 * 
 * 		self.seed(*args)             # <<<<<<<<<<<<<<
 * 
 * 	def seed(self, a=None):
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__seed); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.__init__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":139
 * 		self.seed(*args)
 * 
 * 	def seed(self, a=None):             # <<<<<<<<<<<<<<
 * 		cdef uint32_t seed = get_seed(a)
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_1seed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_1seed = {__Pyx_NAMESTR("seed"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_1seed, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_1seed(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_a = 0;
  uint32_t __pyx_v_seed;
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  uint32_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__a,0};
  __Pyx_RefNannySetupContext("seed");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
        if (value) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "seed") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_a = values[1];
  } else {
    __pyx_v_a = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_a = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("seed", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.seed");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":140
 * 
 * 	def seed(self, a=None):
 * 		cdef uint32_t seed = get_seed(a)             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.seed(seed)
 */
  __pyx_t_1 = __pyx_f_4dcmt_8pyrandom_get_seed(__pyx_v_a); if (unlikely(__pyx_t_1 == -1 && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_seed = __pyx_t_1;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":141
 * 	def seed(self, a=None):
 * 		cdef uint32_t seed = get_seed(a)
 * 		cdef RandomContainer rc = <RandomContainer>self.rc             # <<<<<<<<<<<<<<
 * 		rc.seed(seed)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_2)));
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":142
 * 		cdef uint32_t seed = get_seed(a)
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.seed(seed)             # <<<<<<<<<<<<<<
 * 
 * 	def random(self):
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer *)__pyx_v_rc->__pyx_vtab)->seed(__pyx_v_rc, __pyx_v_seed); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.seed");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":144
 * 		rc.seed(seed)
 * 
 * 	def random(self):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.random()
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_2random(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_2random = {__Pyx_NAMESTR("random"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_2random, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_2random(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("random");
  __pyx_self = __pyx_self;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":145
 * 
 * 	def random(self):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc             # <<<<<<<<<<<<<<
 * 		return rc.random()
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1)));
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":146
 * 	def random(self):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.random()             # <<<<<<<<<<<<<<
 * 
 * 	def random_raw(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer *)__pyx_v_rc->__pyx_vtab)->random(__pyx_v_rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.random");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":148
 * 		return rc.random()
 * 
 * 	def random_raw(self):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.random_raw()
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_3random_raw(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_3random_raw = {__Pyx_NAMESTR("random_raw"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_3random_raw, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_3random_raw(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("random_raw");
  __pyx_self = __pyx_self;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":149
 * 
 * 	def random_raw(self):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc             # <<<<<<<<<<<<<<
 * 		return rc.random_raw()
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1)));
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":150
 * 	def random_raw(self):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.random_raw()             # <<<<<<<<<<<<<<
 * 
 * 	def getstate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer *)__pyx_v_rc->__pyx_vtab)->random_raw(__pyx_v_rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.random_raw");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":152
 * 		return rc.random_raw()
 * 
 * 	def getstate(self):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.getstate()
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_4getstate(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_4getstate = {__Pyx_NAMESTR("getstate"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_4getstate, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_4getstate(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("getstate");
  __pyx_self = __pyx_self;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":153
 * 
 * 	def getstate(self):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc             # <<<<<<<<<<<<<<
 * 		return rc.getstate()
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1)));
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":154
 * 	def getstate(self):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.getstate()             # <<<<<<<<<<<<<<
 * 
 * 	def setstate(self, state):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rc), __pyx_n_s__getstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.getstate");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":156
 * 		return rc.getstate()
 * 
 * 	def setstate(self, state):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.setstate(state)
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_5setstate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_5setstate = {__Pyx_NAMESTR("setstate"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_5setstate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_5setstate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_state = 0;
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__state,0};
  __Pyx_RefNannySetupContext("setstate");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__state);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("setstate", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setstate") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_state = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_state = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("setstate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.setstate");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":157
 * 
 * 	def setstate(self, state):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc             # <<<<<<<<<<<<<<
 * 		rc.setstate(state)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1)));
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":158
 * 	def setstate(self, state):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.setstate(state)             # <<<<<<<<<<<<<<
 * 
 * 	def getrandbits(self, k):
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rc), __pyx_n_s__setstate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_state);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_state);
  __Pyx_GIVEREF(__pyx_v_state);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.setstate");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":160
 * 		rc.setstate(state)
 * 
 * 	def getrandbits(self, k):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.getrandbits(k)
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_6getrandbits(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_6getrandbits = {__Pyx_NAMESTR("getrandbits"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_6getrandbits, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_6getrandbits(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_k = 0;
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__k,0};
  __Pyx_RefNannySetupContext("getrandbits");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("getrandbits", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "getrandbits") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_k = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_k = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getrandbits", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.getrandbits");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":161
 * 
 * 	def getrandbits(self, k):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc             # <<<<<<<<<<<<<<
 * 		return rc.getrandbits(k)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1)));
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":162
 * 	def getrandbits(self, k):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.getrandbits(k)             # <<<<<<<<<<<<<<
 * 
 * 	def jumpahead(self, n):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rc), __pyx_n_s__getrandbits); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_k);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_k);
  __Pyx_GIVEREF(__pyx_v_k);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.getrandbits");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":164
 * 		return rc.getrandbits(k)
 * 
 * 	def jumpahead(self, n):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.jumpahead(n)
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_7jumpahead(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_7jumpahead = {__Pyx_NAMESTR("jumpahead"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_7jumpahead, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_7jumpahead(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_n = 0;
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__n,0};
  __Pyx_RefNannySetupContext("jumpahead");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("jumpahead", 1, 2, 2, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "jumpahead") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_n = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_n = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("jumpahead", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.jumpahead");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":165
 * 
 * 	def jumpahead(self, n):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc             # <<<<<<<<<<<<<<
 * 		rc.jumpahead(n)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1)));
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":166
 * 	def jumpahead(self, n):
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.jumpahead(n)             # <<<<<<<<<<<<<<
 * 
 * 	@classmethod
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rc), __pyx_n_s__jumpahead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_n);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n);
  __Pyx_GIVEREF(__pyx_v_n);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.jumpahead");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rc);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":169
 * 
 * 	@classmethod
 * 	def range(cls, *args, wordlen=32, exponent=521, gen_seed=None):             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i, count
 */

static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_8range(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_8range = {__Pyx_NAMESTR("range"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_8range, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_4dcmt_8pyrandom_10DcmtRandom_8range(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_cls = 0;
  PyObject *__pyx_v_wordlen = 0;
  PyObject *__pyx_v_exponent = 0;
  PyObject *__pyx_v_gen_seed = 0;
  PyObject *__pyx_v_args = 0;
  int __pyx_v_i;
  int __pyx_v_count;
  mt_struct **__pyx_v_mts;
  PyObject *__pyx_v_res;
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *__pyx_v_rc;
  PyObject *__pyx_v_rngs;
  PyObject *__pyx_v_rng;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cls,&__pyx_n_s__wordlen,&__pyx_n_s__exponent,&__pyx_n_s__gen_seed,0};
  __Pyx_RefNannySetupContext("range");
  __pyx_self = __pyx_self;
  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
    if (unlikely(!__pyx_v_args)) return NULL;
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_32);
    values[2] = ((PyObject *)__pyx_int_521);
    values[3] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      default:
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cls);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    while (kw_args > 0) {
      PyObject* value;
      value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wordlen);
      if (value) { values[1] = value; if (!(--kw_args)) break; }
      value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exponent);
      if (value) { values[2] = value; if (!(--kw_args)) break; }
      value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__gen_seed);
      if (value) { values[3] = value; if (!(--kw_args)) break; }
      break;
    }
    if (unlikely(kw_args > 0)) {
      const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "range") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_cls = values[0];
    __pyx_v_wordlen = values[1];
    __pyx_v_exponent = values[2];
    __pyx_v_gen_seed = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_cls = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_wordlen = ((PyObject *)__pyx_int_32);
    __pyx_v_exponent = ((PyObject *)__pyx_int_521);
    __pyx_v_gen_seed = ((PyObject *)Py_None);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("range", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.range");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_res = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_rngs = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_rng = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":172
 * 
 * 		cdef int i, count
 * 		cdef mt_struct **mts = NULL             # <<<<<<<<<<<<<<
 * 
 * 		res = create_mt_range(args, wordlen, exponent, gen_seed, &mts, &count)
 */
  __pyx_v_mts = NULL;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":174
 * 		cdef mt_struct **mts = NULL
 * 
 * 		res = create_mt_range(args, wordlen, exponent, gen_seed, &mts, &count)             # <<<<<<<<<<<<<<
 * 		if res != None:
 * 			return res
 */
  __pyx_t_1 = __pyx_f_4dcmt_8pyrandom_create_mt_range(((PyObject *)__pyx_v_args), __pyx_v_wordlen, __pyx_v_exponent, __pyx_v_gen_seed, (&__pyx_v_mts), (&__pyx_v_count)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_res);
  __pyx_v_res = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":175
 * 
 * 		res = create_mt_range(args, wordlen, exponent, gen_seed, &mts, &count)
 * 		if res != None:             # <<<<<<<<<<<<<<
 * 			return res
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_res, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":176
 * 		res = create_mt_range(args, wordlen, exponent, gen_seed, &mts, &count)
 * 		if res != None:
 * 			return res             # <<<<<<<<<<<<<<
 * 
 * 		cdef RandomContainer rc
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_res);
    __pyx_r = __pyx_v_res;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":179
 * 
 * 		cdef RandomContainer rc
 * 		rngs = []             # <<<<<<<<<<<<<<
 * 		for i in range(count):
 * 			rc = <RandomContainer>RandomContainer()
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(((PyObject *)__pyx_v_rngs));
  __pyx_v_rngs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":180
 * 		cdef RandomContainer rc
 * 		rngs = []
 * 		for i in range(count):             # <<<<<<<<<<<<<<
 * 			rc = <RandomContainer>RandomContainer()
 * 			rc.initWithStruct(mts[i])
 */
  __pyx_t_3 = __pyx_v_count;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":181
 * 		rngs = []
 * 		for i in range(count):
 * 			rc = <RandomContainer>RandomContainer()             # <<<<<<<<<<<<<<
 * 			rc.initWithStruct(mts[i])
 * 
 */
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4dcmt_8pyrandom_RandomContainer)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_v_rc));
    __pyx_v_rc = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":182
 * 		for i in range(count):
 * 			rc = <RandomContainer>RandomContainer()
 * 			rc.initWithStruct(mts[i])             # <<<<<<<<<<<<<<
 * 
 * 			rng = cls.__new__(cls)
 */
    ((struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer *)__pyx_v_rc->__pyx_vtab)->initWithStruct(__pyx_v_rc, (__pyx_v_mts[__pyx_v_i]));

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":184
 * 			rc.initWithStruct(mts[i])
 * 
 * 			rng = cls.__new__(cls)             # <<<<<<<<<<<<<<
 * 			cls.rc = rc
 * 			rng.seed()
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_cls, __pyx_n_s____new__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_INCREF(__pyx_v_cls);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_cls);
    __Pyx_GIVEREF(__pyx_v_cls);
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_v_rng);
    __pyx_v_rng = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":185
 * 
 * 			rng = cls.__new__(cls)
 * 			cls.rc = rc             # <<<<<<<<<<<<<<
 * 			rng.seed()
 * 
 */
    if (PyObject_SetAttr(__pyx_v_cls, __pyx_n_s__rc, ((PyObject *)__pyx_v_rc)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":186
 * 			rng = cls.__new__(cls)
 * 			cls.rc = rc
 * 			rng.seed()             # <<<<<<<<<<<<<<
 * 
 * 			rngs.append(rng)
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_rng, __pyx_n_s__seed); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":188
 * 			rng.seed()
 * 
 * 			rngs.append(rng)             # <<<<<<<<<<<<<<
 * 
 * 		# We do not need array of pointers anymore, but we are keeping pointers to mt_struct's
 */
    if (unlikely(__pyx_v_rngs == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_7 = PyList_Append(__pyx_v_rngs, __pyx_v_rng); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":192
 * 		# We do not need array of pointers anymore, but we are keeping pointers to mt_struct's
 * 		# So we are not using free_mt_struct_array()
 * 		free(mts)             # <<<<<<<<<<<<<<
 * 
 * 		return rngs
 */
  free(__pyx_v_mts);

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":194
 * 		free(mts)
 * 
 * 		return rngs             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_rngs));
  __pyx_r = ((PyObject *)__pyx_v_rngs);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("dcmt.pyrandom.DcmtRandom.range");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_res);
  __Pyx_DECREF((PyObject *)__pyx_v_rc);
  __Pyx_DECREF(__pyx_v_rngs);
  __Pyx_DECREF(__pyx_v_rng);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_4dcmt_8pyrandom_RandomContainer __pyx_vtable_4dcmt_8pyrandom_RandomContainer;

static PyObject *__pyx_tp_new_4dcmt_8pyrandom_RandomContainer(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *)o);
  p->__pyx_vtab = __pyx_vtabptr_4dcmt_8pyrandom_RandomContainer;
  return o;
}

static void __pyx_tp_dealloc_4dcmt_8pyrandom_RandomContainer(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4dcmt_8pyrandom_15RandomContainer_1__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_4dcmt_8pyrandom_RandomContainer[] = {
  {__Pyx_NAMESTR("jumpahead"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_15RandomContainer_2jumpahead, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getrandbits"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_15RandomContainer_3getrandbits, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("getstate"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_15RandomContainer_4getstate, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4dcmt_8pyrandom_15RandomContainer_4getstate)},
  {__Pyx_NAMESTR("setstate"), (PyCFunction)__pyx_pf_4dcmt_8pyrandom_15RandomContainer_5setstate, METH_O, __Pyx_DOCSTR(__pyx_doc_4dcmt_8pyrandom_15RandomContainer_5setstate)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RandomContainer = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RandomContainer = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RandomContainer = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RandomContainer = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_4dcmt_8pyrandom_RandomContainer = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("dcmt.pyrandom.RandomContainer"), /*tp_name*/
  sizeof(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4dcmt_8pyrandom_RandomContainer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_RandomContainer, /*tp_as_number*/
  &__pyx_tp_as_sequence_RandomContainer, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RandomContainer, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RandomContainer, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4dcmt_8pyrandom_RandomContainer, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4dcmt_8pyrandom_15RandomContainer_0__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4dcmt_8pyrandom_RandomContainer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("pyrandom"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
  {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
  {&__pyx_n_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 1},
  {&__pyx_n_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 1},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_n_s__DcmtError, __pyx_k__DcmtError, sizeof(__pyx_k__DcmtError), 0, 0, 1, 1},
  {&__pyx_n_s__DcmtParameterError, __pyx_k__DcmtParameterError, sizeof(__pyx_k__DcmtParameterError), 0, 0, 1, 1},
  {&__pyx_n_s__DcmtRandom, __pyx_k__DcmtRandom, sizeof(__pyx_k__DcmtRandom), 0, 0, 1, 1},
  {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1},
  {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s__Random, __pyx_k__Random, sizeof(__pyx_k__Random), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____new__, __pyx_k____new__, sizeof(__pyx_k____new__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___hexlify, __pyx_k___hexlify, sizeof(__pyx_k___hexlify), 0, 0, 1, 1},
  {&__pyx_n_s___urandom, __pyx_k___urandom, sizeof(__pyx_k___urandom), 0, 0, 1, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__aaa, __pyx_k__aaa, sizeof(__pyx_k__aaa), 0, 0, 1, 1},
  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  {&__pyx_n_s__binascii, __pyx_k__binascii, sizeof(__pyx_k__binascii), 0, 0, 1, 1},
  {&__pyx_n_s__cls, __pyx_k__cls, sizeof(__pyx_k__cls), 0, 0, 1, 1},
  {&__pyx_n_s__exponent, __pyx_k__exponent, sizeof(__pyx_k__exponent), 0, 0, 1, 1},
  {&__pyx_n_s__gen_seed, __pyx_k__gen_seed, sizeof(__pyx_k__gen_seed), 0, 0, 1, 1},
  {&__pyx_n_s__getrandbits, __pyx_k__getrandbits, sizeof(__pyx_k__getrandbits), 0, 0, 1, 1},
  {&__pyx_n_s__getstate, __pyx_k__getstate, sizeof(__pyx_k__getstate), 0, 0, 1, 1},
  {&__pyx_n_s__hexlify, __pyx_k__hexlify, sizeof(__pyx_k__hexlify), 0, 0, 1, 1},
  {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
  {&__pyx_n_s__initWithParams, __pyx_k__initWithParams, sizeof(__pyx_k__initWithParams), 0, 0, 1, 1},
  {&__pyx_n_s__initWithStruct, __pyx_k__initWithStruct, sizeof(__pyx_k__initWithStruct), 0, 0, 1, 1},
  {&__pyx_n_s__jumpahead, __pyx_k__jumpahead, sizeof(__pyx_k__jumpahead), 0, 0, 1, 1},
  {&__pyx_n_s__k, __pyx_k__k, sizeof(__pyx_k__k), 0, 0, 1, 1},
  {&__pyx_n_s__lmask, __pyx_k__lmask, sizeof(__pyx_k__lmask), 0, 0, 1, 1},
  {&__pyx_n_s__maskB, __pyx_k__maskB, sizeof(__pyx_k__maskB), 0, 0, 1, 1},
  {&__pyx_n_s__maskC, __pyx_k__maskC, sizeof(__pyx_k__maskC), 0, 0, 1, 1},
  {&__pyx_n_s__mm, __pyx_k__mm, sizeof(__pyx_k__mm), 0, 0, 1, 1},
  {&__pyx_n_s__mt, __pyx_k__mt, sizeof(__pyx_k__mt), 0, 0, 1, 1},
  {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
  {&__pyx_n_s__nn, __pyx_k__nn, sizeof(__pyx_k__nn), 0, 0, 1, 1},
  {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
  {&__pyx_n_s__random, __pyx_k__random, sizeof(__pyx_k__random), 0, 0, 1, 1},
  {&__pyx_n_s__random_raw, __pyx_k__random_raw, sizeof(__pyx_k__random_raw), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__rc, __pyx_k__rc, sizeof(__pyx_k__rc), 0, 0, 1, 1},
  {&__pyx_n_s__rr, __pyx_k__rr, sizeof(__pyx_k__rr), 0, 0, 1, 1},
  {&__pyx_n_s__seed, __pyx_k__seed, sizeof(__pyx_k__seed), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__setstate, __pyx_k__setstate, sizeof(__pyx_k__setstate), 0, 0, 1, 1},
  {&__pyx_n_s__shift0, __pyx_k__shift0, sizeof(__pyx_k__shift0), 0, 0, 1, 1},
  {&__pyx_n_s__shift1, __pyx_k__shift1, sizeof(__pyx_k__shift1), 0, 0, 1, 1},
  {&__pyx_n_s__shiftB, __pyx_k__shiftB, sizeof(__pyx_k__shiftB), 0, 0, 1, 1},
  {&__pyx_n_s__shiftC, __pyx_k__shiftC, sizeof(__pyx_k__shiftC), 0, 0, 1, 1},
  {&__pyx_n_s__state, __pyx_k__state, sizeof(__pyx_k__state), 0, 0, 1, 1},
  {&__pyx_n_s__time, __pyx_k__time, sizeof(__pyx_k__time), 0, 0, 1, 1},
  {&__pyx_n_s__umask, __pyx_k__umask, sizeof(__pyx_k__umask), 0, 0, 1, 1},
  {&__pyx_n_s__urandom, __pyx_k__urandom, sizeof(__pyx_k__urandom), 0, 0, 1, 1},
  {&__pyx_n_s__wmask, __pyx_k__wmask, sizeof(__pyx_k__wmask), 0, 0, 1, 1},
  {&__pyx_n_s__wordlen, __pyx_k__wordlen, sizeof(__pyx_k__wordlen), 0, 0, 1, 1},
  {&__pyx_n_s__ww, __pyx_k__ww, sizeof(__pyx_k__ww), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":61
 * 	if seed is None:
 * 		try:
 * 			seed = long(_hexlify(_urandom(16)), 16)             # <<<<<<<<<<<<<<
 * 		except NotImplementedError:
 * 			seed = long(time.time() * 256) # use fractional seconds
 */
  __pyx_k_tuple_1 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_1));
  __Pyx_INCREF(__pyx_int_16);
  PyTuple_SET_ITEM(__pyx_k_tuple_1, 0, __pyx_int_16);
  __Pyx_GIVEREF(__pyx_int_16);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_1));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":68
 * 			seed = hash(seed)
 * 		except TypeError:
 * 			raise DcmtParameterError("Seed must be an integer or hashable type")             # <<<<<<<<<<<<<<
 * 
 * 	# not checking for overflow now, since we need 4 lower bytes anyway
 */
  __pyx_k_tuple_3 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
  PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_kp_s_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":85
 * 
 * 	if sid > mid:
 * 		raise DcmtParameterError("Starting ID must be equal to or lower than maximum ID")             # <<<<<<<<<<<<<<
 * 
 * 	if sid < 0 or mid > 65535:
 */
  __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_5));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
  PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":88
 * 
 * 	if sid < 0 or mid > 65535:
 * 		raise DcmtParameterError("All IDs must lie between 0 and 65535")             # <<<<<<<<<<<<<<
 * 
 * 	if w == 31 and p == 521 and sid <= 9 and mid >= 9:
 */
  __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":91
 * 
 * 	if w == 31 and p == 521 and sid <= 9 and mid >= 9:
 * 		raise DcmtParameterError("Known bug: cannot create RNG for wordlen=31, exponent=521, id=9")             # <<<<<<<<<<<<<<
 * 
 * 	if w != 31 and w != 32:
 */
  __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":94
 * 
 * 	if w != 31 and w != 32:
 * 		raise DcmtParameterError("Word length must be equal to 31 or 32")             # <<<<<<<<<<<<<<
 * 
 * 	if p not in (521, 607, 1279, 2203, 2281, 3217, 4253, 4423,
 */
  __pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_11));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
  PyTuple_SET_ITEM(__pyx_k_tuple_11, 0, ((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":98
 * 	if p not in (521, 607, 1279, 2203, 2281, 3217, 4253, 4423,
 * 			9689, 9941, 11213, 19937, 21701, 23209, 44497):
 * 		raise DcmtParameterError("Mersenne exponent is incorrect or not from a supported set")             # <<<<<<<<<<<<<<
 * 
 * 	c_wordlen[0] = w
 */
  __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_13));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
  PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_s_12));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":115
 * 		start_id, max_id = args
 * 	else:
 * 		raise TypeError("range expected 1 or 2 positional arguments")             # <<<<<<<<<<<<<<
 * 
 * 	max_id -= 1
 */
  __pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_15));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_14));
  PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_14));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":130
 * 		if mts != NULL:
 * 			free_mt_struct_array(m, count[0])
 * 		raise DcmtError("dcmt internal error: could not create all requested RNGs")             # <<<<<<<<<<<<<<
 * 
 * 	mts[0] = m
 */
  __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_17));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_kp_s_16));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":21
 * 		self.mt = get_mt_parameter_id_st(wordlen, exponent, id, seed)
 * 		if self.mt == NULL:
 * 			raise DcmtError("Failed to create RNG")             # <<<<<<<<<<<<<<
 * 
 * 	def __dealloc__(self):
 */
  __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_19));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
  PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_kp_s_18));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":66
 * 
 * 		if k <= 0:
 * 			raise ValueError("number of bits must be greater than zero")             # <<<<<<<<<<<<<<
 * 
 * 		bytes = ((k - 1) / 32 + 1) * 4
 */
  __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_22));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_21));
  PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_521 = PyInt_FromLong(521); if (unlikely(!__pyx_int_521)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initpyrandom(void); /*proto*/
PyMODINIT_FUNC initpyrandom(void)
#else
PyMODINIT_FUNC PyInit_pyrandom(void); /*proto*/
PyMODINIT_FUNC PyInit_pyrandom(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_pyrandom(void)", __LINE__, __FILE__);
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __pyx_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("pyrandom"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_dcmt__pyrandom) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_4dcmt_8pyrandom_RandomContainer = &__pyx_vtable_4dcmt_8pyrandom_RandomContainer;
  __pyx_vtable_4dcmt_8pyrandom_RandomContainer.initWithStruct = (void (*)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *, mt_struct *))__pyx_f_4dcmt_8pyrandom_15RandomContainer_initWithStruct;
  __pyx_vtable_4dcmt_8pyrandom_RandomContainer.initWithParams = (void (*)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *, int, int, int, uint32_t))__pyx_f_4dcmt_8pyrandom_15RandomContainer_initWithParams;
  __pyx_vtable_4dcmt_8pyrandom_RandomContainer.seed = (PyObject *(*)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *, uint32_t))__pyx_f_4dcmt_8pyrandom_15RandomContainer_seed;
  __pyx_vtable_4dcmt_8pyrandom_RandomContainer.random = (PyObject *(*)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *))__pyx_f_4dcmt_8pyrandom_15RandomContainer_random;
  __pyx_vtable_4dcmt_8pyrandom_RandomContainer.random_raw = (PyObject *(*)(struct __pyx_obj_4dcmt_8pyrandom_RandomContainer *))__pyx_f_4dcmt_8pyrandom_15RandomContainer_random_raw;
  if (PyType_Ready(&__pyx_type_4dcmt_8pyrandom_RandomContainer) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4dcmt_8pyrandom_RandomContainer.tp_dict, __pyx_vtabptr_4dcmt_8pyrandom_RandomContainer) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RandomContainer", (PyObject *)&__pyx_type_4dcmt_8pyrandom_RandomContainer) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4dcmt_8pyrandom_RandomContainer = &__pyx_type_4dcmt_8pyrandom_RandomContainer;
  /*--- Type import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":45
 * 	double random_float(mt_struct *mt)
 * 
 * from os import urandom as _urandom             # <<<<<<<<<<<<<<
 * from binascii import hexlify as _hexlify
 * import time
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__urandom));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__urandom));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__urandom));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__os), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__urandom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___urandom, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":46
 * 
 * from os import urandom as _urandom
 * from binascii import hexlify as _hexlify             # <<<<<<<<<<<<<<
 * import time
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__hexlify));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__hexlify));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__hexlify));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__binascii), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__hexlify); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___hexlify, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/common.pxi":47
 * from os import urandom as _urandom
 * from binascii import hexlify as _hexlify
 * import time             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__time), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__time, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":3
 * include "common.pxi"
 * 
 * from random import Random             # <<<<<<<<<<<<<<
 * 
 * from dcmt.exceptions import DcmtError, DcmtParameterError
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Random));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Random));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Random));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__random), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__Random); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Random, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":5
 * from random import Random
 * 
 * from dcmt.exceptions import DcmtError, DcmtParameterError             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__DcmtError));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__DcmtError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DcmtError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__DcmtParameterError));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__DcmtParameterError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DcmtParameterError));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s_25), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DcmtError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DcmtError, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DcmtParameterError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DcmtParameterError, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":125
 * 
 * 
 * class DcmtRandom(Random):             # <<<<<<<<<<<<<<
 * 
 * 	def __init__(self, *args, wordlen=32, exponent=521, id=0, gen_seed=None):
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":127
 * class DcmtRandom(Random):
 * 
 * 	def __init__(self, *args, wordlen=32, exponent=521, id=0, gen_seed=None):             # <<<<<<<<<<<<<<
 * 		cdef int w, p, mid, sid
 * 		cdef uint32_t s = get_seed(gen_seed)
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_0__init__, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":139
 * 		self.seed(*args)
 * 
 * 	def seed(self, a=None):             # <<<<<<<<<<<<<<
 * 		cdef uint32_t seed = get_seed(a)
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_1seed, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__seed, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":144
 * 		rc.seed(seed)
 * 
 * 	def random(self):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.random()
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_2random, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__random, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":148
 * 		return rc.random()
 * 
 * 	def random_raw(self):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.random_raw()
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_3random_raw, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__random_raw, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":152
 * 		return rc.random_raw()
 * 
 * 	def getstate(self):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.getstate()
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_4getstate, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__getstate, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":156
 * 		return rc.getstate()
 * 
 * 	def setstate(self, state):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.setstate(state)
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_5setstate, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__setstate, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":160
 * 		rc.setstate(state)
 * 
 * 	def getrandbits(self, k):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		return rc.getrandbits(k)
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_6getrandbits, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__getrandbits, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":164
 * 		return rc.getrandbits(k)
 * 
 * 	def jumpahead(self, n):             # <<<<<<<<<<<<<<
 * 		cdef RandomContainer rc = <RandomContainer>self.rc
 * 		rc.jumpahead(n)
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_7jumpahead, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__jumpahead, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":169
 * 
 * 	@classmethod
 * 	def range(cls, *args, wordlen=32, exponent=521, gen_seed=None):             # <<<<<<<<<<<<<<
 * 
 * 		cdef int i, count
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4dcmt_8pyrandom_10DcmtRandom_8range, NULL, __pyx_n_s_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__range, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":168
 * 		rc.jumpahead(n)
 * 
 * 	@classmethod             # <<<<<<<<<<<<<<
 * 	def range(cls, *args, wordlen=32, exponent=521, gen_seed=None):
 * 
 */
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_n_s__range); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__range, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":125
 * 
 * 
 * class DcmtRandom(Random):             # <<<<<<<<<<<<<<
 * 
 * 	def __init__(self, *args, wordlen=32, exponent=521, id=0, gen_seed=None):
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__Random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__DcmtRandom, __pyx_n_s_26); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DcmtRandom, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/Users/bogdan/github/python-dcmt/src/wrapper/pyrandom.pyx":1
 * include "common.pxi"             # <<<<<<<<<<<<<<
 * 
 * from random import Random
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    __Pyx_AddTraceback("init dcmt.pyrandom");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init dcmt.pyrandom");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}


static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
                 "need more than %d value%s to unpack", (int)index,
        #else
                 "need more than %zd value%s to unpack", index,
        #endif
                 (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
            "too many values to unpack (expected %d)", (int)expected);
        #else
            "too many values to unpack (expected %zd)", expected);
        #endif
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            __Pyx_RaiseNeedMoreValuesError(index);
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}


static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
    PyObject *metaclass;
    /* Default metaclass */
#if PY_MAJOR_VERSION < 3
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, "__class__");
        if (!metaclass) {
            PyErr_Clear();
            metaclass = (PyObject*) Py_TYPE(base);
        }
    } else {
        metaclass = (PyObject *) &PyClass_Type;
    }
#else
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = (PyObject*) Py_TYPE(base);
    } else {
        metaclass = (PyObject *) &PyType_Type;
    }
#endif
    Py_INCREF(metaclass);
    return metaclass;
}

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname) {
    PyObject *result;
    PyObject *metaclass;

    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
        return NULL;

    /* Python2 __metaclass__ */
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
    if (metaclass) {
        Py_INCREF(metaclass);
    } else {
        metaclass = __Pyx_FindPy2Metaclass(bases);
    }
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
    Py_DECREF(metaclass);
    return result;
}


PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) {
	__pyx_binding_PyCFunctionType_object *op = PyObject_GC_New(__pyx_binding_PyCFunctionType_object, __pyx_binding_PyCFunctionType);
    if (op == NULL)
        return NULL;
	op->func.m_ml = ml;
	Py_XINCREF(self);
	op->func.m_self = self;
	Py_XINCREF(module);
	op->func.m_module = module;
	PyObject_GC_Track(op);
	return (PyObject *)op;
}

static void __pyx_binding_PyCFunctionType_dealloc(__pyx_binding_PyCFunctionType_object *m) {
	PyObject_GC_UnTrack(m);
	Py_XDECREF(m->func.m_self);
	Py_XDECREF(m->func.m_module);
    PyObject_GC_Del(m);
}

static PyObject *__pyx_binding_PyCFunctionType_descr_get(PyObject *func, PyObject *obj, PyObject *type) {
	if (obj == Py_None)
		obj = NULL;
	return PyMethod_New(func, obj, type);
}

int __pyx_binding_PyCFunctionType_init(void) {
    __pyx_binding_PyCFunctionType_type = PyCFunction_Type;
    __pyx_binding_PyCFunctionType_type.tp_name = __Pyx_NAMESTR("cython_binding_builtin_function_or_method");
    __pyx_binding_PyCFunctionType_type.tp_dealloc = (destructor)__pyx_binding_PyCFunctionType_dealloc;
    __pyx_binding_PyCFunctionType_type.tp_descr_get = __pyx_binding_PyCFunctionType_descr_get;
    if (PyType_Ready(&__pyx_binding_PyCFunctionType_type) < 0) {
        return -1;
    }
    __pyx_binding_PyCFunctionType = &__pyx_binding_PyCFunctionType_type;
    return 0;

}

static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
    /* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
    else if (PyMethod_Check(method)) { /* python classes */
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else if (PyCFunction_Check(method)) {
        return PyClassMethod_New(method);
    }
#ifdef __pyx_binding_PyCFunctionType_USED
    else if (PyObject_TypeCheck(method, __pyx_binding_PyCFunctionType)) { /* binded CFunction */
        return PyClassMethod_New(method);
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "Class-level classmethod() can only be called on "
                 "a method_descriptor or instance method.");
    return NULL;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }

    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#else /* Python 3+ */

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;

    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    PyErr_SetObject(type, value);

    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }

bad:
    return;
}
#endif

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(uint32_t) == sizeof(char))  ||
        (sizeof(uint32_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(uint32_t) == sizeof(int)) ||
               (sizeof(uint32_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(uint32_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject* x) {
    const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(uint32_t) == sizeof(char)) {
        if (is_unsigned)
            return (uint32_t)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (uint32_t)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(uint32_t) == sizeof(short)) {
        if (is_unsigned)
            return (uint32_t)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (uint32_t)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(uint32_t) == sizeof(int)) {
        if (is_unsigned)
            return (uint32_t)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (uint32_t)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(uint32_t) == sizeof(long)) {
        if (is_unsigned)
            return (uint32_t)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (uint32_t)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (uint32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (uint32_t)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        uint32_t val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        return (uint32_t)-1;
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
