/* Generated by Cython 0.23.4 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
    #error Cython requires Python 2.6+ or Python 3.2+.
#else
#define CYTHON_ABI "0_23_4"
#include <stddef.h>
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
#define CYTHON_USE_PYLONG_INTERNALS 1
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
#define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if PY_VERSION_HEX >= 0x030500B1
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
typedef struct {
    unaryfunc am_await;
    unaryfunc am_aiter;
    unaryfunc am_anext;
} __Pyx_PyAsyncMethodsStruct;
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
#else
#define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)

#ifndef __cplusplus
  #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
  #define CYTHON_INLINE inline
#endif
template<typename T>
void __Pyx_call_destructor(T& x) {
    x.~T();
}
template<typename T>
class __Pyx_FakeReference {
  public:
    __Pyx_FakeReference() : ptr(NULL) { }
    __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
    T *operator->() { return ptr; }
    operator T&() { return *ptr; }
  private:
    T *ptr;
};

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif


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

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

#define __PYX_HAVE__kstreamc
#define __PYX_HAVE_API__kstreamc
#include <utility>
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include <unordered_map>
#include <vector>
#include "string.h"
#include "stdio.h"
#include "pythread.h"
#include "stddef.h"
#include "windows.h"
#include "winsock.h"
#include "evntcons.h"
#include "evntrace.h"
#include "tdh.h"
#include "wchar.h"
#include <string>
#include "python.h"
#include "stdlib.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
    #define __Pyx_sst_abs(value) _abs64(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "kstream\\kstreamc.pyx",
  "kstream\\includes\\python.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_8kstreamc_KEventStreamCollector;
struct __pyx_t_7kstream_7process_PROCESS_INFO;

/* "kstream\process.pxd":19
 * from kstream.includes.windows cimport UCHAR, ULONG, wchar_t
 * 
 * cdef struct PROCESS_INFO:             # <<<<<<<<<<<<<<
 *     # process identifier
 *     ULONG pid
 */
struct __pyx_t_7kstream_7process_PROCESS_INFO {
  ULONG pid;
  ULONG ppid;
  wchar_t *name;
};

/* "kstreamc.pyx":40
 * 
 * 
 * cdef enum:             # <<<<<<<<<<<<<<
 *     GUID_LENGTH = 36
 *     INVALID_PID = 4294967295
 */
enum  {
  __pyx_e_8kstreamc_GUID_LENGTH = 36,
  __pyx_e_8kstreamc_INVALID_PID = 0xFFFFFFFF
};

/* "kstreamc.pyx":62
 * 
 * 
 * cdef class KEventStreamCollector:             # <<<<<<<<<<<<<<
 *     """Kernel event stream collector.
 * 
 */
struct __pyx_obj_8kstreamc_KEventStreamCollector {
  PyObject_HEAD
  struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *__pyx_vtab;
  EVENT_TRACE_LOGFILE ktrace;
  TRACEHANDLE handle;
  int pointer_size;
  std::vector<PyObject *>  *ktuple_filters;
  std::vector<wchar_t *>  *skips;
  std::unordered_map<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO>  *proc_map;
  ULONG pid_filter;
  wchar_t *image_filter;
  ULONG own_pid;
  PyObject *next_kevt_callback;
  PyObject *on_kstream_open_callback;
  PyObject *klogger;
  PyObject *regex;
};



struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector {
  PyObject *(*process_kevent_callback)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, EVENT_RECORD *);
  void (*_process_kevent)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, EVENT_RECORD *);
  PyObject *(*_decref)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, PyObject *);
  PyObject *(*_decref_params)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, std::unordered_map<std::wstring,PyObject *> );
  PyObject *(*_underscore)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, PyObject *);
  PyObject *(*__pyx___parse_property)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, USHORT, USHORT, BYTE *);
  BOOL (*__pyx___apply_filters)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG, ULONG, PyObject *, std::unordered_map<std::wstring,PyObject *> , BOOL);
  BOOL (*__pyx___apply_skips)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG);
  BOOL (*__pyx___apply_prop_filters)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, std::unordered_map<std::wstring,PyObject *> );
  BOOL (*__pyx___apply_image_filter)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG);
  PyObject *(*__pyx___wrap_ktuple)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, GUID, UCHAR);
  BOOL (*__pyx___ktuple_equals)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *__pyx_vtabptr_8kstreamc_KEventStreamCollector;
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_skips(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG);
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_prop_filters(struct __pyx_obj_8kstreamc_KEventStreamCollector *, std::unordered_map<std::wstring,PyObject *> );
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_image_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG);
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(struct __pyx_obj_8kstreamc_KEventStreamCollector *, PyObject *, PyObject *);

/* --- Runtime support code (head) --- */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name);

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

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

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

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

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

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

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE int __Pyx_IterFinish(void);

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

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

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

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

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

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

#ifndef __Pyx_CppExn2PyErr
#include <new>
#include <typeinfo>
#include <stdexcept>
#include <ios>
static void __Pyx_CppExn2PyErr() {
  try {
    if (PyErr_Occurred())
      ; // let the latest Python exn pass through and ignore the current one
    else
      throw;
  } catch (const std::bad_alloc& exn) {
    PyErr_SetString(PyExc_MemoryError, exn.what());
  } catch (const std::bad_cast& exn) {
    PyErr_SetString(PyExc_TypeError, exn.what());
  } catch (const std::domain_error& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::invalid_argument& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::ios_base::failure& exn) {
    PyErr_SetString(PyExc_IOError, exn.what());
  } catch (const std::out_of_range& exn) {
    PyErr_SetString(PyExc_IndexError, exn.what());
  } catch (const std::overflow_error& exn) {
    PyErr_SetString(PyExc_OverflowError, exn.what());
  } catch (const std::range_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::underflow_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::exception& exn) {
    PyErr_SetString(PyExc_RuntimeError, exn.what());
  }
  catch (...)
  {
    PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
  }
}
#endif

static CYTHON_INLINE ULONG __Pyx_PyInt_As_ULONG(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_ULONG(ULONG value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

static CYTHON_INLINE UCHAR __Pyx_PyInt_As_UCHAR(PyObject *);

static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void); /* proto */

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_BOOL(BOOL value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_WORD(WORD value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_UCHAR(UCHAR value);

static int __Pyx_Print(PyObject*, PyObject *, int);
#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
static PyObject* __pyx_print = 0;
static PyObject* __pyx_print_kwargs = 0;
#endif

static int __Pyx_PrintOne(PyObject* stream, PyObject *o);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

static int __Pyx_check_binary_version(void);

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyObject *__Pyx_ImportModule(const char *name);

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector_process_kevent_callback(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, EVENT_RECORD *__pyx_v_kevent_trace); /* proto*/
static void __pyx_f_8kstreamc_21KEventStreamCollector__process_kevent(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, EVENT_RECORD *__pyx_v_kevent_trace); /* proto*/
static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector__decref(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_o); /* proto*/
static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector__decref_params(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, std::unordered_map<std::wstring,PyObject *>  __pyx_v_params); /* proto*/
static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector__underscore(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_o); /* proto*/
static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector___parse_property(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, USHORT __pyx_v_in_type, USHORT __pyx_v_out_type, BYTE *__pyx_v_buf); /* proto*/
static BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_filters(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, ULONG __pyx_v_pid, CYTHON_UNUSED ULONG __pyx_v_tid, PyObject *__pyx_v_ktuple, std::unordered_map<std::wstring,PyObject *>  __pyx_v_params, BOOL __pyx_v_defer); /* proto*/
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_skips(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, ULONG __pyx_v_pid); /* proto*/
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_prop_filters(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, std::unordered_map<std::wstring,PyObject *>  __pyx_v_params); /* proto*/
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_image_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, ULONG __pyx_v_pid); /* proto*/
static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector___wrap_ktuple(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, GUID __pyx_v_guid, UCHAR __pyx_v_opcode); /* proto*/
static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_k1, PyObject *__pyx_v_k2); /* proto*/

/* Module declarations from 'libcpp.utility' */

/* Module declarations from 'libcpp.unordered_map' */

/* Module declarations from 'libcpp.vector' */

/* Module declarations from 'cpython.version' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'libc.stddef' */

/* Module declarations from 'kstream.includes.windows' */

/* Module declarations from 'kstream.includes.etw' */

/* Module declarations from 'kstream.includes.tdh' */

/* Module declarations from 'kstream.includes.string' */

/* Module declarations from 'kstream.includes.python' */
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__unicode(wchar_t *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__ansi(char *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__unicodec(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__ansic(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i8(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u8(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u8_hex(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i16_hex(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i64_hex(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i64(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u64(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i32(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i32_hex(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u32(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i16(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u16(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__float(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__double(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__ntohs(void *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__wstring(std::wstring); /*proto*/
static CYTHON_INLINE wchar_t *__pyx_f_7kstream_8includes_6python__wchar_t(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python_ip_addr(void *); /*proto*/
static CYTHON_INLINE std::wstring __pyx_f_7kstream_8includes_6python_deref_prop(PyObject *); /*proto*/

/* Module declarations from 'kstream.includes.stdlib' */

/* Module declarations from 'kstream.time' */
static CYTHON_INLINE SYSTEMTIME __pyx_f_7kstream_4time_sys_time(LARGE_INTEGER); /*proto*/

/* Module declarations from 'kstream.ktuple' */
static CYTHON_INLINE PyObject *__pyx_f_7kstream_6ktuple_build_ktuple(PyObject *, UCHAR); /*proto*/

/* Module declarations from 'kstream.process' */

/* Module declarations from 'kstreamc' */
static PyTypeObject *__pyx_ptype_8kstreamc_KEventStreamCollector = 0;
static PyObject *__pyx_v_8kstreamc_ENUM_PROCESS;
static PyObject *__pyx_v_8kstreamc_ENUM_THREAD;
static PyObject *__pyx_v_8kstreamc_ENUM_IMAGE;
static PyObject *__pyx_v_8kstreamc_REG_CREATE_KCB;
static PyObject *__pyx_v_8kstreamc_REG_DELETE_KCB;
static PyObject *__pyx_v_8kstreamc_CREATE_PROCESS;
static PyObject *__pyx_v_8kstreamc_TERMINATE_PROCESS;
static std::wstring __pyx_v_8kstreamc_PID_PROP;
static std::wstring __pyx_v_8kstreamc_PPID_PROP;
static std::wstring __pyx_v_8kstreamc_PROCESS_ID_PROP;
static std::wstring __pyx_v_8kstreamc_IMAGE_FILE_NAME_PROP;
#define __Pyx_MODULE_NAME "kstreamc"
int __pyx_module_is_main_kstreamc = 0;

/* Implementation of 'kstreamc' */
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_KeyboardInterrupt;
static char __pyx_k_1[] = "_\\1";
static char __pyx_k_K[] = "K";
static char __pyx_k_L[] = "L";
static char __pyx_k_b[] = "b";
static char __pyx_k_d[] = "d";
static char __pyx_k_f[] = "f";
static char __pyx_k_h[] = "h";
static char __pyx_k_i[] = "i";
static char __pyx_k_k[] = "k";
static char __pyx_k_s[] = "s";
static char __pyx_k_u[] = "u";
static char __pyx_k_os[] = "os";
static char __pyx_k_re[] = "re";
static char __pyx_k_02x[] = "%02x";
static char __pyx_k_PID[] = "PID";
static char __pyx_k_end[] = "end";
static char __pyx_k_sub[] = "sub";
static char __pyx_k_0x_x[] = "0x%x";
static char __pyx_k_file[] = "file";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_lower[] = "lower";
static char __pyx_k_print[] = "print";
static char __pyx_k_getpid[] = "getpid";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_compile[] = "compile";
static char __pyx_k_klogger[] = "klogger";
static char __pyx_k_FS_KGUID[] = "FS_KGUID";
static char __pyx_k_ParentId[] = "ParentId";
static char __pyx_k_Exception[] = "Exception";
static char __pyx_k_ProcessId[] = "ProcessId";
static char __pyx_k_print_exc[] = "print_exc";
static char __pyx_k_thread_id[] = "thread_id";
static char __pyx_k_traceback[] = "traceback";
static char __pyx_k_process_id[] = "process_id";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_ImageFileName[] = "ImageFileName";
static char __pyx_k_close_kstream[] = "close_kstream";
static char __pyx_k_REGISTRY_KGUID[] = "REGISTRY_KGUID";
static char __pyx_k_KeyboardInterrupt[] = "KeyboardInterrupt";
static char __pyx_k_d_d_d_d_02d_02d_d[] = "%d-%d-%d %d:%02d:%02d.%d";
static char __pyx_k_a_z0_9_A_Z_A_Z_a_z[] = "((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))";
static char __pyx_k_2cb15d1d_5fc1_11d2_abe1_00a0c91[] = "{2cb15d1d-5fc1-11d2-abe1-00a0c911f518}";
static char __pyx_k_3d6fa8d0_fe05_11d0_9dda_00c04fd[] = "{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}";
static char __pyx_k_3d6fa8d1_fe05_11d0_9dda_00c04fd[] = "{3d6fa8d1-fe05-11d0-9dda-00c04fd7ba7c}";
static char __pyx_k_90cbdc39_4a3e_11d1_84f4_0000f80[] = "{90cbdc39-4a3e-11d1-84f4-0000f80464e3}";
static char __pyx_k_ae53722e_c863_11d2_8659_00c04fa[] = "{ae53722e-c863-11d2-8659-00c04fa321a1}";
static char __pyx_k_ERROR_Unable_to_open_kernel_even[] = "ERROR - Unable to open kernel event stream. Error %s";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_2cb15d1d_5fc1_11d2_abe1_00a0c91;
static PyObject *__pyx_kp_s_3d6fa8d0_fe05_11d0_9dda_00c04fd;
static PyObject *__pyx_kp_s_3d6fa8d1_fe05_11d0_9dda_00c04fd;
static PyObject *__pyx_kp_s_90cbdc39_4a3e_11d1_84f4_0000f80;
static PyObject *__pyx_kp_s_ERROR_Unable_to_open_kernel_even;
static PyObject *__pyx_n_s_Exception;
static PyObject *__pyx_n_s_FS_KGUID;
static PyObject *__pyx_n_s_ImageFileName;
static PyObject *__pyx_n_s_KeyboardInterrupt;
static PyObject *__pyx_n_s_PID;
static PyObject *__pyx_n_s_ParentId;
static PyObject *__pyx_n_s_ProcessId;
static PyObject *__pyx_n_s_REGISTRY_KGUID;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_s_a_z0_9_A_Z_A_Z_a_z;
static PyObject *__pyx_kp_s_ae53722e_c863_11d2_8659_00c04fa;
static PyObject *__pyx_n_s_close_kstream;
static PyObject *__pyx_n_s_compile;
static PyObject *__pyx_kp_s_d_d_d_d_02d_02d_d;
static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_file;
static PyObject *__pyx_n_s_getpid;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_klogger;
static PyObject *__pyx_n_s_lower;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_os;
static PyObject *__pyx_n_s_print;
static PyObject *__pyx_n_s_print_exc;
static PyObject *__pyx_n_s_process_id;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_re;
static PyObject *__pyx_n_s_sub;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_thread_id;
static PyObject *__pyx_n_s_traceback;
static int __pyx_pf_8kstreamc_21KEventStreamCollector___init__(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_klogger); /* proto */
static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_2open_kstream(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_4close_kstream(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_6set_kstream_open_callback(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_8add_skip(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_skip); /* proto */
static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_10add_ktuple_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_ktuple); /* proto */
static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_12add_pid_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_pid); /* proto */
static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_14add_image_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_image); /* proto */
static PyObject *__pyx_tp_new_8kstreamc_KEventStreamCollector(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_slice__2;

/* "kstreamc.pyx":104
 *     cdef regex
 * 
 *     def __init__(self, klogger):             # <<<<<<<<<<<<<<
 *         self.klogger = klogger
 *         self.handle = 0
 */

/* Python wrapper */
static int __pyx_pw_8kstreamc_21KEventStreamCollector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8kstreamc_21KEventStreamCollector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_klogger = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_klogger,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_klogger)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_klogger = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector___init__(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self), __pyx_v_klogger);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8kstreamc_21KEventStreamCollector___init__(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_klogger) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  std::vector<PyObject *>  *__pyx_t_4;
  std::unordered_map<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO>  *__pyx_t_5;
  std::vector<wchar_t *>  *__pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  ULONG __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "kstreamc.pyx":105
 * 
 *     def __init__(self, klogger):
 *         self.klogger = klogger             # <<<<<<<<<<<<<<
 *         self.handle = 0
 *         self.next_kevt_callback = None
 */
  __Pyx_INCREF(__pyx_v_klogger);
  __Pyx_GIVEREF(__pyx_v_klogger);
  __Pyx_GOTREF(__pyx_v_self->klogger);
  __Pyx_DECREF(__pyx_v_self->klogger);
  __pyx_v_self->klogger = __pyx_v_klogger;

  /* "kstreamc.pyx":106
 *     def __init__(self, klogger):
 *         self.klogger = klogger
 *         self.handle = 0             # <<<<<<<<<<<<<<
 *         self.next_kevt_callback = None
 *         self.on_kstream_open_callback = None
 */
  __pyx_v_self->handle = 0;

  /* "kstreamc.pyx":107
 *         self.klogger = klogger
 *         self.handle = 0
 *         self.next_kevt_callback = None             # <<<<<<<<<<<<<<
 *         self.on_kstream_open_callback = None
 *         self.ktrace.logger_name = PyBytes_AsString(self.klogger)
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->next_kevt_callback);
  __Pyx_DECREF(__pyx_v_self->next_kevt_callback);
  __pyx_v_self->next_kevt_callback = Py_None;

  /* "kstreamc.pyx":108
 *         self.handle = 0
 *         self.next_kevt_callback = None
 *         self.on_kstream_open_callback = None             # <<<<<<<<<<<<<<
 *         self.ktrace.logger_name = PyBytes_AsString(self.klogger)
 *         self.regex = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->on_kstream_open_callback);
  __Pyx_DECREF(__pyx_v_self->on_kstream_open_callback);
  __pyx_v_self->on_kstream_open_callback = Py_None;

  /* "kstreamc.pyx":109
 *         self.next_kevt_callback = None
 *         self.on_kstream_open_callback = None
 *         self.ktrace.logger_name = PyBytes_AsString(self.klogger)             # <<<<<<<<<<<<<<
 *         self.regex = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
 *         self.pointer_size = 8
 */
  __pyx_t_1 = __pyx_v_self->klogger;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyBytes_AsString(__pyx_t_1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->ktrace.LoggerName = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kstreamc.pyx":110
 *         self.on_kstream_open_callback = None
 *         self.ktrace.logger_name = PyBytes_AsString(self.klogger)
 *         self.regex = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')             # <<<<<<<<<<<<<<
 *         self.pointer_size = 8
 *         self.ktuple_filters = new vector[PyObject*]()
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->regex);
  __Pyx_DECREF(__pyx_v_self->regex);
  __pyx_v_self->regex = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "kstreamc.pyx":111
 *         self.ktrace.logger_name = PyBytes_AsString(self.klogger)
 *         self.regex = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
 *         self.pointer_size = 8             # <<<<<<<<<<<<<<
 *         self.ktuple_filters = new vector[PyObject*]()
 *         self.proc_map = new unordered_map[ULONG, PROCESS_INFO]()
 */
  __pyx_v_self->pointer_size = 8;

  /* "kstreamc.pyx":112
 *         self.regex = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
 *         self.pointer_size = 8
 *         self.ktuple_filters = new vector[PyObject*]()             # <<<<<<<<<<<<<<
 *         self.proc_map = new unordered_map[ULONG, PROCESS_INFO]()
 *         self.skips = new vector[wchar_t*]()
 */
  try {
    __pyx_t_4 = new std::vector<PyObject *> ();
  } catch(...) {
    __Pyx_CppExn2PyErr();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_self->ktuple_filters = __pyx_t_4;

  /* "kstreamc.pyx":113
 *         self.pointer_size = 8
 *         self.ktuple_filters = new vector[PyObject*]()
 *         self.proc_map = new unordered_map[ULONG, PROCESS_INFO]()             # <<<<<<<<<<<<<<
 *         self.skips = new vector[wchar_t*]()
 *         self.pid_filter = 0
 */
  try {
    __pyx_t_5 = new std::unordered_map<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO> ();
  } catch(...) {
    __Pyx_CppExn2PyErr();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_self->proc_map = __pyx_t_5;

  /* "kstreamc.pyx":114
 *         self.ktuple_filters = new vector[PyObject*]()
 *         self.proc_map = new unordered_map[ULONG, PROCESS_INFO]()
 *         self.skips = new vector[wchar_t*]()             # <<<<<<<<<<<<<<
 *         self.pid_filter = 0
 *         self.image_filter = NULL
 */
  try {
    __pyx_t_6 = new std::vector<wchar_t *> ();
  } catch(...) {
    __Pyx_CppExn2PyErr();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_self->skips = __pyx_t_6;

  /* "kstreamc.pyx":115
 *         self.proc_map = new unordered_map[ULONG, PROCESS_INFO]()
 *         self.skips = new vector[wchar_t*]()
 *         self.pid_filter = 0             # <<<<<<<<<<<<<<
 *         self.image_filter = NULL
 *         self.own_pid = <ULONG>os.getpid()
 */
  __pyx_v_self->pid_filter = 0;

  /* "kstreamc.pyx":116
 *         self.skips = new vector[wchar_t*]()
 *         self.pid_filter = 0
 *         self.image_filter = NULL             # <<<<<<<<<<<<<<
 *         self.own_pid = <ULONG>os.getpid()
 * 
 */
  __pyx_v_self->image_filter = NULL;

  /* "kstreamc.pyx":117
 *         self.pid_filter = 0
 *         self.image_filter = NULL
 *         self.own_pid = <ULONG>os.getpid()             # <<<<<<<<<<<<<<
 * 
 *     def open_kstream(self, callback):
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_getpid); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_8 = __Pyx_PyInt_As_ULONG(__pyx_t_1); if (unlikely((__pyx_t_8 == (ULONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->own_pid = ((ULONG)__pyx_t_8);

  /* "kstreamc.pyx":104
 *     cdef regex
 * 
 *     def __init__(self, klogger):             # <<<<<<<<<<<<<<
 *         self.klogger = klogger
 *         self.handle = 0
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":119
 *         self.own_pid = <ULONG>os.getpid()
 * 
 *     def open_kstream(self, callback):             # <<<<<<<<<<<<<<
 *         """Initializes the kernel event stream.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_3open_kstream(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static char __pyx_doc_8kstreamc_21KEventStreamCollector_2open_kstream[] = "Initializes the kernel event stream.\n\n        Sets the event record callback and open\n        the trace to consume from kernel event\n        stream.\n\n        Parameters\n        ----------\n\n        callback: callable\n            A python method which is called\n            when kernel event is consumed successfully\n\n        ";
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_3open_kstream(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("open_kstream (wrapper)", 0);
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector_2open_kstream(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self), ((PyObject *)__pyx_v_callback));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_2open_kstream(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_v_status = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("open_kstream", 0);

  /* "kstreamc.pyx":134
 * 
 *         """
 *         self.next_kevt_callback = callback             # <<<<<<<<<<<<<<
 * 
 *         self.ktrace.trace_mode = EVENT_TRACE_REAL_TIME_MODE | PROCESS_TRACE_MODE_EVENT_RECORD
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(__pyx_v_self->next_kevt_callback);
  __Pyx_DECREF(__pyx_v_self->next_kevt_callback);
  __pyx_v_self->next_kevt_callback = __pyx_v_callback;

  /* "kstreamc.pyx":136
 *         self.next_kevt_callback = callback
 * 
 *         self.ktrace.trace_mode = EVENT_TRACE_REAL_TIME_MODE | PROCESS_TRACE_MODE_EVENT_RECORD             # <<<<<<<<<<<<<<
 *         self.ktrace.callback = <PEVENT_RECORD_CALLBACK> self.process_kevent_callback
 *         # because `process_kevent` callback is the instance
 */
  __pyx_v_self->ktrace.ProcessTraceMode = (EVENT_TRACE_REAL_TIME_MODE | PROCESS_TRACE_MODE_EVENT_RECORD);

  /* "kstreamc.pyx":137
 * 
 *         self.ktrace.trace_mode = EVENT_TRACE_REAL_TIME_MODE | PROCESS_TRACE_MODE_EVENT_RECORD
 *         self.ktrace.callback = <PEVENT_RECORD_CALLBACK> self.process_kevent_callback             # <<<<<<<<<<<<<<
 *         # because `process_kevent` callback is the instance
 *         # method and the ETW API expects a callback function with
 */
  __pyx_v_self->ktrace.EventRecordCallback = ((PEVENT_RECORD_CALLBACK)((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->process_kevent_callback);

  /* "kstreamc.pyx":143
 *         # an invalid context. We need to inject the reference
 *         # to this instance into `Context` member.
 *         self.ktrace.context = <PVOID> self             # <<<<<<<<<<<<<<
 * 
 *         self.handle = open_trace(&self.ktrace)
 */
  __pyx_v_self->ktrace.Context = ((PVOID)__pyx_v_self);

  /* "kstreamc.pyx":145
 *         self.ktrace.context = <PVOID> self
 * 
 *         self.handle = open_trace(&self.ktrace)             # <<<<<<<<<<<<<<
 * 
 *         if self.on_kstream_open_callback:
 */
  __pyx_v_self->handle = OpenTrace((&__pyx_v_self->ktrace));

  /* "kstreamc.pyx":147
 *         self.handle = open_trace(&self.ktrace)
 * 
 *         if self.on_kstream_open_callback:             # <<<<<<<<<<<<<<
 *             self.on_kstream_open_callback()
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->on_kstream_open_callback); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "kstreamc.pyx":148
 * 
 *         if self.on_kstream_open_callback:
 *             self.on_kstream_open_callback()             # <<<<<<<<<<<<<<
 * 
 *         # foward the kernel event stream
 */
    __Pyx_INCREF(__pyx_v_self->on_kstream_open_callback);
    __pyx_t_3 = __pyx_v_self->on_kstream_open_callback; __pyx_t_4 = NULL;
    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (__pyx_t_4) {
      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kstreamc.pyx":147
 *         self.handle = open_trace(&self.ktrace)
 * 
 *         if self.on_kstream_open_callback:             # <<<<<<<<<<<<<<
 *             self.on_kstream_open_callback()
 * 
 */
  }

  /* "kstreamc.pyx":152
 *         # foward the kernel event stream
 *         # to the consumer and start the processing
 *         status = process_trace(&self.handle, 1,             # <<<<<<<<<<<<<<
 *                                NULL,
 *                                NULL)
 */
  __pyx_t_2 = __Pyx_PyInt_From_ULONG(ProcessTrace((&__pyx_v_self->handle), 1, NULL, NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_status = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "kstreamc.pyx":155
 *                                NULL,
 *                                NULL)
 *         if status != ERROR_SUCCESS or status != ERROR_CANCELLED:             # <<<<<<<<<<<<<<
 *             if status != INVALID_PROCESSTRACE_HANDLE:
 *                 close_trace(self.handle)
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(ERROR_SUCCESS); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_status, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyInt_From_int(ERROR_CANCELLED); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_status, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_t_5;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "kstreamc.pyx":156
 *                                NULL)
 *         if status != ERROR_SUCCESS or status != ERROR_CANCELLED:
 *             if status != INVALID_PROCESSTRACE_HANDLE:             # <<<<<<<<<<<<<<
 *                 close_trace(self.handle)
 *             else:
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(INVALID_PROCESSTRACE_HANDLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_status, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {

      /* "kstreamc.pyx":157
 *         if status != ERROR_SUCCESS or status != ERROR_CANCELLED:
 *             if status != INVALID_PROCESSTRACE_HANDLE:
 *                 close_trace(self.handle)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise RuntimeError('ERROR - Unable to open kernel event stream. Error %s' % status)
 */
      CloseTrace(__pyx_v_self->handle);

      /* "kstreamc.pyx":156
 *                                NULL)
 *         if status != ERROR_SUCCESS or status != ERROR_CANCELLED:
 *             if status != INVALID_PROCESSTRACE_HANDLE:             # <<<<<<<<<<<<<<
 *                 close_trace(self.handle)
 *             else:
 */
      goto __pyx_L7;
    }

    /* "kstreamc.pyx":159
 *                 close_trace(self.handle)
 *             else:
 *                 raise RuntimeError('ERROR - Unable to open kernel event stream. Error %s' % status)             # <<<<<<<<<<<<<<
 * 
 *     def close_kstream(self):
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_ERROR_Unable_to_open_kernel_even, __pyx_v_status); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;

    /* "kstreamc.pyx":155
 *                                NULL,
 *                                NULL)
 *         if status != ERROR_SUCCESS or status != ERROR_CANCELLED:             # <<<<<<<<<<<<<<
 *             if status != INVALID_PROCESSTRACE_HANDLE:
 *                 close_trace(self.handle)
 */
  }

  /* "kstreamc.pyx":119
 *         self.own_pid = <ULONG>os.getpid()
 * 
 *     def open_kstream(self, callback):             # <<<<<<<<<<<<<<
 *         """Initializes the kernel event stream.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.open_kstream", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_status);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":161
 *                 raise RuntimeError('ERROR - Unable to open kernel event stream. Error %s' % status)
 * 
 *     def close_kstream(self):             # <<<<<<<<<<<<<<
 *         close_trace(self.handle)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_5close_kstream(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_5close_kstream(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close_kstream (wrapper)", 0);
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector_4close_kstream(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_4close_kstream(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close_kstream", 0);

  /* "kstreamc.pyx":162
 * 
 *     def close_kstream(self):
 *         close_trace(self.handle)             # <<<<<<<<<<<<<<
 * 
 *     def set_kstream_open_callback(self, callback):
 */
  CloseTrace(__pyx_v_self->handle);

  /* "kstreamc.pyx":161
 *                 raise RuntimeError('ERROR - Unable to open kernel event stream. Error %s' % status)
 * 
 *     def close_kstream(self):             # <<<<<<<<<<<<<<
 *         close_trace(self.handle)
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":164
 *         close_trace(self.handle)
 * 
 *     def set_kstream_open_callback(self, callback):             # <<<<<<<<<<<<<<
 *         self.on_kstream_open_callback = callback
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_7set_kstream_open_callback(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_7set_kstream_open_callback(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_kstream_open_callback (wrapper)", 0);
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector_6set_kstream_open_callback(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self), ((PyObject *)__pyx_v_callback));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_6set_kstream_open_callback(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_kstream_open_callback", 0);

  /* "kstreamc.pyx":165
 * 
 *     def set_kstream_open_callback(self, callback):
 *         self.on_kstream_open_callback = callback             # <<<<<<<<<<<<<<
 * 
 *     def add_skip(self, skip):
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(__pyx_v_self->on_kstream_open_callback);
  __Pyx_DECREF(__pyx_v_self->on_kstream_open_callback);
  __pyx_v_self->on_kstream_open_callback = __pyx_v_callback;

  /* "kstreamc.pyx":164
 *         close_trace(self.handle)
 * 
 *     def set_kstream_open_callback(self, callback):             # <<<<<<<<<<<<<<
 *         self.on_kstream_open_callback = callback
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":167
 *         self.on_kstream_open_callback = callback
 * 
 *     def add_skip(self, skip):             # <<<<<<<<<<<<<<
 *         self.skips.push_back(_wchar_t(<PyObject*>skip))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_9add_skip(PyObject *__pyx_v_self, PyObject *__pyx_v_skip); /*proto*/
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_9add_skip(PyObject *__pyx_v_self, PyObject *__pyx_v_skip) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_skip (wrapper)", 0);
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector_8add_skip(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self), ((PyObject *)__pyx_v_skip));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_8add_skip(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_skip) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_skip", 0);

  /* "kstreamc.pyx":168
 * 
 *     def add_skip(self, skip):
 *         self.skips.push_back(_wchar_t(<PyObject*>skip))             # <<<<<<<<<<<<<<
 * 
 *     def add_ktuple_filter(self, ktuple):
 */
  try {
    __pyx_v_self->skips->push_back(__pyx_f_7kstream_8includes_6python__wchar_t(((PyObject *)__pyx_v_skip)));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "kstreamc.pyx":167
 *         self.on_kstream_open_callback = callback
 * 
 *     def add_skip(self, skip):             # <<<<<<<<<<<<<<
 *         self.skips.push_back(_wchar_t(<PyObject*>skip))
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.add_skip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":170
 *         self.skips.push_back(_wchar_t(<PyObject*>skip))
 * 
 *     def add_ktuple_filter(self, ktuple):             # <<<<<<<<<<<<<<
 *         kguid, opcode = ktuple
 *         self.ktuple_filters.push_back(build_ktuple(<PyObject*>kguid, <UCHAR>opcode))
 */

/* Python wrapper */
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_11add_ktuple_filter(PyObject *__pyx_v_self, PyObject *__pyx_v_ktuple); /*proto*/
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_11add_ktuple_filter(PyObject *__pyx_v_self, PyObject *__pyx_v_ktuple) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_ktuple_filter (wrapper)", 0);
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector_10add_ktuple_filter(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self), ((PyObject *)__pyx_v_ktuple));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_10add_ktuple_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_ktuple) {
  PyObject *__pyx_v_kguid = NULL;
  PyObject *__pyx_v_opcode = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  UCHAR __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_ktuple_filter", 0);

  /* "kstreamc.pyx":171
 * 
 *     def add_ktuple_filter(self, ktuple):
 *         kguid, opcode = ktuple             # <<<<<<<<<<<<<<
 *         self.ktuple_filters.push_back(build_ktuple(<PyObject*>kguid, <UCHAR>opcode))
 * 
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_ktuple))) || (PyList_CheckExact(__pyx_v_ktuple))) {
    PyObject* sequence = __pyx_v_ktuple;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_ktuple); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_kguid = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_opcode = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "kstreamc.pyx":172
 *     def add_ktuple_filter(self, ktuple):
 *         kguid, opcode = ktuple
 *         self.ktuple_filters.push_back(build_ktuple(<PyObject*>kguid, <UCHAR>opcode))             # <<<<<<<<<<<<<<
 * 
 *     def add_pid_filter(self, pid):
 */
  __pyx_t_5 = __Pyx_PyInt_As_UCHAR(__pyx_v_opcode); if (unlikely((__pyx_t_5 == (UCHAR)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  try {
    __pyx_v_self->ktuple_filters->push_back(__pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_v_kguid), ((UCHAR)__pyx_t_5)));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "kstreamc.pyx":170
 *         self.skips.push_back(_wchar_t(<PyObject*>skip))
 * 
 *     def add_ktuple_filter(self, ktuple):             # <<<<<<<<<<<<<<
 *         kguid, opcode = ktuple
 *         self.ktuple_filters.push_back(build_ktuple(<PyObject*>kguid, <UCHAR>opcode))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.add_ktuple_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_kguid);
  __Pyx_XDECREF(__pyx_v_opcode);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":174
 *         self.ktuple_filters.push_back(build_ktuple(<PyObject*>kguid, <UCHAR>opcode))
 * 
 *     def add_pid_filter(self, pid):             # <<<<<<<<<<<<<<
 *         self.pid_filter = <ULONG>int(pid) if pid else 0
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_13add_pid_filter(PyObject *__pyx_v_self, PyObject *__pyx_v_pid); /*proto*/
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_13add_pid_filter(PyObject *__pyx_v_self, PyObject *__pyx_v_pid) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_pid_filter (wrapper)", 0);
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector_12add_pid_filter(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self), ((PyObject *)__pyx_v_pid));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_12add_pid_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_pid) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  ULONG __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  ULONG __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_pid_filter", 0);

  /* "kstreamc.pyx":175
 * 
 *     def add_pid_filter(self, pid):
 *         self.pid_filter = <ULONG>int(pid) if pid else 0             # <<<<<<<<<<<<<<
 * 
 *     def add_image_filter(self, image):
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_pid); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {
    __pyx_t_3 = PyNumber_Int(__pyx_v_pid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyInt_As_ULONG(__pyx_t_3); if (unlikely((__pyx_t_4 == (ULONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = ((ULONG)__pyx_t_4);
  } else {
    __pyx_t_1 = 0;
  }
  __pyx_v_self->pid_filter = __pyx_t_1;

  /* "kstreamc.pyx":174
 *         self.ktuple_filters.push_back(build_ktuple(<PyObject*>kguid, <UCHAR>opcode))
 * 
 *     def add_pid_filter(self, pid):             # <<<<<<<<<<<<<<
 *         self.pid_filter = <ULONG>int(pid) if pid else 0
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.add_pid_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":177
 *         self.pid_filter = <ULONG>int(pid) if pid else 0
 * 
 *     def add_image_filter(self, image):             # <<<<<<<<<<<<<<
 *         self.image_filter = _wchar_t(<PyObject*>image) if image else NULL
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_15add_image_filter(PyObject *__pyx_v_self, PyObject *__pyx_v_image); /*proto*/
static PyObject *__pyx_pw_8kstreamc_21KEventStreamCollector_15add_image_filter(PyObject *__pyx_v_self, PyObject *__pyx_v_image) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_image_filter (wrapper)", 0);
  __pyx_r = __pyx_pf_8kstreamc_21KEventStreamCollector_14add_image_filter(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_self), ((PyObject *)__pyx_v_image));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8kstreamc_21KEventStreamCollector_14add_image_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_image) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  wchar_t *__pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_image_filter", 0);

  /* "kstreamc.pyx":178
 * 
 *     def add_image_filter(self, image):
 *         self.image_filter = _wchar_t(<PyObject*>image) if image else NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef process_kevent_callback(self, EVENT_RECORD* kevent_trace):
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_image); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {
    __pyx_t_1 = __pyx_f_7kstream_8includes_6python__wchar_t(((PyObject *)__pyx_v_image));
  } else {
    __pyx_t_1 = NULL;
  }
  __pyx_v_self->image_filter = __pyx_t_1;

  /* "kstreamc.pyx":177
 *         self.pid_filter = <ULONG>int(pid) if pid else 0
 * 
 *     def add_image_filter(self, image):             # <<<<<<<<<<<<<<
 *         self.image_filter = _wchar_t(<PyObject*>image) if image else NULL
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.add_image_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":180
 *         self.image_filter = _wchar_t(<PyObject*>image) if image else NULL
 * 
 *     cdef process_kevent_callback(self, EVENT_RECORD* kevent_trace):             # <<<<<<<<<<<<<<
 *         with nogil:
 *             (<KEventStreamCollector>kevent_trace.user_ctx)._process_kevent(kevent_trace)
 */

static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector_process_kevent_callback(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, EVENT_RECORD *__pyx_v_kevent_trace) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("process_kevent_callback", 0);

  /* "kstreamc.pyx":181
 * 
 *     cdef process_kevent_callback(self, EVENT_RECORD* kevent_trace):
 *         with nogil:             # <<<<<<<<<<<<<<
 *             (<KEventStreamCollector>kevent_trace.user_ctx)._process_kevent(kevent_trace)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kstreamc.pyx":182
 *     cdef process_kevent_callback(self, EVENT_RECORD* kevent_trace):
 *         with nogil:
 *             (<KEventStreamCollector>kevent_trace.user_ctx)._process_kevent(kevent_trace)             # <<<<<<<<<<<<<<
 * 
 *     cdef void _process_kevent(self, EVENT_RECORD* kevent_trace) nogil except *:
 */
        ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_kevent_trace->UserContext)->__pyx_vtab)->_process_kevent(((struct __pyx_obj_8kstreamc_KEventStreamCollector *)__pyx_v_kevent_trace->UserContext), __pyx_v_kevent_trace); if (unlikely(__Pyx_ErrOccurredWithGIL())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
      }

      /* "kstreamc.pyx":181
 * 
 *     cdef process_kevent_callback(self, EVENT_RECORD* kevent_trace):
 *         with nogil:             # <<<<<<<<<<<<<<
 *             (<KEventStreamCollector>kevent_trace.user_ctx)._process_kevent(kevent_trace)
 * 
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L4_error: {
          #ifdef WITH_THREAD
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L1_error;
        }
        __pyx_L5:;
      }
  }

  /* "kstreamc.pyx":180
 *         self.image_filter = _wchar_t(<PyObject*>image) if image else NULL
 * 
 *     cdef process_kevent_callback(self, EVENT_RECORD* kevent_trace):             # <<<<<<<<<<<<<<
 *         with nogil:
 *             (<KEventStreamCollector>kevent_trace.user_ctx)._process_kevent(kevent_trace)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector.process_kevent_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":184
 *             (<KEventStreamCollector>kevent_trace.user_ctx)._process_kevent(kevent_trace)
 * 
 *     cdef void _process_kevent(self, EVENT_RECORD* kevent_trace) nogil except *:             # <<<<<<<<<<<<<<
 *         """Kernel event stream callback.
 * 
 */

static void __pyx_f_8kstreamc_21KEventStreamCollector__process_kevent(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, EVENT_RECORD *__pyx_v_kevent_trace) {
  TRACE_EVENT_INFO *__pyx_v_info;
  EVENT_HEADER __pyx_v_kevt_hdr;
  ULONG __pyx_v_buffer_size;
  std::unordered_map<std::wstring,PyObject *>  __pyx_v_params;
  ULONG __pyx_v_property_size;
  PROPERTY_DATA_DESCRIPTOR __pyx_v_descriptor;
  BOOL __pyx_v_dropped;
  struct __pyx_t_7kstream_7process_PROCESS_INFO __pyx_v_pi;
  TDHAPI __pyx_v_status;
  UCHAR __pyx_v_cpuid;
  BYTE __pyx_v_opcode;
  ULONG __pyx_v_pid;
  ULONG __pyx_v_tid;
  PyObject *__pyx_v_ktuple;
  EVENT_PROPERTY_INFO *__pyx_v_props;
  long __pyx_v_i;
  EVENT_PROPERTY_INFO __pyx_v_prop;
  LPTSTR __pyx_v_property_name;
  BYTE *__pyx_v_property_buffer;
  std::wstring *__pyx_v_mapk;
  SYSTEMTIME __pyx_v_ts;
  std::pair<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO>  *__pyx_v_k;
  ULONG __pyx_v_prop_pid;
  PyObject *__pyx_v_timestamp = NULL;
  PyObject *__pyx_v_kparams = NULL;
  PyObject *__pyx_v_kguid = NULL;
  PyObject *__pyx_v_opc = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_e = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  EVENT_HEADER __pyx_t_2;
  EVENT_PROPERTY_INFO *__pyx_t_3;
  ULONG __pyx_t_4;
  std::wstring *__pyx_t_5;
  int __pyx_t_6;
  std::pair<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO>  *__pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  std::unordered_map<std::wstring,PyObject *> ::iterator __pyx_t_20;
  std::pair<std::wstring,PyObject *>  __pyx_t_21;
  PyObject *(*__pyx_t_22)(PyObject *);
  Py_ssize_t __pyx_t_23;
  int __pyx_t_24;
  char const *__pyx_t_25;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  #ifdef WITH_THREAD
  PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
  #endif
  __Pyx_RefNannySetupContext("_process_kevent", 0);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif

  /* "kstreamc.pyx":185
 * 
 *     cdef void _process_kevent(self, EVENT_RECORD* kevent_trace) nogil except *:
 *         """Kernel event stream callback.             # <<<<<<<<<<<<<<
 * 
 *         Parameters
 */
  /*try:*/ {

    /* "kstreamc.pyx":194
 * 
 *         """
 *         cdef TRACE_EVENT_INFO* info = <TRACE_EVENT_INFO*> malloc(4096)             # <<<<<<<<<<<<<<
 * 
 *         # the allocation has failed probably
 */
    __pyx_v_info = ((TRACE_EVENT_INFO *)malloc(0x1000));

    /* "kstreamc.pyx":198
 *         # the allocation has failed probably
 *         # because there is no enough memory
 *         if info == NULL:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":199
 *         # because there is no enough memory
 *         if info == NULL:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         cdef EVENT_HEADER kevt_hdr = kevent_trace.header
 */
      goto __pyx_L3_return;

      /* "kstreamc.pyx":198
 *         # the allocation has failed probably
 *         # because there is no enough memory
 *         if info == NULL:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    }

    /* "kstreamc.pyx":201
 *             return
 * 
 *         cdef EVENT_HEADER kevt_hdr = kevent_trace.header             # <<<<<<<<<<<<<<
 *         cdef ULONG buffer_size = 4096
 *         cdef unordered_map[wstring, PyObject*] params
 */
    __pyx_t_2 = __pyx_v_kevent_trace->EventHeader;
    __pyx_v_kevt_hdr = __pyx_t_2;

    /* "kstreamc.pyx":202
 * 
 *         cdef EVENT_HEADER kevt_hdr = kevent_trace.header
 *         cdef ULONG buffer_size = 4096             # <<<<<<<<<<<<<<
 *         cdef unordered_map[wstring, PyObject*] params
 *         cdef ULONG property_size
 */
    __pyx_v_buffer_size = 0x1000;

    /* "kstreamc.pyx":206
 *         cdef ULONG property_size
 *         cdef PROPERTY_DATA_DESCRIPTOR descriptor
 *         cdef BOOL dropped = False             # <<<<<<<<<<<<<<
 *         cdef PROCESS_INFO pi
 * 
 */
    __pyx_v_dropped = 0;

    /* "kstreamc.pyx":209
 *         cdef PROCESS_INFO pi
 * 
 *         status = tdh_get_event_information(kevent_trace, 0,             # <<<<<<<<<<<<<<
 *                                            NULL,
 *                                            info,
 */
    __pyx_v_status = TdhGetEventInformation(__pyx_v_kevent_trace, 0, NULL, __pyx_v_info, (&__pyx_v_buffer_size));

    /* "kstreamc.pyx":214
 *                                            &buffer_size)
 * 
 *         cpuid = <UCHAR> kevent_trace.buffer_ctx.cpuid             # <<<<<<<<<<<<<<
 *         opcode = <BYTE> kevt_hdr.descriptor.opcode
 *         pid = <ULONG> kevt_hdr.process_id
 */
    __pyx_v_cpuid = ((UCHAR)__pyx_v_kevent_trace->BufferContext.ProcessorNumber);

    /* "kstreamc.pyx":215
 * 
 *         cpuid = <UCHAR> kevent_trace.buffer_ctx.cpuid
 *         opcode = <BYTE> kevt_hdr.descriptor.opcode             # <<<<<<<<<<<<<<
 *         pid = <ULONG> kevt_hdr.process_id
 *         tid = <ULONG> kevt_hdr.thread_id
 */
    __pyx_v_opcode = ((BYTE)__pyx_v_kevt_hdr.EventDescriptor.Opcode);

    /* "kstreamc.pyx":216
 *         cpuid = <UCHAR> kevent_trace.buffer_ctx.cpuid
 *         opcode = <BYTE> kevt_hdr.descriptor.opcode
 *         pid = <ULONG> kevt_hdr.process_id             # <<<<<<<<<<<<<<
 *         tid = <ULONG> kevt_hdr.thread_id
 * 
 */
    __pyx_v_pid = ((ULONG)__pyx_v_kevt_hdr.ProcessId);

    /* "kstreamc.pyx":217
 *         opcode = <BYTE> kevt_hdr.descriptor.opcode
 *         pid = <ULONG> kevt_hdr.process_id
 *         tid = <ULONG> kevt_hdr.thread_id             # <<<<<<<<<<<<<<
 * 
 *         ktuple = self.__wrap_ktuple(info.event_guid, opcode)
 */
    __pyx_v_tid = ((ULONG)__pyx_v_kevt_hdr.ThreadId);

    /* "kstreamc.pyx":219
 *         tid = <ULONG> kevt_hdr.thread_id
 * 
 *         ktuple = self.__wrap_ktuple(info.event_guid, opcode)             # <<<<<<<<<<<<<<
 *         # this shouldn't happen, but just in
 *         # case simply discard the kernel event
 */
    __pyx_v_ktuple = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->__pyx___wrap_ktuple(__pyx_v_self, __pyx_v_info->EventGuid, __pyx_v_opcode);

    /* "kstreamc.pyx":222
 *         # this shouldn't happen, but just in
 *         # case simply discard the kernel event
 *         if ktuple == NULL:             # <<<<<<<<<<<<<<
 *             free(info)
 *             return
 */
    __pyx_t_1 = ((__pyx_v_ktuple == NULL) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":223
 *         # case simply discard the kernel event
 *         if ktuple == NULL:
 *             free(info)             # <<<<<<<<<<<<<<
 *             return
 *         dropped = self.__apply_filters(pid, tid, ktuple, params, True)
 */
      free(__pyx_v_info);

      /* "kstreamc.pyx":224
 *         if ktuple == NULL:
 *             free(info)
 *             return             # <<<<<<<<<<<<<<
 *         dropped = self.__apply_filters(pid, tid, ktuple, params, True)
 * 
 */
      goto __pyx_L3_return;

      /* "kstreamc.pyx":222
 *         # this shouldn't happen, but just in
 *         # case simply discard the kernel event
 *         if ktuple == NULL:             # <<<<<<<<<<<<<<
 *             free(info)
 *             return
 */
    }

    /* "kstreamc.pyx":225
 *             free(info)
 *             return
 *         dropped = self.__apply_filters(pid, tid, ktuple, params, True)             # <<<<<<<<<<<<<<
 * 
 *         if dropped:
 */
    __pyx_v_dropped = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->__pyx___apply_filters(__pyx_v_self, __pyx_v_pid, __pyx_v_tid, __pyx_v_ktuple, __pyx_v_params, 1);

    /* "kstreamc.pyx":227
 *         dropped = self.__apply_filters(pid, tid, ktuple, params, True)
 * 
 *         if dropped:             # <<<<<<<<<<<<<<
 *             with gil:
 *                 free(info)
 */
    __pyx_t_1 = (__pyx_v_dropped != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":228
 * 
 *         if dropped:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 free(info)
 *                 Py_XDECREF(ktuple)
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "kstreamc.pyx":229
 *         if dropped:
 *             with gil:
 *                 free(info)             # <<<<<<<<<<<<<<
 *                 Py_XDECREF(ktuple)
 *             return
 */
            free(__pyx_v_info);

            /* "kstreamc.pyx":230
 *             with gil:
 *                 free(info)
 *                 Py_XDECREF(ktuple)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
            Py_XDECREF(__pyx_v_ktuple);
          }

          /* "kstreamc.pyx":228
 * 
 *         if dropped:
 *             with gil:             # <<<<<<<<<<<<<<
 *                 free(info)
 *                 Py_XDECREF(ktuple)
 */
          /*finally:*/ {
            /*normal exit:*/{
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L11;
            }
            __pyx_L11:;
          }
      }

      /* "kstreamc.pyx":231
 *                 free(info)
 *                 Py_XDECREF(ktuple)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if (kevt_hdr.flags & EVENT_HEADER_FLAG_32_BIT_HEADER) == \
 */
      goto __pyx_L3_return;

      /* "kstreamc.pyx":227
 *         dropped = self.__apply_filters(pid, tid, ktuple, params, True)
 * 
 *         if dropped:             # <<<<<<<<<<<<<<
 *             with gil:
 *                 free(info)
 */
    }

    /* "kstreamc.pyx":233
 *             return
 * 
 *         if (kevt_hdr.flags & EVENT_HEADER_FLAG_32_BIT_HEADER) == \             # <<<<<<<<<<<<<<
 *                 EVENT_HEADER_FLAG_32_BIT_HEADER:
 *             self.pointer_size = 4
 */
    __pyx_t_1 = (((__pyx_v_kevt_hdr.Flags & EVENT_HEADER_FLAG_32_BIT_HEADER) == EVENT_HEADER_FLAG_32_BIT_HEADER) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":235
 *         if (kevt_hdr.flags & EVENT_HEADER_FLAG_32_BIT_HEADER) == \
 *                 EVENT_HEADER_FLAG_32_BIT_HEADER:
 *             self.pointer_size = 4             # <<<<<<<<<<<<<<
 *         else:
 *             self.pointer_size = 8
 */
      __pyx_v_self->pointer_size = 4;

      /* "kstreamc.pyx":233
 *             return
 * 
 *         if (kevt_hdr.flags & EVENT_HEADER_FLAG_32_BIT_HEADER) == \             # <<<<<<<<<<<<<<
 *                 EVENT_HEADER_FLAG_32_BIT_HEADER:
 *             self.pointer_size = 4
 */
      goto __pyx_L12;
    }

    /* "kstreamc.pyx":237
 *             self.pointer_size = 4
 *         else:
 *             self.pointer_size = 8             # <<<<<<<<<<<<<<
 * 
 *         if status == ERROR_SUCCESS:
 */
    /*else*/ {
      __pyx_v_self->pointer_size = 8;
    }
    __pyx_L12:;

    /* "kstreamc.pyx":239
 *             self.pointer_size = 8
 * 
 *         if status == ERROR_SUCCESS:             # <<<<<<<<<<<<<<
 *             props = info.properties
 *             for i from 0 <= i < info.property_count:
 */
    __pyx_t_1 = ((__pyx_v_status == ERROR_SUCCESS) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":240
 * 
 *         if status == ERROR_SUCCESS:
 *             props = info.properties             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < info.property_count:
 *                 prop = <EVENT_PROPERTY_INFO> props[i]
 */
      __pyx_t_3 = __pyx_v_info->EventPropertyInfoArray;
      __pyx_v_props = __pyx_t_3;

      /* "kstreamc.pyx":241
 *         if status == ERROR_SUCCESS:
 *             props = info.properties
 *             for i from 0 <= i < info.property_count:             # <<<<<<<<<<<<<<
 *                 prop = <EVENT_PROPERTY_INFO> props[i]
 * 
 */
      __pyx_t_4 = __pyx_v_info->TopLevelPropertyCount;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_4; __pyx_v_i++) {

        /* "kstreamc.pyx":242
 *             props = info.properties
 *             for i from 0 <= i < info.property_count:
 *                 prop = <EVENT_PROPERTY_INFO> props[i]             # <<<<<<<<<<<<<<
 * 
 *                 property_name = <LPTSTR><BYTE*>info + prop.name_offset
 */
        __pyx_v_prop = (__pyx_v_props[__pyx_v_i]);

        /* "kstreamc.pyx":244
 *                 prop = <EVENT_PROPERTY_INFO> props[i]
 * 
 *                 property_name = <LPTSTR><BYTE*>info + prop.name_offset             # <<<<<<<<<<<<<<
 * 
 *                 descriptor.property_name = <ULONGLONG><BYTE*>info + \
 */
        __pyx_v_property_name = (((LPTSTR)((BYTE *)__pyx_v_info)) + __pyx_v_prop.NameOffset);

        /* "kstreamc.pyx":246
 *                 property_name = <LPTSTR><BYTE*>info + prop.name_offset
 * 
 *                 descriptor.property_name = <ULONGLONG><BYTE*>info + \             # <<<<<<<<<<<<<<
 *                                            prop.name_offset
 *                 descriptor.array_index = 0xFFFFFFFF
 */
        __pyx_v_descriptor.PropertyName = (((ULONGLONG)((BYTE *)__pyx_v_info)) + __pyx_v_prop.NameOffset);

        /* "kstreamc.pyx":248
 *                 descriptor.property_name = <ULONGLONG><BYTE*>info + \
 *                                            prop.name_offset
 *                 descriptor.array_index = 0xFFFFFFFF             # <<<<<<<<<<<<<<
 * 
 *                 # get the property size which
 */
        __pyx_v_descriptor.ArrayIndex = 0xFFFFFFFF;

        /* "kstreamc.pyx":252
 *                 # get the property size which
 *                 # is used to allocate the buffer
 *                 tdh_get_property_size(kevent_trace, 0,             # <<<<<<<<<<<<<<
 *                                       NULL,
 *                                       1,
 */
        TdhGetPropertySize(__pyx_v_kevent_trace, 0, NULL, 1, (&__pyx_v_descriptor), (&__pyx_v_property_size));

        /* "kstreamc.pyx":257
 *                                       &descriptor,
 *                                       &property_size)
 *                 property_buffer = <BYTE*> malloc(property_size)             # <<<<<<<<<<<<<<
 *                 if property_buffer == NULL:
 *                     return
 */
        __pyx_v_property_buffer = ((BYTE *)malloc(__pyx_v_property_size));

        /* "kstreamc.pyx":258
 *                                       &property_size)
 *                 property_buffer = <BYTE*> malloc(property_size)
 *                 if property_buffer == NULL:             # <<<<<<<<<<<<<<
 *                     return
 * 
 */
        __pyx_t_1 = ((__pyx_v_property_buffer == NULL) != 0);
        if (__pyx_t_1) {

          /* "kstreamc.pyx":259
 *                 property_buffer = <BYTE*> malloc(property_size)
 *                 if property_buffer == NULL:
 *                     return             # <<<<<<<<<<<<<<
 * 
 *                 # fill the property buffer
 */
          goto __pyx_L3_return;

          /* "kstreamc.pyx":258
 *                                       &property_size)
 *                 property_buffer = <BYTE*> malloc(property_size)
 *                 if property_buffer == NULL:             # <<<<<<<<<<<<<<
 *                     return
 * 
 */
        }

        /* "kstreamc.pyx":262
 * 
 *                 # fill the property buffer
 *                 status = tdh_get_property(kevent_trace, 0,             # <<<<<<<<<<<<<<
 *                                           NULL,
 *                                           1,
 */
        __pyx_v_status = TdhGetProperty(__pyx_v_kevent_trace, 0, NULL, 1, (&__pyx_v_descriptor), __pyx_v_property_size, __pyx_v_property_buffer);

        /* "kstreamc.pyx":269
 *                                           property_buffer)
 *                 # get the property value and store it in the map
 *                 if status == ERROR_SUCCESS:             # <<<<<<<<<<<<<<
 *                     if property_name != NULL:
 *                         mapk = new wstring(<wchar_t*>property_name)
 */
        __pyx_t_1 = ((__pyx_v_status == ERROR_SUCCESS) != 0);
        if (__pyx_t_1) {

          /* "kstreamc.pyx":270
 *                 # get the property value and store it in the map
 *                 if status == ERROR_SUCCESS:
 *                     if property_name != NULL:             # <<<<<<<<<<<<<<
 *                         mapk = new wstring(<wchar_t*>property_name)
 *                         params[deref(mapk)] = \
 */
          __pyx_t_1 = ((__pyx_v_property_name != NULL) != 0);
          if (__pyx_t_1) {

            /* "kstreamc.pyx":271
 *                 if status == ERROR_SUCCESS:
 *                     if property_name != NULL:
 *                         mapk = new wstring(<wchar_t*>property_name)             # <<<<<<<<<<<<<<
 *                         params[deref(mapk)] = \
 *                             self.__parse_property(prop.non_struct_type.in_type,
 */
            try {
              __pyx_t_5 = new std::wstring(((wchar_t *)__pyx_v_property_name));
            } catch(...) {
              #ifdef WITH_THREAD
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
              #endif
              __Pyx_CppExn2PyErr();
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            }
            __pyx_v_mapk = __pyx_t_5;

            /* "kstreamc.pyx":272
 *                     if property_name != NULL:
 *                         mapk = new wstring(<wchar_t*>property_name)
 *                         params[deref(mapk)] = \             # <<<<<<<<<<<<<<
 *                             self.__parse_property(prop.non_struct_type.in_type,
 *                                                   prop.non_struct_type.out_type,
 */
            (__pyx_v_params[(*__pyx_v_mapk)]) = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->__pyx___parse_property(__pyx_v_self, __pyx_v_prop.nonStructType.InType, __pyx_v_prop.nonStructType.OutType, __pyx_v_property_buffer);

            /* "kstreamc.pyx":276
 *                                                   prop.non_struct_type.out_type,
 *                                                   property_buffer)
 *                         del mapk             # <<<<<<<<<<<<<<
 *                     free(property_buffer)
 *                 else:
 */
            delete __pyx_v_mapk;

            /* "kstreamc.pyx":270
 *                 # get the property value and store it in the map
 *                 if status == ERROR_SUCCESS:
 *                     if property_name != NULL:             # <<<<<<<<<<<<<<
 *                         mapk = new wstring(<wchar_t*>property_name)
 *                         params[deref(mapk)] = \
 */
          }

          /* "kstreamc.pyx":277
 *                                                   property_buffer)
 *                         del mapk
 *                     free(property_buffer)             # <<<<<<<<<<<<<<
 *                 else:
 *                     if property_buffer != NULL:
 */
          free(__pyx_v_property_buffer);

          /* "kstreamc.pyx":269
 *                                           property_buffer)
 *                 # get the property value and store it in the map
 *                 if status == ERROR_SUCCESS:             # <<<<<<<<<<<<<<
 *                     if property_name != NULL:
 *                         mapk = new wstring(<wchar_t*>property_name)
 */
          goto __pyx_L17;
        }

        /* "kstreamc.pyx":279
 *                     free(property_buffer)
 *                 else:
 *                     if property_buffer != NULL:             # <<<<<<<<<<<<<<
 *                         free(property_buffer)
 * 
 */
        /*else*/ {
          __pyx_t_1 = ((__pyx_v_property_buffer != NULL) != 0);
          if (__pyx_t_1) {

            /* "kstreamc.pyx":280
 *                 else:
 *                     if property_buffer != NULL:
 *                         free(property_buffer)             # <<<<<<<<<<<<<<
 * 
 *             free(info)
 */
            free(__pyx_v_property_buffer);

            /* "kstreamc.pyx":279
 *                     free(property_buffer)
 *                 else:
 *                     if property_buffer != NULL:             # <<<<<<<<<<<<<<
 *                         free(property_buffer)
 * 
 */
          }
        }
        __pyx_L17:;
      }

      /* "kstreamc.pyx":282
 *                         free(property_buffer)
 * 
 *             free(info)             # <<<<<<<<<<<<<<
 *             ts = sys_time(kevt_hdr.timestamp)
 * 
 */
      free(__pyx_v_info);

      /* "kstreamc.pyx":283
 * 
 *             free(info)
 *             ts = sys_time(kevt_hdr.timestamp)             # <<<<<<<<<<<<<<
 * 
 *             # build a tiny state machine around the
 */
      __pyx_v_ts = __pyx_f_7kstream_4time_sys_time(__pyx_v_kevt_hdr.TimeStamp);

      /* "kstreamc.pyx":287
 *             # build a tiny state machine around the
 *             # currently running processes on the system
 *             if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \             # <<<<<<<<<<<<<<
 *                 self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                 pi.pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 */
      __pyx_t_6 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_ENUM_PROCESS) != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_1 = __pyx_t_6;
        goto __pyx_L21_bool_binop_done;
      }

      /* "kstreamc.pyx":288
 *             # currently running processes on the system
 *             if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \
 *                 self.__ktuple_equals(ktuple, CREATE_PROCESS):             # <<<<<<<<<<<<<<
 *                 pi.pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                 pi.ppid = <ULONG>wcstol(_wchar_t(params.at(PPID_PROP)), NULL, 16)
 */
      __pyx_t_6 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_CREATE_PROCESS) != 0);
      __pyx_t_1 = __pyx_t_6;
      __pyx_L21_bool_binop_done:;

      /* "kstreamc.pyx":287
 *             # build a tiny state machine around the
 *             # currently running processes on the system
 *             if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \             # <<<<<<<<<<<<<<
 *                 self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                 pi.pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 */
      if (__pyx_t_1) {

        /* "kstreamc.pyx":289
 *             if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \
 *                 self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                 pi.pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)             # <<<<<<<<<<<<<<
 *                 pi.ppid = <ULONG>wcstol(_wchar_t(params.at(PPID_PROP)), NULL, 16)
 *                 pi.name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))
 */
        __pyx_v_pi.pid = ((ULONG)wcstol(__pyx_f_7kstream_8includes_6python__wchar_t(__pyx_v_params.at(__pyx_v_8kstreamc_PROCESS_ID_PROP)), NULL, 16));

        /* "kstreamc.pyx":290
 *                 self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                 pi.pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                 pi.ppid = <ULONG>wcstol(_wchar_t(params.at(PPID_PROP)), NULL, 16)             # <<<<<<<<<<<<<<
 *                 pi.name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))
 *                 k = new pair[ULONG, PROCESS_INFO](<ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16),
 */
        __pyx_v_pi.ppid = ((ULONG)wcstol(__pyx_f_7kstream_8includes_6python__wchar_t(__pyx_v_params.at(__pyx_v_8kstreamc_PPID_PROP)), NULL, 16));

        /* "kstreamc.pyx":291
 *                 pi.pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                 pi.ppid = <ULONG>wcstol(_wchar_t(params.at(PPID_PROP)), NULL, 16)
 *                 pi.name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))             # <<<<<<<<<<<<<<
 *                 k = new pair[ULONG, PROCESS_INFO](<ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16),
 *                                                  pi)
 */
        __pyx_v_pi.name = __pyx_f_7kstream_8includes_6python__wchar_t(__pyx_v_params.at(__pyx_v_8kstreamc_IMAGE_FILE_NAME_PROP));

        /* "kstreamc.pyx":292
 *                 pi.ppid = <ULONG>wcstol(_wchar_t(params.at(PPID_PROP)), NULL, 16)
 *                 pi.name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))
 *                 k = new pair[ULONG, PROCESS_INFO](<ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16),             # <<<<<<<<<<<<<<
 *                                                  pi)
 *                 self.proc_map.insert(deref(k))
 */
        try {
          __pyx_t_7 = new std::pair<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO> (((ULONG)wcstol(__pyx_f_7kstream_8includes_6python__wchar_t(__pyx_v_params.at(__pyx_v_8kstreamc_PROCESS_ID_PROP)), NULL, 16)), __pyx_v_pi);
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        }
        __pyx_v_k = __pyx_t_7;

        /* "kstreamc.pyx":294
 *                 k = new pair[ULONG, PROCESS_INFO](<ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16),
 *                                                  pi)
 *                 self.proc_map.insert(deref(k))             # <<<<<<<<<<<<<<
 *                 del k
 *             elif self.__ktuple_equals(ktuple, TERMINATE_PROCESS):
 */
        __pyx_v_self->proc_map->insert((*__pyx_v_k));

        /* "kstreamc.pyx":295
 *                                                  pi)
 *                 self.proc_map.insert(deref(k))
 *                 del k             # <<<<<<<<<<<<<<
 *             elif self.__ktuple_equals(ktuple, TERMINATE_PROCESS):
 *                 # defer the removal of the pid to be able to capture
 */
        delete __pyx_v_k;

        /* "kstreamc.pyx":287
 *             # build a tiny state machine around the
 *             # currently running processes on the system
 *             if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \             # <<<<<<<<<<<<<<
 *                 self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                 pi.pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 */
        goto __pyx_L20;
      }

      /* "kstreamc.pyx":296
 *                 self.proc_map.insert(deref(k))
 *                 del k
 *             elif self.__ktuple_equals(ktuple, TERMINATE_PROCESS):             # <<<<<<<<<<<<<<
 *                 # defer the removal of the pid to be able to capture
 *                 # `TerminateProcess` if the image filter is set
 */
      __pyx_t_1 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_TERMINATE_PROCESS) != 0);
      if (__pyx_t_1) {

        /* "kstreamc.pyx":299
 *                 # defer the removal of the pid to be able to capture
 *                 # `TerminateProcess` if the image filter is set
 *                 if self.image_filter == NULL:             # <<<<<<<<<<<<<<
 *                     prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                     self.proc_map.erase(prop_pid)
 */
        __pyx_t_1 = ((__pyx_v_self->image_filter == NULL) != 0);
        if (__pyx_t_1) {

          /* "kstreamc.pyx":300
 *                 # `TerminateProcess` if the image filter is set
 *                 if self.image_filter == NULL:
 *                     prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)             # <<<<<<<<<<<<<<
 *                     self.proc_map.erase(prop_pid)
 * 
 */
          __pyx_v_prop_pid = ((ULONG)wcstol(__pyx_f_7kstream_8includes_6python__wchar_t(__pyx_v_params.at(__pyx_v_8kstreamc_PROCESS_ID_PROP)), NULL, 16));

          /* "kstreamc.pyx":301
 *                 if self.image_filter == NULL:
 *                     prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                     self.proc_map.erase(prop_pid)             # <<<<<<<<<<<<<<
 * 
 *             dropped = self.__apply_filters(pid, tid, ktuple, params, False)
 */
          __pyx_v_self->proc_map->erase(__pyx_v_prop_pid);

          /* "kstreamc.pyx":299
 *                 # defer the removal of the pid to be able to capture
 *                 # `TerminateProcess` if the image filter is set
 *                 if self.image_filter == NULL:             # <<<<<<<<<<<<<<
 *                     prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                     self.proc_map.erase(prop_pid)
 */
        }

        /* "kstreamc.pyx":296
 *                 self.proc_map.insert(deref(k))
 *                 del k
 *             elif self.__ktuple_equals(ktuple, TERMINATE_PROCESS):             # <<<<<<<<<<<<<<
 *                 # defer the removal of the pid to be able to capture
 *                 # `TerminateProcess` if the image filter is set
 */
      }
      __pyx_L20:;

      /* "kstreamc.pyx":303
 *                     self.proc_map.erase(prop_pid)
 * 
 *             dropped = self.__apply_filters(pid, tid, ktuple, params, False)             # <<<<<<<<<<<<<<
 *             # now we can erase the pid
 *             if self.image_filter != NULL and \
 */
      __pyx_v_dropped = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->__pyx___apply_filters(__pyx_v_self, __pyx_v_pid, __pyx_v_tid, __pyx_v_ktuple, __pyx_v_params, 0);

      /* "kstreamc.pyx":305
 *             dropped = self.__apply_filters(pid, tid, ktuple, params, False)
 *             # now we can erase the pid
 *             if self.image_filter != NULL and \             # <<<<<<<<<<<<<<
 *                     self.__ktuple_equals(ktuple, TERMINATE_PROCESS):
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 */
      __pyx_t_6 = ((__pyx_v_self->image_filter != NULL) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_1 = __pyx_t_6;
        goto __pyx_L25_bool_binop_done;
      }

      /* "kstreamc.pyx":306
 *             # now we can erase the pid
 *             if self.image_filter != NULL and \
 *                     self.__ktuple_equals(ktuple, TERMINATE_PROCESS):             # <<<<<<<<<<<<<<
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                 self.proc_map.erase(prop_pid)
 */
      __pyx_t_6 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_TERMINATE_PROCESS) != 0);
      __pyx_t_1 = __pyx_t_6;
      __pyx_L25_bool_binop_done:;

      /* "kstreamc.pyx":305
 *             dropped = self.__apply_filters(pid, tid, ktuple, params, False)
 *             # now we can erase the pid
 *             if self.image_filter != NULL and \             # <<<<<<<<<<<<<<
 *                     self.__ktuple_equals(ktuple, TERMINATE_PROCESS):
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 */
      if (__pyx_t_1) {

        /* "kstreamc.pyx":307
 *             if self.image_filter != NULL and \
 *                     self.__ktuple_equals(ktuple, TERMINATE_PROCESS):
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)             # <<<<<<<<<<<<<<
 *                 self.proc_map.erase(prop_pid)
 *             if dropped:
 */
        __pyx_v_prop_pid = ((ULONG)wcstol(__pyx_f_7kstream_8includes_6python__wchar_t(__pyx_v_params.at(__pyx_v_8kstreamc_PROCESS_ID_PROP)), NULL, 16));

        /* "kstreamc.pyx":308
 *                     self.__ktuple_equals(ktuple, TERMINATE_PROCESS):
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                 self.proc_map.erase(prop_pid)             # <<<<<<<<<<<<<<
 *             if dropped:
 *                 with gil:
 */
        __pyx_v_self->proc_map->erase(__pyx_v_prop_pid);

        /* "kstreamc.pyx":305
 *             dropped = self.__apply_filters(pid, tid, ktuple, params, False)
 *             # now we can erase the pid
 *             if self.image_filter != NULL and \             # <<<<<<<<<<<<<<
 *                     self.__ktuple_equals(ktuple, TERMINATE_PROCESS):
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 */
      }

      /* "kstreamc.pyx":309
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                 self.proc_map.erase(prop_pid)
 *             if dropped:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     # decrement references to avoid memory leaks
 */
      __pyx_t_1 = (__pyx_v_dropped != 0);
      if (__pyx_t_1) {

        /* "kstreamc.pyx":310
 *                 self.proc_map.erase(prop_pid)
 *             if dropped:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     # decrement references to avoid memory leaks
 *                     if self.image_filter != NULL:
 */
        {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
            #endif
            /*try:*/ {

              /* "kstreamc.pyx":312
 *                 with gil:
 *                     # decrement references to avoid memory leaks
 *                     if self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *                        self._decref_params(params)
 *                     Py_XDECREF(ktuple)
 */
              __pyx_t_1 = ((__pyx_v_self->image_filter != NULL) != 0);
              if (__pyx_t_1) {

                /* "kstreamc.pyx":313
 *                     # decrement references to avoid memory leaks
 *                     if self.image_filter != NULL:
 *                        self._decref_params(params)             # <<<<<<<<<<<<<<
 *                     Py_XDECREF(ktuple)
 *                 return
 */
                __pyx_t_8 = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->_decref_params(__pyx_v_self, __pyx_v_params); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                /* "kstreamc.pyx":312
 *                 with gil:
 *                     # decrement references to avoid memory leaks
 *                     if self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *                        self._decref_params(params)
 *                     Py_XDECREF(ktuple)
 */
              }

              /* "kstreamc.pyx":314
 *                     if self.image_filter != NULL:
 *                        self._decref_params(params)
 *                     Py_XDECREF(ktuple)             # <<<<<<<<<<<<<<
 *                 return
 *             with gil:
 */
              Py_XDECREF(__pyx_v_ktuple);
            }

            /* "kstreamc.pyx":310
 *                 self.proc_map.erase(prop_pid)
 *             if dropped:
 *                 with gil:             # <<<<<<<<<<<<<<
 *                     # decrement references to avoid memory leaks
 *                     if self.image_filter != NULL:
 */
            /*finally:*/ {
              /*normal exit:*/{
                #ifdef WITH_THREAD
                PyGILState_Release(__pyx_gilstate_save);
                #endif
                goto __pyx_L30;
              }
              __pyx_L29_error: {
                #ifdef WITH_THREAD
                PyGILState_Release(__pyx_gilstate_save);
                #endif
                goto __pyx_L4_error;
              }
              __pyx_L30:;
            }
        }

        /* "kstreamc.pyx":315
 *                        self._decref_params(params)
 *                     Py_XDECREF(ktuple)
 *                 return             # <<<<<<<<<<<<<<
 *             with gil:
 *                 # check for pending signals.
 */
        goto __pyx_L3_return;

        /* "kstreamc.pyx":309
 *                 prop_pid = <ULONG>wcstol(_wchar_t(params.at(PROCESS_ID_PROP)), NULL, 16)
 *                 self.proc_map.erase(prop_pid)
 *             if dropped:             # <<<<<<<<<<<<<<
 *                 with gil:
 *                     # decrement references to avoid memory leaks
 */
      }

      /* "kstreamc.pyx":316
 *                     Py_XDECREF(ktuple)
 *                 return
 *             with gil:             # <<<<<<<<<<<<<<
 *                 # check for pending signals.
 *                 # The default behaviour is to
 */
      {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          /*try:*/ {

            /* "kstreamc.pyx":321
 *                 # raise `KeyboardInterrupt` exception
 *                 # which will be propagated to the caller
 *                 if PyErr_CheckSignals() > 0:             # <<<<<<<<<<<<<<
 *                     self.close_kstream()
 *                     return
 */
            __pyx_t_9 = PyErr_CheckSignals(); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
            __pyx_t_1 = ((__pyx_t_9 > 0) != 0);
            if (__pyx_t_1) {

              /* "kstreamc.pyx":322
 *                 # which will be propagated to the caller
 *                 if PyErr_CheckSignals() > 0:
 *                     self.close_kstream()             # <<<<<<<<<<<<<<
 *                     return
 *                 try:
 */
              __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close_kstream); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_11 = NULL;
              if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_10))) {
                __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
                if (likely(__pyx_t_11)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
                  __Pyx_INCREF(__pyx_t_11);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_10, function);
                }
              }
              if (__pyx_t_11) {
                __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              } else {
                __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
              }
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

              /* "kstreamc.pyx":323
 *                 if PyErr_CheckSignals() > 0:
 *                     self.close_kstream()
 *                     return             # <<<<<<<<<<<<<<
 *                 try:
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,
 */
              goto __pyx_L32_return;

              /* "kstreamc.pyx":321
 *                 # raise `KeyboardInterrupt` exception
 *                 # which will be propagated to the caller
 *                 if PyErr_CheckSignals() > 0:             # <<<<<<<<<<<<<<
 *                     self.close_kstream()
 *                     return
 */
            }

            /* "kstreamc.pyx":324
 *                     self.close_kstream()
 *                     return
 *                 try:             # <<<<<<<<<<<<<<
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,
 *                                                               ts.day, ts.hour,
 */
            /*try:*/ {
              {
                __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_14);
                /*try:*/ {

                  /* "kstreamc.pyx":325
 *                     return
 *                 try:
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,             # <<<<<<<<<<<<<<
 *                                                               ts.day, ts.hour,
 *                                                               ts.minute, ts.second,
 */
                  __pyx_t_8 = __Pyx_PyInt_From_WORD(__pyx_v_ts.wYear); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_8);
                  __pyx_t_10 = __Pyx_PyInt_From_WORD(__pyx_v_ts.wMonth); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_10);

                  /* "kstreamc.pyx":326
 *                 try:
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,
 *                                                               ts.day, ts.hour,             # <<<<<<<<<<<<<<
 *                                                               ts.minute, ts.second,
 *                                                               ts.millis)
 */
                  __pyx_t_11 = __Pyx_PyInt_From_WORD(__pyx_v_ts.wDay); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_11);
                  __pyx_t_15 = __Pyx_PyInt_From_WORD(__pyx_v_ts.wHour); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_15);

                  /* "kstreamc.pyx":327
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,
 *                                                               ts.day, ts.hour,
 *                                                               ts.minute, ts.second,             # <<<<<<<<<<<<<<
 *                                                               ts.millis)
 *                     # convert the property name from
 */
                  __pyx_t_16 = __Pyx_PyInt_From_WORD(__pyx_v_ts.wMinute); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_16);
                  __pyx_t_17 = __Pyx_PyInt_From_WORD(__pyx_v_ts.wSecond); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_17);

                  /* "kstreamc.pyx":328
 *                                                               ts.day, ts.hour,
 *                                                               ts.minute, ts.second,
 *                                                               ts.millis)             # <<<<<<<<<<<<<<
 *                     # convert the property name from
 *                     # camel case to underscore so we have
 */
                  __pyx_t_18 = __Pyx_PyInt_From_WORD(__pyx_v_ts.wMilliseconds); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_18);

                  /* "kstreamc.pyx":325
 *                     return
 *                 try:
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,             # <<<<<<<<<<<<<<
 *                                                               ts.day, ts.hour,
 *                                                               ts.minute, ts.second,
 */
                  __pyx_t_19 = PyTuple_New(7); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_GIVEREF(__pyx_t_8);
                  PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_8);
                  __Pyx_GIVEREF(__pyx_t_10);
                  PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_10);
                  __Pyx_GIVEREF(__pyx_t_11);
                  PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_11);
                  __Pyx_GIVEREF(__pyx_t_15);
                  PyTuple_SET_ITEM(__pyx_t_19, 3, __pyx_t_15);
                  __Pyx_GIVEREF(__pyx_t_16);
                  PyTuple_SET_ITEM(__pyx_t_19, 4, __pyx_t_16);
                  __Pyx_GIVEREF(__pyx_t_17);
                  PyTuple_SET_ITEM(__pyx_t_19, 5, __pyx_t_17);
                  __Pyx_GIVEREF(__pyx_t_18);
                  PyTuple_SET_ITEM(__pyx_t_19, 6, __pyx_t_18);
                  __pyx_t_8 = 0;
                  __pyx_t_10 = 0;
                  __pyx_t_11 = 0;
                  __pyx_t_15 = 0;
                  __pyx_t_16 = 0;
                  __pyx_t_17 = 0;
                  __pyx_t_18 = 0;
                  __pyx_t_18 = __Pyx_PyString_Format(__pyx_kp_s_d_d_d_d_02d_02d_d, __pyx_t_19); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_18);
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __pyx_v_timestamp = ((PyObject*)__pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "kstreamc.pyx":332
 *                     # camel case to underscore so we have
 *                     # PEP 8 compliant coding style
 *                     kparams = {self._underscore(self._decref(_wstring(kparam.first))): self._decref(kparam.second)             # <<<<<<<<<<<<<<
 *                                for kparam in params
 *                                if kparam.second != NULL}
 */
                  { /* enter inner scope */
                    std::pair<std::wstring,PyObject *>  __pyx_7genexpr__pyx_v_kparam;
                    __pyx_t_18 = PyDict_New(); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_18);

                    /* "kstreamc.pyx":333
 *                     # PEP 8 compliant coding style
 *                     kparams = {self._underscore(self._decref(_wstring(kparam.first))): self._decref(kparam.second)
 *                                for kparam in params             # <<<<<<<<<<<<<<
 *                                if kparam.second != NULL}
 *                     kguid, opc = <object>ktuple
 */
                    __pyx_t_20 = __pyx_v_params.begin();
                    for (;;) {
                      if (!(__pyx_t_20 != __pyx_v_params.end())) break;
                      __pyx_t_21 = *__pyx_t_20;
                      ++__pyx_t_20;
                      __pyx_7genexpr__pyx_v_kparam = __pyx_t_21;

                      /* "kstreamc.pyx":334
 *                     kparams = {self._underscore(self._decref(_wstring(kparam.first))): self._decref(kparam.second)
 *                                for kparam in params
 *                                if kparam.second != NULL}             # <<<<<<<<<<<<<<
 *                     kguid, opc = <object>ktuple
 *                     kguid = kguid[:-1]
 */
                      __pyx_t_1 = ((__pyx_7genexpr__pyx_v_kparam.second != NULL) != 0);
                      if (__pyx_t_1) {

                        /* "kstreamc.pyx":332
 *                     # camel case to underscore so we have
 *                     # PEP 8 compliant coding style
 *                     kparams = {self._underscore(self._decref(_wstring(kparam.first))): self._decref(kparam.second)             # <<<<<<<<<<<<<<
 *                                for kparam in params
 *                                if kparam.second != NULL}
 */
                        __pyx_t_19 = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->_decref(__pyx_v_self, __pyx_f_7kstream_8includes_6python__wstring(__pyx_7genexpr__pyx_v_kparam.first)); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                        __Pyx_GOTREF(__pyx_t_19);
                        __pyx_t_17 = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->_underscore(__pyx_v_self, __pyx_t_19); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                        __Pyx_GOTREF(__pyx_t_17);
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __pyx_t_19 = ((struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector *)__pyx_v_self->__pyx_vtab)->_decref(__pyx_v_self, __pyx_7genexpr__pyx_v_kparam.second); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                        __Pyx_GOTREF(__pyx_t_19);
                        if (unlikely(PyDict_SetItem(__pyx_t_18, (PyObject*)__pyx_t_17, (PyObject*)__pyx_t_19))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                        /* "kstreamc.pyx":334
 *                     kparams = {self._underscore(self._decref(_wstring(kparam.first))): self._decref(kparam.second)
 *                                for kparam in params
 *                                if kparam.second != NULL}             # <<<<<<<<<<<<<<
 *                     kguid, opc = <object>ktuple
 *                     kguid = kguid[:-1]
 */
                      }

                      /* "kstreamc.pyx":333
 *                     # PEP 8 compliant coding style
 *                     kparams = {self._underscore(self._decref(_wstring(kparam.first))): self._decref(kparam.second)
 *                                for kparam in params             # <<<<<<<<<<<<<<
 *                                if kparam.second != NULL}
 *                     kguid, opc = <object>ktuple
 */
                    }
                  } /* exit inner scope */
                  __pyx_v_kparams = ((PyObject*)__pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "kstreamc.pyx":335
 *                                for kparam in params
 *                                if kparam.second != NULL}
 *                     kguid, opc = <object>ktuple             # <<<<<<<<<<<<<<
 *                     kguid = kguid[:-1]
 *                     # registry events have a valid process/thread id
 */
                  __pyx_t_18 = ((PyObject *)__pyx_v_ktuple);
                  __Pyx_INCREF(__pyx_t_18);
                  if ((likely(PyTuple_CheckExact(__pyx_t_18))) || (PyList_CheckExact(__pyx_t_18))) {
                    PyObject* sequence = __pyx_t_18;
                    #if CYTHON_COMPILING_IN_CPYTHON
                    Py_ssize_t size = Py_SIZE(sequence);
                    #else
                    Py_ssize_t size = PySequence_Size(sequence);
                    #endif
                    if (unlikely(size != 2)) {
                      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
                      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    }
                    #if CYTHON_COMPILING_IN_CPYTHON
                    if (likely(PyTuple_CheckExact(sequence))) {
                      __pyx_t_19 = PyTuple_GET_ITEM(sequence, 0); 
                      __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); 
                    } else {
                      __pyx_t_19 = PyList_GET_ITEM(sequence, 0); 
                      __pyx_t_17 = PyList_GET_ITEM(sequence, 1); 
                    }
                    __Pyx_INCREF(__pyx_t_19);
                    __Pyx_INCREF(__pyx_t_17);
                    #else
                    __pyx_t_19 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_19);
                    __pyx_t_17 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_17);
                    #endif
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  } else {
                    Py_ssize_t index = -1;
                    __pyx_t_16 = PyObject_GetIter(__pyx_t_18); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_16);
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __pyx_t_22 = Py_TYPE(__pyx_t_16)->tp_iternext;
                    index = 0; __pyx_t_19 = __pyx_t_22(__pyx_t_16); if (unlikely(!__pyx_t_19)) goto __pyx_L50_unpacking_failed;
                    __Pyx_GOTREF(__pyx_t_19);
                    index = 1; __pyx_t_17 = __pyx_t_22(__pyx_t_16); if (unlikely(!__pyx_t_17)) goto __pyx_L50_unpacking_failed;
                    __Pyx_GOTREF(__pyx_t_17);
                    if (__Pyx_IternextUnpackEndCheck(__pyx_t_22(__pyx_t_16), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __pyx_t_22 = NULL;
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    goto __pyx_L51_unpacking_done;
                    __pyx_L50_unpacking_failed:;
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __pyx_t_22 = NULL;
                    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
                    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __pyx_L51_unpacking_done:;
                  }
                  __pyx_v_kguid = __pyx_t_19;
                  __pyx_t_19 = 0;
                  __pyx_v_opc = __pyx_t_17;
                  __pyx_t_17 = 0;

                  /* "kstreamc.pyx":336
 *                                if kparam.second != NULL}
 *                     kguid, opc = <object>ktuple
 *                     kguid = kguid[:-1]             # <<<<<<<<<<<<<<
 *                     # registry events have a valid process/thread id
 *                     # in the event header so we aggregate them
 */
                  __pyx_t_18 = __Pyx_PyObject_GetSlice(__pyx_v_kguid, 0, -1L, NULL, NULL, &__pyx_slice__2, 0, 1, 1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_18);
                  __Pyx_DECREF_SET(__pyx_v_kguid, __pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "kstreamc.pyx":339
 *                     # registry events have a valid process/thread id
 *                     # in the event header so we aggregate them
 *                     if kguid in REGISTRY_KGUID:             # <<<<<<<<<<<<<<
 *                         kparams['thread_id']  = tid
 *                         kparams['process_id'] = pid
 */
                  __pyx_t_18 = __Pyx_GetModuleGlobalName(__pyx_n_s_REGISTRY_KGUID); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_18);
                  __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_kguid, __pyx_t_18, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __pyx_t_6 = (__pyx_t_1 != 0);
                  if (__pyx_t_6) {

                    /* "kstreamc.pyx":340
 *                     # in the event header so we aggregate them
 *                     if kguid in REGISTRY_KGUID:
 *                         kparams['thread_id']  = tid             # <<<<<<<<<<<<<<
 *                         kparams['process_id'] = pid
 *                     elif kguid in FS_KGUID:
 */
                    __pyx_t_18 = __Pyx_PyInt_From_ULONG(__pyx_v_tid); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_18);
                    if (unlikely(PyDict_SetItem(__pyx_v_kparams, __pyx_n_s_thread_id, __pyx_t_18) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                    /* "kstreamc.pyx":341
 *                     if kguid in REGISTRY_KGUID:
 *                         kparams['thread_id']  = tid
 *                         kparams['process_id'] = pid             # <<<<<<<<<<<<<<
 *                     elif kguid in FS_KGUID:
 *                         kparams['process_id']  = pid
 */
                    __pyx_t_18 = __Pyx_PyInt_From_ULONG(__pyx_v_pid); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_18);
                    if (unlikely(PyDict_SetItem(__pyx_v_kparams, __pyx_n_s_process_id, __pyx_t_18) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                    /* "kstreamc.pyx":339
 *                     # registry events have a valid process/thread id
 *                     # in the event header so we aggregate them
 *                     if kguid in REGISTRY_KGUID:             # <<<<<<<<<<<<<<
 *                         kparams['thread_id']  = tid
 *                         kparams['process_id'] = pid
 */
                    goto __pyx_L52;
                  }

                  /* "kstreamc.pyx":342
 *                         kparams['thread_id']  = tid
 *                         kparams['process_id'] = pid
 *                     elif kguid in FS_KGUID:             # <<<<<<<<<<<<<<
 *                         kparams['process_id']  = pid
 *                     if self.next_kevt_callback:
 */
                  __pyx_t_18 = __Pyx_GetModuleGlobalName(__pyx_n_s_FS_KGUID); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_GOTREF(__pyx_t_18);
                  __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_v_kguid, __pyx_t_18, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __pyx_t_1 = (__pyx_t_6 != 0);
                  if (__pyx_t_1) {

                    /* "kstreamc.pyx":343
 *                         kparams['process_id'] = pid
 *                     elif kguid in FS_KGUID:
 *                         kparams['process_id']  = pid             # <<<<<<<<<<<<<<
 *                     if self.next_kevt_callback:
 *                         self.next_kevt_callback((kguid, opc,), cpuid,
 */
                    __pyx_t_18 = __Pyx_PyInt_From_ULONG(__pyx_v_pid); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_18);
                    if (unlikely(PyDict_SetItem(__pyx_v_kparams, __pyx_n_s_process_id, __pyx_t_18) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                    /* "kstreamc.pyx":342
 *                         kparams['thread_id']  = tid
 *                         kparams['process_id'] = pid
 *                     elif kguid in FS_KGUID:             # <<<<<<<<<<<<<<
 *                         kparams['process_id']  = pid
 *                     if self.next_kevt_callback:
 */
                  }
                  __pyx_L52:;

                  /* "kstreamc.pyx":344
 *                     elif kguid in FS_KGUID:
 *                         kparams['process_id']  = pid
 *                     if self.next_kevt_callback:             # <<<<<<<<<<<<<<
 *                         self.next_kevt_callback((kguid, opc,), cpuid,
 *                                                 timestamp,
 */
                  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->next_kevt_callback); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                  if (__pyx_t_1) {

                    /* "kstreamc.pyx":345
 *                         kparams['process_id']  = pid
 *                     if self.next_kevt_callback:
 *                         self.next_kevt_callback((kguid, opc,), cpuid,             # <<<<<<<<<<<<<<
 *                                                 timestamp,
 *                                                 kparams)
 */
                    __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_17);
                    __Pyx_INCREF(__pyx_v_kguid);
                    __Pyx_GIVEREF(__pyx_v_kguid);
                    PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_v_kguid);
                    __Pyx_INCREF(__pyx_v_opc);
                    __Pyx_GIVEREF(__pyx_v_opc);
                    PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_v_opc);
                    __pyx_t_19 = __Pyx_PyInt_From_UCHAR(__pyx_v_cpuid); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_19);

                    /* "kstreamc.pyx":347
 *                         self.next_kevt_callback((kguid, opc,), cpuid,
 *                                                 timestamp,
 *                                                 kparams)             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     print(traceback.print_exc())
 */
                    __Pyx_INCREF(__pyx_v_self->next_kevt_callback);
                    __pyx_t_16 = __pyx_v_self->next_kevt_callback; __pyx_t_15 = NULL;
                    __pyx_t_23 = 0;
                    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_16))) {
                      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_16);
                      if (likely(__pyx_t_15)) {
                        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
                        __Pyx_INCREF(__pyx_t_15);
                        __Pyx_INCREF(function);
                        __Pyx_DECREF_SET(__pyx_t_16, function);
                        __pyx_t_23 = 1;
                      }
                    }
                    __pyx_t_11 = PyTuple_New(4+__pyx_t_23); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_11);
                    if (__pyx_t_15) {
                      __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_15); __pyx_t_15 = NULL;
                    }
                    __Pyx_GIVEREF(__pyx_t_17);
                    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_23, __pyx_t_17);
                    __Pyx_GIVEREF(__pyx_t_19);
                    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_23, __pyx_t_19);
                    __Pyx_INCREF(__pyx_v_timestamp);
                    __Pyx_GIVEREF(__pyx_v_timestamp);
                    PyTuple_SET_ITEM(__pyx_t_11, 2+__pyx_t_23, __pyx_v_timestamp);
                    __Pyx_INCREF(__pyx_v_kparams);
                    __Pyx_GIVEREF(__pyx_v_kparams);
                    PyTuple_SET_ITEM(__pyx_t_11, 3+__pyx_t_23, __pyx_v_kparams);
                    __pyx_t_17 = 0;
                    __pyx_t_19 = 0;
                    __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_11, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
                    __Pyx_GOTREF(__pyx_t_18);
                    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                    /* "kstreamc.pyx":344
 *                     elif kguid in FS_KGUID:
 *                         kparams['process_id']  = pid
 *                     if self.next_kevt_callback:             # <<<<<<<<<<<<<<
 *                         self.next_kevt_callback((kguid, opc,), cpuid,
 *                                                 timestamp,
 */
                  }

                  /* "kstreamc.pyx":324
 *                     self.close_kstream()
 *                     return
 *                 try:             # <<<<<<<<<<<<<<
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,
 *                                                               ts.day, ts.hour,
 */
                }
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                goto __pyx_L46_try_end;
                __pyx_L39_error:;
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;

                /* "kstreamc.pyx":348
 *                                                 timestamp,
 *                                                 kparams)
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     print(traceback.print_exc())
 *                 except KeyboardInterrupt:
 */
                __pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
                if (__pyx_t_9) {
                  __Pyx_AddTraceback("kstreamc.KEventStreamCollector._process_kevent", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_16, &__pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
                  __Pyx_GOTREF(__pyx_t_18);
                  __Pyx_GOTREF(__pyx_t_16);
                  __Pyx_GOTREF(__pyx_t_11);
                  __Pyx_INCREF(__pyx_t_16);
                  __pyx_v_e = __pyx_t_16;

                  /* "kstreamc.pyx":349
 *                                                 kparams)
 *                 except Exception as e:
 *                     print(traceback.print_exc())             # <<<<<<<<<<<<<<
 *                 except KeyboardInterrupt:
 *                     pass
 */
                  __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_traceback); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
                  __Pyx_GOTREF(__pyx_t_17);
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_print_exc); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __pyx_t_17 = NULL;
                  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_15))) {
                    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
                    if (likely(__pyx_t_17)) {
                      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
                      __Pyx_INCREF(__pyx_t_17);
                      __Pyx_INCREF(function);
                      __Pyx_DECREF_SET(__pyx_t_15, function);
                    }
                  }
                  if (__pyx_t_17) {
                    __pyx_t_19 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_17); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  } else {
                    __pyx_t_19 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
                  }
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (__Pyx_PrintOne(0, __pyx_t_19) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                  goto __pyx_L40_exception_handled;
                }

                /* "kstreamc.pyx":350
 *                 except Exception as e:
 *                     print(traceback.print_exc())
 *                 except KeyboardInterrupt:             # <<<<<<<<<<<<<<
 *                     pass
 *                 finally:
 */
                __pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_KeyboardInterrupt);
                if (__pyx_t_9) {
                  PyErr_Restore(0,0,0);
                  goto __pyx_L40_exception_handled;
                }
                goto __pyx_L41_except_error;
                __pyx_L41_except_error:;

                /* "kstreamc.pyx":324
 *                     self.close_kstream()
 *                     return
 *                 try:             # <<<<<<<<<<<<<<
 *                     timestamp = '%d-%d-%d %d:%02d:%02d.%d' % (ts.year, ts.month,
 *                                                               ts.day, ts.hour,
 */
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                goto __pyx_L37_error;
                __pyx_L40_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                __pyx_L46_try_end:;
              }
            }

            /* "kstreamc.pyx":353
 *                     pass
 *                 finally:
 *                     Py_XDECREF(ktuple)             # <<<<<<<<<<<<<<
 *         else:
 *             free(info)
 */
            /*finally:*/ {
              /*normal exit:*/{
                Py_XDECREF(__pyx_v_ktuple);
                goto __pyx_L38;
              }
              /*exception exit:*/{
                __pyx_L37_error:;
                __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28);
                if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_26);
                __Pyx_XGOTREF(__pyx_t_27);
                __Pyx_XGOTREF(__pyx_t_28);
                __pyx_t_9 = __pyx_lineno; __pyx_t_24 = __pyx_clineno; __pyx_t_25 = __pyx_filename;
                {
                  Py_XDECREF(__pyx_v_ktuple);
                }
                if (PY_MAJOR_VERSION >= 3) {
                  __Pyx_XGIVEREF(__pyx_t_26);
                  __Pyx_XGIVEREF(__pyx_t_27);
                  __Pyx_XGIVEREF(__pyx_t_28);
                  __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28);
                }
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_ErrRestore(__pyx_t_14, __pyx_t_13, __pyx_t_12);
                __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
                __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_24; __pyx_filename = __pyx_t_25;
                goto __pyx_L33_error;
              }
              __pyx_L38:;
            }
          }

          /* "kstreamc.pyx":316
 *                     Py_XDECREF(ktuple)
 *                 return
 *             with gil:             # <<<<<<<<<<<<<<
 *                 # check for pending signals.
 *                 # The default behaviour is to
 */
          /*finally:*/ {
            /*normal exit:*/{
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L34;
            }
            __pyx_L32_return: {
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L3_return;
            }
            __pyx_L33_error: {
              #ifdef WITH_THREAD
              PyGILState_Release(__pyx_gilstate_save);
              #endif
              goto __pyx_L4_error;
            }
            __pyx_L34:;
          }
      }

      /* "kstreamc.pyx":239
 *             self.pointer_size = 8
 * 
 *         if status == ERROR_SUCCESS:             # <<<<<<<<<<<<<<
 *             props = info.properties
 *             for i from 0 <= i < info.property_count:
 */
      goto __pyx_L13;
    }

    /* "kstreamc.pyx":355
 *                     Py_XDECREF(ktuple)
 *         else:
 *             free(info)             # <<<<<<<<<<<<<<
 * 
 *     cdef _decref(self, PyObject* o):
 */
    /*else*/ {
      free(__pyx_v_info);
    }
    __pyx_L13:;
  }

  /* "kstreamc.pyx":185
 * 
 *     cdef void _process_kevent(self, EVENT_RECORD* kevent_trace) nogil except *:
 *         """Kernel event stream callback.             # <<<<<<<<<<<<<<
 * 
 *         Parameters
 */
  /*finally:*/ {
    /*normal exit:*/{
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L5;
    }
    __pyx_L3_return: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L0;
    }
    __pyx_L4_error: {
      #ifdef WITH_THREAD
      __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "kstreamc.pyx":184
 *             (<KEventStreamCollector>kevent_trace.user_ctx)._process_kevent(kevent_trace)
 * 
 *     cdef void _process_kevent(self, EVENT_RECORD* kevent_trace) nogil except *:             # <<<<<<<<<<<<<<
 *         """Kernel event stream callback.
 * 
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector._process_kevent", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_timestamp);
  __Pyx_XDECREF(__pyx_v_kparams);
  __Pyx_XDECREF(__pyx_v_kguid);
  __Pyx_XDECREF(__pyx_v_opc);
  __Pyx_XDECREF(__pyx_v_e);
  #ifdef WITH_THREAD
  PyGILState_Release(__pyx_gilstate_save);
  #endif
}

/* "kstreamc.pyx":357
 *             free(info)
 * 
 *     cdef _decref(self, PyObject* o):             # <<<<<<<<<<<<<<
 *         pyo = None
 *         if o != NULL:
 */

static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector__decref(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_v_pyo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("_decref", 0);

  /* "kstreamc.pyx":358
 * 
 *     cdef _decref(self, PyObject* o):
 *         pyo = None             # <<<<<<<<<<<<<<
 *         if o != NULL:
 *             pyo = <object>o
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_pyo = Py_None;

  /* "kstreamc.pyx":359
 *     cdef _decref(self, PyObject* o):
 *         pyo = None
 *         if o != NULL:             # <<<<<<<<<<<<<<
 *             pyo = <object>o
 *             Py_XDECREF(o)
 */
  __pyx_t_1 = ((__pyx_v_o != NULL) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":360
 *         pyo = None
 *         if o != NULL:
 *             pyo = <object>o             # <<<<<<<<<<<<<<
 *             Py_XDECREF(o)
 *         return pyo
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_o);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_pyo, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "kstreamc.pyx":361
 *         if o != NULL:
 *             pyo = <object>o
 *             Py_XDECREF(o)             # <<<<<<<<<<<<<<
 *         return pyo
 * 
 */
    Py_XDECREF(__pyx_v_o);

    /* "kstreamc.pyx":359
 *     cdef _decref(self, PyObject* o):
 *         pyo = None
 *         if o != NULL:             # <<<<<<<<<<<<<<
 *             pyo = <object>o
 *             Py_XDECREF(o)
 */
  }

  /* "kstreamc.pyx":362
 *             pyo = <object>o
 *             Py_XDECREF(o)
 *         return pyo             # <<<<<<<<<<<<<<
 * 
 *     cdef _decref_params(self,  unordered_map[wstring, PyObject*] params):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_pyo);
  __pyx_r = __pyx_v_pyo;
  goto __pyx_L0;

  /* "kstreamc.pyx":357
 *             free(info)
 * 
 *     cdef _decref(self, PyObject* o):             # <<<<<<<<<<<<<<
 *         pyo = None
 *         if o != NULL:
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pyo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":364
 *         return pyo
 * 
 *     cdef _decref_params(self,  unordered_map[wstring, PyObject*] params):             # <<<<<<<<<<<<<<
 *         for kparam in params:
 *             Py_XDECREF(_wstring(kparam.first))
 */

static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector__decref_params(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, std::unordered_map<std::wstring,PyObject *>  __pyx_v_params) {
  std::pair<std::wstring,PyObject *>  __pyx_v_kparam;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  std::unordered_map<std::wstring,PyObject *> ::iterator __pyx_t_1;
  std::pair<std::wstring,PyObject *>  __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_decref_params", 0);

  /* "kstreamc.pyx":365
 * 
 *     cdef _decref_params(self,  unordered_map[wstring, PyObject*] params):
 *         for kparam in params:             # <<<<<<<<<<<<<<
 *             Py_XDECREF(_wstring(kparam.first))
 *             if kparam.second != NULL:
 */
  __pyx_t_1 = __pyx_v_params.begin();
  for (;;) {
    if (!(__pyx_t_1 != __pyx_v_params.end())) break;
    __pyx_t_2 = *__pyx_t_1;
    ++__pyx_t_1;
    __pyx_v_kparam = __pyx_t_2;

    /* "kstreamc.pyx":366
 *     cdef _decref_params(self,  unordered_map[wstring, PyObject*] params):
 *         for kparam in params:
 *             Py_XDECREF(_wstring(kparam.first))             # <<<<<<<<<<<<<<
 *             if kparam.second != NULL:
 *                 Py_XDECREF(kparam.second)
 */
    Py_XDECREF(__pyx_f_7kstream_8includes_6python__wstring(__pyx_v_kparam.first));

    /* "kstreamc.pyx":367
 *         for kparam in params:
 *             Py_XDECREF(_wstring(kparam.first))
 *             if kparam.second != NULL:             # <<<<<<<<<<<<<<
 *                 Py_XDECREF(kparam.second)
 * 
 */
    __pyx_t_3 = ((__pyx_v_kparam.second != NULL) != 0);
    if (__pyx_t_3) {

      /* "kstreamc.pyx":368
 *             Py_XDECREF(_wstring(kparam.first))
 *             if kparam.second != NULL:
 *                 Py_XDECREF(kparam.second)             # <<<<<<<<<<<<<<
 * 
 *     cdef _underscore(self, o):
 */
      Py_XDECREF(__pyx_v_kparam.second);

      /* "kstreamc.pyx":367
 *         for kparam in params:
 *             Py_XDECREF(_wstring(kparam.first))
 *             if kparam.second != NULL:             # <<<<<<<<<<<<<<
 *                 Py_XDECREF(kparam.second)
 * 
 */
    }

    /* "kstreamc.pyx":365
 * 
 *     cdef _decref_params(self,  unordered_map[wstring, PyObject*] params):
 *         for kparam in params:             # <<<<<<<<<<<<<<
 *             Py_XDECREF(_wstring(kparam.first))
 *             if kparam.second != NULL:
 */
  }

  /* "kstreamc.pyx":364
 *         return pyo
 * 
 *     cdef _decref_params(self,  unordered_map[wstring, PyObject*] params):             # <<<<<<<<<<<<<<
 *         for kparam in params:
 *             Py_XDECREF(_wstring(kparam.first))
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":370
 *                 Py_XDECREF(kparam.second)
 * 
 *     cdef _underscore(self, o):             # <<<<<<<<<<<<<<
 *         return self.regex.sub(r'_\1', o).lower()
 * 
 */

static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector__underscore(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_underscore", 0);

  /* "kstreamc.pyx":371
 * 
 *     cdef _underscore(self, o):
 *         return self.regex.sub(r'_\1', o).lower()             # <<<<<<<<<<<<<<
 * 
 *     cdef PyObject* __parse_property(self, USHORT in_type, USHORT out_type,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->regex, __pyx_n_s_sub); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__pyx_t_4) {
    __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
  }
  __Pyx_INCREF(__pyx_kp_s_1);
  __Pyx_GIVEREF(__pyx_kp_s_1);
  PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_kp_s_1);
  __Pyx_INCREF(__pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_o);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "kstreamc.pyx":370
 *                 Py_XDECREF(kparam.second)
 * 
 *     cdef _underscore(self, o):             # <<<<<<<<<<<<<<
 *         return self.regex.sub(r'_\1', o).lower()
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("kstreamc.KEventStreamCollector._underscore", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstreamc.pyx":373
 *         return self.regex.sub(r'_\1', o).lower()
 * 
 *     cdef PyObject* __parse_property(self, USHORT in_type, USHORT out_type,             # <<<<<<<<<<<<<<
 *                                     BYTE* buf) nogil:
 *         """Parses the property value.
 */

static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector___parse_property(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, USHORT __pyx_v_in_type, USHORT __pyx_v_out_type, BYTE *__pyx_v_buf) {
  PyObject *__pyx_r;
  int __pyx_t_1;

  /* "kstreamc.pyx":391
 *             The pointer to the property buffer.
 *         """
 *         if buf == NULL:             # <<<<<<<<<<<<<<
 *             return NULL
 * 
 */
  __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":392
 *         """
 *         if buf == NULL:
 *             return NULL             # <<<<<<<<<<<<<<
 * 
 *         if in_type == TDH_INTYPE_UNICODESTRING:
 */
    __pyx_r = NULL;
    goto __pyx_L0;

    /* "kstreamc.pyx":391
 *             The pointer to the property buffer.
 *         """
 *         if buf == NULL:             # <<<<<<<<<<<<<<
 *             return NULL
 * 
 */
  }

  /* "kstreamc.pyx":394
 *             return NULL
 * 
 *         if in_type == TDH_INTYPE_UNICODESTRING:             # <<<<<<<<<<<<<<
 *             return _unicode(<wchar_t*>buf)
 *         elif in_type == TDH_INTYPE_ANSISTRING:
 */
  switch (__pyx_v_in_type) {
    case TDH_INTYPE_UNICODESTRING:

    /* "kstreamc.pyx":395
 * 
 *         if in_type == TDH_INTYPE_UNICODESTRING:
 *             return _unicode(<wchar_t*>buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_ANSISTRING:
 *             return _ansi(<char*>buf)
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__unicode(((wchar_t *)__pyx_v_buf));
    goto __pyx_L0;

    /* "kstreamc.pyx":394
 *             return NULL
 * 
 *         if in_type == TDH_INTYPE_UNICODESTRING:             # <<<<<<<<<<<<<<
 *             return _unicode(<wchar_t*>buf)
 *         elif in_type == TDH_INTYPE_ANSISTRING:
 */
    break;

    /* "kstreamc.pyx":396
 *         if in_type == TDH_INTYPE_UNICODESTRING:
 *             return _unicode(<wchar_t*>buf)
 *         elif in_type == TDH_INTYPE_ANSISTRING:             # <<<<<<<<<<<<<<
 *             return _ansi(<char*>buf)
 *         elif in_type == TDH_INTYPE_UNICODECHAR:
 */
    case TDH_INTYPE_ANSISTRING:

    /* "kstreamc.pyx":397
 *             return _unicode(<wchar_t*>buf)
 *         elif in_type == TDH_INTYPE_ANSISTRING:
 *             return _ansi(<char*>buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_UNICODECHAR:
 *             return _unicodec(buf)
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__ansi(((char *)__pyx_v_buf));
    goto __pyx_L0;

    /* "kstreamc.pyx":396
 *         if in_type == TDH_INTYPE_UNICODESTRING:
 *             return _unicode(<wchar_t*>buf)
 *         elif in_type == TDH_INTYPE_ANSISTRING:             # <<<<<<<<<<<<<<
 *             return _ansi(<char*>buf)
 *         elif in_type == TDH_INTYPE_UNICODECHAR:
 */
    break;

    /* "kstreamc.pyx":398
 *         elif in_type == TDH_INTYPE_ANSISTRING:
 *             return _ansi(<char*>buf)
 *         elif in_type == TDH_INTYPE_UNICODECHAR:             # <<<<<<<<<<<<<<
 *             return _unicodec(buf)
 *         elif in_type == TDH_INTYPE_ANSICHAR:
 */
    case TDH_INTYPE_UNICODECHAR:

    /* "kstreamc.pyx":399
 *             return _ansi(<char*>buf)
 *         elif in_type == TDH_INTYPE_UNICODECHAR:
 *             return _unicodec(buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_ANSICHAR:
 *             return _ansic(buf)
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__unicodec(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":398
 *         elif in_type == TDH_INTYPE_ANSISTRING:
 *             return _ansi(<char*>buf)
 *         elif in_type == TDH_INTYPE_UNICODECHAR:             # <<<<<<<<<<<<<<
 *             return _unicodec(buf)
 *         elif in_type == TDH_INTYPE_ANSICHAR:
 */
    break;

    /* "kstreamc.pyx":400
 *         elif in_type == TDH_INTYPE_UNICODECHAR:
 *             return _unicodec(buf)
 *         elif in_type == TDH_INTYPE_ANSICHAR:             # <<<<<<<<<<<<<<
 *             return _ansic(buf)
 * 
 */
    case TDH_INTYPE_ANSICHAR:

    /* "kstreamc.pyx":401
 *             return _unicodec(buf)
 *         elif in_type == TDH_INTYPE_ANSICHAR:
 *             return _ansic(buf)             # <<<<<<<<<<<<<<
 * 
 *         elif in_type == TDH_INTYPE_INT8:
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__ansic(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":400
 *         elif in_type == TDH_INTYPE_UNICODECHAR:
 *             return _unicodec(buf)
 *         elif in_type == TDH_INTYPE_ANSICHAR:             # <<<<<<<<<<<<<<
 *             return _ansic(buf)
 * 
 */
    break;

    /* "kstreamc.pyx":403
 *             return _ansic(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT8:             # <<<<<<<<<<<<<<
 *             return _i8(buf)
 *         elif in_type == TDH_INTYPE_UINT8:
 */
    case TDH_INTYPE_INT8:

    /* "kstreamc.pyx":404
 * 
 *         elif in_type == TDH_INTYPE_INT8:
 *             return _i8(buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_UINT8:
 *             if out_type == TDH_OUTTYPE_HEXINT8:
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__i8(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":403
 *             return _ansic(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT8:             # <<<<<<<<<<<<<<
 *             return _i8(buf)
 *         elif in_type == TDH_INTYPE_UINT8:
 */
    break;

    /* "kstreamc.pyx":405
 *         elif in_type == TDH_INTYPE_INT8:
 *             return _i8(buf)
 *         elif in_type == TDH_INTYPE_UINT8:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT8:
 *                 return _u8_hex(buf)
 */
    case TDH_INTYPE_UINT8:

    /* "kstreamc.pyx":406
 *             return _i8(buf)
 *         elif in_type == TDH_INTYPE_UINT8:
 *             if out_type == TDH_OUTTYPE_HEXINT8:             # <<<<<<<<<<<<<<
 *                 return _u8_hex(buf)
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_out_type == TDH_OUTTYPE_HEXINT8) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":407
 *         elif in_type == TDH_INTYPE_UINT8:
 *             if out_type == TDH_OUTTYPE_HEXINT8:
 *                 return _u8_hex(buf)             # <<<<<<<<<<<<<<
 *             else:
 *                 return _u8(buf)
 */
      __pyx_r = __pyx_f_7kstream_8includes_6python__u8_hex(__pyx_v_buf);
      goto __pyx_L0;

      /* "kstreamc.pyx":406
 *             return _i8(buf)
 *         elif in_type == TDH_INTYPE_UINT8:
 *             if out_type == TDH_OUTTYPE_HEXINT8:             # <<<<<<<<<<<<<<
 *                 return _u8_hex(buf)
 *             else:
 */
    }

    /* "kstreamc.pyx":409
 *                 return _u8_hex(buf)
 *             else:
 *                 return _u8(buf)             # <<<<<<<<<<<<<<
 * 
 *         elif in_type == TDH_INTYPE_INT16:
 */
    /*else*/ {
      __pyx_r = __pyx_f_7kstream_8includes_6python__u8(__pyx_v_buf);
      goto __pyx_L0;
    }

    /* "kstreamc.pyx":405
 *         elif in_type == TDH_INTYPE_INT8:
 *             return _i8(buf)
 *         elif in_type == TDH_INTYPE_UINT8:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT8:
 *                 return _u8_hex(buf)
 */
    break;

    /* "kstreamc.pyx":411
 *                 return _u8(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT16:             # <<<<<<<<<<<<<<
 *             return _i16(buf)
 *         elif in_type == TDH_INTYPE_UINT16:
 */
    case TDH_INTYPE_INT16:

    /* "kstreamc.pyx":412
 * 
 *         elif in_type == TDH_INTYPE_INT16:
 *             return _i16(buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_UINT16:
 *             if out_type == TDH_OUTTYPE_HEXINT16:
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__i16(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":411
 *                 return _u8(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT16:             # <<<<<<<<<<<<<<
 *             return _i16(buf)
 *         elif in_type == TDH_INTYPE_UINT16:
 */
    break;

    /* "kstreamc.pyx":413
 *         elif in_type == TDH_INTYPE_INT16:
 *             return _i16(buf)
 *         elif in_type == TDH_INTYPE_UINT16:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT16:
 *                 return _i16_hex(buf)
 */
    case TDH_INTYPE_UINT16:

    /* "kstreamc.pyx":414
 *             return _i16(buf)
 *         elif in_type == TDH_INTYPE_UINT16:
 *             if out_type == TDH_OUTTYPE_HEXINT16:             # <<<<<<<<<<<<<<
 *                 return _i16_hex(buf)
 *             elif out_type == TDH_OUTTYPE_PORT:
 */
    __pyx_t_1 = ((__pyx_v_out_type == TDH_OUTTYPE_HEXINT16) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":415
 *         elif in_type == TDH_INTYPE_UINT16:
 *             if out_type == TDH_OUTTYPE_HEXINT16:
 *                 return _i16_hex(buf)             # <<<<<<<<<<<<<<
 *             elif out_type == TDH_OUTTYPE_PORT:
 *                 return _ntohs(buf)
 */
      __pyx_r = __pyx_f_7kstream_8includes_6python__i16_hex(__pyx_v_buf);
      goto __pyx_L0;

      /* "kstreamc.pyx":414
 *             return _i16(buf)
 *         elif in_type == TDH_INTYPE_UINT16:
 *             if out_type == TDH_OUTTYPE_HEXINT16:             # <<<<<<<<<<<<<<
 *                 return _i16_hex(buf)
 *             elif out_type == TDH_OUTTYPE_PORT:
 */
    }

    /* "kstreamc.pyx":416
 *             if out_type == TDH_OUTTYPE_HEXINT16:
 *                 return _i16_hex(buf)
 *             elif out_type == TDH_OUTTYPE_PORT:             # <<<<<<<<<<<<<<
 *                 return _ntohs(buf)
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_out_type == TDH_OUTTYPE_PORT) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":417
 *                 return _i16_hex(buf)
 *             elif out_type == TDH_OUTTYPE_PORT:
 *                 return _ntohs(buf)             # <<<<<<<<<<<<<<
 *             else:
 *                 return _u16(buf)
 */
      __pyx_r = __pyx_f_7kstream_8includes_6python__ntohs(__pyx_v_buf);
      goto __pyx_L0;

      /* "kstreamc.pyx":416
 *             if out_type == TDH_OUTTYPE_HEXINT16:
 *                 return _i16_hex(buf)
 *             elif out_type == TDH_OUTTYPE_PORT:             # <<<<<<<<<<<<<<
 *                 return _ntohs(buf)
 *             else:
 */
    }

    /* "kstreamc.pyx":419
 *                 return _ntohs(buf)
 *             else:
 *                 return _u16(buf)             # <<<<<<<<<<<<<<
 * 
 *         elif in_type == TDH_INTYPE_INT32:
 */
    /*else*/ {
      __pyx_r = __pyx_f_7kstream_8includes_6python__u16(__pyx_v_buf);
      goto __pyx_L0;
    }

    /* "kstreamc.pyx":413
 *         elif in_type == TDH_INTYPE_INT16:
 *             return _i16(buf)
 *         elif in_type == TDH_INTYPE_UINT16:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT16:
 *                 return _i16_hex(buf)
 */
    break;

    /* "kstreamc.pyx":421
 *                 return _u16(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT32:             # <<<<<<<<<<<<<<
 *             return _i32(buf)
 *         elif in_type == TDH_INTYPE_UINT32:
 */
    case TDH_INTYPE_INT32:

    /* "kstreamc.pyx":422
 * 
 *         elif in_type == TDH_INTYPE_INT32:
 *             return _i32(buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_UINT32:
 *             if out_type == TDH_OUTTYPE_HEXINT32:
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__i32(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":421
 *                 return _u16(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT32:             # <<<<<<<<<<<<<<
 *             return _i32(buf)
 *         elif in_type == TDH_INTYPE_UINT32:
 */
    break;

    /* "kstreamc.pyx":423
 *         elif in_type == TDH_INTYPE_INT32:
 *             return _i32(buf)
 *         elif in_type == TDH_INTYPE_UINT32:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT32:
 *                 return _i32_hex(buf)
 */
    case TDH_INTYPE_UINT32:

    /* "kstreamc.pyx":424
 *             return _i32(buf)
 *         elif in_type == TDH_INTYPE_UINT32:
 *             if out_type == TDH_OUTTYPE_HEXINT32:             # <<<<<<<<<<<<<<
 *                 return _i32_hex(buf)
 *             elif out_type == TDH_OUTTYPE_IPV4:
 */
    __pyx_t_1 = ((__pyx_v_out_type == TDH_OUTTYPE_HEXINT32) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":425
 *         elif in_type == TDH_INTYPE_UINT32:
 *             if out_type == TDH_OUTTYPE_HEXINT32:
 *                 return _i32_hex(buf)             # <<<<<<<<<<<<<<
 *             elif out_type == TDH_OUTTYPE_IPV4:
 *                 return ip_addr(buf)
 */
      __pyx_r = __pyx_f_7kstream_8includes_6python__i32_hex(__pyx_v_buf);
      goto __pyx_L0;

      /* "kstreamc.pyx":424
 *             return _i32(buf)
 *         elif in_type == TDH_INTYPE_UINT32:
 *             if out_type == TDH_OUTTYPE_HEXINT32:             # <<<<<<<<<<<<<<
 *                 return _i32_hex(buf)
 *             elif out_type == TDH_OUTTYPE_IPV4:
 */
    }

    /* "kstreamc.pyx":426
 *             if out_type == TDH_OUTTYPE_HEXINT32:
 *                 return _i32_hex(buf)
 *             elif out_type == TDH_OUTTYPE_IPV4:             # <<<<<<<<<<<<<<
 *                 return ip_addr(buf)
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_out_type == TDH_OUTTYPE_IPV4) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":427
 *                 return _i32_hex(buf)
 *             elif out_type == TDH_OUTTYPE_IPV4:
 *                 return ip_addr(buf)             # <<<<<<<<<<<<<<
 *             else:
 *                 return _u32(buf)
 */
      __pyx_r = __pyx_f_7kstream_8includes_6python_ip_addr(__pyx_v_buf);
      goto __pyx_L0;

      /* "kstreamc.pyx":426
 *             if out_type == TDH_OUTTYPE_HEXINT32:
 *                 return _i32_hex(buf)
 *             elif out_type == TDH_OUTTYPE_IPV4:             # <<<<<<<<<<<<<<
 *                 return ip_addr(buf)
 *             else:
 */
    }

    /* "kstreamc.pyx":429
 *                 return ip_addr(buf)
 *             else:
 *                 return _u32(buf)             # <<<<<<<<<<<<<<
 * 
 *         elif in_type == TDH_INTYPE_INT64:
 */
    /*else*/ {
      __pyx_r = __pyx_f_7kstream_8includes_6python__u32(__pyx_v_buf);
      goto __pyx_L0;
    }

    /* "kstreamc.pyx":423
 *         elif in_type == TDH_INTYPE_INT32:
 *             return _i32(buf)
 *         elif in_type == TDH_INTYPE_UINT32:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT32:
 *                 return _i32_hex(buf)
 */
    break;

    /* "kstreamc.pyx":431
 *                 return _u32(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT64:             # <<<<<<<<<<<<<<
 *             return _i64(buf)
 *         elif in_type == TDH_INTYPE_UINT64:
 */
    case TDH_INTYPE_INT64:

    /* "kstreamc.pyx":432
 * 
 *         elif in_type == TDH_INTYPE_INT64:
 *             return _i64(buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_UINT64:
 *             if out_type == TDH_OUTTYPE_HEXINT64:
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__i64(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":431
 *                 return _u32(buf)
 * 
 *         elif in_type == TDH_INTYPE_INT64:             # <<<<<<<<<<<<<<
 *             return _i64(buf)
 *         elif in_type == TDH_INTYPE_UINT64:
 */
    break;

    /* "kstreamc.pyx":433
 *         elif in_type == TDH_INTYPE_INT64:
 *             return _i64(buf)
 *         elif in_type == TDH_INTYPE_UINT64:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT64:
 *                 return _i64_hex(buf)
 */
    case TDH_INTYPE_UINT64:

    /* "kstreamc.pyx":434
 *             return _i64(buf)
 *         elif in_type == TDH_INTYPE_UINT64:
 *             if out_type == TDH_OUTTYPE_HEXINT64:             # <<<<<<<<<<<<<<
 *                 return _i64_hex(buf)
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_out_type == TDH_OUTTYPE_HEXINT64) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":435
 *         elif in_type == TDH_INTYPE_UINT64:
 *             if out_type == TDH_OUTTYPE_HEXINT64:
 *                 return _i64_hex(buf)             # <<<<<<<<<<<<<<
 *             else:
 *                 return _u64(buf)
 */
      __pyx_r = __pyx_f_7kstream_8includes_6python__i64_hex(__pyx_v_buf);
      goto __pyx_L0;

      /* "kstreamc.pyx":434
 *             return _i64(buf)
 *         elif in_type == TDH_INTYPE_UINT64:
 *             if out_type == TDH_OUTTYPE_HEXINT64:             # <<<<<<<<<<<<<<
 *                 return _i64_hex(buf)
 *             else:
 */
    }

    /* "kstreamc.pyx":437
 *                 return _i64_hex(buf)
 *             else:
 *                 return _u64(buf)             # <<<<<<<<<<<<<<
 * 
 *         elif in_type == TDH_INTYPE_HEXINT32:
 */
    /*else*/ {
      __pyx_r = __pyx_f_7kstream_8includes_6python__u64(__pyx_v_buf);
      goto __pyx_L0;
    }

    /* "kstreamc.pyx":433
 *         elif in_type == TDH_INTYPE_INT64:
 *             return _i64(buf)
 *         elif in_type == TDH_INTYPE_UINT64:             # <<<<<<<<<<<<<<
 *             if out_type == TDH_OUTTYPE_HEXINT64:
 *                 return _i64_hex(buf)
 */
    break;

    /* "kstreamc.pyx":439
 *                 return _u64(buf)
 * 
 *         elif in_type == TDH_INTYPE_HEXINT32:             # <<<<<<<<<<<<<<
 *             return _i32_hex(buf)
 *         elif in_type ==  TDH_INTYPE_HEXINT64:
 */
    case TDH_INTYPE_HEXINT32:

    /* "kstreamc.pyx":440
 * 
 *         elif in_type == TDH_INTYPE_HEXINT32:
 *             return _i32_hex(buf)             # <<<<<<<<<<<<<<
 *         elif in_type ==  TDH_INTYPE_HEXINT64:
 *             return  _i64_hex(buf)
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__i32_hex(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":439
 *                 return _u64(buf)
 * 
 *         elif in_type == TDH_INTYPE_HEXINT32:             # <<<<<<<<<<<<<<
 *             return _i32_hex(buf)
 *         elif in_type ==  TDH_INTYPE_HEXINT64:
 */
    break;

    /* "kstreamc.pyx":441
 *         elif in_type == TDH_INTYPE_HEXINT32:
 *             return _i32_hex(buf)
 *         elif in_type ==  TDH_INTYPE_HEXINT64:             # <<<<<<<<<<<<<<
 *             return  _i64_hex(buf)
 * 
 */
    case TDH_INTYPE_HEXINT64:

    /* "kstreamc.pyx":442
 *             return _i32_hex(buf)
 *         elif in_type ==  TDH_INTYPE_HEXINT64:
 *             return  _i64_hex(buf)             # <<<<<<<<<<<<<<
 * 
 *         elif in_type == TDH_INTYPE_FLOAT:
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__i64_hex(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":441
 *         elif in_type == TDH_INTYPE_HEXINT32:
 *             return _i32_hex(buf)
 *         elif in_type ==  TDH_INTYPE_HEXINT64:             # <<<<<<<<<<<<<<
 *             return  _i64_hex(buf)
 * 
 */
    break;

    /* "kstreamc.pyx":444
 *             return  _i64_hex(buf)
 * 
 *         elif in_type == TDH_INTYPE_FLOAT:             # <<<<<<<<<<<<<<
 *             return _float(buf)
 *         elif in_type == TDH_INTYPE_DOUBLE:
 */
    case TDH_INTYPE_FLOAT:

    /* "kstreamc.pyx":445
 * 
 *         elif in_type == TDH_INTYPE_FLOAT:
 *             return _float(buf)             # <<<<<<<<<<<<<<
 *         elif in_type == TDH_INTYPE_DOUBLE:
 *             return _double(buf)
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__float(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":444
 *             return  _i64_hex(buf)
 * 
 *         elif in_type == TDH_INTYPE_FLOAT:             # <<<<<<<<<<<<<<
 *             return _float(buf)
 *         elif in_type == TDH_INTYPE_DOUBLE:
 */
    break;

    /* "kstreamc.pyx":446
 *         elif in_type == TDH_INTYPE_FLOAT:
 *             return _float(buf)
 *         elif in_type == TDH_INTYPE_DOUBLE:             # <<<<<<<<<<<<<<
 *             return _double(buf)
 * 
 */
    case TDH_INTYPE_DOUBLE:

    /* "kstreamc.pyx":447
 *             return _float(buf)
 *         elif in_type == TDH_INTYPE_DOUBLE:
 *             return _double(buf)             # <<<<<<<<<<<<<<
 * 
 *         elif in_type == TDH_INTYPE_POINTER or \
 */
    __pyx_r = __pyx_f_7kstream_8includes_6python__double(__pyx_v_buf);
    goto __pyx_L0;

    /* "kstreamc.pyx":446
 *         elif in_type == TDH_INTYPE_FLOAT:
 *             return _float(buf)
 *         elif in_type == TDH_INTYPE_DOUBLE:             # <<<<<<<<<<<<<<
 *             return _double(buf)
 * 
 */
    break;

    /* "kstreamc.pyx":449
 *             return _double(buf)
 * 
 *         elif in_type == TDH_INTYPE_POINTER or \             # <<<<<<<<<<<<<<
 *                         in_type == TDH_INTYPE_SIZET:
 *             if self.pointer_size == 8:
 */
    case TDH_INTYPE_POINTER:

    /* "kstreamc.pyx":450
 * 
 *         elif in_type == TDH_INTYPE_POINTER or \
 *                         in_type == TDH_INTYPE_SIZET:             # <<<<<<<<<<<<<<
 *             if self.pointer_size == 8:
 *                 return _u64(buf)
 */
    case TDH_INTYPE_SIZET:

    /* "kstreamc.pyx":451
 *         elif in_type == TDH_INTYPE_POINTER or \
 *                         in_type == TDH_INTYPE_SIZET:
 *             if self.pointer_size == 8:             # <<<<<<<<<<<<<<
 *                 return _u64(buf)
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_self->pointer_size == 8) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":452
 *                         in_type == TDH_INTYPE_SIZET:
 *             if self.pointer_size == 8:
 *                 return _u64(buf)             # <<<<<<<<<<<<<<
 *             else:
 *                 return _u32(buf)
 */
      __pyx_r = __pyx_f_7kstream_8includes_6python__u64(__pyx_v_buf);
      goto __pyx_L0;

      /* "kstreamc.pyx":451
 *         elif in_type == TDH_INTYPE_POINTER or \
 *                         in_type == TDH_INTYPE_SIZET:
 *             if self.pointer_size == 8:             # <<<<<<<<<<<<<<
 *                 return _u64(buf)
 *             else:
 */
    }

    /* "kstreamc.pyx":454
 *                 return _u64(buf)
 *             else:
 *                 return _u32(buf)             # <<<<<<<<<<<<<<
 *         else:
 *             return NULL
 */
    /*else*/ {
      __pyx_r = __pyx_f_7kstream_8includes_6python__u32(__pyx_v_buf);
      goto __pyx_L0;
    }

    /* "kstreamc.pyx":449
 *             return _double(buf)
 * 
 *         elif in_type == TDH_INTYPE_POINTER or \             # <<<<<<<<<<<<<<
 *                         in_type == TDH_INTYPE_SIZET:
 *             if self.pointer_size == 8:
 */
    break;
    default:

    /* "kstreamc.pyx":456
 *                 return _u32(buf)
 *         else:
 *             return NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef BOOL __apply_filters(self, ULONG pid, ULONG tid,
 */
    __pyx_r = NULL;
    goto __pyx_L0;
    break;
  }

  /* "kstreamc.pyx":373
 *         return self.regex.sub(r'_\1', o).lower()
 * 
 *     cdef PyObject* __parse_property(self, USHORT in_type, USHORT out_type,             # <<<<<<<<<<<<<<
 *                                     BYTE* buf) nogil:
 *         """Parses the property value.
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstreamc.pyx":458
 *             return NULL
 * 
 *     cdef BOOL __apply_filters(self, ULONG pid, ULONG tid,             # <<<<<<<<<<<<<<
 *                               PyObject* ktuple,
 *                               unordered_map[wstring, PyObject*] params,
 */

static BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_filters(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, ULONG __pyx_v_pid, CYTHON_UNUSED ULONG __pyx_v_tid, PyObject *__pyx_v_ktuple, std::unordered_map<std::wstring,PyObject *>  __pyx_v_params, BOOL __pyx_v_defer) {
  BOOL __pyx_v_drop;
  long __pyx_v_i;
  PyObject *__pyx_v_ktuple_filter;
  wchar_t *__pyx_v_image_name;
  BOOL __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  size_t __pyx_t_3;
  __Pyx_FakeReference<PyObject *> __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "kstreamc.pyx":462
 *                               unordered_map[wstring, PyObject*] params,
 *                               BOOL defer) nogil:
 *         cdef BOOL drop = True             # <<<<<<<<<<<<<<
 * 
 *         # we don't want to capture any events
 */
  __pyx_v_drop = 1;

  /* "kstreamc.pyx":468
 *         # nor from the process we've declared
 *         # in the excluded process list
 *         if self.own_pid == pid:             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->own_pid == __pyx_v_pid) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":469
 *         # in the excluded process list
 *         if self.own_pid == pid:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *         if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "kstreamc.pyx":468
 *         # nor from the process we've declared
 *         # in the excluded process list
 *         if self.own_pid == pid:             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
  }

  /* "kstreamc.pyx":471
 *             return True
 * 
 *         if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \             # <<<<<<<<<<<<<<
 *             self.__ktuple_equals(ktuple, ENUM_THREAD) or \
 *             self.__ktuple_equals(ktuple, ENUM_IMAGE) or \
 */
  __pyx_t_2 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_ENUM_PROCESS) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }

  /* "kstreamc.pyx":472
 * 
 *         if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \
 *             self.__ktuple_equals(ktuple, ENUM_THREAD) or \             # <<<<<<<<<<<<<<
 *             self.__ktuple_equals(ktuple, ENUM_IMAGE) or \
 *             self.__ktuple_equals(ktuple, REG_CREATE_KCB) or \
 */
  __pyx_t_2 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_ENUM_THREAD) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }

  /* "kstreamc.pyx":473
 *         if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \
 *             self.__ktuple_equals(ktuple, ENUM_THREAD) or \
 *             self.__ktuple_equals(ktuple, ENUM_IMAGE) or \             # <<<<<<<<<<<<<<
 *             self.__ktuple_equals(ktuple, REG_CREATE_KCB) or \
 *             self.__ktuple_equals(ktuple, REG_DELETE_KCB):
 */
  __pyx_t_2 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_ENUM_IMAGE) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }

  /* "kstreamc.pyx":474
 *             self.__ktuple_equals(ktuple, ENUM_THREAD) or \
 *             self.__ktuple_equals(ktuple, ENUM_IMAGE) or \
 *             self.__ktuple_equals(ktuple, REG_CREATE_KCB) or \             # <<<<<<<<<<<<<<
 *             self.__ktuple_equals(ktuple, REG_DELETE_KCB):
 *             return False
 */
  __pyx_t_2 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_REG_CREATE_KCB) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }

  /* "kstreamc.pyx":475
 *             self.__ktuple_equals(ktuple, ENUM_IMAGE) or \
 *             self.__ktuple_equals(ktuple, REG_CREATE_KCB) or \
 *             self.__ktuple_equals(ktuple, REG_DELETE_KCB):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
  __pyx_t_2 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_REG_DELETE_KCB) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;

  /* "kstreamc.pyx":471
 *             return True
 * 
 *         if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \             # <<<<<<<<<<<<<<
 *             self.__ktuple_equals(ktuple, ENUM_THREAD) or \
 *             self.__ktuple_equals(ktuple, ENUM_IMAGE) or \
 */
  if (__pyx_t_1) {

    /* "kstreamc.pyx":476
 *             self.__ktuple_equals(ktuple, REG_CREATE_KCB) or \
 *             self.__ktuple_equals(ktuple, REG_DELETE_KCB):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         # apply skip list as defined
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "kstreamc.pyx":471
 *             return True
 * 
 *         if self.__ktuple_equals(ktuple, ENUM_PROCESS) or \             # <<<<<<<<<<<<<<
 *             self.__ktuple_equals(ktuple, ENUM_THREAD) or \
 *             self.__ktuple_equals(ktuple, ENUM_IMAGE) or \
 */
  }

  /* "kstreamc.pyx":480
 *         # apply skip list as defined
 *         # in the configuration descriptor
 *         drop = self.__apply_skips(pid)             # <<<<<<<<<<<<<<
 *         if drop:
 *             return True
 */
  __pyx_v_drop = __pyx_f_8kstreamc_21KEventStreamCollector___apply_skips(__pyx_v_self, __pyx_v_pid);

  /* "kstreamc.pyx":481
 *         # in the configuration descriptor
 *         drop = self.__apply_skips(pid)
 *         if drop:             # <<<<<<<<<<<<<<
 *             return True
 *         elif self.image_filter != NULL:
 */
  __pyx_t_1 = (__pyx_v_drop != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":482
 *         drop = self.__apply_skips(pid)
 *         if drop:
 *             return True             # <<<<<<<<<<<<<<
 *         elif self.image_filter != NULL:
 *             drop = True
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "kstreamc.pyx":481
 *         # in the configuration descriptor
 *         drop = self.__apply_skips(pid)
 *         if drop:             # <<<<<<<<<<<<<<
 *             return True
 *         elif self.image_filter != NULL:
 */
  }

  /* "kstreamc.pyx":483
 *         if drop:
 *             return True
 *         elif self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *             drop = True
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->image_filter != NULL) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":484
 *             return True
 *         elif self.image_filter != NULL:
 *             drop = True             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < self.ktuple_filters.size():
 */
    __pyx_v_drop = 1;

    /* "kstreamc.pyx":483
 *         if drop:
 *             return True
 *         elif self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *             drop = True
 * 
 */
  }

  /* "kstreamc.pyx":486
 *             drop = True
 * 
 *         for i from 0 <= i < self.ktuple_filters.size():             # <<<<<<<<<<<<<<
 *             ktuple_filter = self.ktuple_filters.at(i)
 *             if self.__ktuple_equals(ktuple, ktuple_filter):
 */
  __pyx_t_3 = __pyx_v_self->ktuple_filters->size();
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {

    /* "kstreamc.pyx":487
 * 
 *         for i from 0 <= i < self.ktuple_filters.size():
 *             ktuple_filter = self.ktuple_filters.at(i)             # <<<<<<<<<<<<<<
 *             if self.__ktuple_equals(ktuple, ktuple_filter):
 *                 drop = False
 */
    try {
      __pyx_t_4 = __pyx_v_self->ktuple_filters->at(__pyx_v_i);
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      PyGILState_Release(__pyx_gilstate_save);
      #endif
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_ktuple_filter = __pyx_t_4;

    /* "kstreamc.pyx":488
 *         for i from 0 <= i < self.ktuple_filters.size():
 *             ktuple_filter = self.ktuple_filters.at(i)
 *             if self.__ktuple_equals(ktuple, ktuple_filter):             # <<<<<<<<<<<<<<
 *                 drop = False
 *                 break
 */
    __pyx_t_1 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_ktuple_filter) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":489
 *             ktuple_filter = self.ktuple_filters.at(i)
 *             if self.__ktuple_equals(ktuple, ktuple_filter):
 *                 drop = False             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
      __pyx_v_drop = 0;

      /* "kstreamc.pyx":490
 *             if self.__ktuple_equals(ktuple, ktuple_filter):
 *                 drop = False
 *                 break             # <<<<<<<<<<<<<<
 * 
 *         # apply pid filter
 */
      goto __pyx_L12_break;

      /* "kstreamc.pyx":488
 *         for i from 0 <= i < self.ktuple_filters.size():
 *             ktuple_filter = self.ktuple_filters.at(i)
 *             if self.__ktuple_equals(ktuple, ktuple_filter):             # <<<<<<<<<<<<<<
 *                 drop = False
 *                 break
 */
    }
  }
  __pyx_L12_break:;

  /* "kstreamc.pyx":493
 * 
 *         # apply pid filter
 *         if self.pid_filter != 0 and self.pid_filter != pid:             # <<<<<<<<<<<<<<
 *             drop = True
 *             # we got an invalid pid from the header
 */
  __pyx_t_2 = ((__pyx_v_self->pid_filter != 0) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L15_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_self->pid_filter != __pyx_v_pid) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L15_bool_binop_done:;
  if (__pyx_t_1) {

    /* "kstreamc.pyx":494
 *         # apply pid filter
 *         if self.pid_filter != 0 and self.pid_filter != pid:
 *             drop = True             # <<<<<<<<<<<<<<
 *             # we got an invalid pid from the header
 *             # and we can't still drop the event
 */
    __pyx_v_drop = 1;

    /* "kstreamc.pyx":497
 *             # we got an invalid pid from the header
 *             # and we can't still drop the event
 *             if pid == INVALID_PID:             # <<<<<<<<<<<<<<
 *                 drop = False
 *         elif self.image_filter != NULL:
 */
    __pyx_t_1 = ((__pyx_v_pid == __pyx_e_8kstreamc_INVALID_PID) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":498
 *             # and we can't still drop the event
 *             if pid == INVALID_PID:
 *                 drop = False             # <<<<<<<<<<<<<<
 *         elif self.image_filter != NULL:
 *             # apply image filter
 */
      __pyx_v_drop = 0;

      /* "kstreamc.pyx":497
 *             # we got an invalid pid from the header
 *             # and we can't still drop the event
 *             if pid == INVALID_PID:             # <<<<<<<<<<<<<<
 *                 drop = False
 *         elif self.image_filter != NULL:
 */
    }

    /* "kstreamc.pyx":493
 * 
 *         # apply pid filter
 *         if self.pid_filter != 0 and self.pid_filter != pid:             # <<<<<<<<<<<<<<
 *             drop = True
 *             # we got an invalid pid from the header
 */
    goto __pyx_L14;
  }

  /* "kstreamc.pyx":499
 *             if pid == INVALID_PID:
 *                 drop = False
 *         elif self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *             # apply image filter
 *             if defer:
 */
  __pyx_t_1 = ((__pyx_v_self->image_filter != NULL) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":501
 *         elif self.image_filter != NULL:
 *             # apply image filter
 *             if defer:             # <<<<<<<<<<<<<<
 *                 return False
 *             if pid == INVALID_PID:
 */
    __pyx_t_1 = (__pyx_v_defer != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":502
 *             # apply image filter
 *             if defer:
 *                 return False             # <<<<<<<<<<<<<<
 *             if pid == INVALID_PID:
 *                 drop = False
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "kstreamc.pyx":501
 *         elif self.image_filter != NULL:
 *             # apply image filter
 *             if defer:             # <<<<<<<<<<<<<<
 *                 return False
 *             if pid == INVALID_PID:
 */
    }

    /* "kstreamc.pyx":503
 *             if defer:
 *                 return False
 *             if pid == INVALID_PID:             # <<<<<<<<<<<<<<
 *                 drop = False
 *             else:
 */
    __pyx_t_1 = ((__pyx_v_pid == __pyx_e_8kstreamc_INVALID_PID) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":504
 *                 return False
 *             if pid == INVALID_PID:
 *                 drop = False             # <<<<<<<<<<<<<<
 *             else:
 *                 drop = self.__apply_image_filter(pid)
 */
      __pyx_v_drop = 0;

      /* "kstreamc.pyx":503
 *             if defer:
 *                 return False
 *             if pid == INVALID_PID:             # <<<<<<<<<<<<<<
 *                 drop = False
 *             else:
 */
      goto __pyx_L19;
    }

    /* "kstreamc.pyx":506
 *                 drop = False
 *             else:
 *                 drop = self.__apply_image_filter(pid)             # <<<<<<<<<<<<<<
 *                 # this only apply to `CreateProcess` events where
 *                 # parent pid is mapped to an image which doesn't match
 */
    /*else*/ {
      __pyx_v_drop = __pyx_f_8kstreamc_21KEventStreamCollector___apply_image_filter(__pyx_v_self, __pyx_v_pid);

      /* "kstreamc.pyx":510
 *                 # parent pid is mapped to an image which doesn't match
 *                 # the child pid's image
 *                 if drop and \             # <<<<<<<<<<<<<<
 *                         self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                     if params.size() > 0:
 */
      __pyx_t_2 = (__pyx_v_drop != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L21_bool_binop_done;
      }

      /* "kstreamc.pyx":511
 *                 # the child pid's image
 *                 if drop and \
 *                         self.__ktuple_equals(ktuple, CREATE_PROCESS):             # <<<<<<<<<<<<<<
 *                     if params.size() > 0:
 *                         image_name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))
 */
      __pyx_t_2 = (__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(__pyx_v_self, __pyx_v_ktuple, __pyx_v_8kstreamc_CREATE_PROCESS) != 0);
      __pyx_t_1 = __pyx_t_2;
      __pyx_L21_bool_binop_done:;

      /* "kstreamc.pyx":510
 *                 # parent pid is mapped to an image which doesn't match
 *                 # the child pid's image
 *                 if drop and \             # <<<<<<<<<<<<<<
 *                         self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                     if params.size() > 0:
 */
      if (__pyx_t_1) {

        /* "kstreamc.pyx":512
 *                 if drop and \
 *                         self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                     if params.size() > 0:             # <<<<<<<<<<<<<<
 *                         image_name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))
 *                         drop = wcscmp(_wcslwr(image_name),
 */
        __pyx_t_1 = ((__pyx_v_params.size() > 0) != 0);
        if (__pyx_t_1) {

          /* "kstreamc.pyx":513
 *                         self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                     if params.size() > 0:
 *                         image_name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))             # <<<<<<<<<<<<<<
 *                         drop = wcscmp(_wcslwr(image_name),
 *                                       _wcslwr(self.image_filter)) != 0
 */
          __pyx_v_image_name = __pyx_f_7kstream_8includes_6python__wchar_t(__pyx_v_params.at(__pyx_v_8kstreamc_IMAGE_FILE_NAME_PROP));

          /* "kstreamc.pyx":514
 *                     if params.size() > 0:
 *                         image_name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))
 *                         drop = wcscmp(_wcslwr(image_name),             # <<<<<<<<<<<<<<
 *                                       _wcslwr(self.image_filter)) != 0
 *         if drop:
 */
          __pyx_v_drop = (wcscmp(_wcslwr(__pyx_v_image_name), _wcslwr(__pyx_v_self->image_filter)) != 0);

          /* "kstreamc.pyx":512
 *                 if drop and \
 *                         self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                     if params.size() > 0:             # <<<<<<<<<<<<<<
 *                         image_name = _wchar_t(params.at(IMAGE_FILE_NAME_PROP))
 *                         drop = wcscmp(_wcslwr(image_name),
 */
        }

        /* "kstreamc.pyx":510
 *                 # parent pid is mapped to an image which doesn't match
 *                 # the child pid's image
 *                 if drop and \             # <<<<<<<<<<<<<<
 *                         self.__ktuple_equals(ktuple, CREATE_PROCESS):
 *                     if params.size() > 0:
 */
      }
    }
    __pyx_L19:;

    /* "kstreamc.pyx":499
 *             if pid == INVALID_PID:
 *                 drop = False
 *         elif self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *             # apply image filter
 *             if defer:
 */
  }
  __pyx_L14:;

  /* "kstreamc.pyx":516
 *                         drop = wcscmp(_wcslwr(image_name),
 *                                       _wcslwr(self.image_filter)) != 0
 *         if drop:             # <<<<<<<<<<<<<<
 *             return True
 *         # now scan for the kernel event
 */
  __pyx_t_1 = (__pyx_v_drop != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":517
 *                                       _wcslwr(self.image_filter)) != 0
 *         if drop:
 *             return True             # <<<<<<<<<<<<<<
 *         # now scan for the kernel event
 *         # properties to find the pid value
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "kstreamc.pyx":516
 *                         drop = wcscmp(_wcslwr(image_name),
 *                                       _wcslwr(self.image_filter)) != 0
 *         if drop:             # <<<<<<<<<<<<<<
 *             return True
 *         # now scan for the kernel event
 */
  }

  /* "kstreamc.pyx":520
 *         # now scan for the kernel event
 *         # properties to find the pid value
 *         drop = self.__apply_prop_filters(params)             # <<<<<<<<<<<<<<
 * 
 *         return drop
 */
  __pyx_v_drop = __pyx_f_8kstreamc_21KEventStreamCollector___apply_prop_filters(__pyx_v_self, __pyx_v_params);

  /* "kstreamc.pyx":522
 *         drop = self.__apply_prop_filters(params)
 * 
 *         return drop             # <<<<<<<<<<<<<<
 * 
 *     cdef inline BOOL __apply_skips(self, ULONG pid) nogil:
 */
  __pyx_r = __pyx_v_drop;
  goto __pyx_L0;

  /* "kstreamc.pyx":458
 *             return NULL
 * 
 *     cdef BOOL __apply_filters(self, ULONG pid, ULONG tid,             # <<<<<<<<<<<<<<
 *                               PyObject* ktuple,
 *                               unordered_map[wstring, PyObject*] params,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kstreamc.KEventStreamCollector.__apply_filters", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "kstreamc.pyx":524
 *         return drop
 * 
 *     cdef inline BOOL __apply_skips(self, ULONG pid) nogil:             # <<<<<<<<<<<<<<
 *         cdef BOOL ignored = False
 *         cdef unordered_map[ULONG, PROCESS_INFO].iterator proc_iterator = self.proc_map.find(pid)
 */

static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_skips(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, ULONG __pyx_v_pid) {
  BOOL __pyx_v_ignored;
  std::unordered_map<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO> ::iterator __pyx_v_proc_iterator;
  long __pyx_v_i;
  wchar_t *__pyx_v_skip;
  struct __pyx_t_7kstream_7process_PROCESS_INFO __pyx_v_pi;
  BOOL __pyx_r;
  int __pyx_t_1;
  size_t __pyx_t_2;
  __Pyx_FakeReference<wchar_t *> __pyx_t_3;
  struct __pyx_t_7kstream_7process_PROCESS_INFO __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "kstreamc.pyx":525
 * 
 *     cdef inline BOOL __apply_skips(self, ULONG pid) nogil:
 *         cdef BOOL ignored = False             # <<<<<<<<<<<<<<
 *         cdef unordered_map[ULONG, PROCESS_INFO].iterator proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():
 */
  __pyx_v_ignored = 0;

  /* "kstreamc.pyx":526
 *     cdef inline BOOL __apply_skips(self, ULONG pid) nogil:
 *         cdef BOOL ignored = False
 *         cdef unordered_map[ULONG, PROCESS_INFO].iterator proc_iterator = self.proc_map.find(pid)             # <<<<<<<<<<<<<<
 *         if proc_iterator != self.proc_map.end():
 *             for i from 0 <= i < self.skips.size():
 */
  __pyx_v_proc_iterator = __pyx_v_self->proc_map->find(__pyx_v_pid);

  /* "kstreamc.pyx":527
 *         cdef BOOL ignored = False
 *         cdef unordered_map[ULONG, PROCESS_INFO].iterator proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < self.skips.size():
 *                 skip = self.skips.at(i)
 */
  __pyx_t_1 = ((__pyx_v_proc_iterator != __pyx_v_self->proc_map->end()) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":528
 *         cdef unordered_map[ULONG, PROCESS_INFO].iterator proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():
 *             for i from 0 <= i < self.skips.size():             # <<<<<<<<<<<<<<
 *                 skip = self.skips.at(i)
 *                 # compare the image name found
 */
    __pyx_t_2 = __pyx_v_self->skips->size();
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

      /* "kstreamc.pyx":529
 *         if proc_iterator != self.proc_map.end():
 *             for i from 0 <= i < self.skips.size():
 *                 skip = self.skips.at(i)             # <<<<<<<<<<<<<<
 *                 # compare the image name found
 *                 # on the proc map with the value
 */
      try {
        __pyx_t_3 = __pyx_v_self->skips->at(__pyx_v_i);
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        PyGILState_Release(__pyx_gilstate_save);
        #endif
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_skip = __pyx_t_3;

      /* "kstreamc.pyx":533
 *                 # on the proc map with the value
 *                 # as defined on the skip list
 *                 pi = deref(proc_iterator).second             # <<<<<<<<<<<<<<
 *                 if wcscmp(_wcslwr(pi.name), _wcslwr(skip)) == 0:
 *                     ignored = True
 */
      __pyx_t_4 = (*__pyx_v_proc_iterator).second;
      __pyx_v_pi = __pyx_t_4;

      /* "kstreamc.pyx":534
 *                 # as defined on the skip list
 *                 pi = deref(proc_iterator).second
 *                 if wcscmp(_wcslwr(pi.name), _wcslwr(skip)) == 0:             # <<<<<<<<<<<<<<
 *                     ignored = True
 *                     break
 */
      __pyx_t_1 = ((wcscmp(_wcslwr(__pyx_v_pi.name), _wcslwr(__pyx_v_skip)) == 0) != 0);
      if (__pyx_t_1) {

        /* "kstreamc.pyx":535
 *                 pi = deref(proc_iterator).second
 *                 if wcscmp(_wcslwr(pi.name), _wcslwr(skip)) == 0:
 *                     ignored = True             # <<<<<<<<<<<<<<
 *                     break
 *         return ignored
 */
        __pyx_v_ignored = 1;

        /* "kstreamc.pyx":536
 *                 if wcscmp(_wcslwr(pi.name), _wcslwr(skip)) == 0:
 *                     ignored = True
 *                     break             # <<<<<<<<<<<<<<
 *         return ignored
 * 
 */
        goto __pyx_L5_break;

        /* "kstreamc.pyx":534
 *                 # as defined on the skip list
 *                 pi = deref(proc_iterator).second
 *                 if wcscmp(_wcslwr(pi.name), _wcslwr(skip)) == 0:             # <<<<<<<<<<<<<<
 *                     ignored = True
 *                     break
 */
      }
    }
    __pyx_L5_break:;

    /* "kstreamc.pyx":527
 *         cdef BOOL ignored = False
 *         cdef unordered_map[ULONG, PROCESS_INFO].iterator proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():             # <<<<<<<<<<<<<<
 *             for i from 0 <= i < self.skips.size():
 *                 skip = self.skips.at(i)
 */
  }

  /* "kstreamc.pyx":537
 *                     ignored = True
 *                     break
 *         return ignored             # <<<<<<<<<<<<<<
 * 
 *     cdef inline BOOL __apply_prop_filters(self, unordered_map[wstring, PyObject*] params) nogil:
 */
  __pyx_r = __pyx_v_ignored;
  goto __pyx_L0;

  /* "kstreamc.pyx":524
 *         return drop
 * 
 *     cdef inline BOOL __apply_skips(self, ULONG pid) nogil:             # <<<<<<<<<<<<<<
 *         cdef BOOL ignored = False
 *         cdef unordered_map[ULONG, PROCESS_INFO].iterator proc_iterator = self.proc_map.find(pid)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kstreamc.KEventStreamCollector.__apply_skips", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 1);
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "kstreamc.pyx":539
 *         return ignored
 * 
 *     cdef inline BOOL __apply_prop_filters(self, unordered_map[wstring, PyObject*] params) nogil:             # <<<<<<<<<<<<<<
 *         cdef unordered_map[wstring, PyObject*].iterator piter = params.begin()
 *         cdef BOOL drop = False
 */

static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_prop_filters(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, std::unordered_map<std::wstring,PyObject *>  __pyx_v_params) {
  std::unordered_map<std::wstring,PyObject *> ::iterator __pyx_v_piter;
  BOOL __pyx_v_drop;
  ULONG __pyx_v_pid;
  std::pair<std::wstring,PyObject *>  __pyx_v_prop;
  std::wstring __pyx_v_prop_name;
  BOOL __pyx_r;
  int __pyx_t_1;
  std::wstring __pyx_t_2;
  int __pyx_t_3;

  /* "kstreamc.pyx":540
 * 
 *     cdef inline BOOL __apply_prop_filters(self, unordered_map[wstring, PyObject*] params) nogil:
 *         cdef unordered_map[wstring, PyObject*].iterator piter = params.begin()             # <<<<<<<<<<<<<<
 *         cdef BOOL drop = False
 *         cdef ULONG pid = 0
 */
  __pyx_v_piter = __pyx_v_params.begin();

  /* "kstreamc.pyx":541
 *     cdef inline BOOL __apply_prop_filters(self, unordered_map[wstring, PyObject*] params) nogil:
 *         cdef unordered_map[wstring, PyObject*].iterator piter = params.begin()
 *         cdef BOOL drop = False             # <<<<<<<<<<<<<<
 *         cdef ULONG pid = 0
 * 
 */
  __pyx_v_drop = 0;

  /* "kstreamc.pyx":542
 *         cdef unordered_map[wstring, PyObject*].iterator piter = params.begin()
 *         cdef BOOL drop = False
 *         cdef ULONG pid = 0             # <<<<<<<<<<<<<<
 * 
 *         while piter != params.end():
 */
  __pyx_v_pid = 0;

  /* "kstreamc.pyx":544
 *         cdef ULONG pid = 0
 * 
 *         while piter != params.end():             # <<<<<<<<<<<<<<
 *             prop = deref(piter)
 *             prop_name = prop.first
 */
  while (1) {
    __pyx_t_1 = ((__pyx_v_piter != __pyx_v_params.end()) != 0);
    if (!__pyx_t_1) break;

    /* "kstreamc.pyx":545
 * 
 *         while piter != params.end():
 *             prop = deref(piter)             # <<<<<<<<<<<<<<
 *             prop_name = prop.first
 * 
 */
    __pyx_v_prop = (*__pyx_v_piter);

    /* "kstreamc.pyx":546
 *         while piter != params.end():
 *             prop = deref(piter)
 *             prop_name = prop.first             # <<<<<<<<<<<<<<
 * 
 *             # get the value of the pid property
 */
    __pyx_t_2 = __pyx_v_prop.first;
    __pyx_v_prop_name = __pyx_t_2;

    /* "kstreamc.pyx":549
 * 
 *             # get the value of the pid property
 *             if prop_name.compare(PID_PROP) == 0:             # <<<<<<<<<<<<<<
 *                 pid = PyLong_AsLong(prop.second)
 * 
 */
    __pyx_t_1 = ((__pyx_v_prop_name.compare(__pyx_v_8kstreamc_PID_PROP) == 0) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":550
 *             # get the value of the pid property
 *             if prop_name.compare(PID_PROP) == 0:
 *                 pid = PyLong_AsLong(prop.second)             # <<<<<<<<<<<<<<
 * 
 *             # apply the filters. At this point
 */
      __pyx_v_pid = PyLong_AsLong(__pyx_v_prop.second);

      /* "kstreamc.pyx":549
 * 
 *             # get the value of the pid property
 *             if prop_name.compare(PID_PROP) == 0:             # <<<<<<<<<<<<<<
 *                 pid = PyLong_AsLong(prop.second)
 * 
 */
    }

    /* "kstreamc.pyx":555
 *             # we also check the kernel event is
 *             # not coming from the fibratus process
 *             if pid != 0:             # <<<<<<<<<<<<<<
 *                 if pid == self.own_pid:
 *                     drop = True
 */
    __pyx_t_1 = ((__pyx_v_pid != 0) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":556
 *             # not coming from the fibratus process
 *             if pid != 0:
 *                 if pid == self.own_pid:             # <<<<<<<<<<<<<<
 *                     drop = True
 *                     break
 */
      __pyx_t_1 = ((__pyx_v_pid == __pyx_v_self->own_pid) != 0);
      if (__pyx_t_1) {

        /* "kstreamc.pyx":557
 *             if pid != 0:
 *                 if pid == self.own_pid:
 *                     drop = True             # <<<<<<<<<<<<<<
 *                     break
 *                 elif self.pid_filter != 0 and self.pid_filter != pid:
 */
        __pyx_v_drop = 1;

        /* "kstreamc.pyx":558
 *                 if pid == self.own_pid:
 *                     drop = True
 *                     break             # <<<<<<<<<<<<<<
 *                 elif self.pid_filter != 0 and self.pid_filter != pid:
 *                     drop = True
 */
        goto __pyx_L4_break;

        /* "kstreamc.pyx":556
 *             # not coming from the fibratus process
 *             if pid != 0:
 *                 if pid == self.own_pid:             # <<<<<<<<<<<<<<
 *                     drop = True
 *                     break
 */
      }

      /* "kstreamc.pyx":559
 *                     drop = True
 *                     break
 *                 elif self.pid_filter != 0 and self.pid_filter != pid:             # <<<<<<<<<<<<<<
 *                     drop = True
 *                     break
 */
      __pyx_t_3 = ((__pyx_v_self->pid_filter != 0) != 0);
      if (__pyx_t_3) {
      } else {
        __pyx_t_1 = __pyx_t_3;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_3 = ((__pyx_v_self->pid_filter != __pyx_v_pid) != 0);
      __pyx_t_1 = __pyx_t_3;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_1) {

        /* "kstreamc.pyx":560
 *                     break
 *                 elif self.pid_filter != 0 and self.pid_filter != pid:
 *                     drop = True             # <<<<<<<<<<<<<<
 *                     break
 *                 elif self.image_filter != NULL:
 */
        __pyx_v_drop = 1;

        /* "kstreamc.pyx":561
 *                 elif self.pid_filter != 0 and self.pid_filter != pid:
 *                     drop = True
 *                     break             # <<<<<<<<<<<<<<
 *                 elif self.image_filter != NULL:
 *                     drop = self.__apply_image_filter(pid)
 */
        goto __pyx_L4_break;

        /* "kstreamc.pyx":559
 *                     drop = True
 *                     break
 *                 elif self.pid_filter != 0 and self.pid_filter != pid:             # <<<<<<<<<<<<<<
 *                     drop = True
 *                     break
 */
      }

      /* "kstreamc.pyx":562
 *                     drop = True
 *                     break
 *                 elif self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *                     drop = self.__apply_image_filter(pid)
 *                     if drop:
 */
      __pyx_t_1 = ((__pyx_v_self->image_filter != NULL) != 0);
      if (__pyx_t_1) {

        /* "kstreamc.pyx":563
 *                     break
 *                 elif self.image_filter != NULL:
 *                     drop = self.__apply_image_filter(pid)             # <<<<<<<<<<<<<<
 *                     if drop:
 *                         break
 */
        __pyx_v_drop = __pyx_f_8kstreamc_21KEventStreamCollector___apply_image_filter(__pyx_v_self, __pyx_v_pid);

        /* "kstreamc.pyx":564
 *                 elif self.image_filter != NULL:
 *                     drop = self.__apply_image_filter(pid)
 *                     if drop:             # <<<<<<<<<<<<<<
 *                         break
 *             inc(piter)
 */
        __pyx_t_1 = (__pyx_v_drop != 0);
        if (__pyx_t_1) {

          /* "kstreamc.pyx":565
 *                     drop = self.__apply_image_filter(pid)
 *                     if drop:
 *                         break             # <<<<<<<<<<<<<<
 *             inc(piter)
 *         return drop
 */
          goto __pyx_L4_break;

          /* "kstreamc.pyx":564
 *                 elif self.image_filter != NULL:
 *                     drop = self.__apply_image_filter(pid)
 *                     if drop:             # <<<<<<<<<<<<<<
 *                         break
 *             inc(piter)
 */
        }

        /* "kstreamc.pyx":562
 *                     drop = True
 *                     break
 *                 elif self.image_filter != NULL:             # <<<<<<<<<<<<<<
 *                     drop = self.__apply_image_filter(pid)
 *                     if drop:
 */
      }

      /* "kstreamc.pyx":555
 *             # we also check the kernel event is
 *             # not coming from the fibratus process
 *             if pid != 0:             # <<<<<<<<<<<<<<
 *                 if pid == self.own_pid:
 *                     drop = True
 */
    }

    /* "kstreamc.pyx":566
 *                     if drop:
 *                         break
 *             inc(piter)             # <<<<<<<<<<<<<<
 *         return drop
 * 
 */
    (++__pyx_v_piter);
  }
  __pyx_L4_break:;

  /* "kstreamc.pyx":567
 *                         break
 *             inc(piter)
 *         return drop             # <<<<<<<<<<<<<<
 * 
 *     cdef inline BOOL __apply_image_filter(self, ULONG pid) nogil:
 */
  __pyx_r = __pyx_v_drop;
  goto __pyx_L0;

  /* "kstreamc.pyx":539
 *         return ignored
 * 
 *     cdef inline BOOL __apply_prop_filters(self, unordered_map[wstring, PyObject*] params) nogil:             # <<<<<<<<<<<<<<
 *         cdef unordered_map[wstring, PyObject*].iterator piter = params.begin()
 *         cdef BOOL drop = False
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstreamc.pyx":569
 *         return drop
 * 
 *     cdef inline BOOL __apply_image_filter(self, ULONG pid) nogil:             # <<<<<<<<<<<<<<
 *         cdef BOOL drop = True
 *         proc_iterator = self.proc_map.find(pid)
 */

static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___apply_image_filter(struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, ULONG __pyx_v_pid) {
  BOOL __pyx_v_drop;
  std::unordered_map<ULONG,struct __pyx_t_7kstream_7process_PROCESS_INFO> ::iterator __pyx_v_proc_iterator;
  struct __pyx_t_7kstream_7process_PROCESS_INFO __pyx_v_pi;
  BOOL __pyx_r;
  int __pyx_t_1;
  struct __pyx_t_7kstream_7process_PROCESS_INFO __pyx_t_2;

  /* "kstreamc.pyx":570
 * 
 *     cdef inline BOOL __apply_image_filter(self, ULONG pid) nogil:
 *         cdef BOOL drop = True             # <<<<<<<<<<<<<<
 *         proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():
 */
  __pyx_v_drop = 1;

  /* "kstreamc.pyx":571
 *     cdef inline BOOL __apply_image_filter(self, ULONG pid) nogil:
 *         cdef BOOL drop = True
 *         proc_iterator = self.proc_map.find(pid)             # <<<<<<<<<<<<<<
 *         if proc_iterator != self.proc_map.end():
 *             pi = deref(proc_iterator).second
 */
  __pyx_v_proc_iterator = __pyx_v_self->proc_map->find(__pyx_v_pid);

  /* "kstreamc.pyx":572
 *         cdef BOOL drop = True
 *         proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():             # <<<<<<<<<<<<<<
 *             pi = deref(proc_iterator).second
 *             drop = wcscmp(_wcslwr(pi.name),
 */
  __pyx_t_1 = ((__pyx_v_proc_iterator != __pyx_v_self->proc_map->end()) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":573
 *         proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():
 *             pi = deref(proc_iterator).second             # <<<<<<<<<<<<<<
 *             drop = wcscmp(_wcslwr(pi.name),
 *                           _wcslwr(self.image_filter)) != 0
 */
    __pyx_t_2 = (*__pyx_v_proc_iterator).second;
    __pyx_v_pi = __pyx_t_2;

    /* "kstreamc.pyx":574
 *         if proc_iterator != self.proc_map.end():
 *             pi = deref(proc_iterator).second
 *             drop = wcscmp(_wcslwr(pi.name),             # <<<<<<<<<<<<<<
 *                           _wcslwr(self.image_filter)) != 0
 *         return drop
 */
    __pyx_v_drop = (wcscmp(_wcslwr(__pyx_v_pi.name), _wcslwr(__pyx_v_self->image_filter)) != 0);

    /* "kstreamc.pyx":572
 *         cdef BOOL drop = True
 *         proc_iterator = self.proc_map.find(pid)
 *         if proc_iterator != self.proc_map.end():             # <<<<<<<<<<<<<<
 *             pi = deref(proc_iterator).second
 *             drop = wcscmp(_wcslwr(pi.name),
 */
  }

  /* "kstreamc.pyx":576
 *             drop = wcscmp(_wcslwr(pi.name),
 *                           _wcslwr(self.image_filter)) != 0
 *         return drop             # <<<<<<<<<<<<<<
 * 
 *     cdef PyObject* __wrap_ktuple(self, GUID guid, UCHAR opcode) nogil:
 */
  __pyx_r = __pyx_v_drop;
  goto __pyx_L0;

  /* "kstreamc.pyx":569
 *         return drop
 * 
 *     cdef inline BOOL __apply_image_filter(self, ULONG pid) nogil:             # <<<<<<<<<<<<<<
 *         cdef BOOL drop = True
 *         proc_iterator = self.proc_map.find(pid)
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstreamc.pyx":578
 *         return drop
 * 
 *     cdef PyObject* __wrap_ktuple(self, GUID guid, UCHAR opcode) nogil:             # <<<<<<<<<<<<<<
 *         cdef wchar_t buf[39]
 * 
 */

static PyObject *__pyx_f_8kstreamc_21KEventStreamCollector___wrap_ktuple(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, GUID __pyx_v_guid, UCHAR __pyx_v_opcode) {
  wchar_t __pyx_v_buf[39];
  PyObject *__pyx_v_kguid;
  PyObject *__pyx_r;
  int __pyx_t_1;

  /* "kstreamc.pyx":581
 *         cdef wchar_t buf[39]
 * 
 *         if string_from_guid(guid, buf, 39) > 0:             # <<<<<<<<<<<<<<
 *             kguid = PyUnicode_FromWideChar(_wcslwr(buf), 39)
 *             return build_ktuple(kguid, opcode)
 */
  __pyx_t_1 = ((StringFromGUID2(__pyx_v_guid, __pyx_v_buf, 39) > 0) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":582
 * 
 *         if string_from_guid(guid, buf, 39) > 0:
 *             kguid = PyUnicode_FromWideChar(_wcslwr(buf), 39)             # <<<<<<<<<<<<<<
 *             return build_ktuple(kguid, opcode)
 *         else:
 */
    __pyx_v_kguid = PyUnicode_FromWideChar(_wcslwr(__pyx_v_buf), 39);

    /* "kstreamc.pyx":583
 *         if string_from_guid(guid, buf, 39) > 0:
 *             kguid = PyUnicode_FromWideChar(_wcslwr(buf), 39)
 *             return build_ktuple(kguid, opcode)             # <<<<<<<<<<<<<<
 *         else:
 *             return NULL
 */
    __pyx_r = __pyx_f_7kstream_6ktuple_build_ktuple(__pyx_v_kguid, __pyx_v_opcode);
    goto __pyx_L0;

    /* "kstreamc.pyx":581
 *         cdef wchar_t buf[39]
 * 
 *         if string_from_guid(guid, buf, 39) > 0:             # <<<<<<<<<<<<<<
 *             kguid = PyUnicode_FromWideChar(_wcslwr(buf), 39)
 *             return build_ktuple(kguid, opcode)
 */
  }

  /* "kstreamc.pyx":585
 *             return build_ktuple(kguid, opcode)
 *         else:
 *             return NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef inline BOOL __ktuple_equals(self, PyObject* k1, PyObject* k2) nogil:
 */
  /*else*/ {
    __pyx_r = NULL;
    goto __pyx_L0;
  }

  /* "kstreamc.pyx":578
 *         return drop
 * 
 *     cdef PyObject* __wrap_ktuple(self, GUID guid, UCHAR opcode) nogil:             # <<<<<<<<<<<<<<
 *         cdef wchar_t buf[39]
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstreamc.pyx":587
 *             return NULL
 * 
 *     cdef inline BOOL __ktuple_equals(self, PyObject* k1, PyObject* k2) nogil:             # <<<<<<<<<<<<<<
 *         cdef BOOL ktuple_equals = False
 *         if PyLong_AsLong(PyTuple_GetItem(k1, 1)) == PyLong_AsLong(PyTuple_GetItem(k2, 1)):
 */

static CYTHON_INLINE BOOL __pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals(CYTHON_UNUSED struct __pyx_obj_8kstreamc_KEventStreamCollector *__pyx_v_self, PyObject *__pyx_v_k1, PyObject *__pyx_v_k2) {
  BOOL __pyx_v_ktuple_equals;
  wchar_t *__pyx_v_kguid1;
  wchar_t *__pyx_v_kguid2;
  BOOL __pyx_r;
  int __pyx_t_1;

  /* "kstreamc.pyx":588
 * 
 *     cdef inline BOOL __ktuple_equals(self, PyObject* k1, PyObject* k2) nogil:
 *         cdef BOOL ktuple_equals = False             # <<<<<<<<<<<<<<
 *         if PyLong_AsLong(PyTuple_GetItem(k1, 1)) == PyLong_AsLong(PyTuple_GetItem(k2, 1)):
 *             kguid1 = _wchar_t(PyTuple_GetItem(k1, 0))
 */
  __pyx_v_ktuple_equals = 0;

  /* "kstreamc.pyx":589
 *     cdef inline BOOL __ktuple_equals(self, PyObject* k1, PyObject* k2) nogil:
 *         cdef BOOL ktuple_equals = False
 *         if PyLong_AsLong(PyTuple_GetItem(k1, 1)) == PyLong_AsLong(PyTuple_GetItem(k2, 1)):             # <<<<<<<<<<<<<<
 *             kguid1 = _wchar_t(PyTuple_GetItem(k1, 0))
 *             kguid2 = _wchar_t(PyTuple_GetItem(k2, 0))
 */
  __pyx_t_1 = ((PyLong_AsLong(PyTuple_GetItem(__pyx_v_k1, 1)) == PyLong_AsLong(PyTuple_GetItem(__pyx_v_k2, 1))) != 0);
  if (__pyx_t_1) {

    /* "kstreamc.pyx":590
 *         cdef BOOL ktuple_equals = False
 *         if PyLong_AsLong(PyTuple_GetItem(k1, 1)) == PyLong_AsLong(PyTuple_GetItem(k2, 1)):
 *             kguid1 = _wchar_t(PyTuple_GetItem(k1, 0))             # <<<<<<<<<<<<<<
 *             kguid2 = _wchar_t(PyTuple_GetItem(k2, 0))
 *             ktuple_equals = wcscmp(kguid1, kguid2) == 0
 */
    __pyx_v_kguid1 = __pyx_f_7kstream_8includes_6python__wchar_t(PyTuple_GetItem(__pyx_v_k1, 0));

    /* "kstreamc.pyx":591
 *         if PyLong_AsLong(PyTuple_GetItem(k1, 1)) == PyLong_AsLong(PyTuple_GetItem(k2, 1)):
 *             kguid1 = _wchar_t(PyTuple_GetItem(k1, 0))
 *             kguid2 = _wchar_t(PyTuple_GetItem(k2, 0))             # <<<<<<<<<<<<<<
 *             ktuple_equals = wcscmp(kguid1, kguid2) == 0
 *             if kguid1 != NULL:
 */
    __pyx_v_kguid2 = __pyx_f_7kstream_8includes_6python__wchar_t(PyTuple_GetItem(__pyx_v_k2, 0));

    /* "kstreamc.pyx":592
 *             kguid1 = _wchar_t(PyTuple_GetItem(k1, 0))
 *             kguid2 = _wchar_t(PyTuple_GetItem(k2, 0))
 *             ktuple_equals = wcscmp(kguid1, kguid2) == 0             # <<<<<<<<<<<<<<
 *             if kguid1 != NULL:
 *                 PyMem_Free(kguid1)
 */
    __pyx_v_ktuple_equals = (wcscmp(__pyx_v_kguid1, __pyx_v_kguid2) == 0);

    /* "kstreamc.pyx":593
 *             kguid2 = _wchar_t(PyTuple_GetItem(k2, 0))
 *             ktuple_equals = wcscmp(kguid1, kguid2) == 0
 *             if kguid1 != NULL:             # <<<<<<<<<<<<<<
 *                 PyMem_Free(kguid1)
 *             if kguid2 != NULL:
 */
    __pyx_t_1 = ((__pyx_v_kguid1 != NULL) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":594
 *             ktuple_equals = wcscmp(kguid1, kguid2) == 0
 *             if kguid1 != NULL:
 *                 PyMem_Free(kguid1)             # <<<<<<<<<<<<<<
 *             if kguid2 != NULL:
 *                 PyMem_Free(kguid2)
 */
      PyMem_Free(__pyx_v_kguid1);

      /* "kstreamc.pyx":593
 *             kguid2 = _wchar_t(PyTuple_GetItem(k2, 0))
 *             ktuple_equals = wcscmp(kguid1, kguid2) == 0
 *             if kguid1 != NULL:             # <<<<<<<<<<<<<<
 *                 PyMem_Free(kguid1)
 *             if kguid2 != NULL:
 */
    }

    /* "kstreamc.pyx":595
 *             if kguid1 != NULL:
 *                 PyMem_Free(kguid1)
 *             if kguid2 != NULL:             # <<<<<<<<<<<<<<
 *                 PyMem_Free(kguid2)
 *         return ktuple_equals
 */
    __pyx_t_1 = ((__pyx_v_kguid2 != NULL) != 0);
    if (__pyx_t_1) {

      /* "kstreamc.pyx":596
 *                 PyMem_Free(kguid1)
 *             if kguid2 != NULL:
 *                 PyMem_Free(kguid2)             # <<<<<<<<<<<<<<
 *         return ktuple_equals
 */
      PyMem_Free(__pyx_v_kguid2);

      /* "kstreamc.pyx":595
 *             if kguid1 != NULL:
 *                 PyMem_Free(kguid1)
 *             if kguid2 != NULL:             # <<<<<<<<<<<<<<
 *                 PyMem_Free(kguid2)
 *         return ktuple_equals
 */
    }

    /* "kstreamc.pyx":589
 *     cdef inline BOOL __ktuple_equals(self, PyObject* k1, PyObject* k2) nogil:
 *         cdef BOOL ktuple_equals = False
 *         if PyLong_AsLong(PyTuple_GetItem(k1, 1)) == PyLong_AsLong(PyTuple_GetItem(k2, 1)):             # <<<<<<<<<<<<<<
 *             kguid1 = _wchar_t(PyTuple_GetItem(k1, 0))
 *             kguid2 = _wchar_t(PyTuple_GetItem(k2, 0))
 */
  }

  /* "kstreamc.pyx":597
 *             if kguid2 != NULL:
 *                 PyMem_Free(kguid2)
 *         return ktuple_equals             # <<<<<<<<<<<<<<
 */
  __pyx_r = __pyx_v_ktuple_equals;
  goto __pyx_L0;

  /* "kstreamc.pyx":587
 *             return NULL
 * 
 *     cdef inline BOOL __ktuple_equals(self, PyObject* k1, PyObject* k2) nogil:             # <<<<<<<<<<<<<<
 *         cdef BOOL ktuple_equals = False
 *         if PyLong_AsLong(PyTuple_GetItem(k1, 1)) == PyLong_AsLong(PyTuple_GetItem(k2, 1)):
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\ktuple.pxd":22
 * from kstream.includes.windows cimport UCHAR
 * 
 * cdef inline PyObject* build_ktuple(PyObject* kguid, UCHAR opcode) nogil:             # <<<<<<<<<<<<<<
 *     cdef PyObject* ktuple = PyTuple_New(2)
 *     cdef PyObject* oco = Py_BuildValue('b', opcode)
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_6ktuple_build_ktuple(PyObject *__pyx_v_kguid, UCHAR __pyx_v_opcode) {
  PyObject *__pyx_v_ktuple;
  PyObject *__pyx_v_oco;
  PyObject *__pyx_r;

  /* "kstream\ktuple.pxd":23
 * 
 * cdef inline PyObject* build_ktuple(PyObject* kguid, UCHAR opcode) nogil:
 *     cdef PyObject* ktuple = PyTuple_New(2)             # <<<<<<<<<<<<<<
 *     cdef PyObject* oco = Py_BuildValue('b', opcode)
 *     PyTuple_SetItem(ktuple, 0, kguid)
 */
  __pyx_v_ktuple = PyTuple_New(2);

  /* "kstream\ktuple.pxd":24
 * cdef inline PyObject* build_ktuple(PyObject* kguid, UCHAR opcode) nogil:
 *     cdef PyObject* ktuple = PyTuple_New(2)
 *     cdef PyObject* oco = Py_BuildValue('b', opcode)             # <<<<<<<<<<<<<<
 *     PyTuple_SetItem(ktuple, 0, kguid)
 *     PyTuple_SetItem(ktuple, 1, oco)
 */
  __pyx_v_oco = Py_BuildValue(__pyx_k_b, __pyx_v_opcode);

  /* "kstream\ktuple.pxd":25
 *     cdef PyObject* ktuple = PyTuple_New(2)
 *     cdef PyObject* oco = Py_BuildValue('b', opcode)
 *     PyTuple_SetItem(ktuple, 0, kguid)             # <<<<<<<<<<<<<<
 *     PyTuple_SetItem(ktuple, 1, oco)
 *     return ktuple
 */
  PyTuple_SetItem(__pyx_v_ktuple, 0, __pyx_v_kguid);

  /* "kstream\ktuple.pxd":26
 *     cdef PyObject* oco = Py_BuildValue('b', opcode)
 *     PyTuple_SetItem(ktuple, 0, kguid)
 *     PyTuple_SetItem(ktuple, 1, oco)             # <<<<<<<<<<<<<<
 *     return ktuple
 */
  PyTuple_SetItem(__pyx_v_ktuple, 1, __pyx_v_oco);

  /* "kstream\ktuple.pxd":27
 *     PyTuple_SetItem(ktuple, 0, kguid)
 *     PyTuple_SetItem(ktuple, 1, oco)
 *     return ktuple             # <<<<<<<<<<<<<<
 */
  __pyx_r = __pyx_v_ktuple;
  goto __pyx_L0;

  /* "kstream\ktuple.pxd":22
 * from kstream.includes.windows cimport UCHAR
 * 
 * cdef inline PyObject* build_ktuple(PyObject* kguid, UCHAR opcode) nogil:             # <<<<<<<<<<<<<<
 *     cdef PyObject* ktuple = PyTuple_New(2)
 *     cdef PyObject* oco = Py_BuildValue('b', opcode)
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\time.pxd":19
 * from kstream.includes.windows cimport *
 * 
 * cdef inline SYSTEMTIME sys_time(LARGE_INTEGER timestamp) nogil:             # <<<<<<<<<<<<<<
 *     cdef FILETIME f
 *     cdef SYSTEMTIME s
 */

static CYTHON_INLINE SYSTEMTIME __pyx_f_7kstream_4time_sys_time(LARGE_INTEGER __pyx_v_timestamp) {
  FILETIME __pyx_v_f;
  SYSTEMTIME __pyx_v_s;
  SYSTEMTIME __pyx_v_tzt;
  SYSTEMTIME __pyx_r;
  LONG __pyx_t_1;
  DWORD __pyx_t_2;

  /* "kstream\time.pxd":24
 *     cdef SYSTEMTIME tzt
 * 
 *     f.high_date = timestamp.high             # <<<<<<<<<<<<<<
 *     f.low_date = timestamp.low
 *     filetime_to_systemtime(&f, &s)
 */
  __pyx_t_1 = __pyx_v_timestamp.HighPart;
  __pyx_v_f.dwHighDateTime = __pyx_t_1;

  /* "kstream\time.pxd":25
 * 
 *     f.high_date = timestamp.high
 *     f.low_date = timestamp.low             # <<<<<<<<<<<<<<
 *     filetime_to_systemtime(&f, &s)
 *     systemtime_to_tz_specific_localtime(NULL, &s, &tzt)
 */
  __pyx_t_2 = __pyx_v_timestamp.LowPart;
  __pyx_v_f.dwLowDateTime = __pyx_t_2;

  /* "kstream\time.pxd":26
 *     f.high_date = timestamp.high
 *     f.low_date = timestamp.low
 *     filetime_to_systemtime(&f, &s)             # <<<<<<<<<<<<<<
 *     systemtime_to_tz_specific_localtime(NULL, &s, &tzt)
 * 
 */
  FileTimeToSystemTime((&__pyx_v_f), (&__pyx_v_s));

  /* "kstream\time.pxd":27
 *     f.low_date = timestamp.low
 *     filetime_to_systemtime(&f, &s)
 *     systemtime_to_tz_specific_localtime(NULL, &s, &tzt)             # <<<<<<<<<<<<<<
 * 
 *     return tzt
 */
  SystemTimeToTzSpecificLocalTime(NULL, (&__pyx_v_s), (&__pyx_v_tzt));

  /* "kstream\time.pxd":29
 *     systemtime_to_tz_specific_localtime(NULL, &s, &tzt)
 * 
 *     return tzt             # <<<<<<<<<<<<<<
 */
  __pyx_r = __pyx_v_tzt;
  goto __pyx_L0;

  /* "kstream\time.pxd":19
 * from kstream.includes.windows cimport *
 * 
 * cdef inline SYSTEMTIME sys_time(LARGE_INTEGER timestamp) nogil:             # <<<<<<<<<<<<<<
 *     cdef FILETIME f
 *     cdef SYSTEMTIME s
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":41
 * 
 * 
 * cdef inline PyObject* _unicode(wchar_t* wchars) nogil:             # <<<<<<<<<<<<<<
 *     return PyUnicode_FromWideChar(wchars, -1)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__unicode(wchar_t *__pyx_v_wchars) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":42
 * 
 * cdef inline PyObject* _unicode(wchar_t* wchars) nogil:
 *     return PyUnicode_FromWideChar(wchars, -1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyUnicode_FromWideChar(__pyx_v_wchars, -1L);
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":41
 * 
 * 
 * cdef inline PyObject* _unicode(wchar_t* wchars) nogil:             # <<<<<<<<<<<<<<
 *     return PyUnicode_FromWideChar(wchars, -1)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":45
 * 
 * 
 * cdef inline PyObject* _ansi(char* chars) nogil:             # <<<<<<<<<<<<<<
 *     return PyUnicode_FromString(chars)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__ansi(char *__pyx_v_chars) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":46
 * 
 * cdef inline PyObject* _ansi(char* chars) nogil:
 *     return PyUnicode_FromString(chars)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyUnicode_FromString(__pyx_v_chars);
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":45
 * 
 * 
 * cdef inline PyObject* _ansi(char* chars) nogil:             # <<<<<<<<<<<<<<
 *     return PyUnicode_FromString(chars)
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":49
 * 
 * 
 * cdef inline PyObject* _unicodec(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('u', (<WCHAR*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__unicodec(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":50
 * 
 * cdef inline PyObject* _unicodec(void* buf) nogil:
 *     return Py_BuildValue('u', (<WCHAR*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_u, (((WCHAR *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":49
 * 
 * 
 * cdef inline PyObject* _unicodec(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('u', (<WCHAR*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":53
 * 
 * 
 * cdef inline PyObject* _ansic(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('s', (<CHAR*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__ansic(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":54
 * 
 * cdef inline PyObject* _ansic(void* buf) nogil:
 *     return Py_BuildValue('s', (<CHAR*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_s, (((CHAR *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":53
 * 
 * 
 * cdef inline PyObject* _ansic(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('s', (<CHAR*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":57
 * 
 * 
 * cdef inline PyObject* _i8(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', (<CHAR*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i8(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":58
 * 
 * cdef inline PyObject* _i8(void* buf) nogil:
 *     return Py_BuildValue('h', (<CHAR*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_h, (((CHAR *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":57
 * 
 * 
 * cdef inline PyObject* _i8(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', (<CHAR*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":61
 * 
 * 
 * cdef inline PyObject* _u8(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('b', (<BYTE*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u8(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":62
 * 
 * cdef inline PyObject* _u8(void* buf) nogil:
 *     return Py_BuildValue('b', (<BYTE*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_b, (((BYTE *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":61
 * 
 * 
 * cdef inline PyObject* _u8(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('b', (<BYTE*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":65
 * 
 * 
 * cdef inline PyObject* _u8_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<SHORT*>buf)[0])
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u8_hex(void *__pyx_v_buf) {
  char __pyx_v_hx[0xC8];
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":67
 * cdef inline PyObject* _u8_hex(void* buf) nogil:
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<SHORT*>buf)[0])             # <<<<<<<<<<<<<<
 *     return _ansi(hx)
 * 
 */
  sprintf(__pyx_v_hx, __pyx_k_02x, (((SHORT *)__pyx_v_buf)[0]));

  /* "kstream\includes\python.pxd":68
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<SHORT*>buf)[0])
 *     return _ansi(hx)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_f_7kstream_8includes_6python__ansi(__pyx_v_hx);
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":65
 * 
 * 
 * cdef inline PyObject* _u8_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<SHORT*>buf)[0])
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":71
 * 
 * 
 * cdef inline PyObject* _i16_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<CHAR*>buf)[0])
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i16_hex(void *__pyx_v_buf) {
  char __pyx_v_hx[0xC8];
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":73
 * cdef inline PyObject* _i16_hex(void* buf) nogil:
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<CHAR*>buf)[0])             # <<<<<<<<<<<<<<
 *     return _ansi(hx)
 * 
 */
  sprintf(__pyx_v_hx, __pyx_k_02x, (((CHAR *)__pyx_v_buf)[0]));

  /* "kstream\includes\python.pxd":74
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<CHAR*>buf)[0])
 *     return _ansi(hx)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_f_7kstream_8includes_6python__ansi(__pyx_v_hx);
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":71
 * 
 * 
 * cdef inline PyObject* _i16_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<CHAR*>buf)[0])
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":77
 * 
 * 
 * cdef inline PyObject* _i64_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<ULONGLONG*>buf)[0])
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i64_hex(void *__pyx_v_buf) {
  char __pyx_v_hx[0xC8];
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":79
 * cdef inline PyObject* _i64_hex(void* buf) nogil:
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<ULONGLONG*>buf)[0])             # <<<<<<<<<<<<<<
 *     return _ansi(hx)
 * 
 */
  sprintf(__pyx_v_hx, __pyx_k_02x, (((ULONGLONG *)__pyx_v_buf)[0]));

  /* "kstream\includes\python.pxd":80
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<ULONGLONG*>buf)[0])
 *     return _ansi(hx)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_f_7kstream_8includes_6python__ansi(__pyx_v_hx);
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":77
 * 
 * 
 * cdef inline PyObject* _i64_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "%02x", (<ULONGLONG*>buf)[0])
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":83
 * 
 * 
 * cdef inline PyObject* _i64(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('L', (<LONGLONG*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i64(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":84
 * 
 * cdef inline PyObject* _i64(void* buf) nogil:
 *     return Py_BuildValue('L', (<LONGLONG*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_L, (((LONGLONG *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":83
 * 
 * 
 * cdef inline PyObject* _i64(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('L', (<LONGLONG*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":87
 * 
 * 
 * cdef inline PyObject* _u64(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('K', (<ULONGLONG*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u64(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":88
 * 
 * cdef inline PyObject* _u64(void* buf) nogil:
 *     return Py_BuildValue('K', (<ULONGLONG*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_K, (((ULONGLONG *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":87
 * 
 * 
 * cdef inline PyObject* _u64(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('K', (<ULONGLONG*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":91
 * 
 * 
 * cdef inline PyObject* _i32(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('i', (<INT32*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i32(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":92
 * 
 * cdef inline PyObject* _i32(void* buf) nogil:
 *     return Py_BuildValue('i', (<INT32*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_i, (((INT32 *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":91
 * 
 * 
 * cdef inline PyObject* _i32(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('i', (<INT32*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":95
 * 
 * 
 * cdef inline PyObject* _i32_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "0x%x", (<ULONG*>buf)[0])
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i32_hex(void *__pyx_v_buf) {
  char __pyx_v_hx[0xC8];
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":97
 * cdef inline PyObject* _i32_hex(void* buf) nogil:
 *     cdef char hx[200]
 *     sprintf(hx, "0x%x", (<ULONG*>buf)[0])             # <<<<<<<<<<<<<<
 *     return _ansi(hx)
 * 
 */
  sprintf(__pyx_v_hx, __pyx_k_0x_x, (((ULONG *)__pyx_v_buf)[0]));

  /* "kstream\includes\python.pxd":98
 *     cdef char hx[200]
 *     sprintf(hx, "0x%x", (<ULONG*>buf)[0])
 *     return _ansi(hx)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_f_7kstream_8includes_6python__ansi(__pyx_v_hx);
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":95
 * 
 * 
 * cdef inline PyObject* _i32_hex(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef char hx[200]
 *     sprintf(hx, "0x%x", (<ULONG*>buf)[0])
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":101
 * 
 * 
 * cdef inline PyObject* _u32(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('k', (<DWORD*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u32(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":102
 * 
 * cdef inline PyObject* _u32(void* buf) nogil:
 *     return Py_BuildValue('k', (<DWORD*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_k, (((DWORD *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":101
 * 
 * 
 * cdef inline PyObject* _u32(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('k', (<DWORD*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":105
 * 
 * 
 * cdef inline PyObject* _i16(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', (<SHORT*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__i16(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":106
 * 
 * cdef inline PyObject* _i16(void* buf) nogil:
 *     return Py_BuildValue('h', (<SHORT*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_h, (((SHORT *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":105
 * 
 * 
 * cdef inline PyObject* _i16(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', (<SHORT*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":109
 * 
 * 
 * cdef inline PyObject* _u16(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', (<USHORT*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__u16(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":110
 * 
 * cdef inline PyObject* _u16(void* buf) nogil:
 *     return Py_BuildValue('h', (<USHORT*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_h, (((USHORT *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":109
 * 
 * 
 * cdef inline PyObject* _u16(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', (<USHORT*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":113
 * 
 * 
 * cdef inline PyObject* _float(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('f', (<FLOAT*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__float(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":114
 * 
 * cdef inline PyObject* _float(void* buf) nogil:
 *     return Py_BuildValue('f', (<FLOAT*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_f, (((FLOAT *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":113
 * 
 * 
 * cdef inline PyObject* _float(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('f', (<FLOAT*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":117
 * 
 * 
 * cdef inline PyObject* _double(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('d', (<DOUBLE*>buf)[0])
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__double(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":118
 * 
 * cdef inline PyObject* _double(void* buf) nogil:
 *     return Py_BuildValue('d', (<DOUBLE*>buf)[0])             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_d, (((DOUBLE *)__pyx_v_buf)[0]));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":117
 * 
 * 
 * cdef inline PyObject* _double(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('d', (<DOUBLE*>buf)[0])
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":121
 * 
 * 
 * cdef inline PyObject* _ntohs(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', ntohs((<USHORT*>buf)[0]))
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__ntohs(void *__pyx_v_buf) {
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":122
 * 
 * cdef inline PyObject* _ntohs(void* buf) nogil:
 *     return Py_BuildValue('h', ntohs((<USHORT*>buf)[0]))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_h, ntohs((((USHORT *)__pyx_v_buf)[0])));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":121
 * 
 * 
 * cdef inline PyObject* _ntohs(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('h', ntohs((<USHORT*>buf)[0]))
 * 
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":125
 * 
 * 
 * cdef inline PyObject* _wstring(wstring ws):             # <<<<<<<<<<<<<<
 *     return PyUnicode_FromWideChar(ws.data(), ws.size())
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python__wstring(std::wstring __pyx_v_ws) {
  PyObject *__pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_wstring", 0);

  /* "kstream\includes\python.pxd":126
 * 
 * cdef inline PyObject* _wstring(wstring ws):
 *     return PyUnicode_FromWideChar(ws.data(), ws.size())             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyUnicode_FromWideChar(__pyx_v_ws.data(), __pyx_v_ws.size());
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":125
 * 
 * 
 * cdef inline PyObject* _wstring(wstring ws):             # <<<<<<<<<<<<<<
 *     return PyUnicode_FromWideChar(ws.data(), ws.size())
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kstream\includes\python.pxd":129
 * 
 * 
 * cdef inline wchar_t* _wchar_t(PyObject* o) nogil:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t size
 *     return PyUnicode_AsWideCharString(o, &size)
 */

static CYTHON_INLINE wchar_t *__pyx_f_7kstream_8includes_6python__wchar_t(PyObject *__pyx_v_o) {
  Py_ssize_t __pyx_v_size;
  wchar_t *__pyx_r;

  /* "kstream\includes\python.pxd":131
 * cdef inline wchar_t* _wchar_t(PyObject* o) nogil:
 *     cdef Py_ssize_t size
 *     return PyUnicode_AsWideCharString(o, &size)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyUnicode_AsWideCharString(__pyx_v_o, (&__pyx_v_size));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":129
 * 
 * 
 * cdef inline wchar_t* _wchar_t(PyObject* o) nogil:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t size
 *     return PyUnicode_AsWideCharString(o, &size)
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":134
 * 
 * 
 * cdef inline PyObject* ip_addr(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef in_addr addr
 *     addr.S_un.S_addr = (<ULONG *>buf)[0]
 */

static CYTHON_INLINE PyObject *__pyx_f_7kstream_8includes_6python_ip_addr(void *__pyx_v_buf) {
  in_addr __pyx_v_addr;
  PyObject *__pyx_r;

  /* "kstream\includes\python.pxd":136
 * cdef inline PyObject* ip_addr(void* buf) nogil:
 *     cdef in_addr addr
 *     addr.S_un.S_addr = (<ULONG *>buf)[0]             # <<<<<<<<<<<<<<
 *     return Py_BuildValue('s', inet_ntoa(addr))
 * 
 */
  __pyx_v_addr.S_un.S_addr = (((ULONG *)__pyx_v_buf)[0]);

  /* "kstream\includes\python.pxd":137
 *     cdef in_addr addr
 *     addr.S_un.S_addr = (<ULONG *>buf)[0]
 *     return Py_BuildValue('s', inet_ntoa(addr))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = Py_BuildValue(__pyx_k_s, inet_ntoa(__pyx_v_addr));
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":134
 * 
 * 
 * cdef inline PyObject* ip_addr(void* buf) nogil:             # <<<<<<<<<<<<<<
 *     cdef in_addr addr
 *     addr.S_un.S_addr = (<ULONG *>buf)[0]
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "kstream\includes\python.pxd":140
 * 
 * 
 * cdef inline wstring deref_prop(prop_name):             # <<<<<<<<<<<<<<
 *     return deref(new wstring(_wchar_t(<PyObject*>prop_name)))
 */

static CYTHON_INLINE std::wstring __pyx_f_7kstream_8includes_6python_deref_prop(PyObject *__pyx_v_prop_name) {
  std::wstring __pyx_r;
  __Pyx_RefNannyDeclarations
  std::wstring *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("deref_prop", 0);

  /* "kstream\includes\python.pxd":141
 * 
 * cdef inline wstring deref_prop(prop_name):
 *     return deref(new wstring(_wchar_t(<PyObject*>prop_name)))             # <<<<<<<<<<<<<<
 */
  try {
    __pyx_t_1 = new std::wstring(__pyx_f_7kstream_8includes_6python__wchar_t(((PyObject *)__pyx_v_prop_name)));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_r = (*__pyx_t_1);
  goto __pyx_L0;

  /* "kstream\includes\python.pxd":140
 * 
 * 
 * cdef inline wstring deref_prop(prop_name):             # <<<<<<<<<<<<<<
 *     return deref(new wstring(_wchar_t(<PyObject*>prop_name)))
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kstream.includes.python.deref_prop", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_8kstreamc_KEventStreamCollector __pyx_vtable_8kstreamc_KEventStreamCollector;

static PyObject *__pyx_tp_new_8kstreamc_KEventStreamCollector(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_8kstreamc_KEventStreamCollector *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_8kstreamc_KEventStreamCollector *)o);
  p->__pyx_vtab = __pyx_vtabptr_8kstreamc_KEventStreamCollector;
  p->next_kevt_callback = Py_None; Py_INCREF(Py_None);
  p->on_kstream_open_callback = Py_None; Py_INCREF(Py_None);
  p->klogger = Py_None; Py_INCREF(Py_None);
  p->regex = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_8kstreamc_KEventStreamCollector(PyObject *o) {
  struct __pyx_obj_8kstreamc_KEventStreamCollector *p = (struct __pyx_obj_8kstreamc_KEventStreamCollector *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->next_kevt_callback);
  Py_CLEAR(p->on_kstream_open_callback);
  Py_CLEAR(p->klogger);
  Py_CLEAR(p->regex);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_8kstreamc_KEventStreamCollector(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8kstreamc_KEventStreamCollector *p = (struct __pyx_obj_8kstreamc_KEventStreamCollector *)o;
  if (p->next_kevt_callback) {
    e = (*v)(p->next_kevt_callback, a); if (e) return e;
  }
  if (p->on_kstream_open_callback) {
    e = (*v)(p->on_kstream_open_callback, a); if (e) return e;
  }
  if (p->klogger) {
    e = (*v)(p->klogger, a); if (e) return e;
  }
  if (p->regex) {
    e = (*v)(p->regex, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8kstreamc_KEventStreamCollector(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_8kstreamc_KEventStreamCollector *p = (struct __pyx_obj_8kstreamc_KEventStreamCollector *)o;
  tmp = ((PyObject*)p->next_kevt_callback);
  p->next_kevt_callback = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->on_kstream_open_callback);
  p->on_kstream_open_callback = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->klogger);
  p->klogger = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->regex);
  p->regex = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_8kstreamc_KEventStreamCollector[] = {
  {"open_kstream", (PyCFunction)__pyx_pw_8kstreamc_21KEventStreamCollector_3open_kstream, METH_O, __pyx_doc_8kstreamc_21KEventStreamCollector_2open_kstream},
  {"close_kstream", (PyCFunction)__pyx_pw_8kstreamc_21KEventStreamCollector_5close_kstream, METH_NOARGS, 0},
  {"set_kstream_open_callback", (PyCFunction)__pyx_pw_8kstreamc_21KEventStreamCollector_7set_kstream_open_callback, METH_O, 0},
  {"add_skip", (PyCFunction)__pyx_pw_8kstreamc_21KEventStreamCollector_9add_skip, METH_O, 0},
  {"add_ktuple_filter", (PyCFunction)__pyx_pw_8kstreamc_21KEventStreamCollector_11add_ktuple_filter, METH_O, 0},
  {"add_pid_filter", (PyCFunction)__pyx_pw_8kstreamc_21KEventStreamCollector_13add_pid_filter, METH_O, 0},
  {"add_image_filter", (PyCFunction)__pyx_pw_8kstreamc_21KEventStreamCollector_15add_image_filter, METH_O, 0},
  {0, 0, 0, 0}
};

static PyTypeObject __pyx_type_8kstreamc_KEventStreamCollector = {
  PyVarObject_HEAD_INIT(0, 0)
  "kstreamc.KEventStreamCollector", /*tp_name*/
  sizeof(struct __pyx_obj_8kstreamc_KEventStreamCollector), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8kstreamc_KEventStreamCollector, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Kernel event stream collector.\n\n\n    Collects events from the kernel event stream and invokes\n    a python callback method for each event delivered\n    to the collector.\n\n    The main motivation behind this Cython extension are the perfomance reasons, where\n    ETW can generate a huge volume of events, and the parsing\n    process is very CPU intensive.\n\n    Use\n    ---\n\n    kevt_stream_collector = KEventStreamCollector(logger_name)\n\n    Register a python callback:\n\n    def next_kevt(ktype, cpuid, ts, kparams):\n        # your logic here\n    kevt_stream_collector.open_kstream(next_kevt)\n\n\n    ", /*tp_doc*/
  __pyx_tp_traverse_8kstreamc_KEventStreamCollector, /*tp_traverse*/
  __pyx_tp_clear_8kstreamc_KEventStreamCollector, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8kstreamc_KEventStreamCollector, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_8kstreamc_21KEventStreamCollector_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8kstreamc_KEventStreamCollector, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

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

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

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_2cb15d1d_5fc1_11d2_abe1_00a0c91, __pyx_k_2cb15d1d_5fc1_11d2_abe1_00a0c91, sizeof(__pyx_k_2cb15d1d_5fc1_11d2_abe1_00a0c91), 0, 0, 1, 0},
  {&__pyx_kp_s_3d6fa8d0_fe05_11d0_9dda_00c04fd, __pyx_k_3d6fa8d0_fe05_11d0_9dda_00c04fd, sizeof(__pyx_k_3d6fa8d0_fe05_11d0_9dda_00c04fd), 0, 0, 1, 0},
  {&__pyx_kp_s_3d6fa8d1_fe05_11d0_9dda_00c04fd, __pyx_k_3d6fa8d1_fe05_11d0_9dda_00c04fd, sizeof(__pyx_k_3d6fa8d1_fe05_11d0_9dda_00c04fd), 0, 0, 1, 0},
  {&__pyx_kp_s_90cbdc39_4a3e_11d1_84f4_0000f80, __pyx_k_90cbdc39_4a3e_11d1_84f4_0000f80, sizeof(__pyx_k_90cbdc39_4a3e_11d1_84f4_0000f80), 0, 0, 1, 0},
  {&__pyx_kp_s_ERROR_Unable_to_open_kernel_even, __pyx_k_ERROR_Unable_to_open_kernel_even, sizeof(__pyx_k_ERROR_Unable_to_open_kernel_even), 0, 0, 1, 0},
  {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  {&__pyx_n_s_FS_KGUID, __pyx_k_FS_KGUID, sizeof(__pyx_k_FS_KGUID), 0, 0, 1, 1},
  {&__pyx_n_s_ImageFileName, __pyx_k_ImageFileName, sizeof(__pyx_k_ImageFileName), 0, 0, 1, 1},
  {&__pyx_n_s_KeyboardInterrupt, __pyx_k_KeyboardInterrupt, sizeof(__pyx_k_KeyboardInterrupt), 0, 0, 1, 1},
  {&__pyx_n_s_PID, __pyx_k_PID, sizeof(__pyx_k_PID), 0, 0, 1, 1},
  {&__pyx_n_s_ParentId, __pyx_k_ParentId, sizeof(__pyx_k_ParentId), 0, 0, 1, 1},
  {&__pyx_n_s_ProcessId, __pyx_k_ProcessId, sizeof(__pyx_k_ProcessId), 0, 0, 1, 1},
  {&__pyx_n_s_REGISTRY_KGUID, __pyx_k_REGISTRY_KGUID, sizeof(__pyx_k_REGISTRY_KGUID), 0, 0, 1, 1},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_s_a_z0_9_A_Z_A_Z_a_z, __pyx_k_a_z0_9_A_Z_A_Z_a_z, sizeof(__pyx_k_a_z0_9_A_Z_A_Z_a_z), 0, 0, 1, 0},
  {&__pyx_kp_s_ae53722e_c863_11d2_8659_00c04fa, __pyx_k_ae53722e_c863_11d2_8659_00c04fa, sizeof(__pyx_k_ae53722e_c863_11d2_8659_00c04fa), 0, 0, 1, 0},
  {&__pyx_n_s_close_kstream, __pyx_k_close_kstream, sizeof(__pyx_k_close_kstream), 0, 0, 1, 1},
  {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
  {&__pyx_kp_s_d_d_d_d_02d_02d_d, __pyx_k_d_d_d_d_02d_02d_d, sizeof(__pyx_k_d_d_d_d_02d_02d_d), 0, 0, 1, 0},
  {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  {&__pyx_n_s_getpid, __pyx_k_getpid, sizeof(__pyx_k_getpid), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_klogger, __pyx_k_klogger, sizeof(__pyx_k_klogger), 0, 0, 1, 1},
  {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
  {&__pyx_n_s_print_exc, __pyx_k_print_exc, sizeof(__pyx_k_print_exc), 0, 0, 1, 1},
  {&__pyx_n_s_process_id, __pyx_k_process_id, sizeof(__pyx_k_process_id), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
  {&__pyx_n_s_sub, __pyx_k_sub, sizeof(__pyx_k_sub), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_thread_id, __pyx_k_thread_id, sizeof(__pyx_k_thread_id), 0, 0, 1, 1},
  {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyboardInterrupt = __Pyx_GetBuiltinName(__pyx_n_s_KeyboardInterrupt); if (!__pyx_builtin_KeyboardInterrupt) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "kstreamc.pyx":110
 *         self.on_kstream_open_callback = None
 *         self.ktrace.logger_name = PyBytes_AsString(self.klogger)
 *         self.regex = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')             # <<<<<<<<<<<<<<
 *         self.pointer_size = 8
 *         self.ktuple_filters = new vector[PyObject*]()
 */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_a_z0_9_A_Z_A_Z_a_z); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "kstreamc.pyx":336
 *                                if kparam.second != NULL}
 *                     kguid, opc = <object>ktuple
 *                     kguid = kguid[:-1]             # <<<<<<<<<<<<<<
 *                     # registry events have a valid process/thread id
 *                     # in the event header so we aggregate them
 */
  __pyx_slice__2 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_slice__2);
  __Pyx_GIVEREF(__pyx_slice__2);
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initkstreamc(void); /*proto*/
PyMODINIT_FUNC initkstreamc(void)
#else
PyMODINIT_FUNC PyInit_kstreamc(void); /*proto*/
PyMODINIT_FUNC PyInit_kstreamc(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_kstreamc(void)", 0);
  if (__Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("kstreamc", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_kstreamc) {
    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "kstreamc")) {
      if (unlikely(PyDict_SetItemString(modules, "kstreamc", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_8kstreamc_KEventStreamCollector = &__pyx_vtable_8kstreamc_KEventStreamCollector;
  __pyx_vtable_8kstreamc_KEventStreamCollector.process_kevent_callback = (PyObject *(*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, EVENT_RECORD *))__pyx_f_8kstreamc_21KEventStreamCollector_process_kevent_callback;
  __pyx_vtable_8kstreamc_KEventStreamCollector._process_kevent = (void (*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, EVENT_RECORD *))__pyx_f_8kstreamc_21KEventStreamCollector__process_kevent;
  __pyx_vtable_8kstreamc_KEventStreamCollector._decref = (PyObject *(*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, PyObject *))__pyx_f_8kstreamc_21KEventStreamCollector__decref;
  __pyx_vtable_8kstreamc_KEventStreamCollector._decref_params = (PyObject *(*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, std::unordered_map<std::wstring,PyObject *> ))__pyx_f_8kstreamc_21KEventStreamCollector__decref_params;
  __pyx_vtable_8kstreamc_KEventStreamCollector._underscore = (PyObject *(*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, PyObject *))__pyx_f_8kstreamc_21KEventStreamCollector__underscore;
  __pyx_vtable_8kstreamc_KEventStreamCollector.__pyx___parse_property = (PyObject *(*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, USHORT, USHORT, BYTE *))__pyx_f_8kstreamc_21KEventStreamCollector___parse_property;
  __pyx_vtable_8kstreamc_KEventStreamCollector.__pyx___apply_filters = (BOOL (*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG, ULONG, PyObject *, std::unordered_map<std::wstring,PyObject *> , BOOL))__pyx_f_8kstreamc_21KEventStreamCollector___apply_filters;
  __pyx_vtable_8kstreamc_KEventStreamCollector.__pyx___apply_skips = (BOOL (*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG))__pyx_f_8kstreamc_21KEventStreamCollector___apply_skips;
  __pyx_vtable_8kstreamc_KEventStreamCollector.__pyx___apply_prop_filters = (BOOL (*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, std::unordered_map<std::wstring,PyObject *> ))__pyx_f_8kstreamc_21KEventStreamCollector___apply_prop_filters;
  __pyx_vtable_8kstreamc_KEventStreamCollector.__pyx___apply_image_filter = (BOOL (*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, ULONG))__pyx_f_8kstreamc_21KEventStreamCollector___apply_image_filter;
  __pyx_vtable_8kstreamc_KEventStreamCollector.__pyx___wrap_ktuple = (PyObject *(*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, GUID, UCHAR))__pyx_f_8kstreamc_21KEventStreamCollector___wrap_ktuple;
  __pyx_vtable_8kstreamc_KEventStreamCollector.__pyx___ktuple_equals = (BOOL (*)(struct __pyx_obj_8kstreamc_KEventStreamCollector *, PyObject *, PyObject *))__pyx_f_8kstreamc_21KEventStreamCollector___ktuple_equals;
  if (PyType_Ready(&__pyx_type_8kstreamc_KEventStreamCollector) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_8kstreamc_KEventStreamCollector.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_8kstreamc_KEventStreamCollector.tp_dict, __pyx_vtabptr_8kstreamc_KEventStreamCollector) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttrString(__pyx_m, "KEventStreamCollector", (PyObject *)&__pyx_type_8kstreamc_KEventStreamCollector) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8kstreamc_KEventStreamCollector = &__pyx_type_8kstreamc_KEventStreamCollector;
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif

  /* "kstreamc.pyx":17
 * # under the License.
 * 
 * import re             # <<<<<<<<<<<<<<
 * import os
 * import traceback
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kstreamc.pyx":18
 * 
 * import re
 * import os             # <<<<<<<<<<<<<<
 * import traceback
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kstreamc.pyx":19
 * import re
 * import os
 * import traceback             # <<<<<<<<<<<<<<
 * 
 * from libcpp.unordered_map cimport unordered_map
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_traceback, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_traceback, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kstreamc.pyx":44
 *     INVALID_PID = 4294967295
 * 
 * cdef PyObject* ENUM_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 3)             # <<<<<<<<<<<<<<
 * cdef PyObject* ENUM_THREAD = build_ktuple(<PyObject*>'{3d6fa8d1-fe05-11d0-9dda-00c04fd7ba7c}', 3)
 * cdef PyObject* ENUM_IMAGE = build_ktuple(<PyObject*>'{2cb15d1d-5fc1-11d2-abe1-00a0c911f518}', 3)
 */
  __pyx_v_8kstreamc_ENUM_PROCESS = __pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_kp_s_3d6fa8d0_fe05_11d0_9dda_00c04fd), 3);

  /* "kstreamc.pyx":45
 * 
 * cdef PyObject* ENUM_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 3)
 * cdef PyObject* ENUM_THREAD = build_ktuple(<PyObject*>'{3d6fa8d1-fe05-11d0-9dda-00c04fd7ba7c}', 3)             # <<<<<<<<<<<<<<
 * cdef PyObject* ENUM_IMAGE = build_ktuple(<PyObject*>'{2cb15d1d-5fc1-11d2-abe1-00a0c911f518}', 3)
 * cdef PyObject* REG_CREATE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 22)
 */
  __pyx_v_8kstreamc_ENUM_THREAD = __pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_kp_s_3d6fa8d1_fe05_11d0_9dda_00c04fd), 3);

  /* "kstreamc.pyx":46
 * cdef PyObject* ENUM_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 3)
 * cdef PyObject* ENUM_THREAD = build_ktuple(<PyObject*>'{3d6fa8d1-fe05-11d0-9dda-00c04fd7ba7c}', 3)
 * cdef PyObject* ENUM_IMAGE = build_ktuple(<PyObject*>'{2cb15d1d-5fc1-11d2-abe1-00a0c911f518}', 3)             # <<<<<<<<<<<<<<
 * cdef PyObject* REG_CREATE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 22)
 * cdef PyObject* REG_DELETE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 23)
 */
  __pyx_v_8kstreamc_ENUM_IMAGE = __pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_kp_s_2cb15d1d_5fc1_11d2_abe1_00a0c91), 3);

  /* "kstreamc.pyx":47
 * cdef PyObject* ENUM_THREAD = build_ktuple(<PyObject*>'{3d6fa8d1-fe05-11d0-9dda-00c04fd7ba7c}', 3)
 * cdef PyObject* ENUM_IMAGE = build_ktuple(<PyObject*>'{2cb15d1d-5fc1-11d2-abe1-00a0c911f518}', 3)
 * cdef PyObject* REG_CREATE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 22)             # <<<<<<<<<<<<<<
 * cdef PyObject* REG_DELETE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 23)
 * 
 */
  __pyx_v_8kstreamc_REG_CREATE_KCB = __pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_kp_s_ae53722e_c863_11d2_8659_00c04fa), 22);

  /* "kstreamc.pyx":48
 * cdef PyObject* ENUM_IMAGE = build_ktuple(<PyObject*>'{2cb15d1d-5fc1-11d2-abe1-00a0c911f518}', 3)
 * cdef PyObject* REG_CREATE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 22)
 * cdef PyObject* REG_DELETE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 23)             # <<<<<<<<<<<<<<
 * 
 * cdef PyObject* CREATE_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 1)
 */
  __pyx_v_8kstreamc_REG_DELETE_KCB = __pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_kp_s_ae53722e_c863_11d2_8659_00c04fa), 23);

  /* "kstreamc.pyx":50
 * cdef PyObject* REG_DELETE_KCB = build_ktuple(<PyObject*>'{ae53722e-c863-11d2-8659-00c04fa321a1}', 23)
 * 
 * cdef PyObject* CREATE_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 1)             # <<<<<<<<<<<<<<
 * cdef PyObject* TERMINATE_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 2)
 * 
 */
  __pyx_v_8kstreamc_CREATE_PROCESS = __pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_kp_s_3d6fa8d0_fe05_11d0_9dda_00c04fd), 1);

  /* "kstreamc.pyx":51
 * 
 * cdef PyObject* CREATE_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 1)
 * cdef PyObject* TERMINATE_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 2)             # <<<<<<<<<<<<<<
 * 
 * cdef wstring PID_PROP = deref_prop("PID")
 */
  __pyx_v_8kstreamc_TERMINATE_PROCESS = __pyx_f_7kstream_6ktuple_build_ktuple(((PyObject *)__pyx_kp_s_3d6fa8d0_fe05_11d0_9dda_00c04fd), 2);

  /* "kstreamc.pyx":53
 * cdef PyObject* TERMINATE_PROCESS = build_ktuple(<PyObject*>'{3d6fa8d0-fe05-11d0-9dda-00c04fd7ba7c}', 2)
 * 
 * cdef wstring PID_PROP = deref_prop("PID")             # <<<<<<<<<<<<<<
 * cdef wstring PPID_PROP = deref_prop("ParentId")
 * cdef wstring PROCESS_ID_PROP = deref_prop("ProcessId")
 */
  __pyx_v_8kstreamc_PID_PROP = __pyx_f_7kstream_8includes_6python_deref_prop(__pyx_n_s_PID);

  /* "kstreamc.pyx":54
 * 
 * cdef wstring PID_PROP = deref_prop("PID")
 * cdef wstring PPID_PROP = deref_prop("ParentId")             # <<<<<<<<<<<<<<
 * cdef wstring PROCESS_ID_PROP = deref_prop("ProcessId")
 * cdef wstring IMAGE_FILE_NAME_PROP = deref_prop("ImageFileName")
 */
  __pyx_v_8kstreamc_PPID_PROP = __pyx_f_7kstream_8includes_6python_deref_prop(__pyx_n_s_ParentId);

  /* "kstreamc.pyx":55
 * cdef wstring PID_PROP = deref_prop("PID")
 * cdef wstring PPID_PROP = deref_prop("ParentId")
 * cdef wstring PROCESS_ID_PROP = deref_prop("ProcessId")             # <<<<<<<<<<<<<<
 * cdef wstring IMAGE_FILE_NAME_PROP = deref_prop("ImageFileName")
 * 
 */
  __pyx_v_8kstreamc_PROCESS_ID_PROP = __pyx_f_7kstream_8includes_6python_deref_prop(__pyx_n_s_ProcessId);

  /* "kstreamc.pyx":56
 * cdef wstring PPID_PROP = deref_prop("ParentId")
 * cdef wstring PROCESS_ID_PROP = deref_prop("ProcessId")
 * cdef wstring IMAGE_FILE_NAME_PROP = deref_prop("ImageFileName")             # <<<<<<<<<<<<<<
 * 
 * REGISTRY_KGUID = '{ae53722e-c863-11d2-8659-00c04fa321a1}'
 */
  __pyx_v_8kstreamc_IMAGE_FILE_NAME_PROP = __pyx_f_7kstream_8includes_6python_deref_prop(__pyx_n_s_ImageFileName);

  /* "kstreamc.pyx":58
 * cdef wstring IMAGE_FILE_NAME_PROP = deref_prop("ImageFileName")
 * 
 * REGISTRY_KGUID = '{ae53722e-c863-11d2-8659-00c04fa321a1}'             # <<<<<<<<<<<<<<
 * FS_KGUID = '{90cbdc39-4a3e-11d1-84f4-0000f80464e3}'
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_REGISTRY_KGUID, __pyx_kp_s_ae53722e_c863_11d2_8659_00c04fa) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kstreamc.pyx":59
 * 
 * REGISTRY_KGUID = '{ae53722e-c863-11d2-8659-00c04fa321a1}'
 * FS_KGUID = '{90cbdc39-4a3e-11d1-84f4-0000f80464e3}'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_FS_KGUID, __pyx_kp_s_90cbdc39_4a3e_11d1_84f4_0000f80) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kstreamc.pyx":1
 * # Copyright 2015 by Nedim Sabic (RabbitStack)             # <<<<<<<<<<<<<<
 * # http://rabbitstack.github.io
 * # All Rights Reserved.
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kstream\includes\python.pxd":140
 * 
 * 
 * cdef inline wstring deref_prop(prop_name):             # <<<<<<<<<<<<<<
 *     return deref(new wstring(_wchar_t(<PyObject*>prop_name)))
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init kstreamc", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init kstreamc");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* --- Runtime support code --- */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

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

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (likely(result)) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = func->ob_type->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
#else
    if (likely(PyCFunction_Check(func))) {
#endif
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (PyErr_ExceptionMatches(PyExc_OverflowError))
                    PyErr_Clear();
                else
                    goto bad;
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_COMPILING_IN_CPYTHON
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
#else
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
#endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#endif
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

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

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    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;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        __pyx_d,      /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

#if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
#endif

static CYTHON_INLINE ULONG __Pyx_PyInt_As_ULONG(PyObject *x) {
    const ULONG neg_one = (ULONG) -1, const_zero = (ULONG) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(ULONG) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(ULONG, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (ULONG) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (ULONG) 0;
                case  1: __PYX_VERIFY_RETURN_INT(ULONG, digit, digits[0])
                case 2:
                    if (8 * sizeof(ULONG) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) >= 2 * PyLong_SHIFT) {
                            return (ULONG) (((((ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(ULONG) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) >= 3 * PyLong_SHIFT) {
                            return (ULONG) (((((((ULONG)digits[2]) << PyLong_SHIFT) | (ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(ULONG) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) >= 4 * PyLong_SHIFT) {
                            return (ULONG) (((((((((ULONG)digits[3]) << PyLong_SHIFT) | (ULONG)digits[2]) << PyLong_SHIFT) | (ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (ULONG) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(ULONG) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(ULONG, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(ULONG) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(ULONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (ULONG) 0;
                case -1: __PYX_VERIFY_RETURN_INT(ULONG, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(ULONG,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(ULONG) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) - 1 > 2 * PyLong_SHIFT) {
                            return (ULONG) (((ULONG)-1)*(((((ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(ULONG) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) - 1 > 2 * PyLong_SHIFT) {
                            return (ULONG) ((((((ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(ULONG) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) - 1 > 3 * PyLong_SHIFT) {
                            return (ULONG) (((ULONG)-1)*(((((((ULONG)digits[2]) << PyLong_SHIFT) | (ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(ULONG) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) - 1 > 3 * PyLong_SHIFT) {
                            return (ULONG) ((((((((ULONG)digits[2]) << PyLong_SHIFT) | (ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(ULONG) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) - 1 > 4 * PyLong_SHIFT) {
                            return (ULONG) (((ULONG)-1)*(((((((((ULONG)digits[3]) << PyLong_SHIFT) | (ULONG)digits[2]) << PyLong_SHIFT) | (ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(ULONG) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(ULONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(ULONG) - 1 > 4 * PyLong_SHIFT) {
                            return (ULONG) ((((((((((ULONG)digits[3]) << PyLong_SHIFT) | (ULONG)digits[2]) << PyLong_SHIFT) | (ULONG)digits[1]) << PyLong_SHIFT) | (ULONG)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(ULONG) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(ULONG, long, PyLong_AsLong(x))
            } else if (sizeof(ULONG) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(ULONG, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            ULONG val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (ULONG) -1;
        }
    } else {
        ULONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (ULONG) -1;
        val = __Pyx_PyInt_As_ULONG(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to ULONG");
    return (ULONG) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to ULONG");
    return (ULONG) -1;
}

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

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

static CYTHON_INLINE UCHAR __Pyx_PyInt_As_UCHAR(PyObject *x) {
    const UCHAR neg_one = (UCHAR) -1, const_zero = (UCHAR) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(UCHAR) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(UCHAR, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (UCHAR) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (UCHAR) 0;
                case  1: __PYX_VERIFY_RETURN_INT(UCHAR, digit, digits[0])
                case 2:
                    if (8 * sizeof(UCHAR) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) >= 2 * PyLong_SHIFT) {
                            return (UCHAR) (((((UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(UCHAR) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) >= 3 * PyLong_SHIFT) {
                            return (UCHAR) (((((((UCHAR)digits[2]) << PyLong_SHIFT) | (UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(UCHAR) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) >= 4 * PyLong_SHIFT) {
                            return (UCHAR) (((((((((UCHAR)digits[3]) << PyLong_SHIFT) | (UCHAR)digits[2]) << PyLong_SHIFT) | (UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (UCHAR) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(UCHAR) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(UCHAR, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(UCHAR) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(UCHAR, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (UCHAR) 0;
                case -1: __PYX_VERIFY_RETURN_INT(UCHAR, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(UCHAR,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(UCHAR) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) - 1 > 2 * PyLong_SHIFT) {
                            return (UCHAR) (((UCHAR)-1)*(((((UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(UCHAR) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) - 1 > 2 * PyLong_SHIFT) {
                            return (UCHAR) ((((((UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(UCHAR) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) - 1 > 3 * PyLong_SHIFT) {
                            return (UCHAR) (((UCHAR)-1)*(((((((UCHAR)digits[2]) << PyLong_SHIFT) | (UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(UCHAR) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) - 1 > 3 * PyLong_SHIFT) {
                            return (UCHAR) ((((((((UCHAR)digits[2]) << PyLong_SHIFT) | (UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(UCHAR) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) - 1 > 4 * PyLong_SHIFT) {
                            return (UCHAR) (((UCHAR)-1)*(((((((((UCHAR)digits[3]) << PyLong_SHIFT) | (UCHAR)digits[2]) << PyLong_SHIFT) | (UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(UCHAR) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(UCHAR, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(UCHAR) - 1 > 4 * PyLong_SHIFT) {
                            return (UCHAR) ((((((((((UCHAR)digits[3]) << PyLong_SHIFT) | (UCHAR)digits[2]) << PyLong_SHIFT) | (UCHAR)digits[1]) << PyLong_SHIFT) | (UCHAR)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(UCHAR) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(UCHAR, long, PyLong_AsLong(x))
            } else if (sizeof(UCHAR) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(UCHAR, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            UCHAR val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (UCHAR) -1;
        }
    } else {
        UCHAR val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (UCHAR) -1;
        val = __Pyx_PyInt_As_UCHAR(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to UCHAR");
    return (UCHAR) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to UCHAR");
    return (UCHAR) -1;
}

static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) {
  int err;
  #ifdef WITH_THREAD
  PyGILState_STATE _save = PyGILState_Ensure();
  #endif
  err = !!PyErr_Occurred();
  #ifdef WITH_THREAD
  PyGILState_Release(_save);
  #endif
  return err;
}

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

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

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

#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject((char *)"stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}
static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
    int i;
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
        PyObject* v;
        if (PyFile_SoftSpace(f, 1)) {
            if (PyFile_WriteString(" ", f) < 0)
                goto error;
        }
        v = PyTuple_GET_ITEM(arg_tuple, i);
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
            goto error;
        if (PyString_Check(v)) {
            char *s = PyString_AsString(v);
            Py_ssize_t len = PyString_Size(v);
            if (len > 0) {
                switch (s[len-1]) {
                    case ' ': break;
                    case '\f': case '\r': case '\n': case '\t': case '\v':
                        PyFile_SoftSpace(f, 0);
                        break;
                    default:  break;
                }
            }
        }
    }
    if (newline) {
        if (PyFile_WriteString("\n", f) < 0)
            goto error;
        PyFile_SoftSpace(f, 0);
    }
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
}
#else
static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
    PyObject* kwargs = 0;
    PyObject* result = 0;
    PyObject* end_string;
    if (unlikely(!__pyx_print)) {
        __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
        if (!__pyx_print)
            return -1;
    }
    if (stream) {
        kwargs = PyDict_New();
        if (unlikely(!kwargs))
            return -1;
        if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
            goto bad;
        if (!newline) {
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                goto bad;
            if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                goto bad;
            }
            Py_DECREF(end_string);
        }
    } else if (!newline) {
        if (unlikely(!__pyx_print_kwargs)) {
            __pyx_print_kwargs = PyDict_New();
            if (unlikely(!__pyx_print_kwargs))
                return -1;
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (unlikely(!end_string))
                return -1;
            if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
                Py_DECREF(end_string);
                return -1;
            }
            Py_DECREF(end_string);
        }
        kwargs = __pyx_print_kwargs;
    }
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
    if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
        Py_DECREF(kwargs);
    if (!result)
        return -1;
    Py_DECREF(result);
    return 0;
bad:
    if (kwargs != __pyx_print_kwargs)
        Py_XDECREF(kwargs);
    return -1;
}
#endif

#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
    if (!f) {
        if (!(f = __Pyx_GetStdout()))
            return -1;
    }
    Py_INCREF(f);
    if (PyFile_SoftSpace(f, 0)) {
        if (PyFile_WriteString(" ", f) < 0)
            goto error;
    }
    if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
        goto error;
    if (PyFile_WriteString("\n", f) < 0)
        goto error;
    Py_DECREF(f);
    return 0;
error:
    Py_DECREF(f);
    return -1;
    /* the line below is just to avoid C compiler
     * warnings about unused functions */
    return __Pyx_Print(f, NULL, 0);
}
#else
static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
    int res;
    PyObject* arg_tuple = PyTuple_Pack(1, o);
    if (unlikely(!arg_tuple))
        return -1;
    res = __Pyx_Print(stream, arg_tuple, 1);
    Py_DECREF(arg_tuple);
    return res;
}
#endif

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

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = (long) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = (int) 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) digits[0])
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

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

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

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

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else
        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_LENGTH(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else
        return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return __Pyx_NewRef(x);
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(x);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
