Generated by Cython 0.28.5

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: cyxor.c

 01: # This file is part of Xpra.
 02: # Copyright (C) 2012-2018 Antoine Martin <antoine@devloop.org.uk>
 03: # Xpra is released under the terms of the GNU GPL v2, or, at your option, any
 04: # later version. See the file COPYING for details.
 05: 
 06: #cython: wraparound=False, language_level=3
 07: from __future__ import absolute_import
 08: 
 09: from libc.stdint cimport uint32_t, uintptr_t
 10: from xpra.buffers.membuf cimport getbuf, object_as_buffer, MemBuf
 11: 
 12: 
+13: def xor_str(a, b):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_3xor_5cyxor_1xor_str(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_3xor_5cyxor_1xor_str = {"xor_str", (PyCFunction)__pyx_pw_4xpra_6codecs_3xor_5cyxor_1xor_str, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4xpra_6codecs_3xor_5cyxor_1xor_str(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("xor_str (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_b,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("xor_str", 1, 2, 2, 1); __PYX_ERR(0, 13, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xor_str") < 0)) __PYX_ERR(0, 13, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("xor_str", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 13, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("xpra.codecs.xor.cyxor.xor_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4xpra_6codecs_3xor_5cyxor_xor_str(__pyx_self, __pyx_v_a, __pyx_v_b);

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

static PyObject *__pyx_pf_4xpra_6codecs_3xor_5cyxor_xor_str(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  Py_ssize_t __pyx_v_alen;
  Py_ssize_t __pyx_v_blen;
  uintptr_t __pyx_v_ap;
  uintptr_t __pyx_v_bp;
  uintptr_t __pyx_v_op;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_out_buf = 0;
  unsigned char *__pyx_v_acbuf;
  unsigned char *__pyx_v_bcbuf;
  unsigned char *__pyx_v_ocbuf;
  uint32_t *__pyx_v_obuf;
  uint32_t *__pyx_v_abuf;
  uint32_t *__pyx_v_bbuf;
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_j;
  unsigned int __pyx_v_steps;
  unsigned int __pyx_v_char_steps;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("xor_str", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("xpra.codecs.xor.cyxor.xor_str", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_out_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__3 = PyTuple_Pack(18, __pyx_n_s_a, __pyx_n_s_b, __pyx_n_s_alen, __pyx_n_s_blen, __pyx_n_s_ap, __pyx_n_s_bp, __pyx_n_s_op, __pyx_n_s_out_buf, __pyx_n_s_acbuf, __pyx_n_s_bcbuf, __pyx_n_s_ocbuf, __pyx_n_s_obuf, __pyx_n_s_abuf, __pyx_n_s_bbuf, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_steps, __pyx_n_s_char_steps); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_3xor_5cyxor_1xor_str, NULL, __pyx_n_s_xpra_codecs_xor_cyxor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_xor_str, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(2, 0, 18, 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_xpra_codecs_xor_cyxor_pyx, __pyx_n_s_xor_str, 13, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 13, __pyx_L1_error)
+14:     assert len(a)==len(b), "cyxor cannot xor strings of different lengths (%s:%s vs %s:%s)" % (type(a), len(a), type(b), len(b))
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 14, __pyx_L1_error)
    __pyx_t_2 = PyObject_Length(__pyx_v_b); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 14, __pyx_L1_error)
    if (unlikely(!((__pyx_t_1 == __pyx_t_2) != 0))) {
      __pyx_t_3 = PyTuple_New(9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = 0;
      __pyx_t_5 = 127;
      __Pyx_INCREF(__pyx_kp_u_cyxor_cannot_xor_strings_of_diff);
      __pyx_t_4 += 47;
      __Pyx_GIVEREF(__pyx_kp_u_cyxor_cannot_xor_strings_of_diff);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_cyxor_cannot_xor_strings_of_diff);
      __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(((PyObject *)Py_TYPE(__pyx_v_a))), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5;
      __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_INCREF(__pyx_kp_u_);
      __pyx_t_4 += 1;
      __Pyx_GIVEREF(__pyx_kp_u_);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_);
      __pyx_t_7 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 14, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_7, 0, ' ', 'd'); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_INCREF(__pyx_kp_u_vs);
      __pyx_t_4 += 4;
      __Pyx_GIVEREF(__pyx_kp_u_vs);
      PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u_vs);
      __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(((PyObject *)Py_TYPE(__pyx_v_b))), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5;
      __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_INCREF(__pyx_kp_u_);
      __pyx_t_4 += 1;
      __Pyx_GIVEREF(__pyx_kp_u_);
      PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_kp_u_);
      __pyx_t_7 = PyObject_Length(__pyx_v_b); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 14, __pyx_L1_error)
      __pyx_t_6 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_7, 0, ' ', 'd'); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 7, __pyx_t_6);
      __pyx_t_6 = 0;
      __Pyx_INCREF(__pyx_kp_u__2);
      __pyx_t_4 += 1;
      __Pyx_GIVEREF(__pyx_kp_u__2);
      PyTuple_SET_ITEM(__pyx_t_3, 8, __pyx_kp_u__2);
      __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_3, 9, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 14, __pyx_L1_error)
    }
  }
  #endif
+15:     cdef Py_ssize_t alen = 0, blen = 0
  __pyx_v_alen = 0;
  __pyx_v_blen = 0;
 16:     cdef uintptr_t ap
 17:     cdef uintptr_t bp
 18:     cdef uintptr_t op
+19:     assert object_as_buffer(a, <const void **> &ap, &alen)==0, "cannot get buffer pointer for %s" % type(a)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_buffer(__pyx_v_a, ((void const **)(&__pyx_v_ap)), (&__pyx_v_alen)) == 0) != 0))) {
      __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_cannot_get_buffer_pointer_for_s, ((PyObject *)Py_TYPE(__pyx_v_a))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 19, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 19, __pyx_L1_error)
    }
  }
  #endif
+20:     assert object_as_buffer(b, <const void **> &bp, &blen)==0, "cannot get buffer pointer for %s" % type(b)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_buffer(__pyx_v_b, ((void const **)(&__pyx_v_bp)), (&__pyx_v_blen)) == 0) != 0))) {
      __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_cannot_get_buffer_pointer_for_s, ((PyObject *)Py_TYPE(__pyx_v_b))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 20, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_6);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_ERR(0, 20, __pyx_L1_error)
    }
  }
  #endif
+21:     assert alen == blen, "python or cython bug? buffers don't have the same length?"
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_alen == __pyx_v_blen) != 0))) {
      PyErr_SetObject(PyExc_AssertionError, __pyx_kp_u_python_or_cython_bug_buffers_don);
      __PYX_ERR(0, 21, __pyx_L1_error)
    }
  }
  #endif
+22:     cdef MemBuf out_buf = getbuf(alen)
  __pyx_t_6 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_alen); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 22, __pyx_L1_error)
  __pyx_v_out_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_6);
  __pyx_t_6 = 0;
+23:     op = <uintptr_t> out_buf.get_mem()
  __pyx_v_op = ((uintptr_t)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_out_buf->__pyx_vtab)->get_mem(__pyx_v_out_buf));
+24:     cdef unsigned char *acbuf = <unsigned char *> ap
  __pyx_v_acbuf = ((unsigned char *)__pyx_v_ap);
+25:     cdef unsigned char *bcbuf = <unsigned char *> bp
  __pyx_v_bcbuf = ((unsigned char *)__pyx_v_bp);
+26:     cdef unsigned char *ocbuf = <unsigned char *> op
  __pyx_v_ocbuf = ((unsigned char *)__pyx_v_op);
+27:     cdef uint32_t *obuf = <uint32_t*> op
  __pyx_v_obuf = ((uint32_t *)__pyx_v_op);
+28:     cdef uint32_t *abuf = <uint32_t*> ap
  __pyx_v_abuf = ((uint32_t *)__pyx_v_ap);
+29:     cdef uint32_t *bbuf = <uint32_t*> bp
  __pyx_v_bbuf = ((uint32_t *)__pyx_v_bp);
 30:     cdef unsigned int i, j, steps, char_steps
+31:     if (ap % 4)!=0 or (bp % 4)!=0:
  __pyx_t_9 = (((__pyx_v_ap % 4) != 0) != 0);
  if (!__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_9 = (((__pyx_v_bp % 4) != 0) != 0);
  __pyx_t_8 = __pyx_t_9;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_8) {
/* … */
    goto __pyx_L3;
  }
 32:         #unaligned access, use byte at a time slow path:
+33:         char_steps = alen
    __pyx_v_char_steps = __pyx_v_alen;
+34:         for 0 <= i < char_steps:
    __pyx_t_10 = __pyx_v_char_steps;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {
+35:             ocbuf[i] = acbuf[i] ^ bcbuf[i]
      (__pyx_v_ocbuf[__pyx_v_i]) = ((__pyx_v_acbuf[__pyx_v_i]) ^ (__pyx_v_bcbuf[__pyx_v_i]));
    }
 36:     else:
 37:         #do 4 bytes at a time:
+38:         steps = alen // 4
  /*else*/ {
    __pyx_v_steps = __Pyx_div_Py_ssize_t(__pyx_v_alen, 4);
+39:         if steps>0:
    __pyx_t_8 = ((__pyx_v_steps > 0) != 0);
    if (__pyx_t_8) {
/* … */
    }
+40:             for 0 <= i < steps:
      __pyx_t_10 = __pyx_v_steps;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {
+41:                 obuf[i] = abuf[i] ^ bbuf[i]
        (__pyx_v_obuf[__pyx_v_i]) = ((__pyx_v_abuf[__pyx_v_i]) ^ (__pyx_v_bbuf[__pyx_v_i]));
      }
 42:         #bytes at a time again at the end:
+43:         char_steps = alen % 4
    __pyx_v_char_steps = __Pyx_mod_Py_ssize_t(__pyx_v_alen, 4);
+44:         if char_steps>0:
    __pyx_t_8 = ((__pyx_v_char_steps > 0) != 0);
    if (__pyx_t_8) {
/* … */
    }
  }
  __pyx_L3:;
+45:             for 0 <= i < char_steps:
      __pyx_t_10 = __pyx_v_char_steps;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) {
+46:                 j = alen-char_steps+i
        __pyx_v_j = ((__pyx_v_alen - __pyx_v_char_steps) + __pyx_v_i);
+47:                 ocbuf[j] = acbuf[j] ^ bcbuf[j]
        (__pyx_v_ocbuf[__pyx_v_j]) = ((__pyx_v_acbuf[__pyx_v_j]) ^ (__pyx_v_bcbuf[__pyx_v_j]));
      }
+48:     return memoryview(out_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_memoryview); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, ((PyObject *)__pyx_v_out_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;
 49: 
 50: 
+51: def hybi_unmask(mask, data):
/* Python wrapper */
static PyObject *__pyx_pw_4xpra_6codecs_3xor_5cyxor_3hybi_unmask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_4xpra_6codecs_3xor_5cyxor_3hybi_unmask = {"hybi_unmask", (PyCFunction)__pyx_pw_4xpra_6codecs_3xor_5cyxor_3hybi_unmask, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_4xpra_6codecs_3xor_5cyxor_3hybi_unmask(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mask = 0;
  PyObject *__pyx_v_data = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("hybi_unmask (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mask,&__pyx_n_s_data,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("hybi_unmask", 1, 2, 2, 1); __PYX_ERR(0, 51, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "hybi_unmask") < 0)) __PYX_ERR(0, 51, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_mask = values[0];
    __pyx_v_data = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("hybi_unmask", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 51, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("xpra.codecs.xor.cyxor.hybi_unmask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4xpra_6codecs_3xor_5cyxor_2hybi_unmask(__pyx_self, __pyx_v_mask, __pyx_v_data);

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

static PyObject *__pyx_pf_4xpra_6codecs_3xor_5cyxor_2hybi_unmask(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_data) {
  Py_ssize_t __pyx_v_mlen;
  Py_ssize_t __pyx_v_dlen;
  uintptr_t __pyx_v_mp;
  uintptr_t __pyx_v_dp;
  uintptr_t __pyx_v_op;
  struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *__pyx_v_out_buf = 0;
  unsigned char *__pyx_v_mcbuf;
  unsigned char *__pyx_v_dcbuf;
  unsigned char *__pyx_v_ocbuf;
  uint32_t *__pyx_v_mbuf;
  uint32_t *__pyx_v_dbuf;
  uint32_t *__pyx_v_obuf;
  uint32_t __pyx_v_mask_value;
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_j;
  unsigned int __pyx_v_steps;
  unsigned int __pyx_v_char_steps;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("hybi_unmask", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("xpra.codecs.xor.cyxor.hybi_unmask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_out_buf);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__5 = PyTuple_Pack(19, __pyx_n_s_mask, __pyx_n_s_data, __pyx_n_s_mlen, __pyx_n_s_dlen, __pyx_n_s_mp, __pyx_n_s_dp, __pyx_n_s_op, __pyx_n_s_out_buf, __pyx_n_s_mcbuf, __pyx_n_s_dcbuf, __pyx_n_s_ocbuf, __pyx_n_s_mbuf, __pyx_n_s_dbuf, __pyx_n_s_obuf, __pyx_n_s_mask_value, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_steps, __pyx_n_s_char_steps); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4xpra_6codecs_3xor_5cyxor_3hybi_unmask, NULL, __pyx_n_s_xpra_codecs_xor_cyxor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_hybi_unmask, __pyx_t_1) < 0) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+52:     assert len(mask)==4, "hybi_unmask invalid mask length %i" % len(mask)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __pyx_t_1 = PyObject_Length(__pyx_v_mask); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 52, __pyx_L1_error)
    if (unlikely(!((__pyx_t_1 == 4) != 0))) {
      __pyx_t_2 = PyObject_Length(__pyx_v_mask); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 52, __pyx_L1_error)
      __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_hybi_unmask_invalid_mask_length, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 52, __pyx_L1_error)
    }
  }
  #endif
+53:     cdef Py_ssize_t mlen = 0, dlen = 0
  __pyx_v_mlen = 0;
  __pyx_v_dlen = 0;
 54:     cdef uintptr_t mp
 55:     cdef uintptr_t dp
 56:     cdef uintptr_t op
+57:     assert object_as_buffer(mask, <const void **> &mp, &mlen)==0, "cannot get buffer pointer for %s" % type(mask)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_buffer(__pyx_v_mask, ((void const **)(&__pyx_v_mp)), (&__pyx_v_mlen)) == 0) != 0))) {
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_cannot_get_buffer_pointer_for_s, ((PyObject *)Py_TYPE(__pyx_v_mask))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 57, __pyx_L1_error)
    }
  }
  #endif
+58:     assert object_as_buffer(data, <const void **> &dp, &dlen)==0, "cannot get buffer pointer for %s" % type(data)
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_f_4xpra_7buffers_6membuf_object_as_buffer(__pyx_v_data, ((void const **)(&__pyx_v_dp)), (&__pyx_v_dlen)) == 0) != 0))) {
      __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_cannot_get_buffer_pointer_for_s, ((PyObject *)Py_TYPE(__pyx_v_data))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_ERR(0, 58, __pyx_L1_error)
    }
  }
  #endif
+59:     assert mlen==4
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    if (unlikely(!((__pyx_v_mlen == 4) != 0))) {
      PyErr_SetNone(PyExc_AssertionError);
      __PYX_ERR(0, 59, __pyx_L1_error)
    }
  }
  #endif
+60:     cdef MemBuf out_buf = getbuf(dlen)
  __pyx_t_4 = __pyx_f_4xpra_7buffers_6membuf_getbuf(__pyx_v_dlen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4xpra_7buffers_6membuf_MemBuf))))) __PYX_ERR(0, 60, __pyx_L1_error)
  __pyx_v_out_buf = ((struct __pyx_obj_4xpra_7buffers_6membuf_MemBuf *)__pyx_t_4);
  __pyx_t_4 = 0;
+61:     op = <uintptr_t> out_buf.get_mem()
  __pyx_v_op = ((uintptr_t)((struct __pyx_vtabstruct_4xpra_7buffers_6membuf_MemBuf *)__pyx_v_out_buf->__pyx_vtab)->get_mem(__pyx_v_out_buf));
+62:     cdef unsigned char *mcbuf = <unsigned char *> mp
  __pyx_v_mcbuf = ((unsigned char *)__pyx_v_mp);
+63:     cdef unsigned char *dcbuf = <unsigned char *> dp
  __pyx_v_dcbuf = ((unsigned char *)__pyx_v_dp);
+64:     cdef unsigned char *ocbuf = <unsigned char *> op
  __pyx_v_ocbuf = ((unsigned char *)__pyx_v_op);
+65:     cdef uint32_t *mbuf = <uint32_t*> mp
  __pyx_v_mbuf = ((uint32_t *)__pyx_v_mp);
+66:     cdef uint32_t *dbuf = <uint32_t*> dp
  __pyx_v_dbuf = ((uint32_t *)__pyx_v_dp);
+67:     cdef uint32_t *obuf = <uint32_t*> op
  __pyx_v_obuf = ((uint32_t *)__pyx_v_op);
+68:     cdef uint32_t mask_value = mbuf[0]
  __pyx_v_mask_value = (__pyx_v_mbuf[0]);
 69:     cdef unsigned int i, j, steps, char_steps
+70:     if (dp % 4)!=0:
  __pyx_t_5 = (((__pyx_v_dp % 4) != 0) != 0);
  if (__pyx_t_5) {
/* … */
    goto __pyx_L3;
  }
 71:         #unaligned access, use byte at a time slow path:
+72:         char_steps = dlen
    __pyx_v_char_steps = __pyx_v_dlen;
+73:         for 0 <= i < char_steps:
    __pyx_t_6 = __pyx_v_char_steps;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {
+74:             ocbuf[i] = dcbuf[i] ^ mcbuf[i%4]
      (__pyx_v_ocbuf[__pyx_v_i]) = ((__pyx_v_dcbuf[__pyx_v_i]) ^ (__pyx_v_mcbuf[__Pyx_mod_long(__pyx_v_i, 4)]));
    }
 75:     else:
 76:         #do 4 bytes at a time:
+77:         steps = dlen // 4
  /*else*/ {
    __pyx_v_steps = __Pyx_div_Py_ssize_t(__pyx_v_dlen, 4);
+78:         if steps>0:
    __pyx_t_5 = ((__pyx_v_steps > 0) != 0);
    if (__pyx_t_5) {
/* … */
    }
+79:             for 0 <= i < steps:
      __pyx_t_6 = __pyx_v_steps;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {
+80:                 obuf[i] = dbuf[i] ^ mask_value
        (__pyx_v_obuf[__pyx_v_i]) = ((__pyx_v_dbuf[__pyx_v_i]) ^ __pyx_v_mask_value);
      }
 81:         #bytes at a time again at the end:
+82:         char_steps = dlen % 4
    __pyx_v_char_steps = __Pyx_mod_Py_ssize_t(__pyx_v_dlen, 4);
+83:         if char_steps>0:
    __pyx_t_5 = ((__pyx_v_char_steps > 0) != 0);
    if (__pyx_t_5) {
/* … */
    }
  }
  __pyx_L3:;
+84:             for 0 <= i < char_steps:
      __pyx_t_6 = __pyx_v_char_steps;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {
+85:                 j = dlen-char_steps+i
        __pyx_v_j = ((__pyx_v_dlen - __pyx_v_char_steps) + __pyx_v_i);
+86:                 ocbuf[j] = dcbuf[j] ^ mcbuf[i]
        (__pyx_v_ocbuf[__pyx_v_j]) = ((__pyx_v_dcbuf[__pyx_v_j]) ^ (__pyx_v_mcbuf[__pyx_v_i]));
      }
+87:     return memoryview(out_buf)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_memoryview); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_out_buf)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;