// File: /workspace/github_c_makefile_star2_O0/WojciechMula[P]pyahocorasick/src/utils.c
// Function: pymod_get_string
static PyObject*
pymod_get_string(PyObject* obj, TRIE_LETTER_TYPE** word, Py_ssize_t* wordlen, bool* is_copy) {

#ifdef INPUT_KEEPS_COPY
    Py_ssize_t i;
    char* bytes;
#endif

#if defined PEP393_UNICODE
    if (F(PyUnicode_Check)(obj)) {
    PyUnicode_READY(obj);
    if (PyUnicode_KIND(obj) == PyUnicode_4BYTE_KIND) {
            *word = (TRIE_LETTER_TYPE*)(PyUnicode_4BYTE_DATA(obj));
            *wordlen = PyUnicode_GET_LENGTH(obj);
            *is_copy = false;
            Py_INCREF(obj);

        return obj;
    } else {
        *word = PyUnicode_AsUCS4Copy(obj);
        *wordlen = PyUnicode_GET_LENGTH(obj);
        *is_copy = true;
        // No INCREF - we have our copy
        return obj;
    }
    }
    else {
    PyErr_SetString(PyExc_TypeError, "string expected");
    return NULL;
    }
#elif defined PY3K
#   ifdef AHOCORASICK_UNICODE
        if (F(PyUnicode_Check)(obj)) {
            *word = (TRIE_LETTER_TYPE*)(PyUnicode_AS_UNICODE(obj));
            *wordlen = PyUnicode_GET_SIZE(obj);
            Py_INCREF(obj);
            return obj;
        }
        else {
            PyErr_SetString(PyExc_TypeError, "string expected");
            return NULL;
        }
#   else
#       ifndef INPUT_KEEPS_COPY
#           error "defines inconsistency"
#       endif
        if (F(PyBytes_Check)(obj)) {
            *wordlen = PyBytes_GET_SIZE(obj);
            *word    = (TRIE_LETTER_TYPE*)memory_alloc(*wordlen * TRIE_LETTER_SIZE);
            if (*word == NULL) {
                PyErr_NoMemory();
                return NULL;
            }

            bytes = PyBytes_AS_STRING(obj);
            for (i=0; i < *wordlen; i++) {
                (*word)[i] = bytes[i];
            }
            // Note: there is no INCREF
            return obj;
        }
        else {
            PyErr_SetString(PyExc_TypeError, "bytes expected");
            return NULL;
        }
#   endif
#else // PY_MAJOR_VERSION == 3
#       ifndef INPUT_KEEPS_COPY
#           error "defines inconsistency"
#       endif
    if (F(PyString_Check)(obj)) {
        *wordlen = PyString_GET_SIZE(obj);
        *word    = (TRIE_LETTER_TYPE*)memory_alloc(*wordlen * TRIE_LETTER_SIZE);
        if (*word == NULL) {
            PyErr_NoMemory();
            return NULL;
        }


        bytes = PyString_AS_STRING(obj);
        for (i=0; i < *wordlen; i++) {
            (*word)[i] = bytes[i];
        };

        Py_INCREF(obj);
        return obj;
    } else {
        PyErr_SetString(PyExc_TypeError, "string required");
        return NULL;
    }
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x10000000, %esi       # imm = 0x10000000
callq 0x4450
cmpl $0x0, %eax
je 0x3940
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x10000000, %esi       # imm = 0x10000000
callq 0x4450
cmpl $0x0, %eax
je 0x361c
jmp 0x363b
leaq 0x8d60(%rip), %rdi      # 0xc383
leaq 0x8d6e(%rip), %rsi      # 0xc398
movl $0x9b, %edx
leaq 0x8d6e(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x7, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x364f
jmp 0x3658
movq -0x10(%rbp), %rdi
callq 0x3040
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x10000000, %esi       # imm = 0x10000000
callq 0x4450
cmpl $0x0, %eax
je 0x3671
jmp 0x3690
leaq 0x8d0b(%rip), %rdi      # 0xc383
leaq 0x8d19(%rip), %rsi      # 0xc398
movl $0x9c, %edx
leaq 0x8d19(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x7, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x36a4
jmp 0x36c3
leaq 0x8d44(%rip), %rdi      # 0xc3ef
leaq 0x8ce6(%rip), %rsi      # 0xc398
movl $0x9c, %edx
leaq 0x8ce6(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x2, %eax
andl $0x7, %eax
cmpl $0x4, %eax
jne 0x38a2
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x10000000, %esi       # imm = 0x10000000
callq 0x4450
cmpl $0x0, %eax
je 0x36f2
jmp 0x3711
leaq 0x8c8a(%rip), %rdi      # 0xc383
leaq 0x8c98(%rip), %rsi      # 0xc398
movl $0x9d, %edx
leaq 0x8c98(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x5, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x37c8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x10000000, %esi       # imm = 0x10000000
callq 0x4450
cmpl $0x0, %eax
je 0x3740
jmp 0x375f
leaq 0x8c3c(%rip), %rdi      # 0xc383
leaq 0x8c4a(%rip), %rsi      # 0xc398
movl $0x9d, %edx
leaq 0x8c4a(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x7, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3773
jmp 0x3792
leaq 0x8c75(%rip), %rdi      # 0xc3ef
leaq 0x8c17(%rip), %rsi      # 0xc398
movl $0x9d, %edx
leaq 0x8c17(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x6, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x37b2
movq -0x10(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x30(%rbp)
jmp 0x37be
movq -0x10(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x3800
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x37d5
jmp 0x37f4
leaq 0x8c2b(%rip), %rdi      # 0xc407
leaq 0x8bb5(%rip), %rsi      # 0xc398
movl $0x9d, %edx
leaq 0x8bb5(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x10000000, %esi       # imm = 0x10000000
callq 0x4450
cmpl $0x0, %eax
je 0x3824
jmp 0x3843
leaq 0x8b58(%rip), %rdi      # 0xc383
leaq 0x8b66(%rip), %rsi      # 0xc398
movl $0x9e, %edx
leaq 0x8b66(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x7, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3857
jmp 0x3876
leaq 0x8b91(%rip), %rdi      # 0xc3ef
leaq 0x8b33(%rip), %rsi      # 0xc398
movl $0x9e, %edx
leaq 0x8b33(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
callq 0x5820
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x395e
movq -0x10(%rbp), %rdi
callq 0x3110
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x10000000, %esi       # imm = 0x10000000
callq 0x4450
cmpl $0x0, %eax
je 0x38ce
jmp 0x38ed
leaq 0x8aae(%rip), %rdi      # 0xc383
leaq 0x8abc(%rip), %rsi      # 0xc398
movl $0xa5, %edx
leaq 0x8abc(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
shrl $0x7, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3901
jmp 0x3920
leaq 0x8ae7(%rip), %rdi      # 0xc3ef
leaq 0x8a89(%rip), %rsi      # 0xc398
movl $0xa5, %edx
leaq 0x8a89(%rip), %rcx      # 0xc3a4
callq 0x3130
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x395e
movq 0xe649(%rip), %rax      # 0x11f90
movq (%rax), %rdi
leaq 0x8ada(%rip), %rsi      # 0xc42b
callq 0x3120
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)