/* Generated by Cython 0.14.1 on Mon Jan 16 15:59:39 2012 */

#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
#endif

#if PY_VERSION_HEX < 0x02060000
  #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

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#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__bzrlib___chk_map_pyx
#include "python-compat.h"
#include "_static_tuple_c.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[] = {
  "_chk_map_pyx.pyx",
  "_static_tuple_c.pxd",
};

/* Type declarations */

#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 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_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_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

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 PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

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 PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

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

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from bzrlib._static_tuple_c */

/* Module declarations from bzrlib._static_tuple_c */

static PyTypeObject *__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = 0;
/* Module declarations from bzrlib._chk_map_pyx */

static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx_crc32 = 0;
static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode = 0;
static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode = 0;
static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx__unknown = 0;
static void *__pyx_f_6bzrlib_12_chk_map_pyx__my_memrchr(void *, int, size_t); /*proto*/
static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx_safe_interned_string_from_size(char *, Py_ssize_t); /*proto*/
static int __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line(char **, char *, char *); /*proto*/
static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__import_globals(void); /*proto*/
#define __Pyx_MODULE_NAME "bzrlib._chk_map_pyx"
static int __pyx_module_is_main_bzrlib___chk_map_pyx = 0;

/* Implementation of bzrlib._chk_map_pyx */
static PyObject *__pyx_builtin_AssertionError;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_TypeError;
static char __pyx_k_1[] = "tried to create a string with an invalid size: %d @0x%x";
static char __pyx_k_2[] = "%08X";
static char __pyx_k_3[] = "Missing %s line\n";
static char __pyx_k_4[] = "%s line not a proper int\n";
static char __pyx_k_5[] = "bytes must be a plain string not %s";
static char __pyx_k_6[] = "chkleaf:\n";
static char __pyx_k_7[] = "not a serialised leaf node: %r";
static char __pyx_k_8[] = "bytes does not end in a newline";
static char __pyx_k_10[] = "Missing the prefix line\n";
static char __pyx_k_12[] = "Prefix has too many nulls versus width";
static char __pyx_k_14[] = "null line\n";
static char __pyx_k_16[] = "fail to find the num value lines null";
static char __pyx_k_18[] = "num value lines";
static char __pyx_k_19[] = "missing trailing newline";
static char __pyx_k_21[] = "bad no null, bad";
static char __pyx_k_23[] = "Too many bits for entry";
static char __pyx_k_25[] = "bad no null";
static char __pyx_k_27[] = "Incorrect number of elements (%d vs %d)";
static char __pyx_k_28[] = "item count (%d) mismatch for key %s, bytes %r";
static char __pyx_k_29[] = "_common_serialised_prefix";
static char __pyx_k_30[] = "_current_size computed incorrectly %d != %d";
static char __pyx_k_31[] = "key %r is not a StaticTuple";
static char __pyx_k_32[] = "chknode:\n";
static char __pyx_k_33[] = "not a serialised internal node: %r";
static char __pyx_k_38[] = "bytes must be a string, got %r";
static char __pyx_k_39[] = "No kind section found.";
static char __pyx_k_41[] = "Kind section should end with \": \", got %r";
static char __pyx_k_42[] = "no newline after file-id";
static char __pyx_k_44[] = "no newline after parent_str";
static char __pyx_k_46[] = "no newline after name str";
static char __pyx_k_48[] = "bzrlib._chk_map_pyx";
static char __pyx_k_49[] = "_deserialise_leaf_node";
static char __pyx_k_50[] = "_deserialise_internal_node";
static char __pyx_k__key[] = "key";
static char __pyx_k___key[] = "_key";
static char __pyx_k___len[] = "_len";
static char __pyx_k__zlib[] = "zlib";
static char __pyx_k__bytes[] = "bytes";
static char __pyx_k__crc32[] = "crc32";
static char __pyx_k__width[] = "width";
static char __pyx_k___items[] = "_items";
static char __pyx_k__append[] = "append";
static char __pyx_k__bzrlib[] = "bzrlib";
static char __pyx_k__intern[] = "intern";
static char __pyx_k__length[] = "length";
static char __pyx_k__chk_map[] = "chk_map";
static char __pyx_k__LeafNode[] = "LeafNode";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k___unknown[] = "_unknown";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k___raw_size[] = "_raw_size";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k___key_width[] = "_key_width";
static char __pyx_k___node_width[] = "_node_width";
static char __pyx_k__InternalNode[] = "InternalNode";
static char __pyx_k__maximum_size[] = "maximum_size";
static char __pyx_k___current_size[] = "_current_size";
static char __pyx_k___maximum_size[] = "_maximum_size";
static char __pyx_k__AssertionError[] = "AssertionError";
static char __pyx_k___search_key_16[] = "_search_key_16";
static char __pyx_k___search_prefix[] = "_search_prefix";
static char __pyx_k___search_key_255[] = "_search_key_255";
static char __pyx_k__search_key_func[] = "search_key_func";
static char __pyx_k___bytes_to_text_key[] = "_bytes_to_text_key";
static PyObject *__pyx_kp_s_1;
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_19;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_kp_s_25;
static PyObject *__pyx_kp_s_27;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_n_s_29;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_30;
static PyObject *__pyx_kp_s_31;
static PyObject *__pyx_kp_s_33;
static PyObject *__pyx_kp_s_38;
static PyObject *__pyx_kp_s_39;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_41;
static PyObject *__pyx_kp_s_42;
static PyObject *__pyx_kp_s_44;
static PyObject *__pyx_kp_s_46;
static PyObject *__pyx_n_s_48;
static PyObject *__pyx_n_s_49;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_n_s_50;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_n_s__AssertionError;
static PyObject *__pyx_n_s__InternalNode;
static PyObject *__pyx_n_s__LeafNode;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___bytes_to_text_key;
static PyObject *__pyx_n_s___current_size;
static PyObject *__pyx_n_s___items;
static PyObject *__pyx_n_s___key;
static PyObject *__pyx_n_s___key_width;
static PyObject *__pyx_n_s___len;
static PyObject *__pyx_n_s___maximum_size;
static PyObject *__pyx_n_s___node_width;
static PyObject *__pyx_n_s___raw_size;
static PyObject *__pyx_n_s___search_key_16;
static PyObject *__pyx_n_s___search_key_255;
static PyObject *__pyx_n_s___search_prefix;
static PyObject *__pyx_n_s___unknown;
static PyObject *__pyx_n_s__append;
static PyObject *__pyx_n_s__bytes;
static PyObject *__pyx_n_s__bzrlib;
static PyObject *__pyx_n_s__chk_map;
static PyObject *__pyx_n_s__crc32;
static PyObject *__pyx_n_s__intern;
static PyObject *__pyx_n_s__key;
static PyObject *__pyx_n_s__search_key_func;
static PyObject *__pyx_n_s__zlib;
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_20;
static PyObject *__pyx_k_tuple_22;
static PyObject *__pyx_k_tuple_24;
static PyObject *__pyx_k_tuple_26;
static PyObject *__pyx_k_tuple_34;
static PyObject *__pyx_k_tuple_35;
static PyObject *__pyx_k_tuple_36;
static PyObject *__pyx_k_tuple_37;
static PyObject *__pyx_k_tuple_40;
static PyObject *__pyx_k_tuple_43;
static PyObject *__pyx_k_tuple_45;
static PyObject *__pyx_k_tuple_47;

/* "bzrlib/_chk_map_pyx.pyx":71
 * 
 * # We shouldn't just copy this from _dirstate_helpers_pyx
 * cdef void* _my_memrchr(void *s, int c, size_t n): # cannot_raise             # <<<<<<<<<<<<<<
 *     # memrchr seems to be a GNU extension, so we have to implement it ourselves
 *     cdef char *pos
 */

static  void *__pyx_f_6bzrlib_12_chk_map_pyx__my_memrchr(void *__pyx_v_s, int __pyx_v_c, size_t __pyx_v_n) {
  char *__pyx_v_pos;
  char *__pyx_v_start;
  void *__pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_my_memrchr");

  /* "bzrlib/_chk_map_pyx.pyx":76
 *     cdef char *start
 * 
 *     start = <char*>s             # <<<<<<<<<<<<<<
 *     pos = start + n - 1
 *     while pos >= start:
 */
  __pyx_v_start = ((char *)__pyx_v_s);

  /* "bzrlib/_chk_map_pyx.pyx":77
 * 
 *     start = <char*>s
 *     pos = start + n - 1             # <<<<<<<<<<<<<<
 *     while pos >= start:
 *         if pos[0] == c:
 */
  __pyx_v_pos = ((__pyx_v_start + __pyx_v_n) - 1);

  /* "bzrlib/_chk_map_pyx.pyx":78
 *     start = <char*>s
 *     pos = start + n - 1
 *     while pos >= start:             # <<<<<<<<<<<<<<
 *         if pos[0] == c:
 *             return <void*>pos
 */
  while (1) {
    __pyx_t_1 = (__pyx_v_pos >= __pyx_v_start);
    if (!__pyx_t_1) break;

    /* "bzrlib/_chk_map_pyx.pyx":79
 *     pos = start + n - 1
 *     while pos >= start:
 *         if pos[0] == c:             # <<<<<<<<<<<<<<
 *             return <void*>pos
 *         pos = pos - 1
 */
    __pyx_t_1 = ((__pyx_v_pos[0]) == __pyx_v_c);
    if (__pyx_t_1) {

      /* "bzrlib/_chk_map_pyx.pyx":80
 *     while pos >= start:
 *         if pos[0] == c:
 *             return <void*>pos             # <<<<<<<<<<<<<<
 *         pos = pos - 1
 *     return NULL
 */
      __pyx_r = ((void *)__pyx_v_pos);
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "bzrlib/_chk_map_pyx.pyx":81
 *         if pos[0] == c:
 *             return <void*>pos
 *         pos = pos - 1             # <<<<<<<<<<<<<<
 *     return NULL
 * 
 */
    __pyx_v_pos = (__pyx_v_pos - 1);
  }

  /* "bzrlib/_chk_map_pyx.pyx":82
 *             return <void*>pos
 *         pos = pos - 1
 *     return NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = NULL;
  goto __pyx_L0;

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

/* "bzrlib/_chk_map_pyx.pyx":85
 * 
 * 
 * cdef object safe_interned_string_from_size(char *s, Py_ssize_t size):             # <<<<<<<<<<<<<<
 *     cdef PyObject *py_str
 *     if size < 0:
 */

static  PyObject *__pyx_f_6bzrlib_12_chk_map_pyx_safe_interned_string_from_size(char *__pyx_v_s, Py_ssize_t __pyx_v_size) {
  PyObject *__pyx_v_py_str;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("safe_interned_string_from_size");
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);

  /* "bzrlib/_chk_map_pyx.pyx":87
 * cdef object safe_interned_string_from_size(char *s, Py_ssize_t size):
 *     cdef PyObject *py_str
 *     if size < 0:             # <<<<<<<<<<<<<<
 *         raise AssertionError(
 *             'tried to create a string with an invalid size: %d @0x%x'
 */
  __pyx_t_1 = (__pyx_v_size < 0);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":90
 *         raise AssertionError(
 *             'tried to create a string with an invalid size: %d @0x%x'
 *             % (size, <int>s))             # <<<<<<<<<<<<<<
 *     py_str = PyString_FromStringAndSize_ptr(s, size)
 *     PyString_InternInPlace(&py_str)
 */
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromLong(((int)__pyx_v_s)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_4), NULL); 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_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "bzrlib/_chk_map_pyx.pyx":91
 *             'tried to create a string with an invalid size: %d @0x%x'
 *             % (size, <int>s))
 *     py_str = PyString_FromStringAndSize_ptr(s, size)             # <<<<<<<<<<<<<<
 *     PyString_InternInPlace(&py_str)
 *     result = <object>py_str
 */
  __pyx_v_py_str = PyString_FromStringAndSize(__pyx_v_s, __pyx_v_size);

  /* "bzrlib/_chk_map_pyx.pyx":92
 *             % (size, <int>s))
 *     py_str = PyString_FromStringAndSize_ptr(s, size)
 *     PyString_InternInPlace(&py_str)             # <<<<<<<<<<<<<<
 *     result = <object>py_str
 *     # Casting a PyObject* to an <object> triggers an INCREF from Pyrex, so we
 */
  PyString_InternInPlace((&__pyx_v_py_str));

  /* "bzrlib/_chk_map_pyx.pyx":93
 *     py_str = PyString_FromStringAndSize_ptr(s, size)
 *     PyString_InternInPlace(&py_str)
 *     result = <object>py_str             # <<<<<<<<<<<<<<
 *     # Casting a PyObject* to an <object> triggers an INCREF from Pyrex, so we
 *     # DECREF it to avoid geting immortal strings
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_py_str));
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_v_py_str);

  /* "bzrlib/_chk_map_pyx.pyx":96
 *     # Casting a PyObject* to an <object> triggers an INCREF from Pyrex, so we
 *     # DECREF it to avoid geting immortal strings
 *     Py_DECREF_ptr(py_str)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  Py_DECREF(__pyx_v_py_str);

  /* "bzrlib/_chk_map_pyx.pyx":97
 *     # DECREF it to avoid geting immortal strings
 *     Py_DECREF_ptr(py_str)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx.safe_interned_string_from_size");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "bzrlib/_chk_map_pyx.pyx":100
 * 
 * 
 * def _search_key_16(key):             # <<<<<<<<<<<<<<
 *     """See chk_map._search_key_16."""
 *     cdef Py_ssize_t num_bits
 */

static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx__search_key_16(PyObject *__pyx_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx__search_key_16[] = "See chk_map._search_key_16.";
static PyMethodDef __pyx_mdef_6bzrlib_12_chk_map_pyx__search_key_16 = {__Pyx_NAMESTR("_search_key_16"), (PyCFunction)__pyx_pf_6bzrlib_12_chk_map_pyx__search_key_16, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_12_chk_map_pyx__search_key_16)};
static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx__search_key_16(PyObject *__pyx_self, PyObject *__pyx_v_key) {
  Py_ssize_t __pyx_v_num_bits;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_num_out_bytes;
  unsigned long __pyx_v_crc_val;
  char *__pyx_v_c_out;
  PyObject *__pyx_v_out;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_search_key_16");
  __pyx_self = __pyx_self;
  __pyx_v_out = Py_None; __Pyx_INCREF(Py_None);

  /* "bzrlib/_chk_map_pyx.pyx":109
 *     cdef char *c_out
 * 
 *     num_bits = len(key)             # <<<<<<<<<<<<<<
 *     # 4 bytes per crc32, and another 1 byte between bits
 *     num_out_bytes = (9 * num_bits) - 1
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_num_bits = __pyx_t_1;

  /* "bzrlib/_chk_map_pyx.pyx":111
 *     num_bits = len(key)
 *     # 4 bytes per crc32, and another 1 byte between bits
 *     num_out_bytes = (9 * num_bits) - 1             # <<<<<<<<<<<<<<
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)
 *     c_out = PyString_AS_STRING(out)
 */
  __pyx_v_num_out_bytes = ((9 * __pyx_v_num_bits) - 1);

  /* "bzrlib/_chk_map_pyx.pyx":112
 *     # 4 bytes per crc32, and another 1 byte between bits
 *     num_out_bytes = (9 * num_bits) - 1
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)             # <<<<<<<<<<<<<<
 *     c_out = PyString_AS_STRING(out)
 *     for i from 0 <= i < num_bits:
 */
  __pyx_t_2 = PyString_FromStringAndSize(NULL, __pyx_v_num_out_bytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_v_out);
  __pyx_v_out = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":113
 *     num_out_bytes = (9 * num_bits) - 1
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)
 *     c_out = PyString_AS_STRING(out)             # <<<<<<<<<<<<<<
 *     for i from 0 <= i < num_bits:
 *         if i > 0:
 */
  __pyx_v_c_out = PyString_AS_STRING(__pyx_v_out);

  /* "bzrlib/_chk_map_pyx.pyx":114
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)
 *     c_out = PyString_AS_STRING(out)
 *     for i from 0 <= i < num_bits:             # <<<<<<<<<<<<<<
 *         if i > 0:
 *             c_out[0] = c'\x00'
 */
  __pyx_t_1 = __pyx_v_num_bits;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "bzrlib/_chk_map_pyx.pyx":115
 *     c_out = PyString_AS_STRING(out)
 *     for i from 0 <= i < num_bits:
 *         if i > 0:             # <<<<<<<<<<<<<<
 *             c_out[0] = c'\x00'
 *             c_out = c_out + 1
 */
    __pyx_t_3 = (__pyx_v_i > 0);
    if (__pyx_t_3) {

      /* "bzrlib/_chk_map_pyx.pyx":116
 *     for i from 0 <= i < num_bits:
 *         if i > 0:
 *             c_out[0] = c'\x00'             # <<<<<<<<<<<<<<
 *             c_out = c_out + 1
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))
 */
      (__pyx_v_c_out[0]) = '\x00';

      /* "bzrlib/_chk_map_pyx.pyx":117
 *         if i > 0:
 *             c_out[0] = c'\x00'
 *             c_out = c_out + 1             # <<<<<<<<<<<<<<
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))
 *         # Hex(val) order
 */
      __pyx_v_c_out = (__pyx_v_c_out + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "bzrlib/_chk_map_pyx.pyx":118
 *             c_out[0] = c'\x00'
 *             c_out = c_out + 1
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))             # <<<<<<<<<<<<<<
 *         # Hex(val) order
 *         sprintf(c_out, '%08X', crc_val)
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_key, __pyx_v_i, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_v_6bzrlib_12_chk_map_pyx_crc32, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_v_crc_val = PyInt_AS_LONG(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":120
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))
 *         # Hex(val) order
 *         sprintf(c_out, '%08X', crc_val)             # <<<<<<<<<<<<<<
 *         c_out = c_out + 8
 *     return out
 */
    sprintf(__pyx_v_c_out, __pyx_k_2, __pyx_v_crc_val);

    /* "bzrlib/_chk_map_pyx.pyx":121
 *         # Hex(val) order
 *         sprintf(c_out, '%08X', crc_val)
 *         c_out = c_out + 8             # <<<<<<<<<<<<<<
 *     return out
 * 
 */
    __pyx_v_c_out = (__pyx_v_c_out + 8);
  }

  /* "bzrlib/_chk_map_pyx.pyx":122
 *         sprintf(c_out, '%08X', crc_val)
 *         c_out = c_out + 8
 *     return out             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._search_key_16");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "bzrlib/_chk_map_pyx.pyx":125
 * 
 * 
 * def _search_key_255(key):             # <<<<<<<<<<<<<<
 *     """See chk_map._search_key_255."""
 *     cdef Py_ssize_t num_bits
 */

static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_1_search_key_255(PyObject *__pyx_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx_1_search_key_255[] = "See chk_map._search_key_255.";
static PyMethodDef __pyx_mdef_6bzrlib_12_chk_map_pyx_1_search_key_255 = {__Pyx_NAMESTR("_search_key_255"), (PyCFunction)__pyx_pf_6bzrlib_12_chk_map_pyx_1_search_key_255, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_12_chk_map_pyx_1_search_key_255)};
static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_1_search_key_255(PyObject *__pyx_self, PyObject *__pyx_v_key) {
  Py_ssize_t __pyx_v_num_bits;
  Py_ssize_t __pyx_v_i;
  Py_ssize_t __pyx_v_j;
  Py_ssize_t __pyx_v_num_out_bytes;
  unsigned long __pyx_v_crc_val;
  char *__pyx_v_c_out;
  PyObject *__pyx_v_out;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_search_key_255");
  __pyx_self = __pyx_self;
  __pyx_v_out = Py_None; __Pyx_INCREF(Py_None);

  /* "bzrlib/_chk_map_pyx.pyx":134
 *     cdef char *c_out
 * 
 *     num_bits = len(key)             # <<<<<<<<<<<<<<
 *     # 4 bytes per crc32, and another 1 byte between bits
 *     num_out_bytes = (5 * num_bits) - 1
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_num_bits = __pyx_t_1;

  /* "bzrlib/_chk_map_pyx.pyx":136
 *     num_bits = len(key)
 *     # 4 bytes per crc32, and another 1 byte between bits
 *     num_out_bytes = (5 * num_bits) - 1             # <<<<<<<<<<<<<<
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)
 *     c_out = PyString_AS_STRING(out)
 */
  __pyx_v_num_out_bytes = ((5 * __pyx_v_num_bits) - 1);

  /* "bzrlib/_chk_map_pyx.pyx":137
 *     # 4 bytes per crc32, and another 1 byte between bits
 *     num_out_bytes = (5 * num_bits) - 1
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)             # <<<<<<<<<<<<<<
 *     c_out = PyString_AS_STRING(out)
 *     for i from 0 <= i < num_bits:
 */
  __pyx_t_2 = PyString_FromStringAndSize(NULL, __pyx_v_num_out_bytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_v_out);
  __pyx_v_out = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":138
 *     num_out_bytes = (5 * num_bits) - 1
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)
 *     c_out = PyString_AS_STRING(out)             # <<<<<<<<<<<<<<
 *     for i from 0 <= i < num_bits:
 *         if i > 0:
 */
  __pyx_v_c_out = PyString_AS_STRING(__pyx_v_out);

  /* "bzrlib/_chk_map_pyx.pyx":139
 *     out = PyString_FromStringAndSize(NULL, num_out_bytes)
 *     c_out = PyString_AS_STRING(out)
 *     for i from 0 <= i < num_bits:             # <<<<<<<<<<<<<<
 *         if i > 0:
 *             c_out[0] = c'\x00'
 */
  __pyx_t_1 = __pyx_v_num_bits;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "bzrlib/_chk_map_pyx.pyx":140
 *     c_out = PyString_AS_STRING(out)
 *     for i from 0 <= i < num_bits:
 *         if i > 0:             # <<<<<<<<<<<<<<
 *             c_out[0] = c'\x00'
 *             c_out = c_out + 1
 */
    __pyx_t_3 = (__pyx_v_i > 0);
    if (__pyx_t_3) {

      /* "bzrlib/_chk_map_pyx.pyx":141
 *     for i from 0 <= i < num_bits:
 *         if i > 0:
 *             c_out[0] = c'\x00'             # <<<<<<<<<<<<<<
 *             c_out = c_out + 1
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))
 */
      (__pyx_v_c_out[0]) = '\x00';

      /* "bzrlib/_chk_map_pyx.pyx":142
 *         if i > 0:
 *             c_out[0] = c'\x00'
 *             c_out = c_out + 1             # <<<<<<<<<<<<<<
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))
 *         # MSB order
 */
      __pyx_v_c_out = (__pyx_v_c_out + 1);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "bzrlib/_chk_map_pyx.pyx":143
 *             c_out[0] = c'\x00'
 *             c_out = c_out + 1
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))             # <<<<<<<<<<<<<<
 *         # MSB order
 *         c_out[0] = (crc_val >> 24) & 0xFF
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_key, __pyx_v_i, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_v_6bzrlib_12_chk_map_pyx_crc32, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_v_crc_val = PyInt_AS_LONG(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":145
 *         crc_val = PyInt_AS_LONG(crc32(key[i]))
 *         # MSB order
 *         c_out[0] = (crc_val >> 24) & 0xFF             # <<<<<<<<<<<<<<
 *         c_out[1] = (crc_val >> 16) & 0xFF
 *         c_out[2] = (crc_val >> 8) & 0xFF
 */
    (__pyx_v_c_out[0]) = ((__pyx_v_crc_val >> 24) & 0xFF);

    /* "bzrlib/_chk_map_pyx.pyx":146
 *         # MSB order
 *         c_out[0] = (crc_val >> 24) & 0xFF
 *         c_out[1] = (crc_val >> 16) & 0xFF             # <<<<<<<<<<<<<<
 *         c_out[2] = (crc_val >> 8) & 0xFF
 *         c_out[3] = (crc_val >> 0) & 0xFF
 */
    (__pyx_v_c_out[1]) = ((__pyx_v_crc_val >> 16) & 0xFF);

    /* "bzrlib/_chk_map_pyx.pyx":147
 *         c_out[0] = (crc_val >> 24) & 0xFF
 *         c_out[1] = (crc_val >> 16) & 0xFF
 *         c_out[2] = (crc_val >> 8) & 0xFF             # <<<<<<<<<<<<<<
 *         c_out[3] = (crc_val >> 0) & 0xFF
 *         for j from 0 <= j < 4:
 */
    (__pyx_v_c_out[2]) = ((__pyx_v_crc_val >> 8) & 0xFF);

    /* "bzrlib/_chk_map_pyx.pyx":148
 *         c_out[1] = (crc_val >> 16) & 0xFF
 *         c_out[2] = (crc_val >> 8) & 0xFF
 *         c_out[3] = (crc_val >> 0) & 0xFF             # <<<<<<<<<<<<<<
 *         for j from 0 <= j < 4:
 *             if c_out[j] == c'\n':
 */
    (__pyx_v_c_out[3]) = ((__pyx_v_crc_val >> 0) & 0xFF);

    /* "bzrlib/_chk_map_pyx.pyx":149
 *         c_out[2] = (crc_val >> 8) & 0xFF
 *         c_out[3] = (crc_val >> 0) & 0xFF
 *         for j from 0 <= j < 4:             # <<<<<<<<<<<<<<
 *             if c_out[j] == c'\n':
 *                 c_out[j] = c'_'
 */
    for (__pyx_v_j = 0; __pyx_v_j < 4; __pyx_v_j++) {

      /* "bzrlib/_chk_map_pyx.pyx":150
 *         c_out[3] = (crc_val >> 0) & 0xFF
 *         for j from 0 <= j < 4:
 *             if c_out[j] == c'\n':             # <<<<<<<<<<<<<<
 *                 c_out[j] = c'_'
 *         c_out = c_out + 4
 */
      __pyx_t_3 = ((__pyx_v_c_out[__pyx_v_j]) == '\n');
      if (__pyx_t_3) {

        /* "bzrlib/_chk_map_pyx.pyx":151
 *         for j from 0 <= j < 4:
 *             if c_out[j] == c'\n':
 *                 c_out[j] = c'_'             # <<<<<<<<<<<<<<
 *         c_out = c_out + 4
 *     return out
 */
        (__pyx_v_c_out[__pyx_v_j]) = '_';
        goto __pyx_L10;
      }
      __pyx_L10:;
    }

    /* "bzrlib/_chk_map_pyx.pyx":152
 *             if c_out[j] == c'\n':
 *                 c_out[j] = c'_'
 *         c_out = c_out + 4             # <<<<<<<<<<<<<<
 *     return out
 * 
 */
    __pyx_v_c_out = (__pyx_v_c_out + 4);
  }

  /* "bzrlib/_chk_map_pyx.pyx":153
 *                 c_out[j] = c'_'
 *         c_out = c_out + 4
 *     return out             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._search_key_255");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_out);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "bzrlib/_chk_map_pyx.pyx":156
 * 
 * 
 * cdef int _get_int_from_line(char **cur, char *end, char *message) except -1:             # <<<<<<<<<<<<<<
 *     """Read a positive integer from the data stream.
 * 
 */

static  int __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line(char **__pyx_v_cur, char *__pyx_v_end, char *__pyx_v_message) {
  int __pyx_v_value;
  char *__pyx_v_next_line;
  char *__pyx_v_next;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_get_int_from_line");

  /* "bzrlib/_chk_map_pyx.pyx":167
 *     cdef char *next_line, *next
 * 
 *     next_line = <char *>memchr(cur[0], c'\n', end - cur[0])             # <<<<<<<<<<<<<<
 *     if next_line == NULL:
 *         raise ValueError("Missing %s line\n" % message)
 */
  __pyx_v_next_line = ((char *)memchr((__pyx_v_cur[0]), '\n', (__pyx_v_end - (__pyx_v_cur[0]))));

  /* "bzrlib/_chk_map_pyx.pyx":168
 * 
 *     next_line = <char *>memchr(cur[0], c'\n', end - cur[0])
 *     if next_line == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError("Missing %s line\n" % message)
 * 
 */
  __pyx_t_1 = (__pyx_v_next_line == NULL);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":169
 *     next_line = <char *>memchr(cur[0], c'\n', end - cur[0])
 *     if next_line == NULL:
 *         raise ValueError("Missing %s line\n" % message)             # <<<<<<<<<<<<<<
 * 
 *     value = strtol(cur[0], &next, 10)
 */
    __pyx_t_2 = PyBytes_FromString(__pyx_v_message); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "bzrlib/_chk_map_pyx.pyx":171
 *         raise ValueError("Missing %s line\n" % message)
 * 
 *     value = strtol(cur[0], &next, 10)             # <<<<<<<<<<<<<<
 *     if next != next_line:
 *         raise ValueError("%s line not a proper int\n" % message)
 */
  __pyx_v_value = strtol((__pyx_v_cur[0]), (&__pyx_v_next), 10);

  /* "bzrlib/_chk_map_pyx.pyx":172
 * 
 *     value = strtol(cur[0], &next, 10)
 *     if next != next_line:             # <<<<<<<<<<<<<<
 *         raise ValueError("%s line not a proper int\n" % message)
 *     cur[0] = next_line + 1
 */
  __pyx_t_1 = (__pyx_v_next != __pyx_v_next_line);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":173
 *     value = strtol(cur[0], &next, 10)
 *     if next != next_line:
 *         raise ValueError("%s line not a proper int\n" % message)             # <<<<<<<<<<<<<<
 *     cur[0] = next_line + 1
 *     return value
 */
    __pyx_t_3 = PyBytes_FromString(__pyx_v_message); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__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 = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__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 = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "bzrlib/_chk_map_pyx.pyx":174
 *     if next != next_line:
 *         raise ValueError("%s line not a proper int\n" % message)
 *     cur[0] = next_line + 1             # <<<<<<<<<<<<<<
 *     return value
 * 
 */
  (__pyx_v_cur[0]) = (__pyx_v_next_line + 1);

  /* "bzrlib/_chk_map_pyx.pyx":175
 *         raise ValueError("%s line not a proper int\n" % message)
 *     cur[0] = next_line + 1
 *     return value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._get_int_from_line");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "bzrlib/_chk_map_pyx.pyx":178
 * 
 * 
 * cdef _import_globals():             # <<<<<<<<<<<<<<
 *     """Set the global attributes. Done lazy to avoid recursive import loops."""
 *     global _LeafNode, _InternalNode, _unknown
 */

static  PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__import_globals(void) {
  PyObject *__pyx_v_chk_map;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_import_globals");
  __pyx_v_chk_map = Py_None; __Pyx_INCREF(Py_None);

  /* "bzrlib/_chk_map_pyx.pyx":182
 *     global _LeafNode, _InternalNode, _unknown
 * 
 *     from bzrlib import chk_map             # <<<<<<<<<<<<<<
 *     _LeafNode = chk_map.LeafNode
 *     _InternalNode = chk_map.InternalNode
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__chk_map));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__chk_map));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__chk_map));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__bzrlib), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __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__chk_map); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_chk_map);
  __pyx_v_chk_map = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":183
 * 
 *     from bzrlib import chk_map
 *     _LeafNode = chk_map.LeafNode             # <<<<<<<<<<<<<<
 *     _InternalNode = chk_map.InternalNode
 *     _unknown = chk_map._unknown
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chk_map, __pyx_n_s__LeafNode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode);
  __Pyx_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_v_6bzrlib_12_chk_map_pyx__LeafNode = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":184
 *     from bzrlib import chk_map
 *     _LeafNode = chk_map.LeafNode
 *     _InternalNode = chk_map.InternalNode             # <<<<<<<<<<<<<<
 *     _unknown = chk_map._unknown
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chk_map, __pyx_n_s__InternalNode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode);
  __Pyx_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_v_6bzrlib_12_chk_map_pyx__InternalNode = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":185
 *     _LeafNode = chk_map.LeafNode
 *     _InternalNode = chk_map.InternalNode
 *     _unknown = chk_map._unknown             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_chk_map, __pyx_n_s___unknown); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_6bzrlib_12_chk_map_pyx__unknown);
  __Pyx_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__unknown);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_v_6bzrlib_12_chk_map_pyx__unknown = __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_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._import_globals");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_chk_map);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "bzrlib/_chk_map_pyx.pyx":188
 * 
 * 
 * def _deserialise_leaf_node(bytes, key, search_key_func=None):             # <<<<<<<<<<<<<<
 *     """Deserialise bytes, with key key, into a LeafNode.
 * 
 */

static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_2_deserialise_leaf_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx_2_deserialise_leaf_node[] = "Deserialise bytes, with key key, into a LeafNode.\n\n    :param bytes: The bytes of the node.\n    :param key: The key that the serialised node has.\n    ";
static PyMethodDef __pyx_mdef_6bzrlib_12_chk_map_pyx_2_deserialise_leaf_node = {__Pyx_NAMESTR("_deserialise_leaf_node"), (PyCFunction)__pyx_pf_6bzrlib_12_chk_map_pyx_2_deserialise_leaf_node, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6bzrlib_12_chk_map_pyx_2_deserialise_leaf_node)};
static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_2_deserialise_leaf_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bytes = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_search_key_func = 0;
  char *__pyx_v_c_bytes;
  char *__pyx_v_cur;
  char *__pyx_v_end;
  char *__pyx_v_next_line;
  Py_ssize_t __pyx_v_c_bytes_len;
  Py_ssize_t __pyx_v_prefix_length;
  Py_ssize_t __pyx_v_items_length;
  int __pyx_v_maximum_size;
  int __pyx_v_width;
  int __pyx_v_length;
  int __pyx_v_i;
  int __pyx_v_prefix_tail_len;
  int __pyx_v_num_value_lines;
  int __pyx_v_num_prefix_bits;
  char *__pyx_v_prefix;
  char *__pyx_v_value_start;
  char *__pyx_v_prefix_tail;
  char *__pyx_v_next_null;
  char *__pyx_v_last_null;
  char *__pyx_v_line_start;
  char *__pyx_v_c_entry;
  char *__pyx_v_entry_start;
  StaticTuple *__pyx_v_entry_bits;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_prefix_bits;
  PyObject *__pyx_v_items;
  PyObject *__pyx_v_entry;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r = NULL;
  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;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bytes,&__pyx_n_s__key,&__pyx_n_s__search_key_func,0};
  __Pyx_RefNannySetupContext("_deserialise_leaf_node");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      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__bytes);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("_deserialise_leaf_node", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__search_key_func);
        if (value) { values[2] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_deserialise_leaf_node") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_bytes = values[0];
    __pyx_v_key = values[1];
    __pyx_v_search_key_func = values[2];
  } else {
    __pyx_v_search_key_func = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_search_key_func = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_bytes = 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("_deserialise_leaf_node", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._deserialise_leaf_node");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_entry_bits = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_prefix_bits = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_items = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_entry = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);

  /* "bzrlib/_chk_map_pyx.pyx":204
 *     cdef StaticTuple entry_bits
 * 
 *     if _LeafNode is None:             # <<<<<<<<<<<<<<
 *         _import_globals()
 * 
 */
  __pyx_t_1 = (__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode == Py_None);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":205
 * 
 *     if _LeafNode is None:
 *         _import_globals()             # <<<<<<<<<<<<<<
 * 
 *     result = _LeafNode(search_key_func=search_key_func)
 */
    __pyx_t_2 = __pyx_f_6bzrlib_12_chk_map_pyx__import_globals(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "bzrlib/_chk_map_pyx.pyx":207
 *         _import_globals()
 * 
 *     result = _LeafNode(search_key_func=search_key_func)             # <<<<<<<<<<<<<<
 *     # Splitlines can split on '\r' so don't use it, split('\n') adds an
 *     # extra '' if the bytes ends in a final newline.
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__search_key_func), __pyx_v_search_key_func) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":210
 *     # Splitlines can split on '\r' so don't use it, split('\n') adds an
 *     # extra '' if the bytes ends in a final newline.
 *     if not PyString_CheckExact(bytes):             # <<<<<<<<<<<<<<
 *         raise TypeError('bytes must be a plain string not %s' % (type(bytes),))
 * 
 */
  __pyx_t_1 = (!PyString_CheckExact(__pyx_v_bytes));
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":211
 *     # extra '' if the bytes ends in a final newline.
 *     if not PyString_CheckExact(bytes):
 *         raise TypeError('bytes must be a plain string not %s' % (type(bytes),))             # <<<<<<<<<<<<<<
 * 
 *     c_bytes = PyString_AS_STRING(bytes)
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_bytes)));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(__pyx_v_bytes)));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_bytes)));
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__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 = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__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 = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "bzrlib/_chk_map_pyx.pyx":213
 *         raise TypeError('bytes must be a plain string not %s' % (type(bytes),))
 * 
 *     c_bytes = PyString_AS_STRING(bytes)             # <<<<<<<<<<<<<<
 *     c_bytes_len = PyString_GET_SIZE(bytes)
 * 
 */
  __pyx_v_c_bytes = PyString_AS_STRING(__pyx_v_bytes);

  /* "bzrlib/_chk_map_pyx.pyx":214
 * 
 *     c_bytes = PyString_AS_STRING(bytes)
 *     c_bytes_len = PyString_GET_SIZE(bytes)             # <<<<<<<<<<<<<<
 * 
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chkleaf:\n", 9) != 0:
 */
  __pyx_v_c_bytes_len = PyString_GET_SIZE(__pyx_v_bytes);

  /* "bzrlib/_chk_map_pyx.pyx":216
 *     c_bytes_len = PyString_GET_SIZE(bytes)
 * 
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chkleaf:\n", 9) != 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("not a serialised leaf node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 */
  __pyx_t_1 = (__pyx_v_c_bytes_len < 9);
  if (!__pyx_t_1) {
    __pyx_t_4 = (memcmp(__pyx_v_c_bytes, __pyx_k_6, 9) != 0);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_1;
  }
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":217
 * 
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chkleaf:\n", 9) != 0:
 *         raise ValueError("not a serialised leaf node: %r" % bytes)             # <<<<<<<<<<<<<<
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 *         raise ValueError("bytes does not end in a newline")
 */
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_v_bytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__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 = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "bzrlib/_chk_map_pyx.pyx":218
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chkleaf:\n", 9) != 0:
 *         raise ValueError("not a serialised leaf node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':             # <<<<<<<<<<<<<<
 *         raise ValueError("bytes does not end in a newline")
 * 
 */
  __pyx_t_5 = ((__pyx_v_c_bytes[(__pyx_v_c_bytes_len - 1)]) != '\n');
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":219
 *         raise ValueError("not a serialised leaf node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 *         raise ValueError("bytes does not end in a newline")             # <<<<<<<<<<<<<<
 * 
 *     end = c_bytes + c_bytes_len
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "bzrlib/_chk_map_pyx.pyx":221
 *         raise ValueError("bytes does not end in a newline")
 * 
 *     end = c_bytes + c_bytes_len             # <<<<<<<<<<<<<<
 *     cur = c_bytes + 9
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 */
  __pyx_v_end = (__pyx_v_c_bytes + __pyx_v_c_bytes_len);

  /* "bzrlib/_chk_map_pyx.pyx":222
 * 
 *     end = c_bytes + c_bytes_len
 *     cur = c_bytes + 9             # <<<<<<<<<<<<<<
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 *     width = _get_int_from_line(&cur, end, "width")
 */
  __pyx_v_cur = (__pyx_v_c_bytes + 9);

  /* "bzrlib/_chk_map_pyx.pyx":223
 *     end = c_bytes + c_bytes_len
 *     cur = c_bytes + 9
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")             # <<<<<<<<<<<<<<
 *     width = _get_int_from_line(&cur, end, "width")
 *     length = _get_int_from_line(&cur, end, "length")
 */
  __pyx_t_6 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur), __pyx_v_end, __pyx_k__maximum_size); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_maximum_size = __pyx_t_6;

  /* "bzrlib/_chk_map_pyx.pyx":224
 *     cur = c_bytes + 9
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 *     width = _get_int_from_line(&cur, end, "width")             # <<<<<<<<<<<<<<
 *     length = _get_int_from_line(&cur, end, "length")
 * 
 */
  __pyx_t_6 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur), __pyx_v_end, __pyx_k__width); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_width = __pyx_t_6;

  /* "bzrlib/_chk_map_pyx.pyx":225
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 *     width = _get_int_from_line(&cur, end, "width")
 *     length = _get_int_from_line(&cur, end, "length")             # <<<<<<<<<<<<<<
 * 
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 */
  __pyx_t_6 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur), __pyx_v_end, __pyx_k__length); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_length = __pyx_t_6;

  /* "bzrlib/_chk_map_pyx.pyx":227
 *     length = _get_int_from_line(&cur, end, "length")
 * 
 *     next_line = <char *>memchr(cur, c'\n', end - cur)             # <<<<<<<<<<<<<<
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')
 */
  __pyx_v_next_line = ((char *)memchr(__pyx_v_cur, '\n', (__pyx_v_end - __pyx_v_cur)));

  /* "bzrlib/_chk_map_pyx.pyx":228
 * 
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 *     if next_line == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('Missing the prefix line\n')
 *     prefix = cur
 */
  __pyx_t_5 = (__pyx_v_next_line == NULL);
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":229
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')             # <<<<<<<<<<<<<<
 *     prefix = cur
 *     prefix_length = next_line - cur
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "bzrlib/_chk_map_pyx.pyx":230
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')
 *     prefix = cur             # <<<<<<<<<<<<<<
 *     prefix_length = next_line - cur
 *     cur = next_line + 1
 */
  __pyx_v_prefix = __pyx_v_cur;

  /* "bzrlib/_chk_map_pyx.pyx":231
 *         raise ValueError('Missing the prefix line\n')
 *     prefix = cur
 *     prefix_length = next_line - cur             # <<<<<<<<<<<<<<
 *     cur = next_line + 1
 * 
 */
  __pyx_v_prefix_length = (__pyx_v_next_line - __pyx_v_cur);

  /* "bzrlib/_chk_map_pyx.pyx":232
 *     prefix = cur
 *     prefix_length = next_line - cur
 *     cur = next_line + 1             # <<<<<<<<<<<<<<
 * 
 *     prefix_bits = []
 */
  __pyx_v_cur = (__pyx_v_next_line + 1);

  /* "bzrlib/_chk_map_pyx.pyx":234
 *     cur = next_line + 1
 * 
 *     prefix_bits = []             # <<<<<<<<<<<<<<
 *     prefix_tail = prefix
 *     num_prefix_bits = 0
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_v_prefix_bits));
  __pyx_v_prefix_bits = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":235
 * 
 *     prefix_bits = []
 *     prefix_tail = prefix             # <<<<<<<<<<<<<<
 *     num_prefix_bits = 0
 *     next_null = <char *>memchr(prefix, c'\0', prefix_length)
 */
  __pyx_v_prefix_tail = __pyx_v_prefix;

  /* "bzrlib/_chk_map_pyx.pyx":236
 *     prefix_bits = []
 *     prefix_tail = prefix
 *     num_prefix_bits = 0             # <<<<<<<<<<<<<<
 *     next_null = <char *>memchr(prefix, c'\0', prefix_length)
 *     while next_null != NULL:
 */
  __pyx_v_num_prefix_bits = 0;

  /* "bzrlib/_chk_map_pyx.pyx":237
 *     prefix_tail = prefix
 *     num_prefix_bits = 0
 *     next_null = <char *>memchr(prefix, c'\0', prefix_length)             # <<<<<<<<<<<<<<
 *     while next_null != NULL:
 *         num_prefix_bits = num_prefix_bits + 1
 */
  __pyx_v_next_null = ((char *)memchr(__pyx_v_prefix, '\x00', __pyx_v_prefix_length));

  /* "bzrlib/_chk_map_pyx.pyx":238
 *     num_prefix_bits = 0
 *     next_null = <char *>memchr(prefix, c'\0', prefix_length)
 *     while next_null != NULL:             # <<<<<<<<<<<<<<
 *         num_prefix_bits = num_prefix_bits + 1
 *         prefix_bits.append(
 */
  while (1) {
    __pyx_t_5 = (__pyx_v_next_null != NULL);
    if (!__pyx_t_5) break;

    /* "bzrlib/_chk_map_pyx.pyx":239
 *     next_null = <char *>memchr(prefix, c'\0', prefix_length)
 *     while next_null != NULL:
 *         num_prefix_bits = num_prefix_bits + 1             # <<<<<<<<<<<<<<
 *         prefix_bits.append(
 *             PyString_FromStringAndSize(prefix_tail, next_null - prefix_tail))
 */
    __pyx_v_num_prefix_bits = (__pyx_v_num_prefix_bits + 1);

    /* "bzrlib/_chk_map_pyx.pyx":240
 *     while next_null != NULL:
 *         num_prefix_bits = num_prefix_bits + 1
 *         prefix_bits.append(             # <<<<<<<<<<<<<<
 *             PyString_FromStringAndSize(prefix_tail, next_null - prefix_tail))
 *         prefix_tail = next_null + 1
 */
    if (unlikely(__pyx_v_prefix_bits == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }

    /* "bzrlib/_chk_map_pyx.pyx":241
 *         num_prefix_bits = num_prefix_bits + 1
 *         prefix_bits.append(
 *             PyString_FromStringAndSize(prefix_tail, next_null - prefix_tail))             # <<<<<<<<<<<<<<
 *         prefix_tail = next_null + 1
 *         next_null = <char *>memchr(prefix_tail, c'\0', next_line - prefix_tail)
 */
    __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_prefix_tail, (__pyx_v_next_null - __pyx_v_prefix_tail)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyList_Append(__pyx_v_prefix_bits, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":242
 *         prefix_bits.append(
 *             PyString_FromStringAndSize(prefix_tail, next_null - prefix_tail))
 *         prefix_tail = next_null + 1             # <<<<<<<<<<<<<<
 *         next_null = <char *>memchr(prefix_tail, c'\0', next_line - prefix_tail)
 *     prefix_tail_len = next_line - prefix_tail
 */
    __pyx_v_prefix_tail = (__pyx_v_next_null + 1);

    /* "bzrlib/_chk_map_pyx.pyx":243
 *             PyString_FromStringAndSize(prefix_tail, next_null - prefix_tail))
 *         prefix_tail = next_null + 1
 *         next_null = <char *>memchr(prefix_tail, c'\0', next_line - prefix_tail)             # <<<<<<<<<<<<<<
 *     prefix_tail_len = next_line - prefix_tail
 * 
 */
    __pyx_v_next_null = ((char *)memchr(__pyx_v_prefix_tail, '\x00', (__pyx_v_next_line - __pyx_v_prefix_tail)));
  }

  /* "bzrlib/_chk_map_pyx.pyx":244
 *         prefix_tail = next_null + 1
 *         next_null = <char *>memchr(prefix_tail, c'\0', next_line - prefix_tail)
 *     prefix_tail_len = next_line - prefix_tail             # <<<<<<<<<<<<<<
 * 
 *     if num_prefix_bits >= width:
 */
  __pyx_v_prefix_tail_len = (__pyx_v_next_line - __pyx_v_prefix_tail);

  /* "bzrlib/_chk_map_pyx.pyx":246
 *     prefix_tail_len = next_line - prefix_tail
 * 
 *     if num_prefix_bits >= width:             # <<<<<<<<<<<<<<
 *         raise ValueError('Prefix has too many nulls versus width')
 * 
 */
  __pyx_t_5 = (__pyx_v_num_prefix_bits >= __pyx_v_width);
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":247
 * 
 *     if num_prefix_bits >= width:
 *         raise ValueError('Prefix has too many nulls versus width')             # <<<<<<<<<<<<<<
 * 
 *     items_length = end - cur
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "bzrlib/_chk_map_pyx.pyx":249
 *         raise ValueError('Prefix has too many nulls versus width')
 * 
 *     items_length = end - cur             # <<<<<<<<<<<<<<
 *     items = {}
 *     while cur < end:
 */
  __pyx_v_items_length = (__pyx_v_end - __pyx_v_cur);

  /* "bzrlib/_chk_map_pyx.pyx":250
 * 
 *     items_length = end - cur
 *     items = {}             # <<<<<<<<<<<<<<
 *     while cur < end:
 *         line_start = cur
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_v_items));
  __pyx_v_items = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":251
 *     items_length = end - cur
 *     items = {}
 *     while cur < end:             # <<<<<<<<<<<<<<
 *         line_start = cur
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 */
  while (1) {
    __pyx_t_5 = (__pyx_v_cur < __pyx_v_end);
    if (!__pyx_t_5) break;

    /* "bzrlib/_chk_map_pyx.pyx":252
 *     items = {}
 *     while cur < end:
 *         line_start = cur             # <<<<<<<<<<<<<<
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 *         if next_line == NULL:
 */
    __pyx_v_line_start = __pyx_v_cur;

    /* "bzrlib/_chk_map_pyx.pyx":253
 *     while cur < end:
 *         line_start = cur
 *         next_line = <char *>memchr(cur, c'\n', end - cur)             # <<<<<<<<<<<<<<
 *         if next_line == NULL:
 *             raise ValueError('null line\n')
 */
    __pyx_v_next_line = ((char *)memchr(__pyx_v_cur, '\n', (__pyx_v_end - __pyx_v_cur)));

    /* "bzrlib/_chk_map_pyx.pyx":254
 *         line_start = cur
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 *         if next_line == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError('null line\n')
 *         last_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 */
    __pyx_t_5 = (__pyx_v_next_line == NULL);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":255
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 *         if next_line == NULL:
 *             raise ValueError('null line\n')             # <<<<<<<<<<<<<<
 *         last_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if last_null == NULL:
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "bzrlib/_chk_map_pyx.pyx":256
 *         if next_line == NULL:
 *             raise ValueError('null line\n')
 *         last_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)             # <<<<<<<<<<<<<<
 *         if last_null == NULL:
 *             raise ValueError('fail to find the num value lines null')
 */
    __pyx_v_last_null = ((char *)__pyx_f_6bzrlib_12_chk_map_pyx__my_memrchr(__pyx_v_cur, '\x00', (__pyx_v_next_line - __pyx_v_cur)));

    /* "bzrlib/_chk_map_pyx.pyx":257
 *             raise ValueError('null line\n')
 *         last_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if last_null == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError('fail to find the num value lines null')
 *         next_null = last_null + 1 # move past NULL
 */
    __pyx_t_5 = (__pyx_v_last_null == NULL);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":258
 *         last_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if last_null == NULL:
 *             raise ValueError('fail to find the num value lines null')             # <<<<<<<<<<<<<<
 *         next_null = last_null + 1 # move past NULL
 *         num_value_lines = _get_int_from_line(&next_null, next_line + 1,
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L17;
    }
    __pyx_L17:;

    /* "bzrlib/_chk_map_pyx.pyx":259
 *         if last_null == NULL:
 *             raise ValueError('fail to find the num value lines null')
 *         next_null = last_null + 1 # move past NULL             # <<<<<<<<<<<<<<
 *         num_value_lines = _get_int_from_line(&next_null, next_line + 1,
 *                                              "num value lines")
 */
    __pyx_v_next_null = (__pyx_v_last_null + 1);

    /* "bzrlib/_chk_map_pyx.pyx":260
 *             raise ValueError('fail to find the num value lines null')
 *         next_null = last_null + 1 # move past NULL
 *         num_value_lines = _get_int_from_line(&next_null, next_line + 1,             # <<<<<<<<<<<<<<
 *                                              "num value lines")
 *         cur = next_line + 1
 */
    __pyx_t_6 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_next_null), (__pyx_v_next_line + 1), __pyx_k_18); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_num_value_lines = __pyx_t_6;

    /* "bzrlib/_chk_map_pyx.pyx":262
 *         num_value_lines = _get_int_from_line(&next_null, next_line + 1,
 *                                              "num value lines")
 *         cur = next_line + 1             # <<<<<<<<<<<<<<
 *         value_start = cur
 *         # Walk num_value_lines forward
 */
    __pyx_v_cur = (__pyx_v_next_line + 1);

    /* "bzrlib/_chk_map_pyx.pyx":263
 *                                              "num value lines")
 *         cur = next_line + 1
 *         value_start = cur             # <<<<<<<<<<<<<<
 *         # Walk num_value_lines forward
 *         for i from 0 <= i < num_value_lines:
 */
    __pyx_v_value_start = __pyx_v_cur;

    /* "bzrlib/_chk_map_pyx.pyx":265
 *         value_start = cur
 *         # Walk num_value_lines forward
 *         for i from 0 <= i < num_value_lines:             # <<<<<<<<<<<<<<
 *             next_line = <char *>memchr(cur, c'\n', end - cur)
 *             if next_line == NULL:
 */
    __pyx_t_6 = __pyx_v_num_value_lines;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

      /* "bzrlib/_chk_map_pyx.pyx":266
 *         # Walk num_value_lines forward
 *         for i from 0 <= i < num_value_lines:
 *             next_line = <char *>memchr(cur, c'\n', end - cur)             # <<<<<<<<<<<<<<
 *             if next_line == NULL:
 *                 raise ValueError('missing trailing newline')
 */
      __pyx_v_next_line = ((char *)memchr(__pyx_v_cur, '\n', (__pyx_v_end - __pyx_v_cur)));

      /* "bzrlib/_chk_map_pyx.pyx":267
 *         for i from 0 <= i < num_value_lines:
 *             next_line = <char *>memchr(cur, c'\n', end - cur)
 *             if next_line == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError('missing trailing newline')
 *             cur = next_line + 1
 */
      __pyx_t_5 = (__pyx_v_next_line == NULL);
      if (__pyx_t_5) {

        /* "bzrlib/_chk_map_pyx.pyx":268
 *             next_line = <char *>memchr(cur, c'\n', end - cur)
 *             if next_line == NULL:
 *                 raise ValueError('missing trailing newline')             # <<<<<<<<<<<<<<
 *             cur = next_line + 1
 *         entry_bits = StaticTuple_New(width)
 */
        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L20;
      }
      __pyx_L20:;

      /* "bzrlib/_chk_map_pyx.pyx":269
 *             if next_line == NULL:
 *                 raise ValueError('missing trailing newline')
 *             cur = next_line + 1             # <<<<<<<<<<<<<<
 *         entry_bits = StaticTuple_New(width)
 *         for i from 0 <= i < num_prefix_bits:
 */
      __pyx_v_cur = (__pyx_v_next_line + 1);
    }

    /* "bzrlib/_chk_map_pyx.pyx":270
 *                 raise ValueError('missing trailing newline')
 *             cur = next_line + 1
 *         entry_bits = StaticTuple_New(width)             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < num_prefix_bits:
 *             # TODO: Use PyList_GetItem, or turn prefix_bits into a
 */
    __pyx_t_2 = ((PyObject *)StaticTuple_New(__pyx_v_width)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_v_entry_bits));
    __pyx_v_entry_bits = ((StaticTuple *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":271
 *             cur = next_line + 1
 *         entry_bits = StaticTuple_New(width)
 *         for i from 0 <= i < num_prefix_bits:             # <<<<<<<<<<<<<<
 *             # TODO: Use PyList_GetItem, or turn prefix_bits into a
 *             #       tuple/StaticTuple
 */
    __pyx_t_6 = __pyx_v_num_prefix_bits;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {

      /* "bzrlib/_chk_map_pyx.pyx":274
 *             # TODO: Use PyList_GetItem, or turn prefix_bits into a
 *             #       tuple/StaticTuple
 *             entry = prefix_bits[i]             # <<<<<<<<<<<<<<
 *             # SET_ITEM 'steals' a reference
 *             Py_INCREF(entry)
 */
      __pyx_t_2 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_prefix_bits), __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_entry);
      __pyx_v_entry = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "bzrlib/_chk_map_pyx.pyx":276
 *             entry = prefix_bits[i]
 *             # SET_ITEM 'steals' a reference
 *             Py_INCREF(entry)             # <<<<<<<<<<<<<<
 *             StaticTuple_SET_ITEM(entry_bits, i, entry)
 *         value = PyString_FromStringAndSize(value_start, next_line - value_start)
 */
      Py_INCREF(__pyx_v_entry);

      /* "bzrlib/_chk_map_pyx.pyx":277
 *             # SET_ITEM 'steals' a reference
 *             Py_INCREF(entry)
 *             StaticTuple_SET_ITEM(entry_bits, i, entry)             # <<<<<<<<<<<<<<
 *         value = PyString_FromStringAndSize(value_start, next_line - value_start)
 *         # The next entry bit needs the 'tail' from the prefix, and first part
 */
      StaticTuple_SET_ITEM(__pyx_v_entry_bits, __pyx_v_i, __pyx_v_entry);
    }

    /* "bzrlib/_chk_map_pyx.pyx":278
 *             Py_INCREF(entry)
 *             StaticTuple_SET_ITEM(entry_bits, i, entry)
 *         value = PyString_FromStringAndSize(value_start, next_line - value_start)             # <<<<<<<<<<<<<<
 *         # The next entry bit needs the 'tail' from the prefix, and first part
 *         # of the line
 */
    __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_value_start, (__pyx_v_next_line - __pyx_v_value_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":281
 *         # The next entry bit needs the 'tail' from the prefix, and first part
 *         # of the line
 *         entry_start = line_start             # <<<<<<<<<<<<<<
 *         next_null = <char *>memchr(entry_start, c'\0',
 *                                    last_null - entry_start + 1)
 */
    __pyx_v_entry_start = __pyx_v_line_start;

    /* "bzrlib/_chk_map_pyx.pyx":283
 *         entry_start = line_start
 *         next_null = <char *>memchr(entry_start, c'\0',
 *                                    last_null - entry_start + 1)             # <<<<<<<<<<<<<<
 *         if next_null == NULL:
 *             raise ValueError('bad no null, bad')
 */
    __pyx_v_next_null = ((char *)memchr(__pyx_v_entry_start, '\x00', ((__pyx_v_last_null - __pyx_v_entry_start) + 1)));

    /* "bzrlib/_chk_map_pyx.pyx":284
 *         next_null = <char *>memchr(entry_start, c'\0',
 *                                    last_null - entry_start + 1)
 *         if next_null == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError('bad no null, bad')
 *         entry = PyString_FromStringAndSize(NULL,
 */
    __pyx_t_5 = (__pyx_v_next_null == NULL);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":285
 *                                    last_null - entry_start + 1)
 *         if next_null == NULL:
 *             raise ValueError('bad no null, bad')             # <<<<<<<<<<<<<<
 *         entry = PyString_FromStringAndSize(NULL,
 *                     prefix_tail_len + next_null - line_start)
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L23;
    }
    __pyx_L23:;

    /* "bzrlib/_chk_map_pyx.pyx":287
 *             raise ValueError('bad no null, bad')
 *         entry = PyString_FromStringAndSize(NULL,
 *                     prefix_tail_len + next_null - line_start)             # <<<<<<<<<<<<<<
 *         c_entry = PyString_AS_STRING(entry)
 *         if prefix_tail_len > 0:
 */
    __pyx_t_2 = PyString_FromStringAndSize(NULL, ((__pyx_v_prefix_tail_len + __pyx_v_next_null) - __pyx_v_line_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_entry);
    __pyx_v_entry = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":288
 *         entry = PyString_FromStringAndSize(NULL,
 *                     prefix_tail_len + next_null - line_start)
 *         c_entry = PyString_AS_STRING(entry)             # <<<<<<<<<<<<<<
 *         if prefix_tail_len > 0:
 *             memcpy(c_entry, prefix_tail, prefix_tail_len)
 */
    __pyx_v_c_entry = PyString_AS_STRING(__pyx_v_entry);

    /* "bzrlib/_chk_map_pyx.pyx":289
 *                     prefix_tail_len + next_null - line_start)
 *         c_entry = PyString_AS_STRING(entry)
 *         if prefix_tail_len > 0:             # <<<<<<<<<<<<<<
 *             memcpy(c_entry, prefix_tail, prefix_tail_len)
 *         if next_null - line_start > 0:
 */
    __pyx_t_5 = (__pyx_v_prefix_tail_len > 0);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":290
 *         c_entry = PyString_AS_STRING(entry)
 *         if prefix_tail_len > 0:
 *             memcpy(c_entry, prefix_tail, prefix_tail_len)             # <<<<<<<<<<<<<<
 *         if next_null - line_start > 0:
 *             memcpy(c_entry + prefix_tail_len, line_start, next_null - line_start)
 */
      memcpy(__pyx_v_c_entry, __pyx_v_prefix_tail, __pyx_v_prefix_tail_len);
      goto __pyx_L24;
    }
    __pyx_L24:;

    /* "bzrlib/_chk_map_pyx.pyx":291
 *         if prefix_tail_len > 0:
 *             memcpy(c_entry, prefix_tail, prefix_tail_len)
 *         if next_null - line_start > 0:             # <<<<<<<<<<<<<<
 *             memcpy(c_entry + prefix_tail_len, line_start, next_null - line_start)
 *         Py_INCREF(entry)
 */
    __pyx_t_5 = ((__pyx_v_next_null - __pyx_v_line_start) > 0);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":292
 *             memcpy(c_entry, prefix_tail, prefix_tail_len)
 *         if next_null - line_start > 0:
 *             memcpy(c_entry + prefix_tail_len, line_start, next_null - line_start)             # <<<<<<<<<<<<<<
 *         Py_INCREF(entry)
 *         i = num_prefix_bits
 */
      memcpy((__pyx_v_c_entry + __pyx_v_prefix_tail_len), __pyx_v_line_start, (__pyx_v_next_null - __pyx_v_line_start));
      goto __pyx_L25;
    }
    __pyx_L25:;

    /* "bzrlib/_chk_map_pyx.pyx":293
 *         if next_null - line_start > 0:
 *             memcpy(c_entry + prefix_tail_len, line_start, next_null - line_start)
 *         Py_INCREF(entry)             # <<<<<<<<<<<<<<
 *         i = num_prefix_bits
 *         StaticTuple_SET_ITEM(entry_bits, i, entry)
 */
    Py_INCREF(__pyx_v_entry);

    /* "bzrlib/_chk_map_pyx.pyx":294
 *             memcpy(c_entry + prefix_tail_len, line_start, next_null - line_start)
 *         Py_INCREF(entry)
 *         i = num_prefix_bits             # <<<<<<<<<<<<<<
 *         StaticTuple_SET_ITEM(entry_bits, i, entry)
 *         while next_null != last_null: # We have remaining bits
 */
    __pyx_v_i = __pyx_v_num_prefix_bits;

    /* "bzrlib/_chk_map_pyx.pyx":295
 *         Py_INCREF(entry)
 *         i = num_prefix_bits
 *         StaticTuple_SET_ITEM(entry_bits, i, entry)             # <<<<<<<<<<<<<<
 *         while next_null != last_null: # We have remaining bits
 *             i = i + 1
 */
    StaticTuple_SET_ITEM(__pyx_v_entry_bits, __pyx_v_i, __pyx_v_entry);

    /* "bzrlib/_chk_map_pyx.pyx":296
 *         i = num_prefix_bits
 *         StaticTuple_SET_ITEM(entry_bits, i, entry)
 *         while next_null != last_null: # We have remaining bits             # <<<<<<<<<<<<<<
 *             i = i + 1
 *             if i > width:
 */
    while (1) {
      __pyx_t_5 = (__pyx_v_next_null != __pyx_v_last_null);
      if (!__pyx_t_5) break;

      /* "bzrlib/_chk_map_pyx.pyx":297
 *         StaticTuple_SET_ITEM(entry_bits, i, entry)
 *         while next_null != last_null: # We have remaining bits
 *             i = i + 1             # <<<<<<<<<<<<<<
 *             if i > width:
 *                 raise ValueError("Too many bits for entry")
 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "bzrlib/_chk_map_pyx.pyx":298
 *         while next_null != last_null: # We have remaining bits
 *             i = i + 1
 *             if i > width:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Too many bits for entry")
 *             entry_start = next_null + 1
 */
      __pyx_t_5 = (__pyx_v_i > __pyx_v_width);
      if (__pyx_t_5) {

        /* "bzrlib/_chk_map_pyx.pyx":299
 *             i = i + 1
 *             if i > width:
 *                 raise ValueError("Too many bits for entry")             # <<<<<<<<<<<<<<
 *             entry_start = next_null + 1
 *             next_null = <char *>memchr(entry_start, c'\0',
 */
        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L28;
      }
      __pyx_L28:;

      /* "bzrlib/_chk_map_pyx.pyx":300
 *             if i > width:
 *                 raise ValueError("Too many bits for entry")
 *             entry_start = next_null + 1             # <<<<<<<<<<<<<<
 *             next_null = <char *>memchr(entry_start, c'\0',
 *                                        last_null - entry_start + 1)
 */
      __pyx_v_entry_start = (__pyx_v_next_null + 1);

      /* "bzrlib/_chk_map_pyx.pyx":302
 *             entry_start = next_null + 1
 *             next_null = <char *>memchr(entry_start, c'\0',
 *                                        last_null - entry_start + 1)             # <<<<<<<<<<<<<<
 *             if next_null == NULL:
 *                 raise ValueError('bad no null')
 */
      __pyx_v_next_null = ((char *)memchr(__pyx_v_entry_start, '\x00', ((__pyx_v_last_null - __pyx_v_entry_start) + 1)));

      /* "bzrlib/_chk_map_pyx.pyx":303
 *             next_null = <char *>memchr(entry_start, c'\0',
 *                                        last_null - entry_start + 1)
 *             if next_null == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError('bad no null')
 *             entry = PyString_FromStringAndSize(entry_start,
 */
      __pyx_t_5 = (__pyx_v_next_null == NULL);
      if (__pyx_t_5) {

        /* "bzrlib/_chk_map_pyx.pyx":304
 *                                        last_null - entry_start + 1)
 *             if next_null == NULL:
 *                 raise ValueError('bad no null')             # <<<<<<<<<<<<<<
 *             entry = PyString_FromStringAndSize(entry_start,
 *                                                next_null - entry_start)
 */
        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_Raise(__pyx_t_2, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L29;
      }
      __pyx_L29:;

      /* "bzrlib/_chk_map_pyx.pyx":306
 *                 raise ValueError('bad no null')
 *             entry = PyString_FromStringAndSize(entry_start,
 *                                                next_null - entry_start)             # <<<<<<<<<<<<<<
 *             Py_INCREF(entry)
 *             StaticTuple_SET_ITEM(entry_bits, i, entry)
 */
      __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_entry_start, (__pyx_v_next_null - __pyx_v_entry_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_entry);
      __pyx_v_entry = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "bzrlib/_chk_map_pyx.pyx":307
 *             entry = PyString_FromStringAndSize(entry_start,
 *                                                next_null - entry_start)
 *             Py_INCREF(entry)             # <<<<<<<<<<<<<<
 *             StaticTuple_SET_ITEM(entry_bits, i, entry)
 *         if StaticTuple_GET_SIZE(entry_bits) != width:
 */
      Py_INCREF(__pyx_v_entry);

      /* "bzrlib/_chk_map_pyx.pyx":308
 *                                                next_null - entry_start)
 *             Py_INCREF(entry)
 *             StaticTuple_SET_ITEM(entry_bits, i, entry)             # <<<<<<<<<<<<<<
 *         if StaticTuple_GET_SIZE(entry_bits) != width:
 *             raise AssertionError(
 */
      StaticTuple_SET_ITEM(__pyx_v_entry_bits, __pyx_v_i, __pyx_v_entry);
    }

    /* "bzrlib/_chk_map_pyx.pyx":309
 *             Py_INCREF(entry)
 *             StaticTuple_SET_ITEM(entry_bits, i, entry)
 *         if StaticTuple_GET_SIZE(entry_bits) != width:             # <<<<<<<<<<<<<<
 *             raise AssertionError(
 *                 'Incorrect number of elements (%d vs %d)'
 */
    __pyx_t_5 = (StaticTuple_GET_SIZE(__pyx_v_entry_bits) != __pyx_v_width);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":312
 *             raise AssertionError(
 *                 'Incorrect number of elements (%d vs %d)'
 *                 % (len(entry_bits)+1, width + 1))             # <<<<<<<<<<<<<<
 *         entry_bits = StaticTuple_Intern(entry_bits)
 *         PyDict_SetItem(items, entry_bits, value)
 */
      __pyx_t_7 = PyObject_Length(((PyObject *)__pyx_v_entry_bits)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_7 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyInt_FromLong((__pyx_v_width + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L30;
    }
    __pyx_L30:;

    /* "bzrlib/_chk_map_pyx.pyx":313
 *                 'Incorrect number of elements (%d vs %d)'
 *                 % (len(entry_bits)+1, width + 1))
 *         entry_bits = StaticTuple_Intern(entry_bits)             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(items, entry_bits, value)
 *     if len(items) != length:
 */
    __pyx_t_3 = ((PyObject *)StaticTuple_Intern(__pyx_v_entry_bits)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_v_entry_bits));
    __pyx_v_entry_bits = ((StaticTuple *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":314
 *                 % (len(entry_bits)+1, width + 1))
 *         entry_bits = StaticTuple_Intern(entry_bits)
 *         PyDict_SetItem(items, entry_bits, value)             # <<<<<<<<<<<<<<
 *     if len(items) != length:
 *         raise ValueError("item count (%d) mismatch for key %s,"
 */
    __pyx_t_6 = PyDict_SetItem(((PyObject *)__pyx_v_items), ((PyObject *)__pyx_v_entry_bits), __pyx_v_value); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "bzrlib/_chk_map_pyx.pyx":315
 *         entry_bits = StaticTuple_Intern(entry_bits)
 *         PyDict_SetItem(items, entry_bits, value)
 *     if len(items) != length:             # <<<<<<<<<<<<<<
 *         raise ValueError("item count (%d) mismatch for key %s,"
 *                          " bytes %r" % (length, entry_bits, bytes))
 */
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_7 = PyDict_Size(((PyObject *)__pyx_v_items)); 
  __pyx_t_5 = (__pyx_t_7 != __pyx_v_length);
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":317
 *     if len(items) != length:
 *         raise ValueError("item count (%d) mismatch for key %s,"
 *                          " bytes %r" % (length, entry_bits, bytes))             # <<<<<<<<<<<<<<
 *     result._items = items
 *     result._len = length
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_entry_bits));
    PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_v_entry_bits));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_entry_bits));
    __Pyx_INCREF(__pyx_v_bytes);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_bytes);
    __Pyx_GIVEREF(__pyx_v_bytes);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L31;
  }
  __pyx_L31:;

  /* "bzrlib/_chk_map_pyx.pyx":318
 *         raise ValueError("item count (%d) mismatch for key %s,"
 *                          " bytes %r" % (length, entry_bits, bytes))
 *     result._items = items             # <<<<<<<<<<<<<<
 *     result._len = length
 *     result._maximum_size = maximum_size
 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___items, ((PyObject *)__pyx_v_items)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "bzrlib/_chk_map_pyx.pyx":319
 *                          " bytes %r" % (length, entry_bits, bytes))
 *     result._items = items
 *     result._len = length             # <<<<<<<<<<<<<<
 *     result._maximum_size = maximum_size
 *     result._key = key
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___len, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":320
 *     result._items = items
 *     result._len = length
 *     result._maximum_size = maximum_size             # <<<<<<<<<<<<<<
 *     result._key = key
 *     result._key_width = width
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_maximum_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___maximum_size, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":321
 *     result._len = length
 *     result._maximum_size = maximum_size
 *     result._key = key             # <<<<<<<<<<<<<<
 *     result._key_width = width
 *     result._raw_size = items_length + length * prefix_length
 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___key, __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "bzrlib/_chk_map_pyx.pyx":322
 *     result._maximum_size = maximum_size
 *     result._key = key
 *     result._key_width = width             # <<<<<<<<<<<<<<
 *     result._raw_size = items_length + length * prefix_length
 *     if length == 0:
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_width); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___key_width, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":323
 *     result._key = key
 *     result._key_width = width
 *     result._raw_size = items_length + length * prefix_length             # <<<<<<<<<<<<<<
 *     if length == 0:
 *         result._search_prefix = None
 */
  __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_items_length + (__pyx_v_length * __pyx_v_prefix_length))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___raw_size, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":324
 *     result._key_width = width
 *     result._raw_size = items_length + length * prefix_length
 *     if length == 0:             # <<<<<<<<<<<<<<
 *         result._search_prefix = None
 *         result._common_serialised_prefix = None
 */
  __pyx_t_5 = (__pyx_v_length == 0);
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":325
 *     result._raw_size = items_length + length * prefix_length
 *     if length == 0:
 *         result._search_prefix = None             # <<<<<<<<<<<<<<
 *         result._common_serialised_prefix = None
 *     else:
 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___search_prefix, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "bzrlib/_chk_map_pyx.pyx":326
 *     if length == 0:
 *         result._search_prefix = None
 *         result._common_serialised_prefix = None             # <<<<<<<<<<<<<<
 *     else:
 *         result._search_prefix = _unknown
 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s_29, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L32;
  }
  /*else*/ {

    /* "bzrlib/_chk_map_pyx.pyx":328
 *         result._common_serialised_prefix = None
 *     else:
 *         result._search_prefix = _unknown             # <<<<<<<<<<<<<<
 *         result._common_serialised_prefix = PyString_FromStringAndSize(prefix,
 *                                                 prefix_length)
 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___search_prefix, __pyx_v_6bzrlib_12_chk_map_pyx__unknown) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "bzrlib/_chk_map_pyx.pyx":330
 *         result._search_prefix = _unknown
 *         result._common_serialised_prefix = PyString_FromStringAndSize(prefix,
 *                                                 prefix_length)             # <<<<<<<<<<<<<<
 *     if c_bytes_len != result._current_size():
 *         raise AssertionError('_current_size computed incorrectly %d != %d',
 */
    __pyx_t_3 = PyString_FromStringAndSize(__pyx_v_prefix, __pyx_v_prefix_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);

    /* "bzrlib/_chk_map_pyx.pyx":329
 *     else:
 *         result._search_prefix = _unknown
 *         result._common_serialised_prefix = PyString_FromStringAndSize(prefix,             # <<<<<<<<<<<<<<
 *                                                 prefix_length)
 *     if c_bytes_len != result._current_size():
 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s_29, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L32:;

  /* "bzrlib/_chk_map_pyx.pyx":331
 *         result._common_serialised_prefix = PyString_FromStringAndSize(prefix,
 *                                                 prefix_length)
 *     if c_bytes_len != result._current_size():             # <<<<<<<<<<<<<<
 *         raise AssertionError('_current_size computed incorrectly %d != %d',
 *             c_bytes_len, result._current_size())
 */
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_c_bytes_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyObject_GetAttr(__pyx_v_result, __pyx_n_s___current_size); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":333
 *     if c_bytes_len != result._current_size():
 *         raise AssertionError('_current_size computed incorrectly %d != %d',
 *             c_bytes_len, result._current_size())             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
    __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_c_bytes_len); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_s___current_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_30));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_8 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L33;
  }
  __pyx_L33:;

  /* "bzrlib/_chk_map_pyx.pyx":334
 *         raise AssertionError('_current_size computed incorrectly %d != %d',
 *             c_bytes_len, result._current_size())
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._deserialise_leaf_node");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_entry_bits);
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_DECREF(__pyx_v_prefix_bits);
  __Pyx_DECREF(__pyx_v_items);
  __Pyx_DECREF(__pyx_v_entry);
  __Pyx_DECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "bzrlib/_chk_map_pyx.pyx":337
 * 
 * 
 * def _deserialise_internal_node(bytes, key, search_key_func=None):             # <<<<<<<<<<<<<<
 *     cdef char *c_bytes, *cur, *next, *end
 *     cdef char *next_line
 */

static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_3_deserialise_internal_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_6bzrlib_12_chk_map_pyx_3_deserialise_internal_node = {__Pyx_NAMESTR("_deserialise_internal_node"), (PyCFunction)__pyx_pf_6bzrlib_12_chk_map_pyx_3_deserialise_internal_node, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_3_deserialise_internal_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bytes = 0;
  PyObject *__pyx_v_key = 0;
  PyObject *__pyx_v_search_key_func = 0;
  char *__pyx_v_c_bytes;
  char *__pyx_v_cur;
  char *__pyx_v_end;
  char *__pyx_v_next_line;
  Py_ssize_t __pyx_v_c_bytes_len;
  Py_ssize_t __pyx_v_prefix_length;
  int __pyx_v_maximum_size;
  int __pyx_v_width;
  int __pyx_v_length;
  char *__pyx_v_prefix;
  char *__pyx_v_next_null;
  char *__pyx_v_c_item_prefix;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_items;
  PyObject *__pyx_v_item_prefix;
  PyObject *__pyx_v_flat_key;
  PyObject *__pyx_r = NULL;
  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;
  Py_ssize_t __pyx_t_7;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bytes,&__pyx_n_s__key,&__pyx_n_s__search_key_func,0};
  __Pyx_RefNannySetupContext("_deserialise_internal_node");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      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__bytes);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__key);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("_deserialise_internal_node", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__search_key_func);
        if (value) { values[2] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_deserialise_internal_node") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_bytes = values[0];
    __pyx_v_key = values[1];
    __pyx_v_search_key_func = values[2];
  } else {
    __pyx_v_search_key_func = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_search_key_func = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2:
      __pyx_v_key = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_bytes = 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("_deserialise_internal_node", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._deserialise_internal_node");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_items = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_item_prefix = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_flat_key = Py_None; __Pyx_INCREF(Py_None);

  /* "bzrlib/_chk_map_pyx.pyx":344
 *     cdef char *prefix, *line_prefix, *next_null, *c_item_prefix
 * 
 *     if _InternalNode is None:             # <<<<<<<<<<<<<<
 *         _import_globals()
 *     result = _InternalNode(search_key_func=search_key_func)
 */
  __pyx_t_1 = (__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode == Py_None);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":345
 * 
 *     if _InternalNode is None:
 *         _import_globals()             # <<<<<<<<<<<<<<
 *     result = _InternalNode(search_key_func=search_key_func)
 * 
 */
    __pyx_t_2 = __pyx_f_6bzrlib_12_chk_map_pyx__import_globals(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "bzrlib/_chk_map_pyx.pyx":346
 *     if _InternalNode is None:
 *         _import_globals()
 *     result = _InternalNode(search_key_func=search_key_func)             # <<<<<<<<<<<<<<
 * 
 *     if not StaticTuple_CheckExact(key):
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__search_key_func), __pyx_v_search_key_func) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":348
 *     result = _InternalNode(search_key_func=search_key_func)
 * 
 *     if not StaticTuple_CheckExact(key):             # <<<<<<<<<<<<<<
 *         raise TypeError('key %r is not a StaticTuple' % (key,))
 *     if not PyString_CheckExact(bytes):
 */
  __pyx_t_1 = (!StaticTuple_CheckExact(__pyx_v_key));
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":349
 * 
 *     if not StaticTuple_CheckExact(key):
 *         raise TypeError('key %r is not a StaticTuple' % (key,))             # <<<<<<<<<<<<<<
 *     if not PyString_CheckExact(bytes):
 *         raise TypeError('bytes must be a plain string not %s' % (type(bytes),))
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(((PyObject *)__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 = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__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 = 349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "bzrlib/_chk_map_pyx.pyx":350
 *     if not StaticTuple_CheckExact(key):
 *         raise TypeError('key %r is not a StaticTuple' % (key,))
 *     if not PyString_CheckExact(bytes):             # <<<<<<<<<<<<<<
 *         raise TypeError('bytes must be a plain string not %s' % (type(bytes),))
 * 
 */
  __pyx_t_1 = (!PyString_CheckExact(__pyx_v_bytes));
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":351
 *         raise TypeError('key %r is not a StaticTuple' % (key,))
 *     if not PyString_CheckExact(bytes):
 *         raise TypeError('bytes must be a plain string not %s' % (type(bytes),))             # <<<<<<<<<<<<<<
 * 
 *     c_bytes = PyString_AS_STRING(bytes)
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_bytes)));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(__pyx_v_bytes)));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_bytes)));
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "bzrlib/_chk_map_pyx.pyx":353
 *         raise TypeError('bytes must be a plain string not %s' % (type(bytes),))
 * 
 *     c_bytes = PyString_AS_STRING(bytes)             # <<<<<<<<<<<<<<
 *     c_bytes_len = PyString_GET_SIZE(bytes)
 * 
 */
  __pyx_v_c_bytes = PyString_AS_STRING(__pyx_v_bytes);

  /* "bzrlib/_chk_map_pyx.pyx":354
 * 
 *     c_bytes = PyString_AS_STRING(bytes)
 *     c_bytes_len = PyString_GET_SIZE(bytes)             # <<<<<<<<<<<<<<
 * 
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chknode:\n", 9) != 0:
 */
  __pyx_v_c_bytes_len = PyString_GET_SIZE(__pyx_v_bytes);

  /* "bzrlib/_chk_map_pyx.pyx":356
 *     c_bytes_len = PyString_GET_SIZE(bytes)
 * 
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chknode:\n", 9) != 0:             # <<<<<<<<<<<<<<
 *         raise ValueError("not a serialised internal node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 */
  __pyx_t_1 = (__pyx_v_c_bytes_len < 9);
  if (!__pyx_t_1) {
    __pyx_t_4 = (memcmp(__pyx_v_c_bytes, __pyx_k_32, 9) != 0);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_1;
  }
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":357
 * 
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chknode:\n", 9) != 0:
 *         raise ValueError("not a serialised internal node: %r" % bytes)             # <<<<<<<<<<<<<<
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 *         raise ValueError("bytes does not end in a newline")
 */
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_v_bytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "bzrlib/_chk_map_pyx.pyx":358
 *     if c_bytes_len < 9 or memcmp(c_bytes, "chknode:\n", 9) != 0:
 *         raise ValueError("not a serialised internal node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':             # <<<<<<<<<<<<<<
 *         raise ValueError("bytes does not end in a newline")
 * 
 */
  __pyx_t_5 = ((__pyx_v_c_bytes[(__pyx_v_c_bytes_len - 1)]) != '\n');
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":359
 *         raise ValueError("not a serialised internal node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 *         raise ValueError("bytes does not end in a newline")             # <<<<<<<<<<<<<<
 * 
 *     items = {}
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __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[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "bzrlib/_chk_map_pyx.pyx":361
 *         raise ValueError("bytes does not end in a newline")
 * 
 *     items = {}             # <<<<<<<<<<<<<<
 *     cur = c_bytes + 9
 *     end = c_bytes + c_bytes_len
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_v_items));
  __pyx_v_items = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":362
 * 
 *     items = {}
 *     cur = c_bytes + 9             # <<<<<<<<<<<<<<
 *     end = c_bytes + c_bytes_len
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 */
  __pyx_v_cur = (__pyx_v_c_bytes + 9);

  /* "bzrlib/_chk_map_pyx.pyx":363
 *     items = {}
 *     cur = c_bytes + 9
 *     end = c_bytes + c_bytes_len             # <<<<<<<<<<<<<<
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 *     width = _get_int_from_line(&cur, end, "width")
 */
  __pyx_v_end = (__pyx_v_c_bytes + __pyx_v_c_bytes_len);

  /* "bzrlib/_chk_map_pyx.pyx":364
 *     cur = c_bytes + 9
 *     end = c_bytes + c_bytes_len
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")             # <<<<<<<<<<<<<<
 *     width = _get_int_from_line(&cur, end, "width")
 *     length = _get_int_from_line(&cur, end, "length")
 */
  __pyx_t_6 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur), __pyx_v_end, __pyx_k__maximum_size); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_maximum_size = __pyx_t_6;

  /* "bzrlib/_chk_map_pyx.pyx":365
 *     end = c_bytes + c_bytes_len
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 *     width = _get_int_from_line(&cur, end, "width")             # <<<<<<<<<<<<<<
 *     length = _get_int_from_line(&cur, end, "length")
 * 
 */
  __pyx_t_6 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur), __pyx_v_end, __pyx_k__width); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_width = __pyx_t_6;

  /* "bzrlib/_chk_map_pyx.pyx":366
 *     maximum_size = _get_int_from_line(&cur, end, "maximum_size")
 *     width = _get_int_from_line(&cur, end, "width")
 *     length = _get_int_from_line(&cur, end, "length")             # <<<<<<<<<<<<<<
 * 
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 */
  __pyx_t_6 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur), __pyx_v_end, __pyx_k__length); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_length = __pyx_t_6;

  /* "bzrlib/_chk_map_pyx.pyx":368
 *     length = _get_int_from_line(&cur, end, "length")
 * 
 *     next_line = <char *>memchr(cur, c'\n', end - cur)             # <<<<<<<<<<<<<<
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')
 */
  __pyx_v_next_line = ((char *)memchr(__pyx_v_cur, '\n', (__pyx_v_end - __pyx_v_cur)));

  /* "bzrlib/_chk_map_pyx.pyx":369
 * 
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 *     if next_line == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('Missing the prefix line\n')
 *     prefix = cur
 */
  __pyx_t_5 = (__pyx_v_next_line == NULL);
  if (__pyx_t_5) {

    /* "bzrlib/_chk_map_pyx.pyx":370
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')             # <<<<<<<<<<<<<<
 *     prefix = cur
 *     prefix_length = next_line - cur
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_35), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __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[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "bzrlib/_chk_map_pyx.pyx":371
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')
 *     prefix = cur             # <<<<<<<<<<<<<<
 *     prefix_length = next_line - cur
 *     cur = next_line + 1
 */
  __pyx_v_prefix = __pyx_v_cur;

  /* "bzrlib/_chk_map_pyx.pyx":372
 *         raise ValueError('Missing the prefix line\n')
 *     prefix = cur
 *     prefix_length = next_line - cur             # <<<<<<<<<<<<<<
 *     cur = next_line + 1
 * 
 */
  __pyx_v_prefix_length = (__pyx_v_next_line - __pyx_v_cur);

  /* "bzrlib/_chk_map_pyx.pyx":373
 *     prefix = cur
 *     prefix_length = next_line - cur
 *     cur = next_line + 1             # <<<<<<<<<<<<<<
 * 
 *     while cur < end:
 */
  __pyx_v_cur = (__pyx_v_next_line + 1);

  /* "bzrlib/_chk_map_pyx.pyx":375
 *     cur = next_line + 1
 * 
 *     while cur < end:             # <<<<<<<<<<<<<<
 *         # Find the null separator
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 */
  while (1) {
    __pyx_t_5 = (__pyx_v_cur < __pyx_v_end);
    if (!__pyx_t_5) break;

    /* "bzrlib/_chk_map_pyx.pyx":377
 *     while cur < end:
 *         # Find the null separator
 *         next_line = <char *>memchr(cur, c'\n', end - cur)             # <<<<<<<<<<<<<<
 *         if next_line == NULL:
 *             raise ValueError('missing trailing newline')
 */
    __pyx_v_next_line = ((char *)memchr(__pyx_v_cur, '\n', (__pyx_v_end - __pyx_v_cur)));

    /* "bzrlib/_chk_map_pyx.pyx":378
 *         # Find the null separator
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 *         if next_line == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError('missing trailing newline')
 *         next_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 */
    __pyx_t_5 = (__pyx_v_next_line == NULL);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":379
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 *         if next_line == NULL:
 *             raise ValueError('missing trailing newline')             # <<<<<<<<<<<<<<
 *         next_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if next_null == NULL:
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_36), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __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[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "bzrlib/_chk_map_pyx.pyx":380
 *         if next_line == NULL:
 *             raise ValueError('missing trailing newline')
 *         next_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)             # <<<<<<<<<<<<<<
 *         if next_null == NULL:
 *             raise ValueError('bad no null')
 */
    __pyx_v_next_null = ((char *)__pyx_f_6bzrlib_12_chk_map_pyx__my_memrchr(__pyx_v_cur, '\x00', (__pyx_v_next_line - __pyx_v_cur)));

    /* "bzrlib/_chk_map_pyx.pyx":381
 *             raise ValueError('missing trailing newline')
 *         next_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if next_null == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError('bad no null')
 *         item_prefix = PyString_FromStringAndSize(NULL,
 */
    __pyx_t_5 = (__pyx_v_next_null == NULL);
    if (__pyx_t_5) {

      /* "bzrlib/_chk_map_pyx.pyx":382
 *         next_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if next_null == NULL:
 *             raise ValueError('bad no null')             # <<<<<<<<<<<<<<
 *         item_prefix = PyString_FromStringAndSize(NULL,
 *             prefix_length + next_null - cur)
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_37), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __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[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "bzrlib/_chk_map_pyx.pyx":384
 *             raise ValueError('bad no null')
 *         item_prefix = PyString_FromStringAndSize(NULL,
 *             prefix_length + next_null - cur)             # <<<<<<<<<<<<<<
 *         c_item_prefix = PyString_AS_STRING(item_prefix)
 *         if prefix_length:
 */
    __pyx_t_3 = PyString_FromStringAndSize(NULL, ((__pyx_v_prefix_length + __pyx_v_next_null) - __pyx_v_cur)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_item_prefix);
    __pyx_v_item_prefix = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":385
 *         item_prefix = PyString_FromStringAndSize(NULL,
 *             prefix_length + next_null - cur)
 *         c_item_prefix = PyString_AS_STRING(item_prefix)             # <<<<<<<<<<<<<<
 *         if prefix_length:
 *             memcpy(c_item_prefix, prefix, prefix_length)
 */
    __pyx_v_c_item_prefix = PyString_AS_STRING(__pyx_v_item_prefix);

    /* "bzrlib/_chk_map_pyx.pyx":386
 *             prefix_length + next_null - cur)
 *         c_item_prefix = PyString_AS_STRING(item_prefix)
 *         if prefix_length:             # <<<<<<<<<<<<<<
 *             memcpy(c_item_prefix, prefix, prefix_length)
 *         memcpy(c_item_prefix + prefix_length, cur, next_null - cur)
 */
    if (__pyx_v_prefix_length) {

      /* "bzrlib/_chk_map_pyx.pyx":387
 *         c_item_prefix = PyString_AS_STRING(item_prefix)
 *         if prefix_length:
 *             memcpy(c_item_prefix, prefix, prefix_length)             # <<<<<<<<<<<<<<
 *         memcpy(c_item_prefix + prefix_length, cur, next_null - cur)
 *         flat_key = PyString_FromStringAndSize(next_null + 1,
 */
      memcpy(__pyx_v_c_item_prefix, __pyx_v_prefix, __pyx_v_prefix_length);
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "bzrlib/_chk_map_pyx.pyx":388
 *         if prefix_length:
 *             memcpy(c_item_prefix, prefix, prefix_length)
 *         memcpy(c_item_prefix + prefix_length, cur, next_null - cur)             # <<<<<<<<<<<<<<
 *         flat_key = PyString_FromStringAndSize(next_null + 1,
 *                                               next_line - next_null - 1)
 */
    memcpy((__pyx_v_c_item_prefix + __pyx_v_prefix_length), __pyx_v_cur, (__pyx_v_next_null - __pyx_v_cur));

    /* "bzrlib/_chk_map_pyx.pyx":390
 *         memcpy(c_item_prefix + prefix_length, cur, next_null - cur)
 *         flat_key = PyString_FromStringAndSize(next_null + 1,
 *                                               next_line - next_null - 1)             # <<<<<<<<<<<<<<
 *         flat_key = StaticTuple(flat_key).intern()
 *         PyDict_SetItem(items, item_prefix, flat_key)
 */
    __pyx_t_3 = PyString_FromStringAndSize((__pyx_v_next_null + 1), ((__pyx_v_next_line - __pyx_v_next_null) - 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_flat_key);
    __pyx_v_flat_key = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":391
 *         flat_key = PyString_FromStringAndSize(next_null + 1,
 *                                               next_line - next_null - 1)
 *         flat_key = StaticTuple(flat_key).intern()             # <<<<<<<<<<<<<<
 *         PyDict_SetItem(items, item_prefix, flat_key)
 *         cur = next_line + 1
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(__pyx_v_flat_key);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_flat_key);
    __Pyx_GIVEREF(__pyx_v_flat_key);
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__intern); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_flat_key);
    __pyx_v_flat_key = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "bzrlib/_chk_map_pyx.pyx":392
 *                                               next_line - next_null - 1)
 *         flat_key = StaticTuple(flat_key).intern()
 *         PyDict_SetItem(items, item_prefix, flat_key)             # <<<<<<<<<<<<<<
 *         cur = next_line + 1
 *     assert len(items) > 0
 */
    __pyx_t_6 = PyDict_SetItem(((PyObject *)__pyx_v_items), __pyx_v_item_prefix, __pyx_v_flat_key); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "bzrlib/_chk_map_pyx.pyx":393
 *         flat_key = StaticTuple(flat_key).intern()
 *         PyDict_SetItem(items, item_prefix, flat_key)
 *         cur = next_line + 1             # <<<<<<<<<<<<<<
 *     assert len(items) > 0
 *     result._items = items
 */
    __pyx_v_cur = (__pyx_v_next_line + 1);
  }

  /* "bzrlib/_chk_map_pyx.pyx":394
 *         PyDict_SetItem(items, item_prefix, flat_key)
 *         cur = next_line + 1
 *     assert len(items) > 0             # <<<<<<<<<<<<<<
 *     result._items = items
 *     result._len = length
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(__pyx_v_items == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_7 = PyDict_Size(((PyObject *)__pyx_v_items)); 
  if (unlikely(!(__pyx_t_7 > 0))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "bzrlib/_chk_map_pyx.pyx":395
 *         cur = next_line + 1
 *     assert len(items) > 0
 *     result._items = items             # <<<<<<<<<<<<<<
 *     result._len = length
 *     result._maximum_size = maximum_size
 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___items, ((PyObject *)__pyx_v_items)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "bzrlib/_chk_map_pyx.pyx":396
 *     assert len(items) > 0
 *     result._items = items
 *     result._len = length             # <<<<<<<<<<<<<<
 *     result._maximum_size = maximum_size
 *     result._key = key
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___len, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":397
 *     result._items = items
 *     result._len = length
 *     result._maximum_size = maximum_size             # <<<<<<<<<<<<<<
 *     result._key = key
 *     result._key_width = width
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_maximum_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___maximum_size, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":398
 *     result._len = length
 *     result._maximum_size = maximum_size
 *     result._key = key             # <<<<<<<<<<<<<<
 *     result._key_width = width
 *     # XXX: InternalNodes don't really care about their size, and this will
 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___key, __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "bzrlib/_chk_map_pyx.pyx":399
 *     result._maximum_size = maximum_size
 *     result._key = key
 *     result._key_width = width             # <<<<<<<<<<<<<<
 *     # XXX: InternalNodes don't really care about their size, and this will
 *     #      change if we add prefix compression
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___key_width, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":402
 *     # XXX: InternalNodes don't really care about their size, and this will
 *     #      change if we add prefix compression
 *     result._raw_size = None # len(bytes)             # <<<<<<<<<<<<<<
 *     result._node_width = len(item_prefix)
 *     result._search_prefix = PyString_FromStringAndSize(prefix, prefix_length)
 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___raw_size, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "bzrlib/_chk_map_pyx.pyx":403
 *     #      change if we add prefix compression
 *     result._raw_size = None # len(bytes)
 *     result._node_width = len(item_prefix)             # <<<<<<<<<<<<<<
 *     result._search_prefix = PyString_FromStringAndSize(prefix, prefix_length)
 *     return result
 */
  __pyx_t_7 = PyObject_Length(__pyx_v_item_prefix); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___node_width, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":404
 *     result._raw_size = None # len(bytes)
 *     result._node_width = len(item_prefix)
 *     result._search_prefix = PyString_FromStringAndSize(prefix, prefix_length)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_prefix, __pyx_v_prefix_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n_s___search_prefix, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":405
 *     result._node_width = len(item_prefix)
 *     result._search_prefix = PyString_FromStringAndSize(prefix, prefix_length)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._deserialise_internal_node");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_result);
  __Pyx_DECREF(__pyx_v_items);
  __Pyx_DECREF(__pyx_v_item_prefix);
  __Pyx_DECREF(__pyx_v_flat_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "bzrlib/_chk_map_pyx.pyx":408
 * 
 * 
 * def _bytes_to_text_key(bytes):             # <<<<<<<<<<<<<<
 *     """Take a CHKInventory value string and return a (file_id, rev_id) tuple"""
 *     cdef StaticTuple key
 */

static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_4_bytes_to_text_key(PyObject *__pyx_self, PyObject *__pyx_v_bytes); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx_4_bytes_to_text_key[] = "Take a CHKInventory value string and return a (file_id, rev_id) tuple";
static PyMethodDef __pyx_mdef_6bzrlib_12_chk_map_pyx_4_bytes_to_text_key = {__Pyx_NAMESTR("_bytes_to_text_key"), (PyCFunction)__pyx_pf_6bzrlib_12_chk_map_pyx_4_bytes_to_text_key, METH_O, __Pyx_DOCSTR(__pyx_doc_6bzrlib_12_chk_map_pyx_4_bytes_to_text_key)};
static PyObject *__pyx_pf_6bzrlib_12_chk_map_pyx_4_bytes_to_text_key(PyObject *__pyx_self, PyObject *__pyx_v_bytes) {
  StaticTuple *__pyx_v_key;
  char *__pyx_v_byte_str;
  char *__pyx_v_cur_end;
  char *__pyx_v_file_id_str;
  char *__pyx_v_byte_end;
  char *__pyx_v_revision_str;
  Py_ssize_t __pyx_v_byte_size;
  PyObject *__pyx_v_file_id;
  PyObject *__pyx_v_revision;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("_bytes_to_text_key");
  __pyx_self = __pyx_self;
  __pyx_v_key = ((StaticTuple *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_file_id = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_revision = Py_None; __Pyx_INCREF(Py_None);

  /* "bzrlib/_chk_map_pyx.pyx":415
 *     cdef Py_ssize_t byte_size, pos, file_id_len
 * 
 *     if not PyString_CheckExact(bytes):             # <<<<<<<<<<<<<<
 *         raise TypeError('bytes must be a string, got %r' % (type(bytes),))
 *     byte_str = PyString_AS_STRING(bytes)
 */
  __pyx_t_1 = (!PyString_CheckExact(__pyx_v_bytes));
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":416
 * 
 *     if not PyString_CheckExact(bytes):
 *         raise TypeError('bytes must be a string, got %r' % (type(bytes),))             # <<<<<<<<<<<<<<
 *     byte_str = PyString_AS_STRING(bytes)
 *     byte_size = PyString_GET_SIZE(bytes)
 */
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_bytes)));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_TYPE(__pyx_v_bytes)));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_bytes)));
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_38), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__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 = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "bzrlib/_chk_map_pyx.pyx":417
 *     if not PyString_CheckExact(bytes):
 *         raise TypeError('bytes must be a string, got %r' % (type(bytes),))
 *     byte_str = PyString_AS_STRING(bytes)             # <<<<<<<<<<<<<<
 *     byte_size = PyString_GET_SIZE(bytes)
 *     byte_end = byte_str + byte_size
 */
  __pyx_v_byte_str = PyString_AS_STRING(__pyx_v_bytes);

  /* "bzrlib/_chk_map_pyx.pyx":418
 *         raise TypeError('bytes must be a string, got %r' % (type(bytes),))
 *     byte_str = PyString_AS_STRING(bytes)
 *     byte_size = PyString_GET_SIZE(bytes)             # <<<<<<<<<<<<<<
 *     byte_end = byte_str + byte_size
 *     cur_end = <char*>memchr(byte_str, c':', byte_size)
 */
  __pyx_v_byte_size = PyString_GET_SIZE(__pyx_v_bytes);

  /* "bzrlib/_chk_map_pyx.pyx":419
 *     byte_str = PyString_AS_STRING(bytes)
 *     byte_size = PyString_GET_SIZE(bytes)
 *     byte_end = byte_str + byte_size             # <<<<<<<<<<<<<<
 *     cur_end = <char*>memchr(byte_str, c':', byte_size)
 *     if cur_end == NULL:
 */
  __pyx_v_byte_end = (__pyx_v_byte_str + __pyx_v_byte_size);

  /* "bzrlib/_chk_map_pyx.pyx":420
 *     byte_size = PyString_GET_SIZE(bytes)
 *     byte_end = byte_str + byte_size
 *     cur_end = <char*>memchr(byte_str, c':', byte_size)             # <<<<<<<<<<<<<<
 *     if cur_end == NULL:
 *         raise ValueError('No kind section found.')
 */
  __pyx_v_cur_end = ((char *)memchr(__pyx_v_byte_str, ':', __pyx_v_byte_size));

  /* "bzrlib/_chk_map_pyx.pyx":421
 *     byte_end = byte_str + byte_size
 *     cur_end = <char*>memchr(byte_str, c':', byte_size)
 *     if cur_end == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('No kind section found.')
 *     if cur_end[1] != c' ':
 */
  __pyx_t_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":422
 *     cur_end = <char*>memchr(byte_str, c':', byte_size)
 *     if cur_end == NULL:
 *         raise ValueError('No kind section found.')             # <<<<<<<<<<<<<<
 *     if cur_end[1] != c' ':
 *         raise ValueError(
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __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[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "bzrlib/_chk_map_pyx.pyx":423
 *     if cur_end == NULL:
 *         raise ValueError('No kind section found.')
 *     if cur_end[1] != c' ':             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             'Kind section should end with ": ", got %r' % str(cur_end[:2],))
 */
  __pyx_t_1 = ((__pyx_v_cur_end[1]) != ' ');
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":425
 *     if cur_end[1] != c' ':
 *         raise ValueError(
 *             'Kind section should end with ": ", got %r' % str(cur_end[:2],))             # <<<<<<<<<<<<<<
 *     file_id_str = cur_end + 2
 *     # file_id is now the data up until the next newline
 */
    __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_cur_end + 0, 2 - 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_41), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __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 = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__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 = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "bzrlib/_chk_map_pyx.pyx":426
 *         raise ValueError(
 *             'Kind section should end with ": ", got %r' % str(cur_end[:2],))
 *     file_id_str = cur_end + 2             # <<<<<<<<<<<<<<
 *     # file_id is now the data up until the next newline
 *     cur_end = <char*>memchr(file_id_str, c'\n', byte_end - file_id_str)
 */
  __pyx_v_file_id_str = (__pyx_v_cur_end + 2);

  /* "bzrlib/_chk_map_pyx.pyx":428
 *     file_id_str = cur_end + 2
 *     # file_id is now the data up until the next newline
 *     cur_end = <char*>memchr(file_id_str, c'\n', byte_end - file_id_str)             # <<<<<<<<<<<<<<
 *     if cur_end == NULL:
 *         raise ValueError('no newline after file-id')
 */
  __pyx_v_cur_end = ((char *)memchr(__pyx_v_file_id_str, '\n', (__pyx_v_byte_end - __pyx_v_file_id_str)));

  /* "bzrlib/_chk_map_pyx.pyx":429
 *     # file_id is now the data up until the next newline
 *     cur_end = <char*>memchr(file_id_str, c'\n', byte_end - file_id_str)
 *     if cur_end == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('no newline after file-id')
 *     file_id = safe_interned_string_from_size(file_id_str,
 */
  __pyx_t_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":430
 *     cur_end = <char*>memchr(file_id_str, c'\n', byte_end - file_id_str)
 *     if cur_end == NULL:
 *         raise ValueError('no newline after file-id')             # <<<<<<<<<<<<<<
 *     file_id = safe_interned_string_from_size(file_id_str,
 *                                              cur_end - file_id_str)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "bzrlib/_chk_map_pyx.pyx":432
 *         raise ValueError('no newline after file-id')
 *     file_id = safe_interned_string_from_size(file_id_str,
 *                                              cur_end - file_id_str)             # <<<<<<<<<<<<<<
 *     # this is the end of the parent_str
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 */
  __pyx_t_2 = __pyx_f_6bzrlib_12_chk_map_pyx_safe_interned_string_from_size(__pyx_v_file_id_str, (__pyx_v_cur_end - __pyx_v_file_id_str)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_v_file_id);
  __pyx_v_file_id = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":434
 *                                              cur_end - file_id_str)
 *     # this is the end of the parent_str
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)             # <<<<<<<<<<<<<<
 *     if cur_end == NULL:
 *         raise ValueError('no newline after parent_str')
 */
  __pyx_v_cur_end = ((char *)memchr((__pyx_v_cur_end + 1), '\n', ((__pyx_v_byte_end - __pyx_v_cur_end) - 1)));

  /* "bzrlib/_chk_map_pyx.pyx":435
 *     # this is the end of the parent_str
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('no newline after parent_str')
 *     # end of the name str
 */
  __pyx_t_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":436
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:
 *         raise ValueError('no newline after parent_str')             # <<<<<<<<<<<<<<
 *     # end of the name str
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "bzrlib/_chk_map_pyx.pyx":438
 *         raise ValueError('no newline after parent_str')
 *     # end of the name str
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)             # <<<<<<<<<<<<<<
 *     if cur_end == NULL:
 *         raise ValueError('no newline after name str')
 */
  __pyx_v_cur_end = ((char *)memchr((__pyx_v_cur_end + 1), '\n', ((__pyx_v_byte_end - __pyx_v_cur_end) - 1)));

  /* "bzrlib/_chk_map_pyx.pyx":439
 *     # end of the name str
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:             # <<<<<<<<<<<<<<
 *         raise ValueError('no newline after name str')
 *     # the next section is the revision info
 */
  __pyx_t_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":440
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:
 *         raise ValueError('no newline after name str')             # <<<<<<<<<<<<<<
 *     # the next section is the revision info
 *     revision_str = cur_end + 1
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "bzrlib/_chk_map_pyx.pyx":442
 *         raise ValueError('no newline after name str')
 *     # the next section is the revision info
 *     revision_str = cur_end + 1             # <<<<<<<<<<<<<<
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:
 */
  __pyx_v_revision_str = (__pyx_v_cur_end + 1);

  /* "bzrlib/_chk_map_pyx.pyx":443
 *     # the next section is the revision info
 *     revision_str = cur_end + 1
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)             # <<<<<<<<<<<<<<
 *     if cur_end == NULL:
 *         # This is probably a dir: entry, which has revision as the last item
 */
  __pyx_v_cur_end = ((char *)memchr((__pyx_v_cur_end + 1), '\n', ((__pyx_v_byte_end - __pyx_v_cur_end) - 1)));

  /* "bzrlib/_chk_map_pyx.pyx":444
 *     revision_str = cur_end + 1
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:             # <<<<<<<<<<<<<<
 *         # This is probably a dir: entry, which has revision as the last item
 *         cur_end = byte_end
 */
  __pyx_t_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_t_1) {

    /* "bzrlib/_chk_map_pyx.pyx":446
 *     if cur_end == NULL:
 *         # This is probably a dir: entry, which has revision as the last item
 *         cur_end = byte_end             # <<<<<<<<<<<<<<
 *     revision = safe_interned_string_from_size(revision_str,
 *         cur_end - revision_str)
 */
    __pyx_v_cur_end = __pyx_v_byte_end;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "bzrlib/_chk_map_pyx.pyx":448
 *         cur_end = byte_end
 *     revision = safe_interned_string_from_size(revision_str,
 *         cur_end - revision_str)             # <<<<<<<<<<<<<<
 *     key = StaticTuple_New(2)
 *     Py_INCREF(file_id)
 */
  __pyx_t_2 = __pyx_f_6bzrlib_12_chk_map_pyx_safe_interned_string_from_size(__pyx_v_revision_str, (__pyx_v_cur_end - __pyx_v_revision_str)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_v_revision);
  __pyx_v_revision = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":449
 *     revision = safe_interned_string_from_size(revision_str,
 *         cur_end - revision_str)
 *     key = StaticTuple_New(2)             # <<<<<<<<<<<<<<
 *     Py_INCREF(file_id)
 *     StaticTuple_SET_ITEM(key, 0, file_id)
 */
  __pyx_t_2 = ((PyObject *)StaticTuple_New(2)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_v_key));
  __pyx_v_key = ((StaticTuple *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":450
 *         cur_end - revision_str)
 *     key = StaticTuple_New(2)
 *     Py_INCREF(file_id)             # <<<<<<<<<<<<<<
 *     StaticTuple_SET_ITEM(key, 0, file_id)
 *     Py_INCREF(revision)
 */
  Py_INCREF(__pyx_v_file_id);

  /* "bzrlib/_chk_map_pyx.pyx":451
 *     key = StaticTuple_New(2)
 *     Py_INCREF(file_id)
 *     StaticTuple_SET_ITEM(key, 0, file_id)             # <<<<<<<<<<<<<<
 *     Py_INCREF(revision)
 *     StaticTuple_SET_ITEM(key, 1, revision)
 */
  StaticTuple_SET_ITEM(__pyx_v_key, 0, __pyx_v_file_id);

  /* "bzrlib/_chk_map_pyx.pyx":452
 *     Py_INCREF(file_id)
 *     StaticTuple_SET_ITEM(key, 0, file_id)
 *     Py_INCREF(revision)             # <<<<<<<<<<<<<<
 *     StaticTuple_SET_ITEM(key, 1, revision)
 *     return StaticTuple_Intern(key)
 */
  Py_INCREF(__pyx_v_revision);

  /* "bzrlib/_chk_map_pyx.pyx":453
 *     StaticTuple_SET_ITEM(key, 0, file_id)
 *     Py_INCREF(revision)
 *     StaticTuple_SET_ITEM(key, 1, revision)             # <<<<<<<<<<<<<<
 *     return StaticTuple_Intern(key)
 */
  StaticTuple_SET_ITEM(__pyx_v_key, 1, __pyx_v_revision);

  /* "bzrlib/_chk_map_pyx.pyx":454
 *     Py_INCREF(revision)
 *     StaticTuple_SET_ITEM(key, 1, revision)
 *     return StaticTuple_Intern(key)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)StaticTuple_Intern(__pyx_v_key)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._bytes_to_text_key");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_key);
  __Pyx_DECREF(__pyx_v_file_id);
  __Pyx_DECREF(__pyx_v_revision);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_chk_map_pyx"),
    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_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__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_19, __pyx_k_19, sizeof(__pyx_k_19), 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_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_n_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
  {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
  {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
  {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
  {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0},
  {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0},
  {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
  {&__pyx_n_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 1},
  {&__pyx_n_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 1},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_n_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 1},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_n_s__AssertionError, __pyx_k__AssertionError, sizeof(__pyx_k__AssertionError), 0, 0, 1, 1},
  {&__pyx_n_s__InternalNode, __pyx_k__InternalNode, sizeof(__pyx_k__InternalNode), 0, 0, 1, 1},
  {&__pyx_n_s__LeafNode, __pyx_k__LeafNode, sizeof(__pyx_k__LeafNode), 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____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___bytes_to_text_key, __pyx_k___bytes_to_text_key, sizeof(__pyx_k___bytes_to_text_key), 0, 0, 1, 1},
  {&__pyx_n_s___current_size, __pyx_k___current_size, sizeof(__pyx_k___current_size), 0, 0, 1, 1},
  {&__pyx_n_s___items, __pyx_k___items, sizeof(__pyx_k___items), 0, 0, 1, 1},
  {&__pyx_n_s___key, __pyx_k___key, sizeof(__pyx_k___key), 0, 0, 1, 1},
  {&__pyx_n_s___key_width, __pyx_k___key_width, sizeof(__pyx_k___key_width), 0, 0, 1, 1},
  {&__pyx_n_s___len, __pyx_k___len, sizeof(__pyx_k___len), 0, 0, 1, 1},
  {&__pyx_n_s___maximum_size, __pyx_k___maximum_size, sizeof(__pyx_k___maximum_size), 0, 0, 1, 1},
  {&__pyx_n_s___node_width, __pyx_k___node_width, sizeof(__pyx_k___node_width), 0, 0, 1, 1},
  {&__pyx_n_s___raw_size, __pyx_k___raw_size, sizeof(__pyx_k___raw_size), 0, 0, 1, 1},
  {&__pyx_n_s___search_key_16, __pyx_k___search_key_16, sizeof(__pyx_k___search_key_16), 0, 0, 1, 1},
  {&__pyx_n_s___search_key_255, __pyx_k___search_key_255, sizeof(__pyx_k___search_key_255), 0, 0, 1, 1},
  {&__pyx_n_s___search_prefix, __pyx_k___search_prefix, sizeof(__pyx_k___search_prefix), 0, 0, 1, 1},
  {&__pyx_n_s___unknown, __pyx_k___unknown, sizeof(__pyx_k___unknown), 0, 0, 1, 1},
  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  {&__pyx_n_s__bytes, __pyx_k__bytes, sizeof(__pyx_k__bytes), 0, 0, 1, 1},
  {&__pyx_n_s__bzrlib, __pyx_k__bzrlib, sizeof(__pyx_k__bzrlib), 0, 0, 1, 1},
  {&__pyx_n_s__chk_map, __pyx_k__chk_map, sizeof(__pyx_k__chk_map), 0, 0, 1, 1},
  {&__pyx_n_s__crc32, __pyx_k__crc32, sizeof(__pyx_k__crc32), 0, 0, 1, 1},
  {&__pyx_n_s__intern, __pyx_k__intern, sizeof(__pyx_k__intern), 0, 0, 1, 1},
  {&__pyx_n_s__key, __pyx_k__key, sizeof(__pyx_k__key), 0, 0, 1, 1},
  {&__pyx_n_s__search_key_func, __pyx_k__search_key_func, sizeof(__pyx_k__search_key_func), 0, 0, 1, 1},
  {&__pyx_n_s__zlib, __pyx_k__zlib, sizeof(__pyx_k__zlib), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_AssertionError = __Pyx_GetName(__pyx_b, __pyx_n_s__AssertionError); if (!__pyx_builtin_AssertionError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __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[0]; __pyx_lineno = 169; __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 = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

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

  /* "bzrlib/_chk_map_pyx.pyx":219
 *         raise ValueError("not a serialised leaf node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 *         raise ValueError("bytes does not end in a newline")             # <<<<<<<<<<<<<<
 * 
 *     end = c_bytes + c_bytes_len
 */
  __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __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));

  /* "bzrlib/_chk_map_pyx.pyx":229
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')             # <<<<<<<<<<<<<<
 *     prefix = cur
 *     prefix_length = next_line - cur
 */
  __pyx_k_tuple_11 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __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));

  /* "bzrlib/_chk_map_pyx.pyx":247
 * 
 *     if num_prefix_bits >= width:
 *         raise ValueError('Prefix has too many nulls versus width')             # <<<<<<<<<<<<<<
 * 
 *     items_length = end - cur
 */
  __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __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));

  /* "bzrlib/_chk_map_pyx.pyx":255
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 *         if next_line == NULL:
 *             raise ValueError('null line\n')             # <<<<<<<<<<<<<<
 *         last_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if last_null == NULL:
 */
  __pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __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));

  /* "bzrlib/_chk_map_pyx.pyx":258
 *         last_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if last_null == NULL:
 *             raise ValueError('fail to find the num value lines null')             # <<<<<<<<<<<<<<
 *         next_null = last_null + 1 # move past NULL
 *         num_value_lines = _get_int_from_line(&next_null, next_line + 1,
 */
  __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __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));

  /* "bzrlib/_chk_map_pyx.pyx":268
 *             next_line = <char *>memchr(cur, c'\n', end - cur)
 *             if next_line == NULL:
 *                 raise ValueError('missing trailing newline')             # <<<<<<<<<<<<<<
 *             cur = next_line + 1
 *         entry_bits = StaticTuple_New(width)
 */
  __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_20));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
  PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20));

  /* "bzrlib/_chk_map_pyx.pyx":285
 *                                    last_null - entry_start + 1)
 *         if next_null == NULL:
 *             raise ValueError('bad no null, bad')             # <<<<<<<<<<<<<<
 *         entry = PyString_FromStringAndSize(NULL,
 *                     prefix_tail_len + next_null - line_start)
 */
  __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __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));

  /* "bzrlib/_chk_map_pyx.pyx":299
 *             i = i + 1
 *             if i > width:
 *                 raise ValueError("Too many bits for entry")             # <<<<<<<<<<<<<<
 *             entry_start = next_null + 1
 *             next_null = <char *>memchr(entry_start, c'\0',
 */
  __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_24));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
  PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));

  /* "bzrlib/_chk_map_pyx.pyx":304
 *                                        last_null - entry_start + 1)
 *             if next_null == NULL:
 *                 raise ValueError('bad no null')             # <<<<<<<<<<<<<<
 *             entry = PyString_FromStringAndSize(entry_start,
 *                                                next_null - entry_start)
 */
  __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_26));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
  PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26));

  /* "bzrlib/_chk_map_pyx.pyx":359
 *         raise ValueError("not a serialised internal node: %r" % bytes)
 *     if c_bytes[c_bytes_len - 1] != c'\n':
 *         raise ValueError("bytes does not end in a newline")             # <<<<<<<<<<<<<<
 * 
 *     items = {}
 */
  __pyx_k_tuple_34 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_34));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34));

  /* "bzrlib/_chk_map_pyx.pyx":370
 *     next_line = <char *>memchr(cur, c'\n', end - cur)
 *     if next_line == NULL:
 *         raise ValueError('Missing the prefix line\n')             # <<<<<<<<<<<<<<
 *     prefix = cur
 *     prefix_length = next_line - cur
 */
  __pyx_k_tuple_35 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_35));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
  PyTuple_SET_ITEM(__pyx_k_tuple_35, 0, ((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35));

  /* "bzrlib/_chk_map_pyx.pyx":379
 *         next_line = <char *>memchr(cur, c'\n', end - cur)
 *         if next_line == NULL:
 *             raise ValueError('missing trailing newline')             # <<<<<<<<<<<<<<
 *         next_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if next_null == NULL:
 */
  __pyx_k_tuple_36 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_36));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
  PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, ((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36));

  /* "bzrlib/_chk_map_pyx.pyx":382
 *         next_null = <char *>_my_memrchr(cur, c'\0', next_line - cur)
 *         if next_null == NULL:
 *             raise ValueError('bad no null')             # <<<<<<<<<<<<<<
 *         item_prefix = PyString_FromStringAndSize(NULL,
 *             prefix_length + next_null - cur)
 */
  __pyx_k_tuple_37 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_37));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
  PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, ((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37));

  /* "bzrlib/_chk_map_pyx.pyx":422
 *     cur_end = <char*>memchr(byte_str, c':', byte_size)
 *     if cur_end == NULL:
 *         raise ValueError('No kind section found.')             # <<<<<<<<<<<<<<
 *     if cur_end[1] != c' ':
 *         raise ValueError(
 */
  __pyx_k_tuple_40 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_40));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_39));
  PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_kp_s_39));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_39));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40));

  /* "bzrlib/_chk_map_pyx.pyx":430
 *     cur_end = <char*>memchr(file_id_str, c'\n', byte_end - file_id_str)
 *     if cur_end == NULL:
 *         raise ValueError('no newline after file-id')             # <<<<<<<<<<<<<<
 *     file_id = safe_interned_string_from_size(file_id_str,
 *                                              cur_end - file_id_str)
 */
  __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_43));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_42));
  PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_42));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43));

  /* "bzrlib/_chk_map_pyx.pyx":436
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:
 *         raise ValueError('no newline after parent_str')             # <<<<<<<<<<<<<<
 *     # end of the name str
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 */
  __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_45));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_44));
  PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_s_44));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_44));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45));

  /* "bzrlib/_chk_map_pyx.pyx":440
 *     cur_end = <char*>memchr(cur_end + 1, c'\n', byte_end - cur_end - 1)
 *     if cur_end == NULL:
 *         raise ValueError('no newline after name str')             # <<<<<<<<<<<<<<
 *     # the next section is the revision info
 *     revision_str = cur_end + 1
 */
  __pyx_k_tuple_47 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_47));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_46));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_kp_s_46));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_46));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
  __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[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_chk_map_pyx(void); /*proto*/
PyMODINIT_FUNC init_chk_map_pyx(void)
#else
PyMODINIT_FUNC PyInit__chk_map_pyx(void); /*proto*/
PyMODINIT_FUNC PyInit__chk_map_pyx(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  #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__chk_map_pyx(void)", __LINE__, __FILE__);
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __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[0]; __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[0]; __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("_chk_map_pyx"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __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[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_bzrlib___chk_map_pyx) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_6bzrlib_12_chk_map_pyx_crc32 = Py_None; Py_INCREF(Py_None);
  __pyx_v_6bzrlib_12_chk_map_pyx__LeafNode = Py_None; Py_INCREF(Py_None);
  __pyx_v_6bzrlib_12_chk_map_pyx__InternalNode = Py_None; Py_INCREF(Py_None);
  __pyx_v_6bzrlib_12_chk_map_pyx__unknown = Py_None; Py_INCREF(Py_None);
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  /*--- Type import code ---*/
  __pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = __Pyx_ImportType("bzrlib._static_tuple_c", "StaticTuple", sizeof(StaticTuple), 0); if (unlikely(!__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "bzrlib/_chk_map_pyx.pyx":57
 * 
 * cdef object crc32
 * from zlib import crc32             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__crc32));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__crc32));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__crc32));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__zlib), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __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__crc32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_6bzrlib_12_chk_map_pyx_crc32);
  __Pyx_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx_crc32);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_6bzrlib_12_chk_map_pyx_crc32 = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":61
 * 
 * # Set up the StaticTuple C_API functionality
 * import_static_tuple_c()             # <<<<<<<<<<<<<<
 * 
 * cdef object _LeafNode
 */
  __pyx_t_3 = import_static_tuple_c(); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "bzrlib/_chk_map_pyx.pyx":64
 * 
 * cdef object _LeafNode
 * _LeafNode = None             # <<<<<<<<<<<<<<
 * cdef object _InternalNode
 * _InternalNode = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GOTREF(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode);
  __Pyx_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode);
  __Pyx_GIVEREF(Py_None);
  __pyx_v_6bzrlib_12_chk_map_pyx__LeafNode = Py_None;

  /* "bzrlib/_chk_map_pyx.pyx":66
 * _LeafNode = None
 * cdef object _InternalNode
 * _InternalNode = None             # <<<<<<<<<<<<<<
 * cdef object _unknown
 * _unknown = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GOTREF(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode);
  __Pyx_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode);
  __Pyx_GIVEREF(Py_None);
  __pyx_v_6bzrlib_12_chk_map_pyx__InternalNode = Py_None;

  /* "bzrlib/_chk_map_pyx.pyx":68
 * _InternalNode = None
 * cdef object _unknown
 * _unknown = None             # <<<<<<<<<<<<<<
 * 
 * # We shouldn't just copy this from _dirstate_helpers_pyx
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GOTREF(__pyx_v_6bzrlib_12_chk_map_pyx__unknown);
  __Pyx_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__unknown);
  __Pyx_GIVEREF(Py_None);
  __pyx_v_6bzrlib_12_chk_map_pyx__unknown = Py_None;

  /* "bzrlib/_chk_map_pyx.pyx":100
 * 
 * 
 * def _search_key_16(key):             # <<<<<<<<<<<<<<
 *     """See chk_map._search_key_16."""
 *     cdef Py_ssize_t num_bits
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_12_chk_map_pyx__search_key_16, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___search_key_16, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":125
 * 
 * 
 * def _search_key_255(key):             # <<<<<<<<<<<<<<
 *     """See chk_map._search_key_255."""
 *     cdef Py_ssize_t num_bits
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_12_chk_map_pyx_1_search_key_255, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___search_key_255, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":188
 * 
 * 
 * def _deserialise_leaf_node(bytes, key, search_key_func=None):             # <<<<<<<<<<<<<<
 *     """Deserialise bytes, with key key, into a LeafNode.
 * 
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_12_chk_map_pyx_2_deserialise_leaf_node, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_49, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":337
 * 
 * 
 * def _deserialise_internal_node(bytes, key, search_key_func=None):             # <<<<<<<<<<<<<<
 *     cdef char *c_bytes, *cur, *next, *end
 *     cdef char *next_line
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_12_chk_map_pyx_3_deserialise_internal_node, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_50, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":408
 * 
 * 
 * def _bytes_to_text_key(bytes):             # <<<<<<<<<<<<<<
 *     """Take a CHKInventory value string and return a (file_id, rev_id) tuple"""
 *     cdef StaticTuple key
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_6bzrlib_12_chk_map_pyx_4_bytes_to_text_key, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___bytes_to_text_key, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "bzrlib/_chk_map_pyx.pyx":1
 * # Copyright (C) 2009, 2010 Canonical Ltd             # <<<<<<<<<<<<<<
 * #
 * # This program is free software; you can redistribute it and/or modify
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    __Pyx_AddTraceback("init bzrlib._chk_map_pyx");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init bzrlib._chk_map_pyx");
  }
  __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 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 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 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 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 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;
    }
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        PyErr_Warn(NULL, warning);
        #else
        PyErr_WarnEx(NULL, warning, 0);
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#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 */
