/* Generated by Pyrex 0.9.8.5 on Thu Nov 25 16:59:30 2010 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#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 PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#include "python-compat.h"
#include "_static_tuple_c.h"


typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;

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

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/

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

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/

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

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

/* Declarations from bzrlib._static_tuple_c */

static PyTypeObject *__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = 0;

/* Declarations from bzrlib._chk_map_pyx */


/* Declarations from implementation of bzrlib._chk_map_pyx */

static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx_crc32;
static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode;
static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode;
static PyObject *__pyx_v_6bzrlib_12_chk_map_pyx__unknown;
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*/

static char __pyx_k1[] = "tried to create a string with an invalid size: %d @0x%x";
static char __pyx_k2[] = "%08X";
static char __pyx_k3[] = "Missing %s line\n";
static char __pyx_k4[] = "%s line not a proper int\n";
static char __pyx_k5[] = "bzrlib";
static char __pyx_k6[] = "chk_map";
static char __pyx_k7[] = "LeafNode";
static char __pyx_k8[] = "InternalNode";
static char __pyx_k9[] = "_unknown";
static char __pyx_k10[] = "search_key_func";
static char __pyx_k11[] = "bytes must be a plain string not %s";
static char __pyx_k12[] = "chkleaf:\n";
static char __pyx_k13[] = "not a serialised leaf node: %r";
static char __pyx_k14[] = "bytes does not end in a newline";
static char __pyx_k15[] = "maximum_size";
static char __pyx_k16[] = "width";
static char __pyx_k17[] = "length";
static char __pyx_k18[] = "Missing the prefix line\n";
static char __pyx_k19[] = "append";
static char __pyx_k20[] = "Prefix has too many nulls versus width";
static char __pyx_k21[] = "null line\n";
static char __pyx_k22[] = "fail to find the num value lines null";
static char __pyx_k23[] = "num value lines";
static char __pyx_k24[] = "missing trailing newline";
static char __pyx_k25[] = "bad no null, bad";
static char __pyx_k26[] = "Too many bits for entry";
static char __pyx_k27[] = "bad no null";
static char __pyx_k28[] = "Incorrect number of elements (%d vs %d)";
static char __pyx_k29[] = "item count (%d) mismatch for key %s, bytes %r";
static char __pyx_k30[] = "_items";
static char __pyx_k31[] = "_len";
static char __pyx_k32[] = "_maximum_size";
static char __pyx_k33[] = "_key";
static char __pyx_k34[] = "_key_width";
static char __pyx_k35[] = "_raw_size";
static char __pyx_k36[] = "_search_prefix";
static char __pyx_k37[] = "_common_serialised_prefix";
static char __pyx_k38[] = "_current_size";
static char __pyx_k39[] = "_current_size computed incorrectly %d != %d";
static char __pyx_k40[] = "key %r is not a StaticTuple";
static char __pyx_k41[] = "chknode:\n";
static char __pyx_k42[] = "not a serialised internal node: %r";
static char __pyx_k43[] = "intern";
static char __pyx_k44[] = "_node_width";
static char __pyx_k45[] = "bytes must be a string";
static char __pyx_k46[] = "No kind section found.";
static char __pyx_k47[] = "Kind section should end with \": \"";
static char __pyx_k48[] = "no newline after file-id";
static char __pyx_k49[] = "no newline after parent_str";
static char __pyx_k50[] = "no newline after name str";
static char __pyx_k51[] = "zlib";
static char __pyx_k52[] = "crc32";

static PyObject *__pyx_n_InternalNode;
static PyObject *__pyx_n_LeafNode;
static PyObject *__pyx_n__common_serialised_prefix;
static PyObject *__pyx_n__current_size;
static PyObject *__pyx_n__items;
static PyObject *__pyx_n__key;
static PyObject *__pyx_n__key_width;
static PyObject *__pyx_n__len;
static PyObject *__pyx_n__maximum_size;
static PyObject *__pyx_n__node_width;
static PyObject *__pyx_n__raw_size;
static PyObject *__pyx_n__search_prefix;
static PyObject *__pyx_n__unknown;
static PyObject *__pyx_n_append;
static PyObject *__pyx_n_bzrlib;
static PyObject *__pyx_n_chk_map;
static PyObject *__pyx_n_crc32;
static PyObject *__pyx_n_intern;
static PyObject *__pyx_n_search_key_func;
static PyObject *__pyx_n_zlib;

static PyObject *__pyx_k1p;
static PyObject *__pyx_k3p;
static PyObject *__pyx_k4p;
static PyObject *__pyx_k11p;
static PyObject *__pyx_k13p;
static PyObject *__pyx_k14p;
static PyObject *__pyx_k18p;
static PyObject *__pyx_k20p;
static PyObject *__pyx_k21p;
static PyObject *__pyx_k22p;
static PyObject *__pyx_k24p;
static PyObject *__pyx_k25p;
static PyObject *__pyx_k26p;
static PyObject *__pyx_k27p;
static PyObject *__pyx_k28p;
static PyObject *__pyx_k29p;
static PyObject *__pyx_k39p;
static PyObject *__pyx_k40p;
static PyObject *__pyx_k42p;
static PyObject *__pyx_k45p;
static PyObject *__pyx_k46p;
static PyObject *__pyx_k47p;
static PyObject *__pyx_k48p;
static PyObject *__pyx_k49p;
static PyObject *__pyx_k50p;

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_InternalNode, 1, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_n_LeafNode, 1, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_n__common_serialised_prefix, 1, __pyx_k37, sizeof(__pyx_k37)},
  {&__pyx_n__current_size, 1, __pyx_k38, sizeof(__pyx_k38)},
  {&__pyx_n__items, 1, __pyx_k30, sizeof(__pyx_k30)},
  {&__pyx_n__key, 1, __pyx_k33, sizeof(__pyx_k33)},
  {&__pyx_n__key_width, 1, __pyx_k34, sizeof(__pyx_k34)},
  {&__pyx_n__len, 1, __pyx_k31, sizeof(__pyx_k31)},
  {&__pyx_n__maximum_size, 1, __pyx_k32, sizeof(__pyx_k32)},
  {&__pyx_n__node_width, 1, __pyx_k44, sizeof(__pyx_k44)},
  {&__pyx_n__raw_size, 1, __pyx_k35, sizeof(__pyx_k35)},
  {&__pyx_n__search_prefix, 1, __pyx_k36, sizeof(__pyx_k36)},
  {&__pyx_n__unknown, 1, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_n_append, 1, __pyx_k19, sizeof(__pyx_k19)},
  {&__pyx_n_bzrlib, 1, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_n_chk_map, 1, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_n_crc32, 1, __pyx_k52, sizeof(__pyx_k52)},
  {&__pyx_n_intern, 1, __pyx_k43, sizeof(__pyx_k43)},
  {&__pyx_n_search_key_func, 1, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_n_zlib, 1, __pyx_k51, sizeof(__pyx_k51)},
  {&__pyx_k1p, 0, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_k3p, 0, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_k4p, 0, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_k11p, 0, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_k13p, 0, __pyx_k13, sizeof(__pyx_k13)},
  {&__pyx_k14p, 0, __pyx_k14, sizeof(__pyx_k14)},
  {&__pyx_k18p, 0, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_k20p, 0, __pyx_k20, sizeof(__pyx_k20)},
  {&__pyx_k21p, 0, __pyx_k21, sizeof(__pyx_k21)},
  {&__pyx_k22p, 0, __pyx_k22, sizeof(__pyx_k22)},
  {&__pyx_k24p, 0, __pyx_k24, sizeof(__pyx_k24)},
  {&__pyx_k25p, 0, __pyx_k25, sizeof(__pyx_k25)},
  {&__pyx_k26p, 0, __pyx_k26, sizeof(__pyx_k26)},
  {&__pyx_k27p, 0, __pyx_k27, sizeof(__pyx_k27)},
  {&__pyx_k28p, 0, __pyx_k28, sizeof(__pyx_k28)},
  {&__pyx_k29p, 0, __pyx_k29, sizeof(__pyx_k29)},
  {&__pyx_k39p, 0, __pyx_k39, sizeof(__pyx_k39)},
  {&__pyx_k40p, 0, __pyx_k40, sizeof(__pyx_k40)},
  {&__pyx_k42p, 0, __pyx_k42, sizeof(__pyx_k42)},
  {&__pyx_k45p, 0, __pyx_k45, sizeof(__pyx_k45)},
  {&__pyx_k46p, 0, __pyx_k46, sizeof(__pyx_k46)},
  {&__pyx_k47p, 0, __pyx_k47, sizeof(__pyx_k47)},
  {&__pyx_k48p, 0, __pyx_k48, sizeof(__pyx_k48)},
  {&__pyx_k49p, 0, __pyx_k49, sizeof(__pyx_k49)},
  {&__pyx_k50p, 0, __pyx_k50, sizeof(__pyx_k50)},
  {0, 0, 0, 0}
};

static PyObject *__pyx_d1;
static PyObject *__pyx_d2;


/* Implementation of bzrlib._chk_map_pyx */

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_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":76 */
  __pyx_v_start = ((char *)__pyx_v_s);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":77 */
  __pyx_v_pos = ((__pyx_v_start + __pyx_v_n) - 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":78 */
  while (1) {
    __pyx_1 = (__pyx_v_pos >= __pyx_v_start);
    if (!__pyx_1) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":79 */
    __pyx_1 = ((__pyx_v_pos[0]) == __pyx_v_c);
    if (__pyx_1) {
      __pyx_r = __pyx_v_pos;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":81 */
    __pyx_v_pos = (__pyx_v_pos - 1);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":82 */
  __pyx_r = NULL;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  __pyx_v_result = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":87 */
  __pyx_1 = (__pyx_v_size < 0);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromSsize_t(__pyx_v_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(((int)__pyx_v_s)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k1p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_4 = PyObject_CallObject(PyExc_AssertionError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":91 */
  __pyx_v_py_str = PyString_FromStringAndSize(__pyx_v_s,__pyx_v_size);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":92 */
  PyString_InternInPlace((&__pyx_v_py_str));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":93 */
  Py_INCREF(((PyObject *)__pyx_v_py_str));
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = ((PyObject *)__pyx_v_py_str);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":96 */
  Py_DECREF(__pyx_v_py_str);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":97 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx.safe_interned_string_from_size");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__search_key_16(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx__search_key_16[] = "See chk_map._search_key_16.";
static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__search_key_16(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  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;
  Py_ssize_t __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"key",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_key)) return 0;
  Py_INCREF(__pyx_v_key);
  __pyx_v_out = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":109 */
  __pyx_1 = PyObject_Length(__pyx_v_key); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; goto __pyx_L1;}
  __pyx_v_num_bits = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":111 */
  __pyx_v_num_out_bytes = ((9 * __pyx_v_num_bits) - 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":112 */
  __pyx_2 = PyString_FromStringAndSize(NULL,__pyx_v_num_out_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; goto __pyx_L1;}
  Py_DECREF(__pyx_v_out);
  __pyx_v_out = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":113 */
  __pyx_v_c_out = PyString_AS_STRING(__pyx_v_out);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":114 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_bits; ++__pyx_v_i) {

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":115 */
    __pyx_3 = (__pyx_v_i > 0);
    if (__pyx_3) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":116 */
      (__pyx_v_c_out[0]) = '\x000';

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":117 */
      __pyx_v_c_out = (__pyx_v_c_out + 1);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":118 */
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_key, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_v_6bzrlib_12_chk_map_pyx_crc32, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_crc_val = PyInt_AS_LONG(__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":120 */
    sprintf(__pyx_v_c_out,__pyx_k2,__pyx_v_crc_val);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":121 */
    __pyx_v_c_out = (__pyx_v_c_out + 8);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":122 */
  Py_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._search_key_16");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_out);
  Py_DECREF(__pyx_v_key);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__search_key_255(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx__search_key_255[] = "See chk_map._search_key_255.";
static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__search_key_255(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_key = 0;
  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;
  Py_ssize_t __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"key",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_key)) return 0;
  Py_INCREF(__pyx_v_key);
  __pyx_v_out = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":134 */
  __pyx_1 = PyObject_Length(__pyx_v_key); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;}
  __pyx_v_num_bits = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":136 */
  __pyx_v_num_out_bytes = ((5 * __pyx_v_num_bits) - 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":137 */
  __pyx_2 = PyString_FromStringAndSize(NULL,__pyx_v_num_out_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; goto __pyx_L1;}
  Py_DECREF(__pyx_v_out);
  __pyx_v_out = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":138 */
  __pyx_v_c_out = PyString_AS_STRING(__pyx_v_out);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":139 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_bits; ++__pyx_v_i) {

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":140 */
    __pyx_3 = (__pyx_v_i > 0);
    if (__pyx_3) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":141 */
      (__pyx_v_c_out[0]) = '\x000';

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":142 */
      __pyx_v_c_out = (__pyx_v_c_out + 1);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":143 */
    __pyx_2 = __Pyx_GetItemInt(__pyx_v_key, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_v_6bzrlib_12_chk_map_pyx_crc32, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_crc_val = PyInt_AS_LONG(__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":145 */
    (__pyx_v_c_out[0]) = ((__pyx_v_crc_val >> 24) & 0xFF);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":146 */
    (__pyx_v_c_out[1]) = ((__pyx_v_crc_val >> 16) & 0xFF);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":147 */
    (__pyx_v_c_out[2]) = ((__pyx_v_crc_val >> 8) & 0xFF);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":148 */
    (__pyx_v_c_out[3]) = ((__pyx_v_crc_val >> 0) & 0xFF);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":149 */
    for (__pyx_v_j = 0; __pyx_v_j < 4; ++__pyx_v_j) {
      __pyx_3 = ((__pyx_v_c_out[__pyx_v_j]) == '\n');
      if (__pyx_3) {
        (__pyx_v_c_out[__pyx_v_j]) = '_';
        goto __pyx_L7;
      }
      __pyx_L7:;
    }

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":152 */
    __pyx_v_c_out = (__pyx_v_c_out + 4);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":153 */
  Py_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._search_key_255");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_out);
  Py_DECREF(__pyx_v_key);
  return __pyx_r;
}

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_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":167 */
  __pyx_v_next_line = ((char *)memchr((__pyx_v_cur[0]),'\n',(__pyx_v_end - (__pyx_v_cur[0]))));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":168 */
  __pyx_1 = (__pyx_v_next_line == NULL);
  if (__pyx_1) {
    __pyx_2 = PyString_FromString(__pyx_v_message); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k3p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":171 */
  __pyx_v_value = strtol((__pyx_v_cur[0]),(&__pyx_v_next),10);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":172 */
  __pyx_1 = (__pyx_v_next != __pyx_v_next_line);
  if (__pyx_1) {
    __pyx_2 = PyString_FromString(__pyx_v_message); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k4p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":174 */
  (__pyx_v_cur[0]) = (__pyx_v_next_line + 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":175 */
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._get_int_from_line");
  __pyx_r = (-1);
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__import_globals(void) {
  PyObject *__pyx_v_chk_map;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_v_chk_map = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":182 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  Py_INCREF(__pyx_n_chk_map);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_chk_map);
  __pyx_2 = __Pyx_Import(__pyx_n_bzrlib, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_chk_map); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;}
  Py_DECREF(__pyx_v_chk_map);
  __pyx_v_chk_map = __pyx_1;
  __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":183 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_chk_map, __pyx_n_LeafNode); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;}
  Py_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode);
  __pyx_v_6bzrlib_12_chk_map_pyx__LeafNode = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":184 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_chk_map, __pyx_n_InternalNode); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L1;}
  Py_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode);
  __pyx_v_6bzrlib_12_chk_map_pyx__InternalNode = __pyx_1;
  __pyx_1 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":185 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_chk_map, __pyx_n__unknown); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; goto __pyx_L1;}
  Py_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__unknown);
  __pyx_v_6bzrlib_12_chk_map_pyx__unknown = __pyx_2;
  __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._import_globals");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_chk_map);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__deserialise_leaf_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx__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 PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5;
  static char *__pyx_argnames[] = {"bytes","key","search_key_func",0};
  __pyx_v_search_key_func = __pyx_d1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_bytes, &__pyx_v_key, &__pyx_v_search_key_func)) return 0;
  Py_INCREF(__pyx_v_bytes);
  Py_INCREF(__pyx_v_key);
  Py_INCREF(__pyx_v_search_key_func);
  __pyx_v_entry_bits = ((StaticTuple *)Py_None); Py_INCREF(Py_None);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  __pyx_v_prefix_bits = Py_None; Py_INCREF(Py_None);
  __pyx_v_items = Py_None; Py_INCREF(Py_None);
  __pyx_v_entry = Py_None; Py_INCREF(Py_None);
  __pyx_v_value = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":204 */
  __pyx_1 = __pyx_v_6bzrlib_12_chk_map_pyx__LeafNode == Py_None;
  if (__pyx_1) {
    __pyx_2 = __pyx_f_6bzrlib_12_chk_map_pyx__import_globals(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":207 */
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
  __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
  if (PyDict_SetItem(__pyx_3, __pyx_n_search_key_func, __pyx_v_search_key_func) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
  __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_4;
  __pyx_4 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":210 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_bytes));
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
    Py_INCREF(__pyx_v_bytes);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_bytes);
    __pyx_3 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k11p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_4 = PyObject_CallObject(PyExc_TypeError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":213 */
  __pyx_v_c_bytes = PyString_AS_STRING(__pyx_v_bytes);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":214 */
  __pyx_v_c_bytes_len = PyString_GET_SIZE(__pyx_v_bytes);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":216 */
  __pyx_1 = (__pyx_v_c_bytes_len < 9);
  if (!__pyx_1) {
    __pyx_1 = (memcmp(__pyx_v_c_bytes,__pyx_k12,9) != 0);
  }
  if (__pyx_1) {
    __pyx_2 = PyNumber_Remainder(__pyx_k13p, __pyx_v_bytes); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":218 */
  __pyx_1 = ((__pyx_v_c_bytes[(__pyx_v_c_bytes_len - 1)]) != '\n');
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;}
    Py_INCREF(__pyx_k14p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k14p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":221 */
  __pyx_v_end = (__pyx_v_c_bytes + __pyx_v_c_bytes_len);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":222 */
  __pyx_v_cur = (__pyx_v_c_bytes + 9);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":223 */
  __pyx_1 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur),__pyx_v_end,__pyx_k15); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; goto __pyx_L1;}
  __pyx_v_maximum_size = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":224 */
  __pyx_1 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur),__pyx_v_end,__pyx_k16); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; goto __pyx_L1;}
  __pyx_v_width = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":225 */
  __pyx_1 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur),__pyx_v_end,__pyx_k17); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; goto __pyx_L1;}
  __pyx_v_length = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":227 */
  __pyx_v_next_line = ((char *)memchr(__pyx_v_cur,'\n',(__pyx_v_end - __pyx_v_cur)));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":228 */
  __pyx_1 = (__pyx_v_next_line == NULL);
  if (__pyx_1) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}
    Py_INCREF(__pyx_k18p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k18p);
    __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; goto __pyx_L1;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":230 */
  __pyx_v_prefix = __pyx_v_cur;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":231 */
  __pyx_v_prefix_length = (__pyx_v_next_line - __pyx_v_cur);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":232 */
  __pyx_v_cur = (__pyx_v_next_line + 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":234 */
  __pyx_3 = PyList_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; goto __pyx_L1;}
  Py_DECREF(__pyx_v_prefix_bits);
  __pyx_v_prefix_bits = __pyx_3;
  __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":235 */
  __pyx_v_prefix_tail = __pyx_v_prefix;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":236 */
  __pyx_v_num_prefix_bits = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":237 */
  __pyx_v_next_null = ((char *)memchr(__pyx_v_prefix,'\0',__pyx_v_prefix_length));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":238 */
  while (1) {
    __pyx_1 = (__pyx_v_next_null != NULL);
    if (!__pyx_1) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":239 */
    __pyx_v_num_prefix_bits = (__pyx_v_num_prefix_bits + 1);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":240 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_prefix_bits, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;}
    __pyx_2 = PyString_FromStringAndSize(__pyx_v_prefix_tail,(__pyx_v_next_null - __pyx_v_prefix_tail)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":242 */
    __pyx_v_prefix_tail = (__pyx_v_next_null + 1);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":243 */
    __pyx_v_next_null = ((char *)memchr(__pyx_v_prefix_tail,'\0',(__pyx_v_next_line - __pyx_v_prefix_tail)));
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":244 */
  __pyx_v_prefix_tail_len = (__pyx_v_next_line - __pyx_v_prefix_tail);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":246 */
  __pyx_1 = (__pyx_v_num_prefix_bits >= __pyx_v_width);
  if (__pyx_1) {
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
    Py_INCREF(__pyx_k20p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k20p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; goto __pyx_L1;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":249 */
  __pyx_v_items_length = (__pyx_v_end - __pyx_v_cur);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":250 */
  __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; goto __pyx_L1;}
  Py_DECREF(__pyx_v_items);
  __pyx_v_items = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":251 */
  while (1) {
    __pyx_1 = (__pyx_v_cur < __pyx_v_end);
    if (!__pyx_1) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":252 */
    __pyx_v_line_start = __pyx_v_cur;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":253 */
    __pyx_v_next_line = ((char *)memchr(__pyx_v_cur,'\n',(__pyx_v_end - __pyx_v_cur)));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":254 */
    __pyx_1 = (__pyx_v_next_line == NULL);
    if (__pyx_1) {
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
      Py_INCREF(__pyx_k21p);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k21p);
      __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; goto __pyx_L1;}
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":256 */
    __pyx_v_last_null = ((char *)__pyx_f_6bzrlib_12_chk_map_pyx__my_memrchr(__pyx_v_cur,'\0',(__pyx_v_next_line - __pyx_v_cur)));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":257 */
    __pyx_1 = (__pyx_v_last_null == NULL);
    if (__pyx_1) {
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;}
      Py_INCREF(__pyx_k22p);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k22p);
      __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; goto __pyx_L1;}
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":259 */
    __pyx_v_next_null = (__pyx_v_last_null + 1);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":260 */
    __pyx_1 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_next_null),(__pyx_v_next_line + 1),__pyx_k23); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; goto __pyx_L1;}
    __pyx_v_num_value_lines = __pyx_1;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":262 */
    __pyx_v_cur = (__pyx_v_next_line + 1);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":263 */
    __pyx_v_value_start = __pyx_v_cur;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":265 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_value_lines; ++__pyx_v_i) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":266 */
      __pyx_v_next_line = ((char *)memchr(__pyx_v_cur,'\n',(__pyx_v_end - __pyx_v_cur)));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":267 */
      __pyx_1 = (__pyx_v_next_line == NULL);
      if (__pyx_1) {
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;}
        Py_INCREF(__pyx_k24p);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k24p);
        __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __Pyx_Raise(__pyx_2, 0, 0);
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; goto __pyx_L1;}
        goto __pyx_L16;
      }
      __pyx_L16:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":269 */
      __pyx_v_cur = (__pyx_v_next_line + 1);
    }

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":270 */
    __pyx_4 = ((PyObject *)StaticTuple_New(__pyx_v_width)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_entry_bits));
    __pyx_v_entry_bits = ((StaticTuple *)__pyx_4);
    __pyx_4 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":271 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_num_prefix_bits; ++__pyx_v_i) {

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":274 */
      __pyx_3 = __Pyx_GetItemInt(__pyx_v_prefix_bits, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; goto __pyx_L1;}
      Py_DECREF(__pyx_v_entry);
      __pyx_v_entry = __pyx_3;
      __pyx_3 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":276 */
      Py_INCREF(__pyx_v_entry);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":277 */
      StaticTuple_SET_ITEM(__pyx_v_entry_bits,__pyx_v_i,__pyx_v_entry);
    }

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":278 */
    __pyx_2 = PyString_FromStringAndSize(__pyx_v_value_start,(__pyx_v_next_line - __pyx_v_value_start)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; goto __pyx_L1;}
    Py_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_2;
    __pyx_2 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":281 */
    __pyx_v_entry_start = __pyx_v_line_start;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":282 */
    __pyx_v_next_null = ((char *)memchr(__pyx_v_entry_start,'\0',((__pyx_v_last_null - __pyx_v_entry_start) + 1)));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":284 */
    __pyx_1 = (__pyx_v_next_null == NULL);
    if (__pyx_1) {
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;}
      Py_INCREF(__pyx_k25p);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k25p);
      __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; goto __pyx_L1;}
      goto __pyx_L19;
    }
    __pyx_L19:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":286 */
    __pyx_2 = PyString_FromStringAndSize(NULL,((__pyx_v_prefix_tail_len + __pyx_v_next_null) - __pyx_v_line_start)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; goto __pyx_L1;}
    Py_DECREF(__pyx_v_entry);
    __pyx_v_entry = __pyx_2;
    __pyx_2 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":288 */
    __pyx_v_c_entry = PyString_AS_STRING(__pyx_v_entry);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":289 */
    __pyx_1 = (__pyx_v_prefix_tail_len > 0);
    if (__pyx_1) {
      memcpy(__pyx_v_c_entry,__pyx_v_prefix_tail,__pyx_v_prefix_tail_len);
      goto __pyx_L20;
    }
    __pyx_L20:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":291 */
    __pyx_1 = ((__pyx_v_next_null - __pyx_v_line_start) > 0);
    if (__pyx_1) {
      memcpy((__pyx_v_c_entry + __pyx_v_prefix_tail_len),__pyx_v_line_start,(__pyx_v_next_null - __pyx_v_line_start));
      goto __pyx_L21;
    }
    __pyx_L21:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":293 */
    Py_INCREF(__pyx_v_entry);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":294 */
    __pyx_v_i = __pyx_v_num_prefix_bits;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":295 */
    StaticTuple_SET_ITEM(__pyx_v_entry_bits,__pyx_v_i,__pyx_v_entry);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":296 */
    while (1) {
      __pyx_1 = (__pyx_v_next_null != __pyx_v_last_null);
      if (!__pyx_1) break;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":297 */
      __pyx_v_i = (__pyx_v_i + 1);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":298 */
      __pyx_1 = (__pyx_v_i > __pyx_v_width);
      if (__pyx_1) {
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
        Py_INCREF(__pyx_k26p);
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k26p);
        __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __Pyx_Raise(__pyx_3, 0, 0);
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
        goto __pyx_L24;
      }
      __pyx_L24:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":300 */
      __pyx_v_entry_start = (__pyx_v_next_null + 1);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":301 */
      __pyx_v_next_null = ((char *)memchr(__pyx_v_entry_start,'\0',((__pyx_v_last_null - __pyx_v_entry_start) + 1)));

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":303 */
      __pyx_1 = (__pyx_v_next_null == NULL);
      if (__pyx_1) {
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}
        Py_INCREF(__pyx_k27p);
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k27p);
        __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __Pyx_Raise(__pyx_4, 0, 0);
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}
        goto __pyx_L25;
      }
      __pyx_L25:;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":305 */
      __pyx_3 = PyString_FromStringAndSize(__pyx_v_entry_start,(__pyx_v_next_null - __pyx_v_entry_start)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}
      Py_DECREF(__pyx_v_entry);
      __pyx_v_entry = __pyx_3;
      __pyx_3 = 0;

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":307 */
      Py_INCREF(__pyx_v_entry);

      /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":308 */
      StaticTuple_SET_ITEM(__pyx_v_entry_bits,__pyx_v_i,__pyx_v_entry);
    }

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":309 */
    __pyx_1 = (StaticTuple_GET_SIZE(__pyx_v_entry_bits) != __pyx_v_width);
    if (__pyx_1) {
      __pyx_5 = PyObject_Length(((PyObject *)__pyx_v_entry_bits)); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}
      __pyx_2 = PyInt_FromSsize_t((__pyx_5 + 1)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong((__pyx_v_width + 1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
      __pyx_2 = 0;
      __pyx_4 = 0;
      __pyx_2 = PyNumber_Remainder(__pyx_k28p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
      __pyx_2 = 0;
      __pyx_3 = PyObject_CallObject(PyExc_AssertionError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; goto __pyx_L1;}
      goto __pyx_L26;
    }
    __pyx_L26:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":313 */
    __pyx_2 = ((PyObject *)StaticTuple_Intern(__pyx_v_entry_bits)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_entry_bits));
    __pyx_v_entry_bits = ((StaticTuple *)__pyx_2);
    __pyx_2 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":314 */
    __pyx_1 = PyDict_SetItem(__pyx_v_items,((PyObject *)__pyx_v_entry_bits),__pyx_v_value); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; goto __pyx_L1;}
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":315 */
  __pyx_5 = PyObject_Length(__pyx_v_items); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;}
  __pyx_1 = (__pyx_5 != __pyx_v_length);
  if (__pyx_1) {
    __pyx_4 = PyInt_FromLong(__pyx_v_length); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
    Py_INCREF(((PyObject *)__pyx_v_entry_bits));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_entry_bits));
    Py_INCREF(__pyx_v_bytes);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_v_bytes);
    __pyx_4 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k29p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; goto __pyx_L1;}
    goto __pyx_L27;
  }
  __pyx_L27:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":318 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__items, __pyx_v_items) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":319 */
  __pyx_2 = PyInt_FromLong(__pyx_v_length); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__len, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":320 */
  __pyx_4 = PyInt_FromLong(__pyx_v_maximum_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__maximum_size, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":321 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__key, __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":322 */
  __pyx_3 = PyInt_FromLong(__pyx_v_width); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__key_width, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":323 */
  __pyx_2 = PyInt_FromSsize_t((__pyx_v_items_length + (__pyx_v_length * __pyx_v_prefix_length))); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__raw_size, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":324 */
  __pyx_1 = (__pyx_v_length == 0);
  if (__pyx_1) {

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":325 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n__search_prefix, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; goto __pyx_L1;}

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":326 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n__common_serialised_prefix, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; goto __pyx_L1;}
    goto __pyx_L28;
  }
  /*else*/ {

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":328 */
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n__search_prefix, __pyx_v_6bzrlib_12_chk_map_pyx__unknown) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; goto __pyx_L1;}

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":329 */
    __pyx_4 = PyString_FromStringAndSize(__pyx_v_prefix,__pyx_v_prefix_length); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;}
    if (PyObject_SetAttr(__pyx_v_result, __pyx_n__common_serialised_prefix, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L28:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":331 */
  __pyx_3 = PyInt_FromSsize_t(__pyx_v_c_bytes_len); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n__current_size); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyObject_Cmp(__pyx_3, __pyx_4, &__pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; goto __pyx_L1;}
  __pyx_1 = __pyx_1 != 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {
    __pyx_2 = PyInt_FromSsize_t(__pyx_v_c_bytes_len); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_v_result, __pyx_n__current_size); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}
    Py_INCREF(__pyx_k39p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k39p);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_4);
    __pyx_2 = 0;
    __pyx_4 = 0;
    __pyx_2 = PyObject_CallObject(PyExc_AssertionError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; goto __pyx_L1;}
    goto __pyx_L29;
  }
  __pyx_L29:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":334 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._deserialise_leaf_node");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_entry_bits);
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_prefix_bits);
  Py_DECREF(__pyx_v_items);
  Py_DECREF(__pyx_v_entry);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_bytes);
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_search_key_func);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__deserialise_internal_node(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_ssize_t __pyx_5;
  static char *__pyx_argnames[] = {"bytes","key","search_key_func",0};
  __pyx_v_search_key_func = __pyx_d2;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_bytes, &__pyx_v_key, &__pyx_v_search_key_func)) return 0;
  Py_INCREF(__pyx_v_bytes);
  Py_INCREF(__pyx_v_key);
  Py_INCREF(__pyx_v_search_key_func);
  __pyx_v_result = Py_None; Py_INCREF(Py_None);
  __pyx_v_items = Py_None; Py_INCREF(Py_None);
  __pyx_v_item_prefix = Py_None; Py_INCREF(Py_None);
  __pyx_v_flat_key = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":344 */
  __pyx_1 = __pyx_v_6bzrlib_12_chk_map_pyx__InternalNode == Py_None;
  if (__pyx_1) {
    __pyx_2 = __pyx_f_6bzrlib_12_chk_map_pyx__import_globals(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":346 */
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_3 = PyDict_New(); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
  if (PyDict_SetItem(__pyx_3, __pyx_n_search_key_func, __pyx_v_search_key_func) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_4 = PyEval_CallObjectWithKeywords(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode, __pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_4;
  __pyx_4 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":348 */
  __pyx_1 = (!StaticTuple_CheckExact(__pyx_v_key));
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_INCREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_key);
    __pyx_3 = PyNumber_Remainder(__pyx_k40p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_2 = PyObject_CallObject(PyExc_TypeError, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":350 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_bytes));
  if (__pyx_1) {
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_INCREF(__pyx_v_bytes);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_bytes);
    __pyx_4 = PyObject_CallObject(((PyObject *)(&PyType_Type)), __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_3 = PyNumber_Remainder(__pyx_k11p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_2 = PyObject_CallObject(PyExc_TypeError, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":353 */
  __pyx_v_c_bytes = PyString_AS_STRING(__pyx_v_bytes);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":354 */
  __pyx_v_c_bytes_len = PyString_GET_SIZE(__pyx_v_bytes);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":356 */
  __pyx_1 = (__pyx_v_c_bytes_len < 9);
  if (!__pyx_1) {
    __pyx_1 = (memcmp(__pyx_v_c_bytes,__pyx_k41,9) != 0);
  }
  if (__pyx_1) {
    __pyx_3 = PyNumber_Remainder(__pyx_k42p, __pyx_v_bytes); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":358 */
  __pyx_1 = ((__pyx_v_c_bytes[(__pyx_v_c_bytes_len - 1)]) != '\n');
  if (__pyx_1) {
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;}
    Py_INCREF(__pyx_k14p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k14p);
    __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":361 */
  __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; goto __pyx_L1;}
  Py_DECREF(__pyx_v_items);
  __pyx_v_items = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":362 */
  __pyx_v_cur = (__pyx_v_c_bytes + 9);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":363 */
  __pyx_v_end = (__pyx_v_c_bytes + __pyx_v_c_bytes_len);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":364 */
  __pyx_1 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur),__pyx_v_end,__pyx_k15); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; goto __pyx_L1;}
  __pyx_v_maximum_size = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":365 */
  __pyx_1 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur),__pyx_v_end,__pyx_k16); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; goto __pyx_L1;}
  __pyx_v_width = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":366 */
  __pyx_1 = __pyx_f_6bzrlib_12_chk_map_pyx__get_int_from_line((&__pyx_v_cur),__pyx_v_end,__pyx_k17); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
  __pyx_v_length = __pyx_1;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":368 */
  __pyx_v_next_line = ((char *)memchr(__pyx_v_cur,'\n',(__pyx_v_end - __pyx_v_cur)));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":369 */
  __pyx_1 = (__pyx_v_next_line == NULL);
  if (__pyx_1) {
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;}
    Py_INCREF(__pyx_k18p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k18p);
    __pyx_4 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":371 */
  __pyx_v_prefix = __pyx_v_cur;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":372 */
  __pyx_v_prefix_length = (__pyx_v_next_line - __pyx_v_cur);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":373 */
  __pyx_v_cur = (__pyx_v_next_line + 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":375 */
  while (1) {
    __pyx_1 = (__pyx_v_cur < __pyx_v_end);
    if (!__pyx_1) break;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":377 */
    __pyx_v_next_line = ((char *)memchr(__pyx_v_cur,'\n',(__pyx_v_end - __pyx_v_cur)));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":378 */
    __pyx_1 = (__pyx_v_next_line == NULL);
    if (__pyx_1) {
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;}
      Py_INCREF(__pyx_k24p);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k24p);
      __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;}
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":380 */
    __pyx_v_next_null = ((char *)__pyx_f_6bzrlib_12_chk_map_pyx__my_memrchr(__pyx_v_cur,'\0',(__pyx_v_next_line - __pyx_v_cur)));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":381 */
    __pyx_1 = (__pyx_v_next_null == NULL);
    if (__pyx_1) {
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
      Py_INCREF(__pyx_k27p);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k27p);
      __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __Pyx_Raise(__pyx_2, 0, 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; goto __pyx_L1;}
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":383 */
    __pyx_3 = PyString_FromStringAndSize(NULL,((__pyx_v_prefix_length + __pyx_v_next_null) - __pyx_v_cur)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;}
    Py_DECREF(__pyx_v_item_prefix);
    __pyx_v_item_prefix = __pyx_3;
    __pyx_3 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":385 */
    __pyx_v_c_item_prefix = PyString_AS_STRING(__pyx_v_item_prefix);

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":386 */
    __pyx_5 = __pyx_v_prefix_length;
    if (__pyx_5) {
      memcpy(__pyx_v_c_item_prefix,__pyx_v_prefix,__pyx_v_prefix_length);
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":388 */
    memcpy((__pyx_v_c_item_prefix + __pyx_v_prefix_length),__pyx_v_cur,(__pyx_v_next_null - __pyx_v_cur));

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":389 */
    __pyx_4 = PyString_FromStringAndSize((__pyx_v_next_null + 1),((__pyx_v_next_line - __pyx_v_next_null) - 1)); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; goto __pyx_L1;}
    Py_DECREF(__pyx_v_flat_key);
    __pyx_v_flat_key = __pyx_4;
    __pyx_4 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":391 */
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_INCREF(__pyx_v_flat_key);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_flat_key);
    __pyx_3 = PyObject_CallObject(((PyObject *)__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_intern); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_v_flat_key);
    __pyx_v_flat_key = __pyx_2;
    __pyx_2 = 0;

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":392 */
    __pyx_1 = PyDict_SetItem(__pyx_v_items,__pyx_v_item_prefix,__pyx_v_flat_key); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; goto __pyx_L1;}

    /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":393 */
    __pyx_v_cur = (__pyx_v_next_line + 1);
  }

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":394 */
  #ifndef PYREX_WITHOUT_ASSERTIONS
  __pyx_5 = PyObject_Length(__pyx_v_items); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; goto __pyx_L1;}
  if (!(__pyx_5 > 0)) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; goto __pyx_L1;}
  }
  #endif

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":395 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__items, __pyx_v_items) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":396 */
  __pyx_3 = PyInt_FromLong(__pyx_v_length); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__len, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":397 */
  __pyx_4 = PyInt_FromLong(__pyx_v_maximum_size); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__maximum_size, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":398 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__key, __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":399 */
  __pyx_2 = PyInt_FromLong(__pyx_v_width); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__key_width, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":402 */
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__raw_size, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":403 */
  __pyx_5 = PyObject_Length(__pyx_v_item_prefix); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_3 = PyInt_FromSsize_t(__pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__node_width, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":404 */
  __pyx_4 = PyString_FromStringAndSize(__pyx_v_prefix,__pyx_v_prefix_length); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_v_result, __pyx_n__search_prefix, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":405 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._deserialise_internal_node");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF(__pyx_v_items);
  Py_DECREF(__pyx_v_item_prefix);
  Py_DECREF(__pyx_v_flat_key);
  Py_DECREF(__pyx_v_bytes);
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_search_key_func);
  return __pyx_r;
}

static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__bytes_to_text_key(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_6bzrlib_12_chk_map_pyx__bytes_to_text_key[] = "Take a CHKInventory value string and return a (file_id, rev_id) tuple";
static PyObject *__pyx_f_6bzrlib_12_chk_map_pyx__bytes_to_text_key(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bytes = 0;
  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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"bytes",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_bytes)) return 0;
  Py_INCREF(__pyx_v_bytes);
  __pyx_v_key = ((StaticTuple *)Py_None); Py_INCREF(Py_None);
  __pyx_v_file_id = Py_None; Py_INCREF(Py_None);
  __pyx_v_revision = Py_None; Py_INCREF(Py_None);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":415 */
  __pyx_1 = (!PyString_CheckExact(__pyx_v_bytes));
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;}
    Py_INCREF(__pyx_k45p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k45p);
    __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":417 */
  __pyx_v_byte_str = PyString_AS_STRING(__pyx_v_bytes);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":418 */
  __pyx_v_byte_size = PyString_GET_SIZE(__pyx_v_bytes);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":419 */
  __pyx_v_byte_end = (__pyx_v_byte_str + __pyx_v_byte_size);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":420 */
  __pyx_v_cur_end = ((char *)memchr(__pyx_v_byte_str,':',__pyx_v_byte_size));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":421 */
  __pyx_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}
    Py_INCREF(__pyx_k46p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k46p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":423 */
  __pyx_1 = ((__pyx_v_cur_end[1]) != ' ');
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;}
    Py_INCREF(__pyx_k47p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k47p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":425 */
  __pyx_v_file_id_str = (__pyx_v_cur_end + 2);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":427 */
  __pyx_v_cur_end = ((char *)memchr(__pyx_v_file_id_str,'\n',(__pyx_v_byte_end - __pyx_v_file_id_str)));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":428 */
  __pyx_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;}
    Py_INCREF(__pyx_k48p);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k48p);
    __pyx_3 = PyObject_CallObject(PyExc_ValueError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":430 */
  __pyx_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 (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; goto __pyx_L1;}
  Py_DECREF(__pyx_v_file_id);
  __pyx_v_file_id = __pyx_2;
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":433 */
  __pyx_v_cur_end = ((char *)memchr((__pyx_v_cur_end + 1),'\n',((__pyx_v_byte_end - __pyx_v_cur_end) - 1)));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":434 */
  __pyx_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_1) {
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;}
    Py_INCREF(__pyx_k49p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k49p);
    __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; goto __pyx_L1;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":437 */
  __pyx_v_cur_end = ((char *)memchr((__pyx_v_cur_end + 1),'\n',((__pyx_v_byte_end - __pyx_v_cur_end) - 1)));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":438 */
  __pyx_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_1) {
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}
    Py_INCREF(__pyx_k50p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k50p);
    __pyx_2 = PyObject_CallObject(PyExc_ValueError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":441 */
  __pyx_v_revision_str = (__pyx_v_cur_end + 1);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":442 */
  __pyx_v_cur_end = ((char *)memchr((__pyx_v_cur_end + 1),'\n',((__pyx_v_byte_end - __pyx_v_cur_end) - 1)));

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":443 */
  __pyx_1 = (__pyx_v_cur_end == NULL);
  if (__pyx_1) {
    __pyx_v_cur_end = __pyx_v_byte_end;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":446 */
  __pyx_3 = __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 (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;}
  Py_DECREF(__pyx_v_revision);
  __pyx_v_revision = __pyx_3;
  __pyx_3 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":448 */
  __pyx_2 = ((PyObject *)StaticTuple_New(2)); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_key));
  __pyx_v_key = ((StaticTuple *)__pyx_2);
  __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":449 */
  Py_INCREF(__pyx_v_file_id);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":450 */
  StaticTuple_SET_ITEM(__pyx_v_key,0,__pyx_v_file_id);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":451 */
  Py_INCREF(__pyx_v_revision);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":452 */
  StaticTuple_SET_ITEM(__pyx_v_key,1,__pyx_v_revision);

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":453 */
  __pyx_3 = ((PyObject *)StaticTuple_Intern(__pyx_v_key)); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; goto __pyx_L1;}
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx._bytes_to_text_key");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_file_id);
  Py_DECREF(__pyx_v_revision);
  Py_DECREF(__pyx_v_bytes);
  return __pyx_r;
}

static struct PyMethodDef __pyx_methods[] = {
  {"_search_key_16", (PyCFunction)__pyx_f_6bzrlib_12_chk_map_pyx__search_key_16, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_12_chk_map_pyx__search_key_16},
  {"_search_key_255", (PyCFunction)__pyx_f_6bzrlib_12_chk_map_pyx__search_key_255, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_12_chk_map_pyx__search_key_255},
  {"_deserialise_leaf_node", (PyCFunction)__pyx_f_6bzrlib_12_chk_map_pyx__deserialise_leaf_node, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_12_chk_map_pyx__deserialise_leaf_node},
  {"_deserialise_internal_node", (PyCFunction)__pyx_f_6bzrlib_12_chk_map_pyx__deserialise_internal_node, METH_VARARGS|METH_KEYWORDS, 0},
  {"_bytes_to_text_key", (PyCFunction)__pyx_f_6bzrlib_12_chk_map_pyx__bytes_to_text_key, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6bzrlib_12_chk_map_pyx__bytes_to_text_key},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_chk_map_pyx(void); /*proto*/
PyMODINIT_FUNC init_chk_map_pyx(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_chk_map_pyx", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; goto __pyx_L1;};
  __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);
  __pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple = __Pyx_ImportType("bzrlib._static_tuple_c", "StaticTuple", sizeof(StaticTuple)); if (!__pyx_ptype_6bzrlib_15_static_tuple_c_StaticTuple) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":57 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_INCREF(__pyx_n_crc32);
  PyList_SET_ITEM(__pyx_1, 0, __pyx_n_crc32);
  __pyx_2 = __Pyx_Import(__pyx_n_zlib, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_crc32); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx_crc32);
  __pyx_v_6bzrlib_12_chk_map_pyx_crc32 = __pyx_1;
  __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":61 */
  __pyx_3 = import_static_tuple_c(); if (__pyx_3 == (-1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; goto __pyx_L1;}

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":64 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__LeafNode);
  __pyx_v_6bzrlib_12_chk_map_pyx__LeafNode = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":66 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__InternalNode);
  __pyx_v_6bzrlib_12_chk_map_pyx__InternalNode = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":68 */
  Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_6bzrlib_12_chk_map_pyx__unknown);
  __pyx_v_6bzrlib_12_chk_map_pyx__unknown = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":188 */
  Py_INCREF(Py_None);
  __pyx_d1 = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":337 */
  Py_INCREF(Py_None);
  __pyx_d2 = Py_None;

  /* "/home/vila/src/bzr/releases/prepare-2.2.2/bzrlib/_chk_map_pyx.pyx":408 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("bzrlib._chk_map_pyx");
}

static char *__pyx_filenames[] = {
  "_chk_map_pyx.pyx",
  "_static_tuple_c.pxd",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

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 {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) type->ob_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
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i) {
    PyTypeObject *t = o->ob_type;
    PyObject *r;
    if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
        r = PySequence_GetItem(o, i);
    else {
        PyObject *j = PyInt_FromLong(i);
        if (!j)
            return 0;
        r = PyObject_GetItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__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_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        if (t->i)
            PyString_InternInPlace(t->p);
        ++t;
    }
    return 0;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, 
    long size) 
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    result = PyObject_GetAttrString(py_module, class_name);
    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 (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s does not appear to be the correct type object",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(char *name) {
    PyObject *py_name = 0;
    
    py_name = PyString_FromString(name);
    if (!py_name)
        goto bad;
    return PyImport_Import(py_name);
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

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

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*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(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
