1 /* Generated by Cython 0.29.22 */
2 
3 /* BEGIN: Cython Metadata
4 {
5     "distutils": {
6         "name": "cutadapt.qualtrim",
7         "sources": [
8             "src/cutadapt/qualtrim.pyx"
9         ]
10     },
11     "module_name": "cutadapt.qualtrim"
12 }
13 END: Cython Metadata */
14 
15 #define PY_SSIZE_T_CLEAN
16 #include "Python.h"
17 #ifndef Py_PYTHON_H
18     #error Python headers needed to compile C extensions, please install development version of Python.
19 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
20     #error Cython requires Python 2.6+ or Python 3.3+.
21 #else
22 #define CYTHON_ABI "0_29_22"
23 #define CYTHON_HEX_VERSION 0x001D16F0
24 #define CYTHON_FUTURE_DIVISION 1
25 #include <stddef.h>
26 #ifndef offsetof
27   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
28 #endif
29 #if !defined(WIN32) && !defined(MS_WINDOWS)
30   #ifndef __stdcall
31     #define __stdcall
32   #endif
33   #ifndef __cdecl
34     #define __cdecl
35   #endif
36   #ifndef __fastcall
37     #define __fastcall
38   #endif
39 #endif
40 #ifndef DL_IMPORT
41   #define DL_IMPORT(t) t
42 #endif
43 #ifndef DL_EXPORT
44   #define DL_EXPORT(t) t
45 #endif
46 #define __PYX_COMMA ,
47 #ifndef HAVE_LONG_LONG
48   #if PY_VERSION_HEX >= 0x02070000
49     #define HAVE_LONG_LONG
50   #endif
51 #endif
52 #ifndef PY_LONG_LONG
53   #define PY_LONG_LONG LONG_LONG
54 #endif
55 #ifndef Py_HUGE_VAL
56   #define Py_HUGE_VAL HUGE_VAL
57 #endif
58 #ifdef PYPY_VERSION
59   #define CYTHON_COMPILING_IN_PYPY 1
60   #define CYTHON_COMPILING_IN_PYSTON 0
61   #define CYTHON_COMPILING_IN_CPYTHON 0
62   #undef CYTHON_USE_TYPE_SLOTS
63   #define CYTHON_USE_TYPE_SLOTS 0
64   #undef CYTHON_USE_PYTYPE_LOOKUP
65   #define CYTHON_USE_PYTYPE_LOOKUP 0
66   #if PY_VERSION_HEX < 0x03050000
67     #undef CYTHON_USE_ASYNC_SLOTS
68     #define CYTHON_USE_ASYNC_SLOTS 0
69   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
70     #define CYTHON_USE_ASYNC_SLOTS 1
71   #endif
72   #undef CYTHON_USE_PYLIST_INTERNALS
73   #define CYTHON_USE_PYLIST_INTERNALS 0
74   #undef CYTHON_USE_UNICODE_INTERNALS
75   #define CYTHON_USE_UNICODE_INTERNALS 0
76   #undef CYTHON_USE_UNICODE_WRITER
77   #define CYTHON_USE_UNICODE_WRITER 0
78   #undef CYTHON_USE_PYLONG_INTERNALS
79   #define CYTHON_USE_PYLONG_INTERNALS 0
80   #undef CYTHON_AVOID_BORROWED_REFS
81   #define CYTHON_AVOID_BORROWED_REFS 1
82   #undef CYTHON_ASSUME_SAFE_MACROS
83   #define CYTHON_ASSUME_SAFE_MACROS 0
84   #undef CYTHON_UNPACK_METHODS
85   #define CYTHON_UNPACK_METHODS 0
86   #undef CYTHON_FAST_THREAD_STATE
87   #define CYTHON_FAST_THREAD_STATE 0
88   #undef CYTHON_FAST_PYCALL
89   #define CYTHON_FAST_PYCALL 0
90   #undef CYTHON_PEP489_MULTI_PHASE_INIT
91   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
92   #undef CYTHON_USE_TP_FINALIZE
93   #define CYTHON_USE_TP_FINALIZE 0
94   #undef CYTHON_USE_DICT_VERSIONS
95   #define CYTHON_USE_DICT_VERSIONS 0
96   #undef CYTHON_USE_EXC_INFO_STACK
97   #define CYTHON_USE_EXC_INFO_STACK 0
98 #elif defined(PYSTON_VERSION)
99   #define CYTHON_COMPILING_IN_PYPY 0
100   #define CYTHON_COMPILING_IN_PYSTON 1
101   #define CYTHON_COMPILING_IN_CPYTHON 0
102   #ifndef CYTHON_USE_TYPE_SLOTS
103     #define CYTHON_USE_TYPE_SLOTS 1
104   #endif
105   #undef CYTHON_USE_PYTYPE_LOOKUP
106   #define CYTHON_USE_PYTYPE_LOOKUP 0
107   #undef CYTHON_USE_ASYNC_SLOTS
108   #define CYTHON_USE_ASYNC_SLOTS 0
109   #undef CYTHON_USE_PYLIST_INTERNALS
110   #define CYTHON_USE_PYLIST_INTERNALS 0
111   #ifndef CYTHON_USE_UNICODE_INTERNALS
112     #define CYTHON_USE_UNICODE_INTERNALS 1
113   #endif
114   #undef CYTHON_USE_UNICODE_WRITER
115   #define CYTHON_USE_UNICODE_WRITER 0
116   #undef CYTHON_USE_PYLONG_INTERNALS
117   #define CYTHON_USE_PYLONG_INTERNALS 0
118   #ifndef CYTHON_AVOID_BORROWED_REFS
119     #define CYTHON_AVOID_BORROWED_REFS 0
120   #endif
121   #ifndef CYTHON_ASSUME_SAFE_MACROS
122     #define CYTHON_ASSUME_SAFE_MACROS 1
123   #endif
124   #ifndef CYTHON_UNPACK_METHODS
125     #define CYTHON_UNPACK_METHODS 1
126   #endif
127   #undef CYTHON_FAST_THREAD_STATE
128   #define CYTHON_FAST_THREAD_STATE 0
129   #undef CYTHON_FAST_PYCALL
130   #define CYTHON_FAST_PYCALL 0
131   #undef CYTHON_PEP489_MULTI_PHASE_INIT
132   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
133   #undef CYTHON_USE_TP_FINALIZE
134   #define CYTHON_USE_TP_FINALIZE 0
135   #undef CYTHON_USE_DICT_VERSIONS
136   #define CYTHON_USE_DICT_VERSIONS 0
137   #undef CYTHON_USE_EXC_INFO_STACK
138   #define CYTHON_USE_EXC_INFO_STACK 0
139 #else
140   #define CYTHON_COMPILING_IN_PYPY 0
141   #define CYTHON_COMPILING_IN_PYSTON 0
142   #define CYTHON_COMPILING_IN_CPYTHON 1
143   #ifndef CYTHON_USE_TYPE_SLOTS
144     #define CYTHON_USE_TYPE_SLOTS 1
145   #endif
146   #if PY_VERSION_HEX < 0x02070000
147     #undef CYTHON_USE_PYTYPE_LOOKUP
148     #define CYTHON_USE_PYTYPE_LOOKUP 0
149   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
150     #define CYTHON_USE_PYTYPE_LOOKUP 1
151   #endif
152   #if PY_MAJOR_VERSION < 3
153     #undef CYTHON_USE_ASYNC_SLOTS
154     #define CYTHON_USE_ASYNC_SLOTS 0
155   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
156     #define CYTHON_USE_ASYNC_SLOTS 1
157   #endif
158   #if PY_VERSION_HEX < 0x02070000
159     #undef CYTHON_USE_PYLONG_INTERNALS
160     #define CYTHON_USE_PYLONG_INTERNALS 0
161   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
162     #define CYTHON_USE_PYLONG_INTERNALS 1
163   #endif
164   #ifndef CYTHON_USE_PYLIST_INTERNALS
165     #define CYTHON_USE_PYLIST_INTERNALS 1
166   #endif
167   #ifndef CYTHON_USE_UNICODE_INTERNALS
168     #define CYTHON_USE_UNICODE_INTERNALS 1
169   #endif
170   #if PY_VERSION_HEX < 0x030300F0
171     #undef CYTHON_USE_UNICODE_WRITER
172     #define CYTHON_USE_UNICODE_WRITER 0
173   #elif !defined(CYTHON_USE_UNICODE_WRITER)
174     #define CYTHON_USE_UNICODE_WRITER 1
175   #endif
176   #ifndef CYTHON_AVOID_BORROWED_REFS
177     #define CYTHON_AVOID_BORROWED_REFS 0
178   #endif
179   #ifndef CYTHON_ASSUME_SAFE_MACROS
180     #define CYTHON_ASSUME_SAFE_MACROS 1
181   #endif
182   #ifndef CYTHON_UNPACK_METHODS
183     #define CYTHON_UNPACK_METHODS 1
184   #endif
185   #ifndef CYTHON_FAST_THREAD_STATE
186     #define CYTHON_FAST_THREAD_STATE 1
187   #endif
188   #ifndef CYTHON_FAST_PYCALL
189     #define CYTHON_FAST_PYCALL 1
190   #endif
191   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
192     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
193   #endif
194   #ifndef CYTHON_USE_TP_FINALIZE
195     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
196   #endif
197   #ifndef CYTHON_USE_DICT_VERSIONS
198     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
199   #endif
200   #ifndef CYTHON_USE_EXC_INFO_STACK
201     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
202   #endif
203 #endif
204 #if !defined(CYTHON_FAST_PYCCALL)
205 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
206 #endif
207 #if CYTHON_USE_PYLONG_INTERNALS
208   #include "longintrepr.h"
209   #undef SHIFT
210   #undef BASE
211   #undef MASK
212   #ifdef SIZEOF_VOID_P
213     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
214   #endif
215 #endif
216 #ifndef __has_attribute
217   #define __has_attribute(x) 0
218 #endif
219 #ifndef __has_cpp_attribute
220   #define __has_cpp_attribute(x) 0
221 #endif
222 #ifndef CYTHON_RESTRICT
223   #if defined(__GNUC__)
224     #define CYTHON_RESTRICT __restrict__
225   #elif defined(_MSC_VER) && _MSC_VER >= 1400
226     #define CYTHON_RESTRICT __restrict
227   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
228     #define CYTHON_RESTRICT restrict
229   #else
230     #define CYTHON_RESTRICT
231   #endif
232 #endif
233 #ifndef CYTHON_UNUSED
234 # if defined(__GNUC__)
235 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
236 #     define CYTHON_UNUSED __attribute__ ((__unused__))
237 #   else
238 #     define CYTHON_UNUSED
239 #   endif
240 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
241 #   define CYTHON_UNUSED __attribute__ ((__unused__))
242 # else
243 #   define CYTHON_UNUSED
244 # endif
245 #endif
246 #ifndef CYTHON_MAYBE_UNUSED_VAR
247 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)248      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
249 #  else
250 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
251 #  endif
252 #endif
253 #ifndef CYTHON_NCP_UNUSED
254 # if CYTHON_COMPILING_IN_CPYTHON
255 #  define CYTHON_NCP_UNUSED
256 # else
257 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
258 # endif
259 #endif
260 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
261 #ifdef _MSC_VER
262     #ifndef _MSC_STDINT_H_
263         #if _MSC_VER < 1300
264            typedef unsigned char     uint8_t;
265            typedef unsigned int      uint32_t;
266         #else
267            typedef unsigned __int8   uint8_t;
268            typedef unsigned __int32  uint32_t;
269         #endif
270     #endif
271 #else
272    #include <stdint.h>
273 #endif
274 #ifndef CYTHON_FALLTHROUGH
275   #if defined(__cplusplus) && __cplusplus >= 201103L
276     #if __has_cpp_attribute(fallthrough)
277       #define CYTHON_FALLTHROUGH [[fallthrough]]
278     #elif __has_cpp_attribute(clang::fallthrough)
279       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
280     #elif __has_cpp_attribute(gnu::fallthrough)
281       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
282     #endif
283   #endif
284   #ifndef CYTHON_FALLTHROUGH
285     #if __has_attribute(fallthrough)
286       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
287     #else
288       #define CYTHON_FALLTHROUGH
289     #endif
290   #endif
291   #if defined(__clang__ ) && defined(__apple_build_version__)
292     #if __apple_build_version__ < 7000000
293       #undef  CYTHON_FALLTHROUGH
294       #define CYTHON_FALLTHROUGH
295     #endif
296   #endif
297 #endif
298 
299 #ifndef CYTHON_INLINE
300   #if defined(__clang__)
301     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
302   #elif defined(__GNUC__)
303     #define CYTHON_INLINE __inline__
304   #elif defined(_MSC_VER)
305     #define CYTHON_INLINE __inline
306   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
307     #define CYTHON_INLINE inline
308   #else
309     #define CYTHON_INLINE
310   #endif
311 #endif
312 
313 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
314   #define Py_OptimizeFlag 0
315 #endif
316 #define __PYX_BUILD_PY_SSIZE_T "n"
317 #define CYTHON_FORMAT_SSIZE_T "z"
318 #if PY_MAJOR_VERSION < 3
319   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
320   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
321           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
322   #define __Pyx_DefaultClassType PyClass_Type
323 #else
324   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
325 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
326   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
327           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
328 #else
329   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
330           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
331 #endif
332   #define __Pyx_DefaultClassType PyType_Type
333 #endif
334 #ifndef Py_TPFLAGS_CHECKTYPES
335   #define Py_TPFLAGS_CHECKTYPES 0
336 #endif
337 #ifndef Py_TPFLAGS_HAVE_INDEX
338   #define Py_TPFLAGS_HAVE_INDEX 0
339 #endif
340 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
341   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
342 #endif
343 #ifndef Py_TPFLAGS_HAVE_FINALIZE
344   #define Py_TPFLAGS_HAVE_FINALIZE 0
345 #endif
346 #ifndef METH_STACKLESS
347   #define METH_STACKLESS 0
348 #endif
349 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
350   #ifndef METH_FASTCALL
351      #define METH_FASTCALL 0x80
352   #endif
353   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
354   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
355                                                           Py_ssize_t nargs, PyObject *kwnames);
356 #else
357   #define __Pyx_PyCFunctionFast _PyCFunctionFast
358   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
359 #endif
360 #if CYTHON_FAST_PYCCALL
361 #define __Pyx_PyFastCFunction_Check(func)\
362     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
363 #else
364 #define __Pyx_PyFastCFunction_Check(func) 0
365 #endif
366 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
367   #define PyObject_Malloc(s)   PyMem_Malloc(s)
368   #define PyObject_Free(p)     PyMem_Free(p)
369   #define PyObject_Realloc(p)  PyMem_Realloc(p)
370 #endif
371 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
372   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
373   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
374   #define PyMem_RawFree(p)             PyMem_Free(p)
375 #endif
376 #if CYTHON_COMPILING_IN_PYSTON
377   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
378   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
379 #else
380   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
381   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
382 #endif
383 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
384   #define __Pyx_PyThreadState_Current PyThreadState_GET()
385 #elif PY_VERSION_HEX >= 0x03060000
386   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
387 #elif PY_VERSION_HEX >= 0x03000000
388   #define __Pyx_PyThreadState_Current PyThreadState_GET()
389 #else
390   #define __Pyx_PyThreadState_Current _PyThreadState_Current
391 #endif
392 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
393 #include "pythread.h"
394 #define Py_tss_NEEDS_INIT 0
395 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)396 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
397   *key = PyThread_create_key();
398   return 0;
399 }
PyThread_tss_alloc(void)400 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
401   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
402   *key = Py_tss_NEEDS_INIT;
403   return key;
404 }
PyThread_tss_free(Py_tss_t * key)405 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
406   PyObject_Free(key);
407 }
PyThread_tss_is_created(Py_tss_t * key)408 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
409   return *key != Py_tss_NEEDS_INIT;
410 }
PyThread_tss_delete(Py_tss_t * key)411 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
412   PyThread_delete_key(*key);
413   *key = Py_tss_NEEDS_INIT;
414 }
PyThread_tss_set(Py_tss_t * key,void * value)415 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
416   return PyThread_set_key_value(*key, value);
417 }
PyThread_tss_get(Py_tss_t * key)418 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
419   return PyThread_get_key_value(*key);
420 }
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
423 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
424 #else
425 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
426 #endif
427 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
428   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
429   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
430 #else
431   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
432   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
433 #endif
434 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
435 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
436 #else
437 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
438 #endif
439 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
440   #define CYTHON_PEP393_ENABLED 1
441   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
442                                               0 : _PyUnicode_Ready((PyObject *)(op)))
443   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
444   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
445   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
446   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
447   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
448   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
449   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
450   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
451   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
452   #else
453   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
454   #endif
455 #else
456   #define CYTHON_PEP393_ENABLED 0
457   #define PyUnicode_1BYTE_KIND  1
458   #define PyUnicode_2BYTE_KIND  2
459   #define PyUnicode_4BYTE_KIND  4
460   #define __Pyx_PyUnicode_READY(op)       (0)
461   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
462   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
463   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
464   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
465   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
466   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
467   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
468   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
469 #endif
470 #if CYTHON_COMPILING_IN_PYPY
471   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
472   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
473 #else
474   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
475   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
476       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
477 #endif
478 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
479   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
480 #endif
481 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
482   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
483 #endif
484 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
485   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
486 #endif
487 #define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
488 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
489 #if PY_MAJOR_VERSION >= 3
490   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
491 #else
492   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
493 #endif
494 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
495   #define PyObject_ASCII(o)            PyObject_Repr(o)
496 #endif
497 #if PY_MAJOR_VERSION >= 3
498   #define PyBaseString_Type            PyUnicode_Type
499   #define PyStringObject               PyUnicodeObject
500   #define PyString_Type                PyUnicode_Type
501   #define PyString_Check               PyUnicode_Check
502   #define PyString_CheckExact          PyUnicode_CheckExact
503 #ifndef PyObject_Unicode
504   #define PyObject_Unicode             PyObject_Str
505 #endif
506 #endif
507 #if PY_MAJOR_VERSION >= 3
508   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
509   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
510 #else
511   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
512   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
513 #endif
514 #ifndef PySet_CheckExact
515   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
516 #endif
517 #if PY_VERSION_HEX >= 0x030900A4
518   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
519   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
520 #else
521   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
522   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
523 #endif
524 #if CYTHON_ASSUME_SAFE_MACROS
525   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
526 #else
527   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
528 #endif
529 #if PY_MAJOR_VERSION >= 3
530   #define PyIntObject                  PyLongObject
531   #define PyInt_Type                   PyLong_Type
532   #define PyInt_Check(op)              PyLong_Check(op)
533   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
534   #define PyInt_FromString             PyLong_FromString
535   #define PyInt_FromUnicode            PyLong_FromUnicode
536   #define PyInt_FromLong               PyLong_FromLong
537   #define PyInt_FromSize_t             PyLong_FromSize_t
538   #define PyInt_FromSsize_t            PyLong_FromSsize_t
539   #define PyInt_AsLong                 PyLong_AsLong
540   #define PyInt_AS_LONG                PyLong_AS_LONG
541   #define PyInt_AsSsize_t              PyLong_AsSsize_t
542   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
543   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
544   #define PyNumber_Int                 PyNumber_Long
545 #endif
546 #if PY_MAJOR_VERSION >= 3
547   #define PyBoolObject                 PyLongObject
548 #endif
549 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
550   #ifndef PyUnicode_InternFromString
551     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
552   #endif
553 #endif
554 #if PY_VERSION_HEX < 0x030200A4
555   typedef long Py_hash_t;
556   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
557   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
558 #else
559   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
560   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
561 #endif
562 #if PY_MAJOR_VERSION >= 3
563   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
564 #else
565   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
566 #endif
567 #if CYTHON_USE_ASYNC_SLOTS
568   #if PY_VERSION_HEX >= 0x030500B1
569     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
570     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
571   #else
572     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
573   #endif
574 #else
575   #define __Pyx_PyType_AsAsync(obj) NULL
576 #endif
577 #ifndef __Pyx_PyAsyncMethodsStruct
578     typedef struct {
579         unaryfunc am_await;
580         unaryfunc am_aiter;
581         unaryfunc am_anext;
582     } __Pyx_PyAsyncMethodsStruct;
583 #endif
584 
585 #if defined(WIN32) || defined(MS_WINDOWS)
586   #define _USE_MATH_DEFINES
587 #endif
588 #include <math.h>
589 #ifdef NAN
590 #define __PYX_NAN() ((float) NAN)
591 #else
__PYX_NAN()592 static CYTHON_INLINE float __PYX_NAN() {
593   float value;
594   memset(&value, 0xFF, sizeof(value));
595   return value;
596 }
597 #endif
598 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
599 #define __Pyx_truncl trunc
600 #else
601 #define __Pyx_truncl truncl
602 #endif
603 
604 #define __PYX_MARK_ERR_POS(f_index, lineno) \
605     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
606 #define __PYX_ERR(f_index, lineno, Ln_error) \
607     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
608 
609 #ifndef __PYX_EXTERN_C
610   #ifdef __cplusplus
611     #define __PYX_EXTERN_C extern "C"
612   #else
613     #define __PYX_EXTERN_C extern
614   #endif
615 #endif
616 
617 #define __PYX_HAVE__cutadapt__qualtrim
618 #define __PYX_HAVE_API__cutadapt__qualtrim
619 /* Early includes */
620 #ifdef _OPENMP
621 #include <omp.h>
622 #endif /* _OPENMP */
623 
624 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
625 #define CYTHON_WITHOUT_ASSERTIONS
626 #endif
627 
628 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
629                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
630 
631 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
632 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
633 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
634 #define __PYX_DEFAULT_STRING_ENCODING ""
635 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
636 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
637 #define __Pyx_uchar_cast(c) ((unsigned char)c)
638 #define __Pyx_long_cast(x) ((long)x)
639 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
640     (sizeof(type) < sizeof(Py_ssize_t))  ||\
641     (sizeof(type) > sizeof(Py_ssize_t) &&\
642           likely(v < (type)PY_SSIZE_T_MAX ||\
643                  v == (type)PY_SSIZE_T_MAX)  &&\
644           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
645                                 v == (type)PY_SSIZE_T_MIN)))  ||\
646     (sizeof(type) == sizeof(Py_ssize_t) &&\
647           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
648                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)649 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
650     return (size_t) i < (size_t) limit;
651 }
652 #if defined (__cplusplus) && __cplusplus >= 201103L
653     #include <cstdlib>
654     #define __Pyx_sst_abs(value) std::abs(value)
655 #elif SIZEOF_INT >= SIZEOF_SIZE_T
656     #define __Pyx_sst_abs(value) abs(value)
657 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
658     #define __Pyx_sst_abs(value) labs(value)
659 #elif defined (_MSC_VER)
660     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
661 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
662     #define __Pyx_sst_abs(value) llabs(value)
663 #elif defined (__GNUC__)
664     #define __Pyx_sst_abs(value) __builtin_llabs(value)
665 #else
666     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
667 #endif
668 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
669 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
670 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
671 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
672 #define __Pyx_PyBytes_FromString        PyBytes_FromString
673 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
674 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
675 #if PY_MAJOR_VERSION < 3
676     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
677     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
678 #else
679     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
680     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
681 #endif
682 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
683 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
684 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
685 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
686 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
687 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
688 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
689 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
690 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
691 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
692 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
693 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
694 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
695 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
696 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
697 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)698 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
699     const Py_UNICODE *u_end = u;
700     while (*u_end++) ;
701     return (size_t)(u_end - u - 1);
702 }
703 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
704 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
705 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
706 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
707 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
708 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
709 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
710 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
711 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
712 #define __Pyx_PySequence_Tuple(obj)\
713     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
714 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
715 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
716 #if CYTHON_ASSUME_SAFE_MACROS
717 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
718 #else
719 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
720 #endif
721 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
722 #if PY_MAJOR_VERSION >= 3
723 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
724 #else
725 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
726 #endif
727 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
728 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
729 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)730 static int __Pyx_init_sys_getdefaultencoding_params(void) {
731     PyObject* sys;
732     PyObject* default_encoding = NULL;
733     PyObject* ascii_chars_u = NULL;
734     PyObject* ascii_chars_b = NULL;
735     const char* default_encoding_c;
736     sys = PyImport_ImportModule("sys");
737     if (!sys) goto bad;
738     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
739     Py_DECREF(sys);
740     if (!default_encoding) goto bad;
741     default_encoding_c = PyBytes_AsString(default_encoding);
742     if (!default_encoding_c) goto bad;
743     if (strcmp(default_encoding_c, "ascii") == 0) {
744         __Pyx_sys_getdefaultencoding_not_ascii = 0;
745     } else {
746         char ascii_chars[128];
747         int c;
748         for (c = 0; c < 128; c++) {
749             ascii_chars[c] = c;
750         }
751         __Pyx_sys_getdefaultencoding_not_ascii = 1;
752         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
753         if (!ascii_chars_u) goto bad;
754         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
755         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
756             PyErr_Format(
757                 PyExc_ValueError,
758                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
759                 default_encoding_c);
760             goto bad;
761         }
762         Py_DECREF(ascii_chars_u);
763         Py_DECREF(ascii_chars_b);
764     }
765     Py_DECREF(default_encoding);
766     return 0;
767 bad:
768     Py_XDECREF(default_encoding);
769     Py_XDECREF(ascii_chars_u);
770     Py_XDECREF(ascii_chars_b);
771     return -1;
772 }
773 #endif
774 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
775 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
776 #else
777 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
778 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
779 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)780 static int __Pyx_init_sys_getdefaultencoding_params(void) {
781     PyObject* sys;
782     PyObject* default_encoding = NULL;
783     char* default_encoding_c;
784     sys = PyImport_ImportModule("sys");
785     if (!sys) goto bad;
786     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
787     Py_DECREF(sys);
788     if (!default_encoding) goto bad;
789     default_encoding_c = PyBytes_AsString(default_encoding);
790     if (!default_encoding_c) goto bad;
791     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
792     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
793     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
794     Py_DECREF(default_encoding);
795     return 0;
796 bad:
797     Py_XDECREF(default_encoding);
798     return -1;
799 }
800 #endif
801 #endif
802 
803 
804 /* Test for GCC > 2.95 */
805 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
806   #define likely(x)   __builtin_expect(!!(x), 1)
807   #define unlikely(x) __builtin_expect(!!(x), 0)
808 #else /* !__GNUC__ or GCC < 2.95 */
809   #define likely(x)   (x)
810   #define unlikely(x) (x)
811 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)812 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
813 
814 static PyObject *__pyx_m = NULL;
815 static PyObject *__pyx_d;
816 static PyObject *__pyx_b;
817 static PyObject *__pyx_cython_runtime = NULL;
818 static PyObject *__pyx_empty_tuple;
819 static PyObject *__pyx_empty_bytes;
820 static PyObject *__pyx_empty_unicode;
821 static int __pyx_lineno;
822 static int __pyx_clineno = 0;
823 static const char * __pyx_cfilenm= __FILE__;
824 static const char *__pyx_filename;
825 
826 
827 static const char *__pyx_f[] = {
828   "src/cutadapt/qualtrim.pyx",
829 };
830 
831 /*--- Type declarations ---*/
832 
833 /* --- Runtime support code (head) --- */
834 /* Refnanny.proto */
835 #ifndef CYTHON_REFNANNY
836   #define CYTHON_REFNANNY 0
837 #endif
838 #if CYTHON_REFNANNY
839   typedef struct {
840     void (*INCREF)(void*, PyObject*, int);
841     void (*DECREF)(void*, PyObject*, int);
842     void (*GOTREF)(void*, PyObject*, int);
843     void (*GIVEREF)(void*, PyObject*, int);
844     void* (*SetupContext)(const char*, int, const char*);
845     void (*FinishContext)(void**);
846   } __Pyx_RefNannyAPIStruct;
847   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
848   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
849   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
850 #ifdef WITH_THREAD
851   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
852           if (acquire_gil) {\
853               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
854               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
855               PyGILState_Release(__pyx_gilstate_save);\
856           } else {\
857               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
858           }
859 #else
860   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
861           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
862 #endif
863   #define __Pyx_RefNannyFinishContext()\
864           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
865   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
866   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
867   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
868   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
869   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
870   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
871   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
872   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
873 #else
874   #define __Pyx_RefNannyDeclarations
875   #define __Pyx_RefNannySetupContext(name, acquire_gil)
876   #define __Pyx_RefNannyFinishContext()
877   #define __Pyx_INCREF(r) Py_INCREF(r)
878   #define __Pyx_DECREF(r) Py_DECREF(r)
879   #define __Pyx_GOTREF(r)
880   #define __Pyx_GIVEREF(r)
881   #define __Pyx_XINCREF(r) Py_XINCREF(r)
882   #define __Pyx_XDECREF(r) Py_XDECREF(r)
883   #define __Pyx_XGOTREF(r)
884   #define __Pyx_XGIVEREF(r)
885 #endif
886 #define __Pyx_XDECREF_SET(r, v) do {\
887         PyObject *tmp = (PyObject *) r;\
888         r = v; __Pyx_XDECREF(tmp);\
889     } while (0)
890 #define __Pyx_DECREF_SET(r, v) do {\
891         PyObject *tmp = (PyObject *) r;\
892         r = v; __Pyx_DECREF(tmp);\
893     } while (0)
894 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
895 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
896 
897 /* PyObjectGetAttrStr.proto */
898 #if CYTHON_USE_TYPE_SLOTS
899 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
900 #else
901 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
902 #endif
903 
904 /* GetBuiltinName.proto */
905 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
906 
907 /* RaiseArgTupleInvalid.proto */
908 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
909     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
910 
911 /* RaiseDoubleKeywords.proto */
912 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
913 
914 /* ParseKeywords.proto */
915 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
916     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
917     const char* function_name);
918 
919 /* ArgTypeTest.proto */
920 #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
921     ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
922         __Pyx__ArgTypeTest(obj, type, name, exact))
923 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
924 
925 /* GetItemIntUnicode.proto */
926 #define __Pyx_GetItemInt_Unicode(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
927     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
928     __Pyx_GetItemInt_Unicode_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
929     (PyErr_SetString(PyExc_IndexError, "string index out of range"), (Py_UCS4)-1))
930 static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i,
931                                                            int wraparound, int boundscheck);
932 
933 /* UnicodeAsUCS4.proto */
934 static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*);
935 
936 /* object_ord.proto */
937 #if PY_MAJOR_VERSION >= 3
938 #define __Pyx_PyObject_Ord(c)\
939     (likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c))
940 #else
941 #define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c)
942 #endif
943 static long __Pyx__PyObject_Ord(PyObject* c);
944 
945 /* GetItemInt.proto */
946 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
947     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
948     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
949     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
950                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
951 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
952     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
953     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
954     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
955 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
956                                                               int wraparound, int boundscheck);
957 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
958     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
959     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
960     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
961 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
962                                                               int wraparound, int boundscheck);
963 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
964 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
965                                                      int is_list, int wraparound, int boundscheck);
966 
967 /* IncludeStringH.proto */
968 #include <string.h>
969 
970 /* BytesEquals.proto */
971 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
972 
973 /* UnicodeEquals.proto */
974 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
975 
976 /* PyDictVersioning.proto */
977 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
978 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
979 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
980 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
981     (version_var) = __PYX_GET_DICT_VERSION(dict);\
982     (cache_var) = (value);
983 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
984     static PY_UINT64_T __pyx_dict_version = 0;\
985     static PyObject *__pyx_dict_cached_value = NULL;\
986     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
987         (VAR) = __pyx_dict_cached_value;\
988     } else {\
989         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
990         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
991     }\
992 }
993 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
994 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
995 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
996 #else
997 #define __PYX_GET_DICT_VERSION(dict)  (0)
998 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
999 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1000 #endif
1001 
1002 /* PyThreadStateGet.proto */
1003 #if CYTHON_FAST_THREAD_STATE
1004 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1005 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1006 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1007 #else
1008 #define __Pyx_PyThreadState_declare
1009 #define __Pyx_PyThreadState_assign
1010 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1011 #endif
1012 
1013 /* PyErrFetchRestore.proto */
1014 #if CYTHON_FAST_THREAD_STATE
1015 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1016 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1017 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1018 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1019 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1020 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1021 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1022 #if CYTHON_COMPILING_IN_CPYTHON
1023 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1024 #else
1025 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1026 #endif
1027 #else
1028 #define __Pyx_PyErr_Clear() PyErr_Clear()
1029 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1030 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1031 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1032 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1033 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1034 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1035 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1036 #endif
1037 
1038 /* CLineInTraceback.proto */
1039 #ifdef CYTHON_CLINE_IN_TRACEBACK
1040 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1041 #else
1042 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1043 #endif
1044 
1045 /* CodeObjectCache.proto */
1046 typedef struct {
1047     PyCodeObject* code_object;
1048     int code_line;
1049 } __Pyx_CodeObjectCacheEntry;
1050 struct __Pyx_CodeObjectCache {
1051     int count;
1052     int max_count;
1053     __Pyx_CodeObjectCacheEntry* entries;
1054 };
1055 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1056 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1057 static PyCodeObject *__pyx_find_code_object(int code_line);
1058 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1059 
1060 /* AddTraceback.proto */
1061 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1062                                int py_line, const char *filename);
1063 
1064 /* GCCDiagnostics.proto */
1065 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1066 #define __Pyx_HAS_GCC_DIAGNOSTIC
1067 #endif
1068 
1069 /* CIntFromPy.proto */
1070 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1071 
1072 /* CIntToPy.proto */
1073 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1074 
1075 /* CIntToPy.proto */
1076 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1077 
1078 /* CIntFromPy.proto */
1079 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1080 
1081 /* FastTypeChecks.proto */
1082 #if CYTHON_COMPILING_IN_CPYTHON
1083 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1084 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1085 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1086 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1087 #else
1088 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1089 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1090 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1091 #endif
1092 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1093 
1094 /* CheckBinaryVersion.proto */
1095 static int __Pyx_check_binary_version(void);
1096 
1097 /* InitStrings.proto */
1098 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1099 
1100 
1101 /* Module declarations from 'cutadapt.qualtrim' */
1102 #define __Pyx_MODULE_NAME "cutadapt.qualtrim"
1103 extern int __pyx_module_is_main_cutadapt__qualtrim;
1104 int __pyx_module_is_main_cutadapt__qualtrim = 0;
1105 
1106 /* Implementation of 'cutadapt.qualtrim' */
1107 static PyObject *__pyx_builtin_range;
1108 static PyObject *__pyx_builtin_reversed;
1109 static PyObject *__pyx_builtin_xrange;
1110 static const char __pyx_k_G[] = "G";
1111 static const char __pyx_k_e[] = "e";
1112 static const char __pyx_k_i[] = "i";
1113 static const char __pyx_k_q[] = "q";
1114 static const char __pyx_k_s[] = "s";
1115 static const char __pyx_k_cq[] = "cq";
1116 static const char __pyx_k_base[] = "base";
1117 static const char __pyx_k_main[] = "__main__";
1118 static const char __pyx_k_name[] = "__name__";
1119 static const char __pyx_k_stop[] = "stop";
1120 static const char __pyx_k_test[] = "__test__";
1121 static const char __pyx_k_bases[] = "bases";
1122 static const char __pyx_k_max_i[] = "max_i";
1123 static const char __pyx_k_quals[] = "quals";
1124 static const char __pyx_k_range[] = "range";
1125 static const char __pyx_k_start[] = "start";
1126 static const char __pyx_k_cutoff[] = "cutoff";
1127 static const char __pyx_k_xrange[] = "xrange";
1128 static const char __pyx_k_max_qual[] = "max_qual";
1129 static const char __pyx_k_reversed[] = "reversed";
1130 static const char __pyx_k_sequence[] = "sequence";
1131 static const char __pyx_k_qualities[] = "qualities";
1132 static const char __pyx_k_cutoff_back[] = "cutoff_back";
1133 static const char __pyx_k_cutoff_front[] = "cutoff_front";
1134 static const char __pyx_k_expected_errors[] = "expected_errors";
1135 static const char __pyx_k_Quality_trimming[] = "\nQuality trimming.\n";
1136 static const char __pyx_k_cutadapt_qualtrim[] = "cutadapt.qualtrim";
1137 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1138 static const char __pyx_k_nextseq_trim_index[] = "nextseq_trim_index";
1139 static const char __pyx_k_quality_trim_index[] = "quality_trim_index";
1140 static const char __pyx_k_src_cutadapt_qualtrim_pyx[] = "src/cutadapt/qualtrim.pyx";
1141 static PyObject *__pyx_n_u_G;
1142 static PyObject *__pyx_n_s_base;
1143 static PyObject *__pyx_n_s_bases;
1144 static PyObject *__pyx_n_s_cline_in_traceback;
1145 static PyObject *__pyx_n_s_cq;
1146 static PyObject *__pyx_n_s_cutadapt_qualtrim;
1147 static PyObject *__pyx_n_s_cutoff;
1148 static PyObject *__pyx_n_s_cutoff_back;
1149 static PyObject *__pyx_n_s_cutoff_front;
1150 static PyObject *__pyx_n_s_e;
1151 static PyObject *__pyx_n_s_expected_errors;
1152 static PyObject *__pyx_n_s_i;
1153 static PyObject *__pyx_n_s_main;
1154 static PyObject *__pyx_n_s_max_i;
1155 static PyObject *__pyx_n_s_max_qual;
1156 static PyObject *__pyx_n_s_name;
1157 static PyObject *__pyx_n_s_nextseq_trim_index;
1158 static PyObject *__pyx_n_s_q;
1159 static PyObject *__pyx_n_s_qualities;
1160 static PyObject *__pyx_n_s_quality_trim_index;
1161 static PyObject *__pyx_n_s_quals;
1162 static PyObject *__pyx_n_s_range;
1163 static PyObject *__pyx_n_s_reversed;
1164 static PyObject *__pyx_n_s_s;
1165 static PyObject *__pyx_n_s_sequence;
1166 static PyObject *__pyx_kp_s_src_cutadapt_qualtrim_pyx;
1167 static PyObject *__pyx_n_s_start;
1168 static PyObject *__pyx_n_s_stop;
1169 static PyObject *__pyx_n_s_test;
1170 static PyObject *__pyx_n_s_xrange;
1171 static PyObject *__pyx_pf_8cutadapt_8qualtrim_quality_trim_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_cutoff_front, int __pyx_v_cutoff_back, int __pyx_v_base); /* proto */
1172 static PyObject *__pyx_pf_8cutadapt_8qualtrim_2nextseq_trim_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence, int __pyx_v_cutoff, int __pyx_v_base); /* proto */
1173 static PyObject *__pyx_pf_8cutadapt_8qualtrim_4expected_errors(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_base); /* proto */
1174 static PyObject *__pyx_tuple_;
1175 static PyObject *__pyx_tuple__3;
1176 static PyObject *__pyx_tuple__5;
1177 static PyObject *__pyx_codeobj__2;
1178 static PyObject *__pyx_codeobj__4;
1179 static PyObject *__pyx_codeobj__6;
1180 /* Late includes */
1181 
1182 
1183 /* Python wrapper */
1184 static PyObject *__pyx_pw_8cutadapt_8qualtrim_1quality_trim_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1185 static char __pyx_doc_8cutadapt_8qualtrim_quality_trim_index[] = "\n    Find the positions at which to trim low-quality ends from a nucleotide sequence.\n    Return tuple (start, stop) that indicates the good-quality segment.\n\n    Qualities are assumed to be ASCII-encoded as chr(qual + base).\n\n    The algorithm is the same as the one used by BWA within the function\n    'bwa_trim_read':\n    - Subtract the cutoff value from all qualities.\n    - Compute partial sums from all indices to the end of the sequence.\n    - Trim sequence at the index at which the sum is minimal.\n    ";
1186 static PyMethodDef __pyx_mdef_8cutadapt_8qualtrim_1quality_trim_index = {"quality_trim_index", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8cutadapt_8qualtrim_1quality_trim_index, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8cutadapt_8qualtrim_quality_trim_index};
__pyx_pw_8cutadapt_8qualtrim_1quality_trim_index(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1187 static PyObject *__pyx_pw_8cutadapt_8qualtrim_1quality_trim_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1188   PyObject *__pyx_v_qualities = 0;
1189   int __pyx_v_cutoff_front;
1190   int __pyx_v_cutoff_back;
1191   int __pyx_v_base;
1192   int __pyx_lineno = 0;
1193   const char *__pyx_filename = NULL;
1194   int __pyx_clineno = 0;
1195   PyObject *__pyx_r = 0;
1196   __Pyx_RefNannyDeclarations
1197   __Pyx_RefNannySetupContext("quality_trim_index (wrapper)", 0);
1198   {
1199     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_qualities,&__pyx_n_s_cutoff_front,&__pyx_n_s_cutoff_back,&__pyx_n_s_base,0};
1200     PyObject* values[4] = {0,0,0,0};
1201     if (unlikely(__pyx_kwds)) {
1202       Py_ssize_t kw_args;
1203       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1204       switch (pos_args) {
1205         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
1206         CYTHON_FALLTHROUGH;
1207         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1208         CYTHON_FALLTHROUGH;
1209         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1210         CYTHON_FALLTHROUGH;
1211         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1212         CYTHON_FALLTHROUGH;
1213         case  0: break;
1214         default: goto __pyx_L5_argtuple_error;
1215       }
1216       kw_args = PyDict_Size(__pyx_kwds);
1217       switch (pos_args) {
1218         case  0:
1219         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_qualities)) != 0)) kw_args--;
1220         else goto __pyx_L5_argtuple_error;
1221         CYTHON_FALLTHROUGH;
1222         case  1:
1223         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cutoff_front)) != 0)) kw_args--;
1224         else {
1225           __Pyx_RaiseArgtupleInvalid("quality_trim_index", 0, 3, 4, 1); __PYX_ERR(0, 6, __pyx_L3_error)
1226         }
1227         CYTHON_FALLTHROUGH;
1228         case  2:
1229         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cutoff_back)) != 0)) kw_args--;
1230         else {
1231           __Pyx_RaiseArgtupleInvalid("quality_trim_index", 0, 3, 4, 2); __PYX_ERR(0, 6, __pyx_L3_error)
1232         }
1233         CYTHON_FALLTHROUGH;
1234         case  3:
1235         if (kw_args > 0) {
1236           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base);
1237           if (value) { values[3] = value; kw_args--; }
1238         }
1239       }
1240       if (unlikely(kw_args > 0)) {
1241         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "quality_trim_index") < 0)) __PYX_ERR(0, 6, __pyx_L3_error)
1242       }
1243     } else {
1244       switch (PyTuple_GET_SIZE(__pyx_args)) {
1245         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
1246         CYTHON_FALLTHROUGH;
1247         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1248         values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1249         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1250         break;
1251         default: goto __pyx_L5_argtuple_error;
1252       }
1253     }
1254     __pyx_v_qualities = ((PyObject*)values[0]);
1255     __pyx_v_cutoff_front = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_cutoff_front == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 6, __pyx_L3_error)
1256     __pyx_v_cutoff_back = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_cutoff_back == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 6, __pyx_L3_error)
1257     if (values[3]) {
1258       __pyx_v_base = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_base == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 6, __pyx_L3_error)
1259     } else {
1260       __pyx_v_base = ((int)33);
1261     }
1262   }
1263   goto __pyx_L4_argument_unpacking_done;
1264   __pyx_L5_argtuple_error:;
1265   __Pyx_RaiseArgtupleInvalid("quality_trim_index", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 6, __pyx_L3_error)
1266   __pyx_L3_error:;
1267   __Pyx_AddTraceback("cutadapt.qualtrim.quality_trim_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
1268   __Pyx_RefNannyFinishContext();
1269   return NULL;
1270   __pyx_L4_argument_unpacking_done:;
1271   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_qualities), (&PyUnicode_Type), 1, "qualities", 1))) __PYX_ERR(0, 6, __pyx_L1_error)
1272   __pyx_r = __pyx_pf_8cutadapt_8qualtrim_quality_trim_index(__pyx_self, __pyx_v_qualities, __pyx_v_cutoff_front, __pyx_v_cutoff_back, __pyx_v_base);
1273 
1274   /* function exit code */
1275   goto __pyx_L0;
1276   __pyx_L1_error:;
1277   __pyx_r = NULL;
1278   __pyx_L0:;
1279   __Pyx_RefNannyFinishContext();
1280   return __pyx_r;
1281 }
1282 
__pyx_pf_8cutadapt_8qualtrim_quality_trim_index(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_qualities,int __pyx_v_cutoff_front,int __pyx_v_cutoff_back,int __pyx_v_base)1283 static PyObject *__pyx_pf_8cutadapt_8qualtrim_quality_trim_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_cutoff_front, int __pyx_v_cutoff_back, int __pyx_v_base) {
1284   int __pyx_v_s;
1285   int __pyx_v_max_qual;
1286   int __pyx_v_stop;
1287   int __pyx_v_start;
1288   int __pyx_v_i;
1289   PyObject *__pyx_r = NULL;
1290   __Pyx_RefNannyDeclarations
1291   Py_ssize_t __pyx_t_1;
1292   Py_ssize_t __pyx_t_2;
1293   int __pyx_t_3;
1294   Py_UCS4 __pyx_t_4;
1295   int __pyx_t_5;
1296   int __pyx_t_6;
1297   PyObject *__pyx_t_7 = NULL;
1298   PyObject *__pyx_t_8 = NULL;
1299   PyObject *__pyx_t_9 = NULL;
1300   int __pyx_lineno = 0;
1301   const char *__pyx_filename = NULL;
1302   int __pyx_clineno = 0;
1303   __Pyx_RefNannySetupContext("quality_trim_index", 0);
1304 
1305   if (unlikely(__pyx_v_qualities == Py_None)) {
1306     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
1307     __PYX_ERR(0, 22, __pyx_L1_error)
1308   }
1309   __pyx_t_1 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_qualities); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 22, __pyx_L1_error)
1310   __pyx_v_stop = __pyx_t_1;
1311 
1312   __pyx_v_start = 0;
1313 
1314   __pyx_v_s = 0;
1315 
1316   __pyx_v_max_qual = 0;
1317 
1318   if (unlikely(__pyx_v_qualities == Py_None)) {
1319     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
1320     __PYX_ERR(0, 29, __pyx_L1_error)
1321   }
1322   __pyx_t_1 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_qualities); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 29, __pyx_L1_error)
1323   __pyx_t_2 = __pyx_t_1;
1324   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
1325     __pyx_v_i = __pyx_t_3;
1326 
1327     __pyx_t_4 = __Pyx_GetItemInt_Unicode(__pyx_v_qualities, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_4 == (Py_UCS4)-1)) __PYX_ERR(0, 30, __pyx_L1_error)
1328     __pyx_v_s = (__pyx_v_s + (__pyx_v_cutoff_front - (((long)__pyx_t_4) - __pyx_v_base)));
1329 
1330     __pyx_t_5 = ((__pyx_v_s < 0) != 0);
1331     if (__pyx_t_5) {
1332 
1333       goto __pyx_L4_break;
1334 
1335     }
1336 
1337     __pyx_t_5 = ((__pyx_v_s > __pyx_v_max_qual) != 0);
1338     if (__pyx_t_5) {
1339 
1340       __pyx_v_max_qual = __pyx_v_s;
1341 
1342       __pyx_v_start = (__pyx_v_i + 1);
1343 
1344     }
1345   }
1346   __pyx_L4_break:;
1347 
1348   __pyx_v_max_qual = 0;
1349 
1350   __pyx_v_s = 0;
1351 
1352   if (unlikely(__pyx_v_qualities == Py_None)) {
1353     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
1354     __PYX_ERR(0, 40, __pyx_L1_error)
1355   }
1356   __pyx_t_1 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_qualities); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 40, __pyx_L1_error)
1357   for (__pyx_t_3 = __pyx_t_1-1; __pyx_t_3 >= 0; __pyx_t_3-=1) {
1358     __pyx_v_i = __pyx_t_3;
1359 
1360     __pyx_t_4 = __Pyx_GetItemInt_Unicode(__pyx_v_qualities, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_4 == (Py_UCS4)-1)) __PYX_ERR(0, 41, __pyx_L1_error)
1361     __pyx_v_s = (__pyx_v_s + (__pyx_v_cutoff_back - (((long)__pyx_t_4) - __pyx_v_base)));
1362 
1363     __pyx_t_5 = ((__pyx_v_s < 0) != 0);
1364     if (__pyx_t_5) {
1365 
1366       goto __pyx_L8_break;
1367 
1368     }
1369 
1370     __pyx_t_5 = ((__pyx_v_s > __pyx_v_max_qual) != 0);
1371     if (__pyx_t_5) {
1372 
1373       __pyx_v_max_qual = __pyx_v_s;
1374 
1375       __pyx_v_stop = __pyx_v_i;
1376 
1377     }
1378   }
1379   __pyx_L8_break:;
1380 
1381   __pyx_t_5 = ((__pyx_v_start >= __pyx_v_stop) != 0);
1382   if (__pyx_t_5) {
1383 
1384     __pyx_t_3 = 0;
1385     __pyx_t_6 = 0;
1386     __pyx_v_start = __pyx_t_3;
1387     __pyx_v_stop = __pyx_t_6;
1388 
1389   }
1390 
1391   __Pyx_XDECREF(__pyx_r);
1392   __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_start); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error)
1393   __Pyx_GOTREF(__pyx_t_7);
1394   __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_stop); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 49, __pyx_L1_error)
1395   __Pyx_GOTREF(__pyx_t_8);
1396   __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 49, __pyx_L1_error)
1397   __Pyx_GOTREF(__pyx_t_9);
1398   __Pyx_GIVEREF(__pyx_t_7);
1399   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7);
1400   __Pyx_GIVEREF(__pyx_t_8);
1401   PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
1402   __pyx_t_7 = 0;
1403   __pyx_t_8 = 0;
1404   __pyx_r = __pyx_t_9;
1405   __pyx_t_9 = 0;
1406   goto __pyx_L0;
1407 
1408 
1409   /* function exit code */
1410   __pyx_L1_error:;
1411   __Pyx_XDECREF(__pyx_t_7);
1412   __Pyx_XDECREF(__pyx_t_8);
1413   __Pyx_XDECREF(__pyx_t_9);
1414   __Pyx_AddTraceback("cutadapt.qualtrim.quality_trim_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
1415   __pyx_r = NULL;
1416   __pyx_L0:;
1417   __Pyx_XGIVEREF(__pyx_r);
1418   __Pyx_RefNannyFinishContext();
1419   return __pyx_r;
1420 }
1421 
1422 
1423 /* Python wrapper */
1424 static PyObject *__pyx_pw_8cutadapt_8qualtrim_3nextseq_trim_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1425 static char __pyx_doc_8cutadapt_8qualtrim_2nextseq_trim_index[] = "\n    Variant of the above quality trimming routine that works on NextSeq data.\n    With Illumina NextSeq, bases are encoded with two colors. 'No color' (a\n    dark cycle) usually means that a 'G' was sequenced, but that also occurs\n    when sequencing falls off the end of the fragment. The read then contains\n    a run of high-quality G bases in the end.\n\n    This routine works as the one above, but counts qualities belonging to 'G'\n    bases as being equal to cutoff - 1.\n    ";
1426 static PyMethodDef __pyx_mdef_8cutadapt_8qualtrim_3nextseq_trim_index = {"nextseq_trim_index", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8cutadapt_8qualtrim_3nextseq_trim_index, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8cutadapt_8qualtrim_2nextseq_trim_index};
__pyx_pw_8cutadapt_8qualtrim_3nextseq_trim_index(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1427 static PyObject *__pyx_pw_8cutadapt_8qualtrim_3nextseq_trim_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1428   PyObject *__pyx_v_sequence = 0;
1429   int __pyx_v_cutoff;
1430   int __pyx_v_base;
1431   int __pyx_lineno = 0;
1432   const char *__pyx_filename = NULL;
1433   int __pyx_clineno = 0;
1434   PyObject *__pyx_r = 0;
1435   __Pyx_RefNannyDeclarations
1436   __Pyx_RefNannySetupContext("nextseq_trim_index (wrapper)", 0);
1437   {
1438     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sequence,&__pyx_n_s_cutoff,&__pyx_n_s_base,0};
1439     PyObject* values[3] = {0,0,0};
1440     if (unlikely(__pyx_kwds)) {
1441       Py_ssize_t kw_args;
1442       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1443       switch (pos_args) {
1444         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1445         CYTHON_FALLTHROUGH;
1446         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1447         CYTHON_FALLTHROUGH;
1448         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1449         CYTHON_FALLTHROUGH;
1450         case  0: break;
1451         default: goto __pyx_L5_argtuple_error;
1452       }
1453       kw_args = PyDict_Size(__pyx_kwds);
1454       switch (pos_args) {
1455         case  0:
1456         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sequence)) != 0)) kw_args--;
1457         else goto __pyx_L5_argtuple_error;
1458         CYTHON_FALLTHROUGH;
1459         case  1:
1460         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cutoff)) != 0)) kw_args--;
1461         else {
1462           __Pyx_RaiseArgtupleInvalid("nextseq_trim_index", 0, 2, 3, 1); __PYX_ERR(0, 52, __pyx_L3_error)
1463         }
1464         CYTHON_FALLTHROUGH;
1465         case  2:
1466         if (kw_args > 0) {
1467           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base);
1468           if (value) { values[2] = value; kw_args--; }
1469         }
1470       }
1471       if (unlikely(kw_args > 0)) {
1472         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "nextseq_trim_index") < 0)) __PYX_ERR(0, 52, __pyx_L3_error)
1473       }
1474     } else {
1475       switch (PyTuple_GET_SIZE(__pyx_args)) {
1476         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1477         CYTHON_FALLTHROUGH;
1478         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1479         values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1480         break;
1481         default: goto __pyx_L5_argtuple_error;
1482       }
1483     }
1484     __pyx_v_sequence = values[0];
1485     __pyx_v_cutoff = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_cutoff == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 52, __pyx_L3_error)
1486     if (values[2]) {
1487       __pyx_v_base = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_base == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 52, __pyx_L3_error)
1488     } else {
1489       __pyx_v_base = ((int)33);
1490     }
1491   }
1492   goto __pyx_L4_argument_unpacking_done;
1493   __pyx_L5_argtuple_error:;
1494   __Pyx_RaiseArgtupleInvalid("nextseq_trim_index", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 52, __pyx_L3_error)
1495   __pyx_L3_error:;
1496   __Pyx_AddTraceback("cutadapt.qualtrim.nextseq_trim_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
1497   __Pyx_RefNannyFinishContext();
1498   return NULL;
1499   __pyx_L4_argument_unpacking_done:;
1500   __pyx_r = __pyx_pf_8cutadapt_8qualtrim_2nextseq_trim_index(__pyx_self, __pyx_v_sequence, __pyx_v_cutoff, __pyx_v_base);
1501 
1502   /* function exit code */
1503   __Pyx_RefNannyFinishContext();
1504   return __pyx_r;
1505 }
1506 
__pyx_pf_8cutadapt_8qualtrim_2nextseq_trim_index(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_sequence,int __pyx_v_cutoff,int __pyx_v_base)1507 static PyObject *__pyx_pf_8cutadapt_8qualtrim_2nextseq_trim_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sequence, int __pyx_v_cutoff, int __pyx_v_base) {
1508   PyObject *__pyx_v_bases = NULL;
1509   PyObject *__pyx_v_qualities = NULL;
1510   int __pyx_v_s;
1511   int __pyx_v_max_qual;
1512   int __pyx_v_max_i;
1513   int __pyx_v_i;
1514   int __pyx_v_q;
1515   PyObject *__pyx_r = NULL;
1516   __Pyx_RefNannyDeclarations
1517   PyObject *__pyx_t_1 = NULL;
1518   Py_ssize_t __pyx_t_2;
1519   int __pyx_t_3;
1520   long __pyx_t_4;
1521   int __pyx_t_5;
1522   int __pyx_lineno = 0;
1523   const char *__pyx_filename = NULL;
1524   int __pyx_clineno = 0;
1525   __Pyx_RefNannySetupContext("nextseq_trim_index", 0);
1526 
1527   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sequence, __pyx_n_s_sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
1528   __Pyx_GOTREF(__pyx_t_1);
1529   __pyx_v_bases = __pyx_t_1;
1530   __pyx_t_1 = 0;
1531 
1532   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_sequence, __pyx_n_s_qualities); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error)
1533   __Pyx_GOTREF(__pyx_t_1);
1534   __pyx_v_qualities = __pyx_t_1;
1535   __pyx_t_1 = 0;
1536 
1537   __pyx_v_s = 0;
1538 
1539   __pyx_v_max_qual = 0;
1540 
1541   __pyx_t_2 = PyObject_Length(__pyx_v_qualities); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 68, __pyx_L1_error)
1542   __pyx_v_max_i = __pyx_t_2;
1543 
1544   __pyx_v_s = 0;
1545 
1546   __pyx_v_max_qual = 0;
1547 
1548   __pyx_t_2 = PyObject_Length(__pyx_v_qualities); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 73, __pyx_L1_error)
1549   __pyx_v_max_i = __pyx_t_2;
1550 
1551   for (__pyx_t_3 = __pyx_v_max_i-1; __pyx_t_3 >= 0; __pyx_t_3-=1) {
1552     __pyx_v_i = __pyx_t_3;
1553 
1554     __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_qualities, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
1555     __Pyx_GOTREF(__pyx_t_1);
1556     __pyx_t_4 = __Pyx_PyObject_Ord(__pyx_t_1); if (unlikely(__pyx_t_4 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 75, __pyx_L1_error)
1557     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1558     __pyx_v_q = (__pyx_t_4 - __pyx_v_base);
1559 
1560     __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bases, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
1561     __Pyx_GOTREF(__pyx_t_1);
1562     __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_G, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 76, __pyx_L1_error)
1563     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1564     if (__pyx_t_5) {
1565 
1566       __pyx_v_q = (__pyx_v_cutoff - 1);
1567 
1568     }
1569 
1570     __pyx_v_s = (__pyx_v_s + (__pyx_v_cutoff - __pyx_v_q));
1571 
1572     __pyx_t_5 = ((__pyx_v_s < 0) != 0);
1573     if (__pyx_t_5) {
1574 
1575       goto __pyx_L4_break;
1576 
1577     }
1578 
1579     __pyx_t_5 = ((__pyx_v_s > __pyx_v_max_qual) != 0);
1580     if (__pyx_t_5) {
1581 
1582       __pyx_v_max_qual = __pyx_v_s;
1583 
1584       __pyx_v_max_i = __pyx_v_i;
1585 
1586     }
1587   }
1588   __pyx_L4_break:;
1589 
1590   __Pyx_XDECREF(__pyx_r);
1591   __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_max_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
1592   __Pyx_GOTREF(__pyx_t_1);
1593   __pyx_r = __pyx_t_1;
1594   __pyx_t_1 = 0;
1595   goto __pyx_L0;
1596 
1597 
1598   /* function exit code */
1599   __pyx_L1_error:;
1600   __Pyx_XDECREF(__pyx_t_1);
1601   __Pyx_AddTraceback("cutadapt.qualtrim.nextseq_trim_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
1602   __pyx_r = NULL;
1603   __pyx_L0:;
1604   __Pyx_XDECREF(__pyx_v_bases);
1605   __Pyx_XDECREF(__pyx_v_qualities);
1606   __Pyx_XGIVEREF(__pyx_r);
1607   __Pyx_RefNannyFinishContext();
1608   return __pyx_r;
1609 }
1610 
1611 
1612 /* Python wrapper */
1613 static PyObject *__pyx_pw_8cutadapt_8qualtrim_5expected_errors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1614 static char __pyx_doc_8cutadapt_8qualtrim_4expected_errors[] = "\n    Return the number of expected errors (as double) from a read\342\200\231s\n    qualities.\n\n    This uses the formula in Edgar et al. (2015),\n    see Section 2.2 in <https://academic.oup.com/bioinformatics/article/31/21/3476/194979>.\n\n    qualities -- ASCII-encoded qualities (chr(qual + base))\n    ";
1615 static PyMethodDef __pyx_mdef_8cutadapt_8qualtrim_5expected_errors = {"expected_errors", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8cutadapt_8qualtrim_5expected_errors, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8cutadapt_8qualtrim_4expected_errors};
__pyx_pw_8cutadapt_8qualtrim_5expected_errors(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1616 static PyObject *__pyx_pw_8cutadapt_8qualtrim_5expected_errors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1617   PyObject *__pyx_v_qualities = 0;
1618   int __pyx_v_base;
1619   int __pyx_lineno = 0;
1620   const char *__pyx_filename = NULL;
1621   int __pyx_clineno = 0;
1622   PyObject *__pyx_r = 0;
1623   __Pyx_RefNannyDeclarations
1624   __Pyx_RefNannySetupContext("expected_errors (wrapper)", 0);
1625   {
1626     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_qualities,&__pyx_n_s_base,0};
1627     PyObject* values[2] = {0,0};
1628     if (unlikely(__pyx_kwds)) {
1629       Py_ssize_t kw_args;
1630       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1631       switch (pos_args) {
1632         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1633         CYTHON_FALLTHROUGH;
1634         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1635         CYTHON_FALLTHROUGH;
1636         case  0: break;
1637         default: goto __pyx_L5_argtuple_error;
1638       }
1639       kw_args = PyDict_Size(__pyx_kwds);
1640       switch (pos_args) {
1641         case  0:
1642         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_qualities)) != 0)) kw_args--;
1643         else goto __pyx_L5_argtuple_error;
1644         CYTHON_FALLTHROUGH;
1645         case  1:
1646         if (kw_args > 0) {
1647           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base);
1648           if (value) { values[1] = value; kw_args--; }
1649         }
1650       }
1651       if (unlikely(kw_args > 0)) {
1652         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "expected_errors") < 0)) __PYX_ERR(0, 87, __pyx_L3_error)
1653       }
1654     } else {
1655       switch (PyTuple_GET_SIZE(__pyx_args)) {
1656         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1657         CYTHON_FALLTHROUGH;
1658         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1659         break;
1660         default: goto __pyx_L5_argtuple_error;
1661       }
1662     }
1663     __pyx_v_qualities = ((PyObject*)values[0]);
1664     if (values[1]) {
1665       __pyx_v_base = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_base == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L3_error)
1666     } else {
1667       __pyx_v_base = ((int)33);
1668     }
1669   }
1670   goto __pyx_L4_argument_unpacking_done;
1671   __pyx_L5_argtuple_error:;
1672   __Pyx_RaiseArgtupleInvalid("expected_errors", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 87, __pyx_L3_error)
1673   __pyx_L3_error:;
1674   __Pyx_AddTraceback("cutadapt.qualtrim.expected_errors", __pyx_clineno, __pyx_lineno, __pyx_filename);
1675   __Pyx_RefNannyFinishContext();
1676   return NULL;
1677   __pyx_L4_argument_unpacking_done:;
1678   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_qualities), (&PyUnicode_Type), 1, "qualities", 1))) __PYX_ERR(0, 87, __pyx_L1_error)
1679   __pyx_r = __pyx_pf_8cutadapt_8qualtrim_4expected_errors(__pyx_self, __pyx_v_qualities, __pyx_v_base);
1680 
1681   /* function exit code */
1682   goto __pyx_L0;
1683   __pyx_L1_error:;
1684   __pyx_r = NULL;
1685   __pyx_L0:;
1686   __Pyx_RefNannyFinishContext();
1687   return __pyx_r;
1688 }
1689 
__pyx_pf_8cutadapt_8qualtrim_4expected_errors(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_qualities,int __pyx_v_base)1690 static PyObject *__pyx_pf_8cutadapt_8qualtrim_4expected_errors(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_base) {
1691   int __pyx_v_i;
1692   int __pyx_v_q;
1693   PyObject *__pyx_v_quals = 0;
1694   char *__pyx_v_cq;
1695   double __pyx_v_e;
1696   PyObject *__pyx_r = NULL;
1697   __Pyx_RefNannyDeclarations
1698   PyObject *__pyx_t_1 = NULL;
1699   char *__pyx_t_2;
1700   Py_ssize_t __pyx_t_3;
1701   Py_ssize_t __pyx_t_4;
1702   int __pyx_t_5;
1703   int __pyx_lineno = 0;
1704   const char *__pyx_filename = NULL;
1705   int __pyx_clineno = 0;
1706   __Pyx_RefNannySetupContext("expected_errors", 0);
1707 
1708   if (unlikely(__pyx_v_qualities == Py_None)) {
1709     PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
1710     __PYX_ERR(0, 99, __pyx_L1_error)
1711   }
1712   __pyx_t_1 = PyUnicode_AsEncodedString(__pyx_v_qualities, NULL, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
1713   __Pyx_GOTREF(__pyx_t_1);
1714   __pyx_v_quals = ((PyObject*)__pyx_t_1);
1715   __pyx_t_1 = 0;
1716 
1717   if (unlikely(__pyx_v_quals == Py_None)) {
1718     PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
1719     __PYX_ERR(0, 100, __pyx_L1_error)
1720   }
1721   __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_quals); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L1_error)
1722   __pyx_v_cq = __pyx_t_2;
1723 
1724   __pyx_v_e = 0.0;
1725 
1726   if (unlikely(__pyx_v_qualities == Py_None)) {
1727     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
1728     __PYX_ERR(0, 103, __pyx_L1_error)
1729   }
1730   __pyx_t_3 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_qualities); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 103, __pyx_L1_error)
1731   __pyx_t_4 = __pyx_t_3;
1732   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
1733     __pyx_v_i = __pyx_t_5;
1734 
1735     __pyx_v_q = ((__pyx_v_cq[__pyx_v_i]) - __pyx_v_base);
1736 
1737     __pyx_v_e = (__pyx_v_e + pow(10.0, (((double)(-__pyx_v_q)) / 10.0)));
1738   }
1739 
1740   __Pyx_XDECREF(__pyx_r);
1741   __pyx_t_1 = PyFloat_FromDouble(__pyx_v_e); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
1742   __Pyx_GOTREF(__pyx_t_1);
1743   __pyx_r = __pyx_t_1;
1744   __pyx_t_1 = 0;
1745   goto __pyx_L0;
1746 
1747 
1748   /* function exit code */
1749   __pyx_L1_error:;
1750   __Pyx_XDECREF(__pyx_t_1);
1751   __Pyx_AddTraceback("cutadapt.qualtrim.expected_errors", __pyx_clineno, __pyx_lineno, __pyx_filename);
1752   __pyx_r = NULL;
1753   __pyx_L0:;
1754   __Pyx_XDECREF(__pyx_v_quals);
1755   __Pyx_XGIVEREF(__pyx_r);
1756   __Pyx_RefNannyFinishContext();
1757   return __pyx_r;
1758 }
1759 
1760 static PyMethodDef __pyx_methods[] = {
1761   {0, 0, 0, 0}
1762 };
1763 
1764 #if PY_MAJOR_VERSION >= 3
1765 #if CYTHON_PEP489_MULTI_PHASE_INIT
1766 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
1767 static int __pyx_pymod_exec_qualtrim(PyObject* module); /*proto*/
1768 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
1769   {Py_mod_create, (void*)__pyx_pymod_create},
1770   {Py_mod_exec, (void*)__pyx_pymod_exec_qualtrim},
1771   {0, NULL}
1772 };
1773 #endif
1774 
1775 static struct PyModuleDef __pyx_moduledef = {
1776     PyModuleDef_HEAD_INIT,
1777     "qualtrim",
1778     __pyx_k_Quality_trimming, /* m_doc */
1779   #if CYTHON_PEP489_MULTI_PHASE_INIT
1780     0, /* m_size */
1781   #else
1782     -1, /* m_size */
1783   #endif
1784     __pyx_methods /* m_methods */,
1785   #if CYTHON_PEP489_MULTI_PHASE_INIT
1786     __pyx_moduledef_slots, /* m_slots */
1787   #else
1788     NULL, /* m_reload */
1789   #endif
1790     NULL, /* m_traverse */
1791     NULL, /* m_clear */
1792     NULL /* m_free */
1793 };
1794 #endif
1795 #ifndef CYTHON_SMALL_CODE
1796 #if defined(__clang__)
1797     #define CYTHON_SMALL_CODE
1798 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1799     #define CYTHON_SMALL_CODE __attribute__((cold))
1800 #else
1801     #define CYTHON_SMALL_CODE
1802 #endif
1803 #endif
1804 
1805 static __Pyx_StringTabEntry __pyx_string_tab[] = {
1806   {&__pyx_n_u_G, __pyx_k_G, sizeof(__pyx_k_G), 0, 1, 0, 1},
1807   {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
1808   {&__pyx_n_s_bases, __pyx_k_bases, sizeof(__pyx_k_bases), 0, 0, 1, 1},
1809   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
1810   {&__pyx_n_s_cq, __pyx_k_cq, sizeof(__pyx_k_cq), 0, 0, 1, 1},
1811   {&__pyx_n_s_cutadapt_qualtrim, __pyx_k_cutadapt_qualtrim, sizeof(__pyx_k_cutadapt_qualtrim), 0, 0, 1, 1},
1812   {&__pyx_n_s_cutoff, __pyx_k_cutoff, sizeof(__pyx_k_cutoff), 0, 0, 1, 1},
1813   {&__pyx_n_s_cutoff_back, __pyx_k_cutoff_back, sizeof(__pyx_k_cutoff_back), 0, 0, 1, 1},
1814   {&__pyx_n_s_cutoff_front, __pyx_k_cutoff_front, sizeof(__pyx_k_cutoff_front), 0, 0, 1, 1},
1815   {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
1816   {&__pyx_n_s_expected_errors, __pyx_k_expected_errors, sizeof(__pyx_k_expected_errors), 0, 0, 1, 1},
1817   {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
1818   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
1819   {&__pyx_n_s_max_i, __pyx_k_max_i, sizeof(__pyx_k_max_i), 0, 0, 1, 1},
1820   {&__pyx_n_s_max_qual, __pyx_k_max_qual, sizeof(__pyx_k_max_qual), 0, 0, 1, 1},
1821   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
1822   {&__pyx_n_s_nextseq_trim_index, __pyx_k_nextseq_trim_index, sizeof(__pyx_k_nextseq_trim_index), 0, 0, 1, 1},
1823   {&__pyx_n_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 1},
1824   {&__pyx_n_s_qualities, __pyx_k_qualities, sizeof(__pyx_k_qualities), 0, 0, 1, 1},
1825   {&__pyx_n_s_quality_trim_index, __pyx_k_quality_trim_index, sizeof(__pyx_k_quality_trim_index), 0, 0, 1, 1},
1826   {&__pyx_n_s_quals, __pyx_k_quals, sizeof(__pyx_k_quals), 0, 0, 1, 1},
1827   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
1828   {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
1829   {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
1830   {&__pyx_n_s_sequence, __pyx_k_sequence, sizeof(__pyx_k_sequence), 0, 0, 1, 1},
1831   {&__pyx_kp_s_src_cutadapt_qualtrim_pyx, __pyx_k_src_cutadapt_qualtrim_pyx, sizeof(__pyx_k_src_cutadapt_qualtrim_pyx), 0, 0, 1, 0},
1832   {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
1833   {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
1834   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
1835   {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 0, 0, 1, 1},
1836   {0, 0, 0, 0, 0, 0, 0}
1837 };
__Pyx_InitCachedBuiltins(void)1838 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
1839   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 29, __pyx_L1_error)
1840   __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 40, __pyx_L1_error)
1841   #if PY_MAJOR_VERSION >= 3
1842   __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) __PYX_ERR(0, 40, __pyx_L1_error)
1843   #else
1844   __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) __PYX_ERR(0, 40, __pyx_L1_error)
1845   #endif
1846   return 0;
1847   __pyx_L1_error:;
1848   return -1;
1849 }
1850 
__Pyx_InitCachedConstants(void)1851 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
1852   __Pyx_RefNannyDeclarations
1853   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
1854 
1855   __pyx_tuple_ = PyTuple_Pack(9, __pyx_n_s_qualities, __pyx_n_s_cutoff_front, __pyx_n_s_cutoff_back, __pyx_n_s_base, __pyx_n_s_s, __pyx_n_s_max_qual, __pyx_n_s_stop, __pyx_n_s_start, __pyx_n_s_i); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 6, __pyx_L1_error)
1856   __Pyx_GOTREF(__pyx_tuple_);
1857   __Pyx_GIVEREF(__pyx_tuple_);
1858   __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cutadapt_qualtrim_pyx, __pyx_n_s_quality_trim_index, 6, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 6, __pyx_L1_error)
1859 
1860   __pyx_tuple__3 = PyTuple_Pack(10, __pyx_n_s_sequence, __pyx_n_s_cutoff, __pyx_n_s_base, __pyx_n_s_bases, __pyx_n_s_qualities, __pyx_n_s_s, __pyx_n_s_max_qual, __pyx_n_s_max_i, __pyx_n_s_i, __pyx_n_s_q); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 52, __pyx_L1_error)
1861   __Pyx_GOTREF(__pyx_tuple__3);
1862   __Pyx_GIVEREF(__pyx_tuple__3);
1863   __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(3, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cutadapt_qualtrim_pyx, __pyx_n_s_nextseq_trim_index, 52, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 52, __pyx_L1_error)
1864 
1865   __pyx_tuple__5 = PyTuple_Pack(7, __pyx_n_s_qualities, __pyx_n_s_base, __pyx_n_s_i, __pyx_n_s_q, __pyx_n_s_quals, __pyx_n_s_cq, __pyx_n_s_e); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 87, __pyx_L1_error)
1866   __Pyx_GOTREF(__pyx_tuple__5);
1867   __Pyx_GIVEREF(__pyx_tuple__5);
1868   __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_cutadapt_qualtrim_pyx, __pyx_n_s_expected_errors, 87, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 87, __pyx_L1_error)
1869   __Pyx_RefNannyFinishContext();
1870   return 0;
1871   __pyx_L1_error:;
1872   __Pyx_RefNannyFinishContext();
1873   return -1;
1874 }
1875 
__Pyx_InitGlobals(void)1876 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
1877   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
1878   return 0;
1879   __pyx_L1_error:;
1880   return -1;
1881 }
1882 
1883 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
1884 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
1885 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
1886 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
1887 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
1888 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
1889 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
1890 
__Pyx_modinit_global_init_code(void)1891 static int __Pyx_modinit_global_init_code(void) {
1892   __Pyx_RefNannyDeclarations
1893   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
1894   /*--- Global init code ---*/
1895   __Pyx_RefNannyFinishContext();
1896   return 0;
1897 }
1898 
__Pyx_modinit_variable_export_code(void)1899 static int __Pyx_modinit_variable_export_code(void) {
1900   __Pyx_RefNannyDeclarations
1901   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
1902   /*--- Variable export code ---*/
1903   __Pyx_RefNannyFinishContext();
1904   return 0;
1905 }
1906 
__Pyx_modinit_function_export_code(void)1907 static int __Pyx_modinit_function_export_code(void) {
1908   __Pyx_RefNannyDeclarations
1909   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
1910   /*--- Function export code ---*/
1911   __Pyx_RefNannyFinishContext();
1912   return 0;
1913 }
1914 
__Pyx_modinit_type_init_code(void)1915 static int __Pyx_modinit_type_init_code(void) {
1916   __Pyx_RefNannyDeclarations
1917   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
1918   /*--- Type init code ---*/
1919   __Pyx_RefNannyFinishContext();
1920   return 0;
1921 }
1922 
__Pyx_modinit_type_import_code(void)1923 static int __Pyx_modinit_type_import_code(void) {
1924   __Pyx_RefNannyDeclarations
1925   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
1926   /*--- Type import code ---*/
1927   __Pyx_RefNannyFinishContext();
1928   return 0;
1929 }
1930 
__Pyx_modinit_variable_import_code(void)1931 static int __Pyx_modinit_variable_import_code(void) {
1932   __Pyx_RefNannyDeclarations
1933   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
1934   /*--- Variable import code ---*/
1935   __Pyx_RefNannyFinishContext();
1936   return 0;
1937 }
1938 
__Pyx_modinit_function_import_code(void)1939 static int __Pyx_modinit_function_import_code(void) {
1940   __Pyx_RefNannyDeclarations
1941   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
1942   /*--- Function import code ---*/
1943   __Pyx_RefNannyFinishContext();
1944   return 0;
1945 }
1946 
1947 
1948 #ifndef CYTHON_NO_PYINIT_EXPORT
1949 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
1950 #elif PY_MAJOR_VERSION < 3
1951 #ifdef __cplusplus
1952 #define __Pyx_PyMODINIT_FUNC extern "C" void
1953 #else
1954 #define __Pyx_PyMODINIT_FUNC void
1955 #endif
1956 #else
1957 #ifdef __cplusplus
1958 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
1959 #else
1960 #define __Pyx_PyMODINIT_FUNC PyObject *
1961 #endif
1962 #endif
1963 
1964 
1965 #if PY_MAJOR_VERSION < 3
1966 __Pyx_PyMODINIT_FUNC initqualtrim(void) CYTHON_SMALL_CODE; /*proto*/
initqualtrim(void)1967 __Pyx_PyMODINIT_FUNC initqualtrim(void)
1968 #else
1969 __Pyx_PyMODINIT_FUNC PyInit_qualtrim(void) CYTHON_SMALL_CODE; /*proto*/
1970 __Pyx_PyMODINIT_FUNC PyInit_qualtrim(void)
1971 #if CYTHON_PEP489_MULTI_PHASE_INIT
1972 {
1973   return PyModuleDef_Init(&__pyx_moduledef);
1974 }
1975 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
1976     #if PY_VERSION_HEX >= 0x030700A1
1977     static PY_INT64_T main_interpreter_id = -1;
1978     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
1979     if (main_interpreter_id == -1) {
1980         main_interpreter_id = current_id;
1981         return (unlikely(current_id == -1)) ? -1 : 0;
1982     } else if (unlikely(main_interpreter_id != current_id))
1983     #else
1984     static PyInterpreterState *main_interpreter = NULL;
1985     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
1986     if (!main_interpreter) {
1987         main_interpreter = current_interpreter;
1988     } else if (unlikely(main_interpreter != current_interpreter))
1989     #endif
1990     {
1991         PyErr_SetString(
1992             PyExc_ImportError,
1993             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
1994         return -1;
1995     }
1996     return 0;
1997 }
1998 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
1999     PyObject *value = PyObject_GetAttrString(spec, from_name);
2000     int result = 0;
2001     if (likely(value)) {
2002         if (allow_none || value != Py_None) {
2003             result = PyDict_SetItemString(moddict, to_name, value);
2004         }
2005         Py_DECREF(value);
2006     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
2007         PyErr_Clear();
2008     } else {
2009         result = -1;
2010     }
2011     return result;
2012 }
2013 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
2014     PyObject *module = NULL, *moddict, *modname;
2015     if (__Pyx_check_single_interpreter())
2016         return NULL;
2017     if (__pyx_m)
2018         return __Pyx_NewRef(__pyx_m);
2019     modname = PyObject_GetAttrString(spec, "name");
2020     if (unlikely(!modname)) goto bad;
2021     module = PyModule_NewObject(modname);
2022     Py_DECREF(modname);
2023     if (unlikely(!module)) goto bad;
2024     moddict = PyModule_GetDict(module);
2025     if (unlikely(!moddict)) goto bad;
2026     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
2027     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
2028     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
2029     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
2030     return module;
2031 bad:
2032     Py_XDECREF(module);
2033     return NULL;
2034 }
2035 
2036 
2037 static CYTHON_SMALL_CODE int __pyx_pymod_exec_qualtrim(PyObject *__pyx_pyinit_module)
2038 #endif
2039 #endif
2040 {
2041   PyObject *__pyx_t_1 = NULL;
2042   int __pyx_lineno = 0;
2043   const char *__pyx_filename = NULL;
2044   int __pyx_clineno = 0;
2045   __Pyx_RefNannyDeclarations
2046   #if CYTHON_PEP489_MULTI_PHASE_INIT
2047   if (__pyx_m) {
2048     if (__pyx_m == __pyx_pyinit_module) return 0;
2049     PyErr_SetString(PyExc_RuntimeError, "Module 'qualtrim' has already been imported. Re-initialisation is not supported.");
2050     return -1;
2051   }
2052   #elif PY_MAJOR_VERSION >= 3
2053   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
2054   #endif
2055   #if CYTHON_REFNANNY
2056 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2057 if (!__Pyx_RefNanny) {
2058   PyErr_Clear();
2059   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2060   if (!__Pyx_RefNanny)
2061       Py_FatalError("failed to import 'refnanny' module");
2062 }
2063 #endif
2064   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_qualtrim(void)", 0);
2065   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2066   #ifdef __Pxy_PyFrame_Initialize_Offsets
2067   __Pxy_PyFrame_Initialize_Offsets();
2068   #endif
2069   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
2070   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
2071   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
2072   #ifdef __Pyx_CyFunction_USED
2073   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2074   #endif
2075   #ifdef __Pyx_FusedFunction_USED
2076   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2077   #endif
2078   #ifdef __Pyx_Coroutine_USED
2079   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2080   #endif
2081   #ifdef __Pyx_Generator_USED
2082   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2083   #endif
2084   #ifdef __Pyx_AsyncGen_USED
2085   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2086   #endif
2087   #ifdef __Pyx_StopAsyncIteration_USED
2088   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2089   #endif
2090   /*--- Library function declarations ---*/
2091   /*--- Threads initialization code ---*/
2092   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
2093   #ifdef WITH_THREAD /* Python build with threading support? */
2094   PyEval_InitThreads();
2095   #endif
2096   #endif
2097   /*--- Module creation code ---*/
2098   #if CYTHON_PEP489_MULTI_PHASE_INIT
2099   __pyx_m = __pyx_pyinit_module;
2100   Py_INCREF(__pyx_m);
2101   #else
2102   #if PY_MAJOR_VERSION < 3
2103   __pyx_m = Py_InitModule4("qualtrim", __pyx_methods, __pyx_k_Quality_trimming, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
2104   #else
2105   __pyx_m = PyModule_Create(&__pyx_moduledef);
2106   #endif
2107   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
2108   #endif
2109   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
2110   Py_INCREF(__pyx_d);
2111   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
2112   Py_INCREF(__pyx_b);
2113   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
2114   Py_INCREF(__pyx_cython_runtime);
2115   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
2116   /*--- Initialize various global constants etc. ---*/
2117   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2118   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
2119   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2120   #endif
2121   if (__pyx_module_is_main_cutadapt__qualtrim) {
2122     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2123   }
2124   #if PY_MAJOR_VERSION >= 3
2125   {
2126     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
2127     if (!PyDict_GetItemString(modules, "cutadapt.qualtrim")) {
2128       if (unlikely(PyDict_SetItemString(modules, "cutadapt.qualtrim", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2129     }
2130   }
2131   #endif
2132   /*--- Builtin init code ---*/
2133   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2134   /*--- Constants init code ---*/
2135   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2136   /*--- Global type/function init code ---*/
2137   (void)__Pyx_modinit_global_init_code();
2138   (void)__Pyx_modinit_variable_export_code();
2139   (void)__Pyx_modinit_function_export_code();
2140   (void)__Pyx_modinit_type_init_code();
2141   (void)__Pyx_modinit_type_import_code();
2142   (void)__Pyx_modinit_variable_import_code();
2143   (void)__Pyx_modinit_function_import_code();
2144   /*--- Execution code ---*/
2145   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
2146   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2147   #endif
2148 
2149   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_8qualtrim_1quality_trim_index, NULL, __pyx_n_s_cutadapt_qualtrim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
2150   __Pyx_GOTREF(__pyx_t_1);
2151   if (PyDict_SetItem(__pyx_d, __pyx_n_s_quality_trim_index, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
2152   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2153 
2154   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_8qualtrim_3nextseq_trim_index, NULL, __pyx_n_s_cutadapt_qualtrim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
2155   __Pyx_GOTREF(__pyx_t_1);
2156   if (PyDict_SetItem(__pyx_d, __pyx_n_s_nextseq_trim_index, __pyx_t_1) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
2157   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2158 
2159   __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_8qualtrim_5expected_errors, NULL, __pyx_n_s_cutadapt_qualtrim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
2160   __Pyx_GOTREF(__pyx_t_1);
2161   if (PyDict_SetItem(__pyx_d, __pyx_n_s_expected_errors, __pyx_t_1) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
2162   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2163 
2164   __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
2165   __Pyx_GOTREF(__pyx_t_1);
2166   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2167   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2168 
2169   /*--- Wrapped vars code ---*/
2170 
2171   goto __pyx_L0;
2172   __pyx_L1_error:;
2173   __Pyx_XDECREF(__pyx_t_1);
2174   if (__pyx_m) {
2175     if (__pyx_d) {
2176       __Pyx_AddTraceback("init cutadapt.qualtrim", __pyx_clineno, __pyx_lineno, __pyx_filename);
2177     }
2178     Py_CLEAR(__pyx_m);
2179   } else if (!PyErr_Occurred()) {
2180     PyErr_SetString(PyExc_ImportError, "init cutadapt.qualtrim");
2181   }
2182   __pyx_L0:;
2183   __Pyx_RefNannyFinishContext();
2184   #if CYTHON_PEP489_MULTI_PHASE_INIT
2185   return (__pyx_m != NULL) ? 0 : -1;
2186   #elif PY_MAJOR_VERSION >= 3
2187   return __pyx_m;
2188   #else
2189   return;
2190   #endif
2191 }
2192 
2193 /* --- Runtime support code --- */
2194 /* Refnanny */
2195 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)2196 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2197     PyObject *m = NULL, *p = NULL;
2198     void *r = NULL;
2199     m = PyImport_ImportModule(modname);
2200     if (!m) goto end;
2201     p = PyObject_GetAttrString(m, "RefNannyAPI");
2202     if (!p) goto end;
2203     r = PyLong_AsVoidPtr(p);
2204 end:
2205     Py_XDECREF(p);
2206     Py_XDECREF(m);
2207     return (__Pyx_RefNannyAPIStruct *)r;
2208 }
2209 #endif
2210 
2211 /* PyObjectGetAttrStr */
2212 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)2213 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
2214     PyTypeObject* tp = Py_TYPE(obj);
2215     if (likely(tp->tp_getattro))
2216         return tp->tp_getattro(obj, attr_name);
2217 #if PY_MAJOR_VERSION < 3
2218     if (likely(tp->tp_getattr))
2219         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
2220 #endif
2221     return PyObject_GetAttr(obj, attr_name);
2222 }
2223 #endif
2224 
2225 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)2226 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2227     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2228     if (unlikely(!result)) {
2229         PyErr_Format(PyExc_NameError,
2230 #if PY_MAJOR_VERSION >= 3
2231             "name '%U' is not defined", name);
2232 #else
2233             "name '%.200s' is not defined", PyString_AS_STRING(name));
2234 #endif
2235     }
2236     return result;
2237 }
2238 
2239 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)2240 static void __Pyx_RaiseArgtupleInvalid(
2241     const char* func_name,
2242     int exact,
2243     Py_ssize_t num_min,
2244     Py_ssize_t num_max,
2245     Py_ssize_t num_found)
2246 {
2247     Py_ssize_t num_expected;
2248     const char *more_or_less;
2249     if (num_found < num_min) {
2250         num_expected = num_min;
2251         more_or_less = "at least";
2252     } else {
2253         num_expected = num_max;
2254         more_or_less = "at most";
2255     }
2256     if (exact) {
2257         more_or_less = "exactly";
2258     }
2259     PyErr_Format(PyExc_TypeError,
2260                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2261                  func_name, more_or_less, num_expected,
2262                  (num_expected == 1) ? "" : "s", num_found);
2263 }
2264 
2265 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)2266 static void __Pyx_RaiseDoubleKeywordsError(
2267     const char* func_name,
2268     PyObject* kw_name)
2269 {
2270     PyErr_Format(PyExc_TypeError,
2271         #if PY_MAJOR_VERSION >= 3
2272         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
2273         #else
2274         "%s() got multiple values for keyword argument '%s'", func_name,
2275         PyString_AsString(kw_name));
2276         #endif
2277 }
2278 
2279 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)2280 static int __Pyx_ParseOptionalKeywords(
2281     PyObject *kwds,
2282     PyObject **argnames[],
2283     PyObject *kwds2,
2284     PyObject *values[],
2285     Py_ssize_t num_pos_args,
2286     const char* function_name)
2287 {
2288     PyObject *key = 0, *value = 0;
2289     Py_ssize_t pos = 0;
2290     PyObject*** name;
2291     PyObject*** first_kw_arg = argnames + num_pos_args;
2292     while (PyDict_Next(kwds, &pos, &key, &value)) {
2293         name = first_kw_arg;
2294         while (*name && (**name != key)) name++;
2295         if (*name) {
2296             values[name-argnames] = value;
2297             continue;
2298         }
2299         name = first_kw_arg;
2300         #if PY_MAJOR_VERSION < 3
2301         if (likely(PyString_Check(key))) {
2302             while (*name) {
2303                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
2304                         && _PyString_Eq(**name, key)) {
2305                     values[name-argnames] = value;
2306                     break;
2307                 }
2308                 name++;
2309             }
2310             if (*name) continue;
2311             else {
2312                 PyObject*** argname = argnames;
2313                 while (argname != first_kw_arg) {
2314                     if ((**argname == key) || (
2315                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
2316                              && _PyString_Eq(**argname, key))) {
2317                         goto arg_passed_twice;
2318                     }
2319                     argname++;
2320                 }
2321             }
2322         } else
2323         #endif
2324         if (likely(PyUnicode_Check(key))) {
2325             while (*name) {
2326                 int cmp = (**name == key) ? 0 :
2327                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2328                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2329                 #endif
2330                     PyUnicode_Compare(**name, key);
2331                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2332                 if (cmp == 0) {
2333                     values[name-argnames] = value;
2334                     break;
2335                 }
2336                 name++;
2337             }
2338             if (*name) continue;
2339             else {
2340                 PyObject*** argname = argnames;
2341                 while (argname != first_kw_arg) {
2342                     int cmp = (**argname == key) ? 0 :
2343                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2344                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2345                     #endif
2346                         PyUnicode_Compare(**argname, key);
2347                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2348                     if (cmp == 0) goto arg_passed_twice;
2349                     argname++;
2350                 }
2351             }
2352         } else
2353             goto invalid_keyword_type;
2354         if (kwds2) {
2355             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
2356         } else {
2357             goto invalid_keyword;
2358         }
2359     }
2360     return 0;
2361 arg_passed_twice:
2362     __Pyx_RaiseDoubleKeywordsError(function_name, key);
2363     goto bad;
2364 invalid_keyword_type:
2365     PyErr_Format(PyExc_TypeError,
2366         "%.200s() keywords must be strings", function_name);
2367     goto bad;
2368 invalid_keyword:
2369     PyErr_Format(PyExc_TypeError,
2370     #if PY_MAJOR_VERSION < 3
2371         "%.200s() got an unexpected keyword argument '%.200s'",
2372         function_name, PyString_AsString(key));
2373     #else
2374         "%s() got an unexpected keyword argument '%U'",
2375         function_name, key);
2376     #endif
2377 bad:
2378     return -1;
2379 }
2380 
2381 /* ArgTypeTest */
__Pyx__ArgTypeTest(PyObject * obj,PyTypeObject * type,const char * name,int exact)2382 static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
2383 {
2384     if (unlikely(!type)) {
2385         PyErr_SetString(PyExc_SystemError, "Missing type object");
2386         return 0;
2387     }
2388     else if (exact) {
2389         #if PY_MAJOR_VERSION == 2
2390         if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
2391         #endif
2392     }
2393     else {
2394         if (likely(__Pyx_TypeCheck(obj, type))) return 1;
2395     }
2396     PyErr_Format(PyExc_TypeError,
2397         "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
2398         name, type->tp_name, Py_TYPE(obj)->tp_name);
2399     return 0;
2400 }
2401 
2402 /* GetItemIntUnicode */
__Pyx_GetItemInt_Unicode_Fast(PyObject * ustring,Py_ssize_t i,int wraparound,int boundscheck)2403 static CYTHON_INLINE Py_UCS4 __Pyx_GetItemInt_Unicode_Fast(PyObject* ustring, Py_ssize_t i,
2404                                                            int wraparound, int boundscheck) {
2405     Py_ssize_t length;
2406     if (unlikely(__Pyx_PyUnicode_READY(ustring) < 0)) return (Py_UCS4)-1;
2407     if (wraparound | boundscheck) {
2408         length = __Pyx_PyUnicode_GET_LENGTH(ustring);
2409         if (wraparound & unlikely(i < 0)) i += length;
2410         if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
2411             return __Pyx_PyUnicode_READ_CHAR(ustring, i);
2412         } else {
2413             PyErr_SetString(PyExc_IndexError, "string index out of range");
2414             return (Py_UCS4)-1;
2415         }
2416     } else {
2417         return __Pyx_PyUnicode_READ_CHAR(ustring, i);
2418     }
2419 }
2420 
2421 /* UnicodeAsUCS4 */
__Pyx_PyUnicode_AsPy_UCS4(PyObject * x)2422 static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) {
2423    Py_ssize_t length;
2424    #if CYTHON_PEP393_ENABLED
2425    length = PyUnicode_GET_LENGTH(x);
2426    if (likely(length == 1)) {
2427        return PyUnicode_READ_CHAR(x, 0);
2428    }
2429    #else
2430    length = PyUnicode_GET_SIZE(x);
2431    if (likely(length == 1)) {
2432        return PyUnicode_AS_UNICODE(x)[0];
2433    }
2434    #if Py_UNICODE_SIZE == 2
2435    else if (PyUnicode_GET_SIZE(x) == 2) {
2436        Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0];
2437        if (high_val >= 0xD800 && high_val <= 0xDBFF) {
2438            Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1];
2439            if (low_val >= 0xDC00 && low_val <= 0xDFFF) {
2440                return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1)));
2441            }
2442        }
2443    }
2444    #endif
2445    #endif
2446    PyErr_Format(PyExc_ValueError,
2447                 "only single character unicode strings can be converted to Py_UCS4, "
2448                 "got length %" CYTHON_FORMAT_SSIZE_T "d", length);
2449    return (Py_UCS4)-1;
2450 }
2451 
2452 /* object_ord */
__Pyx__PyObject_Ord(PyObject * c)2453 static long __Pyx__PyObject_Ord(PyObject* c) {
2454     Py_ssize_t size;
2455     if (PyBytes_Check(c)) {
2456         size = PyBytes_GET_SIZE(c);
2457         if (likely(size == 1)) {
2458             return (unsigned char) PyBytes_AS_STRING(c)[0];
2459         }
2460 #if PY_MAJOR_VERSION < 3
2461     } else if (PyUnicode_Check(c)) {
2462         return (long)__Pyx_PyUnicode_AsPy_UCS4(c);
2463 #endif
2464 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
2465     } else if (PyByteArray_Check(c)) {
2466         size = PyByteArray_GET_SIZE(c);
2467         if (likely(size == 1)) {
2468             return (unsigned char) PyByteArray_AS_STRING(c)[0];
2469         }
2470 #endif
2471     } else {
2472         PyErr_Format(PyExc_TypeError,
2473             "ord() expected string of length 1, but %.200s found", c->ob_type->tp_name);
2474         return (long)(Py_UCS4)-1;
2475     }
2476     PyErr_Format(PyExc_TypeError,
2477         "ord() expected a character, but string of length %zd found", size);
2478     return (long)(Py_UCS4)-1;
2479 }
2480 
2481 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)2482 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
2483     PyObject *r;
2484     if (!j) return NULL;
2485     r = PyObject_GetItem(o, j);
2486     Py_DECREF(j);
2487     return r;
2488 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)2489 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
2490                                                               CYTHON_NCP_UNUSED int wraparound,
2491                                                               CYTHON_NCP_UNUSED int boundscheck) {
2492 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2493     Py_ssize_t wrapped_i = i;
2494     if (wraparound & unlikely(i < 0)) {
2495         wrapped_i += PyList_GET_SIZE(o);
2496     }
2497     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
2498         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
2499         Py_INCREF(r);
2500         return r;
2501     }
2502     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2503 #else
2504     return PySequence_GetItem(o, i);
2505 #endif
2506 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)2507 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
2508                                                               CYTHON_NCP_UNUSED int wraparound,
2509                                                               CYTHON_NCP_UNUSED int boundscheck) {
2510 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2511     Py_ssize_t wrapped_i = i;
2512     if (wraparound & unlikely(i < 0)) {
2513         wrapped_i += PyTuple_GET_SIZE(o);
2514     }
2515     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
2516         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
2517         Py_INCREF(r);
2518         return r;
2519     }
2520     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2521 #else
2522     return PySequence_GetItem(o, i);
2523 #endif
2524 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)2525 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
2526                                                      CYTHON_NCP_UNUSED int wraparound,
2527                                                      CYTHON_NCP_UNUSED int boundscheck) {
2528 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
2529     if (is_list || PyList_CheckExact(o)) {
2530         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
2531         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
2532             PyObject *r = PyList_GET_ITEM(o, n);
2533             Py_INCREF(r);
2534             return r;
2535         }
2536     }
2537     else if (PyTuple_CheckExact(o)) {
2538         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
2539         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
2540             PyObject *r = PyTuple_GET_ITEM(o, n);
2541             Py_INCREF(r);
2542             return r;
2543         }
2544     } else {
2545         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
2546         if (likely(m && m->sq_item)) {
2547             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
2548                 Py_ssize_t l = m->sq_length(o);
2549                 if (likely(l >= 0)) {
2550                     i += l;
2551                 } else {
2552                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
2553                         return NULL;
2554                     PyErr_Clear();
2555                 }
2556             }
2557             return m->sq_item(o, i);
2558         }
2559     }
2560 #else
2561     if (is_list || PySequence_Check(o)) {
2562         return PySequence_GetItem(o, i);
2563     }
2564 #endif
2565     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2566 }
2567 
2568 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)2569 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
2570 #if CYTHON_COMPILING_IN_PYPY
2571     return PyObject_RichCompareBool(s1, s2, equals);
2572 #else
2573     if (s1 == s2) {
2574         return (equals == Py_EQ);
2575     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
2576         const char *ps1, *ps2;
2577         Py_ssize_t length = PyBytes_GET_SIZE(s1);
2578         if (length != PyBytes_GET_SIZE(s2))
2579             return (equals == Py_NE);
2580         ps1 = PyBytes_AS_STRING(s1);
2581         ps2 = PyBytes_AS_STRING(s2);
2582         if (ps1[0] != ps2[0]) {
2583             return (equals == Py_NE);
2584         } else if (length == 1) {
2585             return (equals == Py_EQ);
2586         } else {
2587             int result;
2588 #if CYTHON_USE_UNICODE_INTERNALS
2589             Py_hash_t hash1, hash2;
2590             hash1 = ((PyBytesObject*)s1)->ob_shash;
2591             hash2 = ((PyBytesObject*)s2)->ob_shash;
2592             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
2593                 return (equals == Py_NE);
2594             }
2595 #endif
2596             result = memcmp(ps1, ps2, (size_t)length);
2597             return (equals == Py_EQ) ? (result == 0) : (result != 0);
2598         }
2599     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
2600         return (equals == Py_NE);
2601     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
2602         return (equals == Py_NE);
2603     } else {
2604         int result;
2605         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
2606         if (!py_result)
2607             return -1;
2608         result = __Pyx_PyObject_IsTrue(py_result);
2609         Py_DECREF(py_result);
2610         return result;
2611     }
2612 #endif
2613 }
2614 
2615 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)2616 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
2617 #if CYTHON_COMPILING_IN_PYPY
2618     return PyObject_RichCompareBool(s1, s2, equals);
2619 #else
2620 #if PY_MAJOR_VERSION < 3
2621     PyObject* owned_ref = NULL;
2622 #endif
2623     int s1_is_unicode, s2_is_unicode;
2624     if (s1 == s2) {
2625         goto return_eq;
2626     }
2627     s1_is_unicode = PyUnicode_CheckExact(s1);
2628     s2_is_unicode = PyUnicode_CheckExact(s2);
2629 #if PY_MAJOR_VERSION < 3
2630     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
2631         owned_ref = PyUnicode_FromObject(s2);
2632         if (unlikely(!owned_ref))
2633             return -1;
2634         s2 = owned_ref;
2635         s2_is_unicode = 1;
2636     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
2637         owned_ref = PyUnicode_FromObject(s1);
2638         if (unlikely(!owned_ref))
2639             return -1;
2640         s1 = owned_ref;
2641         s1_is_unicode = 1;
2642     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
2643         return __Pyx_PyBytes_Equals(s1, s2, equals);
2644     }
2645 #endif
2646     if (s1_is_unicode & s2_is_unicode) {
2647         Py_ssize_t length;
2648         int kind;
2649         void *data1, *data2;
2650         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
2651             return -1;
2652         length = __Pyx_PyUnicode_GET_LENGTH(s1);
2653         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
2654             goto return_ne;
2655         }
2656 #if CYTHON_USE_UNICODE_INTERNALS
2657         {
2658             Py_hash_t hash1, hash2;
2659         #if CYTHON_PEP393_ENABLED
2660             hash1 = ((PyASCIIObject*)s1)->hash;
2661             hash2 = ((PyASCIIObject*)s2)->hash;
2662         #else
2663             hash1 = ((PyUnicodeObject*)s1)->hash;
2664             hash2 = ((PyUnicodeObject*)s2)->hash;
2665         #endif
2666             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
2667                 goto return_ne;
2668             }
2669         }
2670 #endif
2671         kind = __Pyx_PyUnicode_KIND(s1);
2672         if (kind != __Pyx_PyUnicode_KIND(s2)) {
2673             goto return_ne;
2674         }
2675         data1 = __Pyx_PyUnicode_DATA(s1);
2676         data2 = __Pyx_PyUnicode_DATA(s2);
2677         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
2678             goto return_ne;
2679         } else if (length == 1) {
2680             goto return_eq;
2681         } else {
2682             int result = memcmp(data1, data2, (size_t)(length * kind));
2683             #if PY_MAJOR_VERSION < 3
2684             Py_XDECREF(owned_ref);
2685             #endif
2686             return (equals == Py_EQ) ? (result == 0) : (result != 0);
2687         }
2688     } else if ((s1 == Py_None) & s2_is_unicode) {
2689         goto return_ne;
2690     } else if ((s2 == Py_None) & s1_is_unicode) {
2691         goto return_ne;
2692     } else {
2693         int result;
2694         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
2695         #if PY_MAJOR_VERSION < 3
2696         Py_XDECREF(owned_ref);
2697         #endif
2698         if (!py_result)
2699             return -1;
2700         result = __Pyx_PyObject_IsTrue(py_result);
2701         Py_DECREF(py_result);
2702         return result;
2703     }
2704 return_eq:
2705     #if PY_MAJOR_VERSION < 3
2706     Py_XDECREF(owned_ref);
2707     #endif
2708     return (equals == Py_EQ);
2709 return_ne:
2710     #if PY_MAJOR_VERSION < 3
2711     Py_XDECREF(owned_ref);
2712     #endif
2713     return (equals == Py_NE);
2714 #endif
2715 }
2716 
2717 /* PyDictVersioning */
2718 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)2719 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
2720     PyObject *dict = Py_TYPE(obj)->tp_dict;
2721     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
2722 }
__Pyx_get_object_dict_version(PyObject * obj)2723 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
2724     PyObject **dictptr = NULL;
2725     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
2726     if (offset) {
2727 #if CYTHON_COMPILING_IN_CPYTHON
2728         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
2729 #else
2730         dictptr = _PyObject_GetDictPtr(obj);
2731 #endif
2732     }
2733     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
2734 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)2735 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
2736     PyObject *dict = Py_TYPE(obj)->tp_dict;
2737     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
2738         return 0;
2739     return obj_dict_version == __Pyx_get_object_dict_version(obj);
2740 }
2741 #endif
2742 
2743 /* PyErrFetchRestore */
2744 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)2745 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
2746     PyObject *tmp_type, *tmp_value, *tmp_tb;
2747     tmp_type = tstate->curexc_type;
2748     tmp_value = tstate->curexc_value;
2749     tmp_tb = tstate->curexc_traceback;
2750     tstate->curexc_type = type;
2751     tstate->curexc_value = value;
2752     tstate->curexc_traceback = tb;
2753     Py_XDECREF(tmp_type);
2754     Py_XDECREF(tmp_value);
2755     Py_XDECREF(tmp_tb);
2756 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)2757 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
2758     *type = tstate->curexc_type;
2759     *value = tstate->curexc_value;
2760     *tb = tstate->curexc_traceback;
2761     tstate->curexc_type = 0;
2762     tstate->curexc_value = 0;
2763     tstate->curexc_traceback = 0;
2764 }
2765 #endif
2766 
2767 /* CLineInTraceback */
2768 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)2769 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
2770     PyObject *use_cline;
2771     PyObject *ptype, *pvalue, *ptraceback;
2772 #if CYTHON_COMPILING_IN_CPYTHON
2773     PyObject **cython_runtime_dict;
2774 #endif
2775     if (unlikely(!__pyx_cython_runtime)) {
2776         return c_line;
2777     }
2778     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
2779 #if CYTHON_COMPILING_IN_CPYTHON
2780     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
2781     if (likely(cython_runtime_dict)) {
2782         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
2783             use_cline, *cython_runtime_dict,
2784             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
2785     } else
2786 #endif
2787     {
2788       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
2789       if (use_cline_obj) {
2790         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
2791         Py_DECREF(use_cline_obj);
2792       } else {
2793         PyErr_Clear();
2794         use_cline = NULL;
2795       }
2796     }
2797     if (!use_cline) {
2798         c_line = 0;
2799         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
2800     }
2801     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
2802         c_line = 0;
2803     }
2804     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
2805     return c_line;
2806 }
2807 #endif
2808 
2809 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)2810 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
2811     int start = 0, mid = 0, end = count - 1;
2812     if (end >= 0 && code_line > entries[end].code_line) {
2813         return count;
2814     }
2815     while (start < end) {
2816         mid = start + (end - start) / 2;
2817         if (code_line < entries[mid].code_line) {
2818             end = mid;
2819         } else if (code_line > entries[mid].code_line) {
2820              start = mid + 1;
2821         } else {
2822             return mid;
2823         }
2824     }
2825     if (code_line <= entries[mid].code_line) {
2826         return mid;
2827     } else {
2828         return mid + 1;
2829     }
2830 }
__pyx_find_code_object(int code_line)2831 static PyCodeObject *__pyx_find_code_object(int code_line) {
2832     PyCodeObject* code_object;
2833     int pos;
2834     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
2835         return NULL;
2836     }
2837     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2838     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
2839         return NULL;
2840     }
2841     code_object = __pyx_code_cache.entries[pos].code_object;
2842     Py_INCREF(code_object);
2843     return code_object;
2844 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)2845 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
2846     int pos, i;
2847     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
2848     if (unlikely(!code_line)) {
2849         return;
2850     }
2851     if (unlikely(!entries)) {
2852         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
2853         if (likely(entries)) {
2854             __pyx_code_cache.entries = entries;
2855             __pyx_code_cache.max_count = 64;
2856             __pyx_code_cache.count = 1;
2857             entries[0].code_line = code_line;
2858             entries[0].code_object = code_object;
2859             Py_INCREF(code_object);
2860         }
2861         return;
2862     }
2863     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2864     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
2865         PyCodeObject* tmp = entries[pos].code_object;
2866         entries[pos].code_object = code_object;
2867         Py_DECREF(tmp);
2868         return;
2869     }
2870     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
2871         int new_max = __pyx_code_cache.max_count + 64;
2872         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
2873             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
2874         if (unlikely(!entries)) {
2875             return;
2876         }
2877         __pyx_code_cache.entries = entries;
2878         __pyx_code_cache.max_count = new_max;
2879     }
2880     for (i=__pyx_code_cache.count; i>pos; i--) {
2881         entries[i] = entries[i-1];
2882     }
2883     entries[pos].code_line = code_line;
2884     entries[pos].code_object = code_object;
2885     __pyx_code_cache.count++;
2886     Py_INCREF(code_object);
2887 }
2888 
2889 /* AddTraceback */
2890 #include "compile.h"
2891 #include "frameobject.h"
2892 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)2893 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
2894             const char *funcname, int c_line,
2895             int py_line, const char *filename) {
2896     PyCodeObject *py_code = 0;
2897     PyObject *py_srcfile = 0;
2898     PyObject *py_funcname = 0;
2899     #if PY_MAJOR_VERSION < 3
2900     py_srcfile = PyString_FromString(filename);
2901     #else
2902     py_srcfile = PyUnicode_FromString(filename);
2903     #endif
2904     if (!py_srcfile) goto bad;
2905     if (c_line) {
2906         #if PY_MAJOR_VERSION < 3
2907         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2908         #else
2909         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2910         #endif
2911     }
2912     else {
2913         #if PY_MAJOR_VERSION < 3
2914         py_funcname = PyString_FromString(funcname);
2915         #else
2916         py_funcname = PyUnicode_FromString(funcname);
2917         #endif
2918     }
2919     if (!py_funcname) goto bad;
2920     py_code = __Pyx_PyCode_New(
2921         0,
2922         0,
2923         0,
2924         0,
2925         0,
2926         __pyx_empty_bytes, /*PyObject *code,*/
2927         __pyx_empty_tuple, /*PyObject *consts,*/
2928         __pyx_empty_tuple, /*PyObject *names,*/
2929         __pyx_empty_tuple, /*PyObject *varnames,*/
2930         __pyx_empty_tuple, /*PyObject *freevars,*/
2931         __pyx_empty_tuple, /*PyObject *cellvars,*/
2932         py_srcfile,   /*PyObject *filename,*/
2933         py_funcname,  /*PyObject *name,*/
2934         py_line,
2935         __pyx_empty_bytes  /*PyObject *lnotab*/
2936     );
2937     Py_DECREF(py_srcfile);
2938     Py_DECREF(py_funcname);
2939     return py_code;
2940 bad:
2941     Py_XDECREF(py_srcfile);
2942     Py_XDECREF(py_funcname);
2943     return NULL;
2944 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)2945 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2946                                int py_line, const char *filename) {
2947     PyCodeObject *py_code = 0;
2948     PyFrameObject *py_frame = 0;
2949     PyThreadState *tstate = __Pyx_PyThreadState_Current;
2950     if (c_line) {
2951         c_line = __Pyx_CLineForTraceback(tstate, c_line);
2952     }
2953     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
2954     if (!py_code) {
2955         py_code = __Pyx_CreateCodeObjectForTraceback(
2956             funcname, c_line, py_line, filename);
2957         if (!py_code) goto bad;
2958         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
2959     }
2960     py_frame = PyFrame_New(
2961         tstate,            /*PyThreadState *tstate,*/
2962         py_code,           /*PyCodeObject *code,*/
2963         __pyx_d,    /*PyObject *globals,*/
2964         0                  /*PyObject *locals*/
2965     );
2966     if (!py_frame) goto bad;
2967     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
2968     PyTraceBack_Here(py_frame);
2969 bad:
2970     Py_XDECREF(py_code);
2971     Py_XDECREF(py_frame);
2972 }
2973 
2974 /* CIntFromPyVerify */
2975 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
2976     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
2977 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
2978     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
2979 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
2980     {\
2981         func_type value = func_value;\
2982         if (sizeof(target_type) < sizeof(func_type)) {\
2983             if (unlikely(value != (func_type) (target_type) value)) {\
2984                 func_type zero = 0;\
2985                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
2986                     return (target_type) -1;\
2987                 if (is_unsigned && unlikely(value < zero))\
2988                     goto raise_neg_overflow;\
2989                 else\
2990                     goto raise_overflow;\
2991             }\
2992         }\
2993         return (target_type) value;\
2994     }
2995 
2996 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)2997 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
2998 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
2999 #pragma GCC diagnostic push
3000 #pragma GCC diagnostic ignored "-Wconversion"
3001 #endif
3002     const int neg_one = (int) -1, const_zero = (int) 0;
3003 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3004 #pragma GCC diagnostic pop
3005 #endif
3006     const int is_unsigned = neg_one > const_zero;
3007 #if PY_MAJOR_VERSION < 3
3008     if (likely(PyInt_Check(x))) {
3009         if (sizeof(int) < sizeof(long)) {
3010             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3011         } else {
3012             long val = PyInt_AS_LONG(x);
3013             if (is_unsigned && unlikely(val < 0)) {
3014                 goto raise_neg_overflow;
3015             }
3016             return (int) val;
3017         }
3018     } else
3019 #endif
3020     if (likely(PyLong_Check(x))) {
3021         if (is_unsigned) {
3022 #if CYTHON_USE_PYLONG_INTERNALS
3023             const digit* digits = ((PyLongObject*)x)->ob_digit;
3024             switch (Py_SIZE(x)) {
3025                 case  0: return (int) 0;
3026                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
3027                 case 2:
3028                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3029                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3030                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3031                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
3032                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3033                         }
3034                     }
3035                     break;
3036                 case 3:
3037                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3038                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3039                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3040                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
3041                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3042                         }
3043                     }
3044                     break;
3045                 case 4:
3046                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3047                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3048                             __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])))
3049                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
3050                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3051                         }
3052                     }
3053                     break;
3054             }
3055 #endif
3056 #if CYTHON_COMPILING_IN_CPYTHON
3057             if (unlikely(Py_SIZE(x) < 0)) {
3058                 goto raise_neg_overflow;
3059             }
3060 #else
3061             {
3062                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3063                 if (unlikely(result < 0))
3064                     return (int) -1;
3065                 if (unlikely(result == 1))
3066                     goto raise_neg_overflow;
3067             }
3068 #endif
3069             if (sizeof(int) <= sizeof(unsigned long)) {
3070                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
3071 #ifdef HAVE_LONG_LONG
3072             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3073                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3074 #endif
3075             }
3076         } else {
3077 #if CYTHON_USE_PYLONG_INTERNALS
3078             const digit* digits = ((PyLongObject*)x)->ob_digit;
3079             switch (Py_SIZE(x)) {
3080                 case  0: return (int) 0;
3081                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
3082                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
3083                 case -2:
3084                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
3085                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3086                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3087                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3088                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3089                         }
3090                     }
3091                     break;
3092                 case 2:
3093                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3094                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3095                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3096                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3097                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3098                         }
3099                     }
3100                     break;
3101                 case -3:
3102                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3103                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3104                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3105                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3106                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3107                         }
3108                     }
3109                     break;
3110                 case 3:
3111                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3112                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3113                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3114                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3115                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3116                         }
3117                     }
3118                     break;
3119                 case -4:
3120                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3121                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3122                             __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])))
3123                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3124                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3125                         }
3126                     }
3127                     break;
3128                 case 4:
3129                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3130                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3131                             __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])))
3132                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3133                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3134                         }
3135                     }
3136                     break;
3137             }
3138 #endif
3139             if (sizeof(int) <= sizeof(long)) {
3140                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
3141 #ifdef HAVE_LONG_LONG
3142             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3143                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
3144 #endif
3145             }
3146         }
3147         {
3148 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3149             PyErr_SetString(PyExc_RuntimeError,
3150                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3151 #else
3152             int val;
3153             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3154  #if PY_MAJOR_VERSION < 3
3155             if (likely(v) && !PyLong_Check(v)) {
3156                 PyObject *tmp = v;
3157                 v = PyNumber_Long(tmp);
3158                 Py_DECREF(tmp);
3159             }
3160  #endif
3161             if (likely(v)) {
3162                 int one = 1; int is_little = (int)*(unsigned char *)&one;
3163                 unsigned char *bytes = (unsigned char *)&val;
3164                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3165                                               bytes, sizeof(val),
3166                                               is_little, !is_unsigned);
3167                 Py_DECREF(v);
3168                 if (likely(!ret))
3169                     return val;
3170             }
3171 #endif
3172             return (int) -1;
3173         }
3174     } else {
3175         int val;
3176         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3177         if (!tmp) return (int) -1;
3178         val = __Pyx_PyInt_As_int(tmp);
3179         Py_DECREF(tmp);
3180         return val;
3181     }
3182 raise_overflow:
3183     PyErr_SetString(PyExc_OverflowError,
3184         "value too large to convert to int");
3185     return (int) -1;
3186 raise_neg_overflow:
3187     PyErr_SetString(PyExc_OverflowError,
3188         "can't convert negative value to int");
3189     return (int) -1;
3190 }
3191 
3192 /* CIntToPy */
__Pyx_PyInt_From_int(int value)3193 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
3194 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3195 #pragma GCC diagnostic push
3196 #pragma GCC diagnostic ignored "-Wconversion"
3197 #endif
3198     const int neg_one = (int) -1, const_zero = (int) 0;
3199 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3200 #pragma GCC diagnostic pop
3201 #endif
3202     const int is_unsigned = neg_one > const_zero;
3203     if (is_unsigned) {
3204         if (sizeof(int) < sizeof(long)) {
3205             return PyInt_FromLong((long) value);
3206         } else if (sizeof(int) <= sizeof(unsigned long)) {
3207             return PyLong_FromUnsignedLong((unsigned long) value);
3208 #ifdef HAVE_LONG_LONG
3209         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3210             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3211 #endif
3212         }
3213     } else {
3214         if (sizeof(int) <= sizeof(long)) {
3215             return PyInt_FromLong((long) value);
3216 #ifdef HAVE_LONG_LONG
3217         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3218             return PyLong_FromLongLong((PY_LONG_LONG) value);
3219 #endif
3220         }
3221     }
3222     {
3223         int one = 1; int little = (int)*(unsigned char *)&one;
3224         unsigned char *bytes = (unsigned char *)&value;
3225         return _PyLong_FromByteArray(bytes, sizeof(int),
3226                                      little, !is_unsigned);
3227     }
3228 }
3229 
3230 /* CIntToPy */
__Pyx_PyInt_From_long(long value)3231 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
3232 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3233 #pragma GCC diagnostic push
3234 #pragma GCC diagnostic ignored "-Wconversion"
3235 #endif
3236     const long neg_one = (long) -1, const_zero = (long) 0;
3237 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3238 #pragma GCC diagnostic pop
3239 #endif
3240     const int is_unsigned = neg_one > const_zero;
3241     if (is_unsigned) {
3242         if (sizeof(long) < sizeof(long)) {
3243             return PyInt_FromLong((long) value);
3244         } else if (sizeof(long) <= sizeof(unsigned long)) {
3245             return PyLong_FromUnsignedLong((unsigned long) value);
3246 #ifdef HAVE_LONG_LONG
3247         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
3248             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3249 #endif
3250         }
3251     } else {
3252         if (sizeof(long) <= sizeof(long)) {
3253             return PyInt_FromLong((long) value);
3254 #ifdef HAVE_LONG_LONG
3255         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
3256             return PyLong_FromLongLong((PY_LONG_LONG) value);
3257 #endif
3258         }
3259     }
3260     {
3261         int one = 1; int little = (int)*(unsigned char *)&one;
3262         unsigned char *bytes = (unsigned char *)&value;
3263         return _PyLong_FromByteArray(bytes, sizeof(long),
3264                                      little, !is_unsigned);
3265     }
3266 }
3267 
3268 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)3269 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
3270 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3271 #pragma GCC diagnostic push
3272 #pragma GCC diagnostic ignored "-Wconversion"
3273 #endif
3274     const long neg_one = (long) -1, const_zero = (long) 0;
3275 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3276 #pragma GCC diagnostic pop
3277 #endif
3278     const int is_unsigned = neg_one > const_zero;
3279 #if PY_MAJOR_VERSION < 3
3280     if (likely(PyInt_Check(x))) {
3281         if (sizeof(long) < sizeof(long)) {
3282             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
3283         } else {
3284             long val = PyInt_AS_LONG(x);
3285             if (is_unsigned && unlikely(val < 0)) {
3286                 goto raise_neg_overflow;
3287             }
3288             return (long) val;
3289         }
3290     } else
3291 #endif
3292     if (likely(PyLong_Check(x))) {
3293         if (is_unsigned) {
3294 #if CYTHON_USE_PYLONG_INTERNALS
3295             const digit* digits = ((PyLongObject*)x)->ob_digit;
3296             switch (Py_SIZE(x)) {
3297                 case  0: return (long) 0;
3298                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
3299                 case 2:
3300                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
3301                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3302                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3303                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
3304                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3305                         }
3306                     }
3307                     break;
3308                 case 3:
3309                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
3310                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3311                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3312                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
3313                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3314                         }
3315                     }
3316                     break;
3317                 case 4:
3318                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
3319                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3320                             __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])))
3321                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
3322                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
3323                         }
3324                     }
3325                     break;
3326             }
3327 #endif
3328 #if CYTHON_COMPILING_IN_CPYTHON
3329             if (unlikely(Py_SIZE(x) < 0)) {
3330                 goto raise_neg_overflow;
3331             }
3332 #else
3333             {
3334                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3335                 if (unlikely(result < 0))
3336                     return (long) -1;
3337                 if (unlikely(result == 1))
3338                     goto raise_neg_overflow;
3339             }
3340 #endif
3341             if (sizeof(long) <= sizeof(unsigned long)) {
3342                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
3343 #ifdef HAVE_LONG_LONG
3344             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
3345                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3346 #endif
3347             }
3348         } else {
3349 #if CYTHON_USE_PYLONG_INTERNALS
3350             const digit* digits = ((PyLongObject*)x)->ob_digit;
3351             switch (Py_SIZE(x)) {
3352                 case  0: return (long) 0;
3353                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
3354                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
3355                 case -2:
3356                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
3357                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3358                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3359                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3360                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3361                         }
3362                     }
3363                     break;
3364                 case 2:
3365                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
3366                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3367                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3368                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3369                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3370                         }
3371                     }
3372                     break;
3373                 case -3:
3374                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
3375                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3376                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3377                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3378                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3379                         }
3380                     }
3381                     break;
3382                 case 3:
3383                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
3384                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3385                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3386                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3387                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3388                         }
3389                     }
3390                     break;
3391                 case -4:
3392                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
3393                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3394                             __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])))
3395                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3396                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3397                         }
3398                     }
3399                     break;
3400                 case 4:
3401                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
3402                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3403                             __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])))
3404                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
3405                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
3406                         }
3407                     }
3408                     break;
3409             }
3410 #endif
3411             if (sizeof(long) <= sizeof(long)) {
3412                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
3413 #ifdef HAVE_LONG_LONG
3414             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
3415                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
3416 #endif
3417             }
3418         }
3419         {
3420 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3421             PyErr_SetString(PyExc_RuntimeError,
3422                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3423 #else
3424             long val;
3425             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3426  #if PY_MAJOR_VERSION < 3
3427             if (likely(v) && !PyLong_Check(v)) {
3428                 PyObject *tmp = v;
3429                 v = PyNumber_Long(tmp);
3430                 Py_DECREF(tmp);
3431             }
3432  #endif
3433             if (likely(v)) {
3434                 int one = 1; int is_little = (int)*(unsigned char *)&one;
3435                 unsigned char *bytes = (unsigned char *)&val;
3436                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
3437                                               bytes, sizeof(val),
3438                                               is_little, !is_unsigned);
3439                 Py_DECREF(v);
3440                 if (likely(!ret))
3441                     return val;
3442             }
3443 #endif
3444             return (long) -1;
3445         }
3446     } else {
3447         long val;
3448         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3449         if (!tmp) return (long) -1;
3450         val = __Pyx_PyInt_As_long(tmp);
3451         Py_DECREF(tmp);
3452         return val;
3453     }
3454 raise_overflow:
3455     PyErr_SetString(PyExc_OverflowError,
3456         "value too large to convert to long");
3457     return (long) -1;
3458 raise_neg_overflow:
3459     PyErr_SetString(PyExc_OverflowError,
3460         "can't convert negative value to long");
3461     return (long) -1;
3462 }
3463 
3464 /* FastTypeChecks */
3465 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)3466 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
3467     while (a) {
3468         a = a->tp_base;
3469         if (a == b)
3470             return 1;
3471     }
3472     return b == &PyBaseObject_Type;
3473 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)3474 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
3475     PyObject *mro;
3476     if (a == b) return 1;
3477     mro = a->tp_mro;
3478     if (likely(mro)) {
3479         Py_ssize_t i, n;
3480         n = PyTuple_GET_SIZE(mro);
3481         for (i = 0; i < n; i++) {
3482             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
3483                 return 1;
3484         }
3485         return 0;
3486     }
3487     return __Pyx_InBases(a, b);
3488 }
3489 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)3490 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
3491     PyObject *exception, *value, *tb;
3492     int res;
3493     __Pyx_PyThreadState_declare
3494     __Pyx_PyThreadState_assign
3495     __Pyx_ErrFetch(&exception, &value, &tb);
3496     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
3497     if (unlikely(res == -1)) {
3498         PyErr_WriteUnraisable(err);
3499         res = 0;
3500     }
3501     if (!res) {
3502         res = PyObject_IsSubclass(err, exc_type2);
3503         if (unlikely(res == -1)) {
3504             PyErr_WriteUnraisable(err);
3505             res = 0;
3506         }
3507     }
3508     __Pyx_ErrRestore(exception, value, tb);
3509     return res;
3510 }
3511 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)3512 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
3513     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
3514     if (!res) {
3515         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
3516     }
3517     return res;
3518 }
3519 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)3520 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3521     Py_ssize_t i, n;
3522     assert(PyExceptionClass_Check(exc_type));
3523     n = PyTuple_GET_SIZE(tuple);
3524 #if PY_MAJOR_VERSION >= 3
3525     for (i=0; i<n; i++) {
3526         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3527     }
3528 #endif
3529     for (i=0; i<n; i++) {
3530         PyObject *t = PyTuple_GET_ITEM(tuple, i);
3531         #if PY_MAJOR_VERSION < 3
3532         if (likely(exc_type == t)) return 1;
3533         #endif
3534         if (likely(PyExceptionClass_Check(t))) {
3535             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
3536         } else {
3537         }
3538     }
3539     return 0;
3540 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)3541 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
3542     if (likely(err == exc_type)) return 1;
3543     if (likely(PyExceptionClass_Check(err))) {
3544         if (likely(PyExceptionClass_Check(exc_type))) {
3545             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
3546         } else if (likely(PyTuple_Check(exc_type))) {
3547             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
3548         } else {
3549         }
3550     }
3551     return PyErr_GivenExceptionMatches(err, exc_type);
3552 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)3553 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
3554     assert(PyExceptionClass_Check(exc_type1));
3555     assert(PyExceptionClass_Check(exc_type2));
3556     if (likely(err == exc_type1 || err == exc_type2)) return 1;
3557     if (likely(PyExceptionClass_Check(err))) {
3558         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
3559     }
3560     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
3561 }
3562 #endif
3563 
3564 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)3565 static int __Pyx_check_binary_version(void) {
3566     char ctversion[4], rtversion[4];
3567     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
3568     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
3569     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
3570         char message[200];
3571         PyOS_snprintf(message, sizeof(message),
3572                       "compiletime version %s of module '%.100s' "
3573                       "does not match runtime version %s",
3574                       ctversion, __Pyx_MODULE_NAME, rtversion);
3575         return PyErr_WarnEx(NULL, message, 1);
3576     }
3577     return 0;
3578 }
3579 
3580 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)3581 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
3582     while (t->p) {
3583         #if PY_MAJOR_VERSION < 3
3584         if (t->is_unicode) {
3585             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
3586         } else if (t->intern) {
3587             *t->p = PyString_InternFromString(t->s);
3588         } else {
3589             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
3590         }
3591         #else
3592         if (t->is_unicode | t->is_str) {
3593             if (t->intern) {
3594                 *t->p = PyUnicode_InternFromString(t->s);
3595             } else if (t->encoding) {
3596                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
3597             } else {
3598                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
3599             }
3600         } else {
3601             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
3602         }
3603         #endif
3604         if (!*t->p)
3605             return -1;
3606         if (PyObject_Hash(*t->p) == -1)
3607             return -1;
3608         ++t;
3609     }
3610     return 0;
3611 }
3612 
__Pyx_PyUnicode_FromString(const char * c_str)3613 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
3614     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
3615 }
__Pyx_PyObject_AsString(PyObject * o)3616 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
3617     Py_ssize_t ignore;
3618     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
3619 }
3620 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
3621 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)3622 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3623     char* defenc_c;
3624     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
3625     if (!defenc) return NULL;
3626     defenc_c = PyBytes_AS_STRING(defenc);
3627 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3628     {
3629         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
3630         char* c;
3631         for (c = defenc_c; c < end; c++) {
3632             if ((unsigned char) (*c) >= 128) {
3633                 PyUnicode_AsASCIIString(o);
3634                 return NULL;
3635             }
3636         }
3637     }
3638 #endif
3639     *length = PyBytes_GET_SIZE(defenc);
3640     return defenc_c;
3641 }
3642 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)3643 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3644     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
3645 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3646     if (likely(PyUnicode_IS_ASCII(o))) {
3647         *length = PyUnicode_GET_LENGTH(o);
3648         return PyUnicode_AsUTF8(o);
3649     } else {
3650         PyUnicode_AsASCIIString(o);
3651         return NULL;
3652     }
3653 #else
3654     return PyUnicode_AsUTF8AndSize(o, length);
3655 #endif
3656 }
3657 #endif
3658 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)3659 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3660 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
3661     if (
3662 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3663             __Pyx_sys_getdefaultencoding_not_ascii &&
3664 #endif
3665             PyUnicode_Check(o)) {
3666         return __Pyx_PyUnicode_AsStringAndSize(o, length);
3667     } else
3668 #endif
3669 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
3670     if (PyByteArray_Check(o)) {
3671         *length = PyByteArray_GET_SIZE(o);
3672         return PyByteArray_AS_STRING(o);
3673     } else
3674 #endif
3675     {
3676         char* result;
3677         int r = PyBytes_AsStringAndSize(o, &result, length);
3678         if (unlikely(r < 0)) {
3679             return NULL;
3680         } else {
3681             return result;
3682         }
3683     }
3684 }
__Pyx_PyObject_IsTrue(PyObject * x)3685 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
3686    int is_true = x == Py_True;
3687    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
3688    else return PyObject_IsTrue(x);
3689 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)3690 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
3691     int retval;
3692     if (unlikely(!x)) return -1;
3693     retval = __Pyx_PyObject_IsTrue(x);
3694     Py_DECREF(x);
3695     return retval;
3696 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)3697 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
3698 #if PY_MAJOR_VERSION >= 3
3699     if (PyLong_Check(result)) {
3700         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
3701                 "__int__ returned non-int (type %.200s).  "
3702                 "The ability to return an instance of a strict subclass of int "
3703                 "is deprecated, and may be removed in a future version of Python.",
3704                 Py_TYPE(result)->tp_name)) {
3705             Py_DECREF(result);
3706             return NULL;
3707         }
3708         return result;
3709     }
3710 #endif
3711     PyErr_Format(PyExc_TypeError,
3712                  "__%.4s__ returned non-%.4s (type %.200s)",
3713                  type_name, type_name, Py_TYPE(result)->tp_name);
3714     Py_DECREF(result);
3715     return NULL;
3716 }
__Pyx_PyNumber_IntOrLong(PyObject * x)3717 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
3718 #if CYTHON_USE_TYPE_SLOTS
3719   PyNumberMethods *m;
3720 #endif
3721   const char *name = NULL;
3722   PyObject *res = NULL;
3723 #if PY_MAJOR_VERSION < 3
3724   if (likely(PyInt_Check(x) || PyLong_Check(x)))
3725 #else
3726   if (likely(PyLong_Check(x)))
3727 #endif
3728     return __Pyx_NewRef(x);
3729 #if CYTHON_USE_TYPE_SLOTS
3730   m = Py_TYPE(x)->tp_as_number;
3731   #if PY_MAJOR_VERSION < 3
3732   if (m && m->nb_int) {
3733     name = "int";
3734     res = m->nb_int(x);
3735   }
3736   else if (m && m->nb_long) {
3737     name = "long";
3738     res = m->nb_long(x);
3739   }
3740   #else
3741   if (likely(m && m->nb_int)) {
3742     name = "int";
3743     res = m->nb_int(x);
3744   }
3745   #endif
3746 #else
3747   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
3748     res = PyNumber_Int(x);
3749   }
3750 #endif
3751   if (likely(res)) {
3752 #if PY_MAJOR_VERSION < 3
3753     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
3754 #else
3755     if (unlikely(!PyLong_CheckExact(res))) {
3756 #endif
3757         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
3758     }
3759   }
3760   else if (!PyErr_Occurred()) {
3761     PyErr_SetString(PyExc_TypeError,
3762                     "an integer is required");
3763   }
3764   return res;
3765 }
3766 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
3767   Py_ssize_t ival;
3768   PyObject *x;
3769 #if PY_MAJOR_VERSION < 3
3770   if (likely(PyInt_CheckExact(b))) {
3771     if (sizeof(Py_ssize_t) >= sizeof(long))
3772         return PyInt_AS_LONG(b);
3773     else
3774         return PyInt_AsSsize_t(b);
3775   }
3776 #endif
3777   if (likely(PyLong_CheckExact(b))) {
3778     #if CYTHON_USE_PYLONG_INTERNALS
3779     const digit* digits = ((PyLongObject*)b)->ob_digit;
3780     const Py_ssize_t size = Py_SIZE(b);
3781     if (likely(__Pyx_sst_abs(size) <= 1)) {
3782         ival = likely(size) ? digits[0] : 0;
3783         if (size == -1) ival = -ival;
3784         return ival;
3785     } else {
3786       switch (size) {
3787          case 2:
3788            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3789              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3790            }
3791            break;
3792          case -2:
3793            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3794              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3795            }
3796            break;
3797          case 3:
3798            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3799              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3800            }
3801            break;
3802          case -3:
3803            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3804              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3805            }
3806            break;
3807          case 4:
3808            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3809              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]));
3810            }
3811            break;
3812          case -4:
3813            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3814              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]));
3815            }
3816            break;
3817       }
3818     }
3819     #endif
3820     return PyLong_AsSsize_t(b);
3821   }
3822   x = PyNumber_Index(b);
3823   if (!x) return -1;
3824   ival = PyInt_AsSsize_t(x);
3825   Py_DECREF(x);
3826   return ival;
3827 }
3828 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
3829   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
3830 }
3831 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
3832     return PyInt_FromSize_t(ival);
3833 }
3834 
3835 
3836 #endif /* Py_PYTHON_H */
3837