// File: /workspace/github_c_makefile_star2_O0/WojciechMula[P]pyahocorasick/src/AutomatonItemsIter.c
// Function: automaton_items_iter_new
static PyObject*
automaton_items_iter_new(
    Automaton* automaton,
    const TRIE_LETTER_TYPE* word,
    const Py_ssize_t wordlen,

    const bool use_wildcard,
    const TRIE_LETTER_TYPE wildcard,
    const PatternMatchType matchtype
) {
    AutomatonItemsIter* iter;
    StackItem* new_item;

    iter = (AutomatonItemsIter*)F(PyObject_New)(AutomatonItemsIter, &automaton_items_iter_type);
    if (iter == NULL)
        return NULL;

    iter->automaton = automaton;
    iter->version   = automaton->version;
    iter->state = NULL;
    iter->type = ITER_KEYS;
    iter->buffer = NULL;
#ifndef AHOCORASICK_UNICODE
    iter->char_buffer = NULL;
#endif
    iter->pattern = NULL;
    iter->use_wildcard = use_wildcard;
    iter->wildcard = wildcard;
    iter->matchtype = matchtype;
    list_init(&iter->stack);

    Py_INCREF((PyObject*)iter->automaton);

    iter->buffer = memory_alloc((automaton->longest_word + 1) * TRIE_LETTER_SIZE);
    if (iter->buffer == NULL) {
        goto no_memory;
    }

#ifndef AHOCORASICK_UNICODE
    iter->char_buffer = memory_alloc(automaton->longest_word + 1);
    if (iter->char_buffer == NULL) {
        goto no_memory;
    }
#endif

    if (word) {
        iter->pattern = (TRIE_LETTER_TYPE*)memory_alloc(wordlen * TRIE_LETTER_SIZE);
        if (UNLIKELY(iter->pattern == NULL)) {
            goto no_memory;
        }
        else {
            iter->pattern_length = wordlen;
            memcpy(iter->pattern, word, wordlen * TRIE_LETTER_SIZE);
        }
    }
    else
        iter->pattern_length = 0;

    new_item = (StackItem*)list_item_new(sizeof(StackItem));
    if (UNLIKELY(new_item == NULL)) {
        goto no_memory;
    }

    new_item->node = automaton->root;
    new_item->depth = 0;
    list_push_front(&iter->stack, (ListItem*)new_item);

    return (PyObject*)iter;

no_memory:
    Py_DECREF((PyObject*)iter);
    PyErr_NoMemory();
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
leaq 0xb9de(%rip), %rdi      # 0x126e8
callq 0x32b0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x6d27
movq $0x0, -0x8(%rbp)
jmp 0x6ebd
movq -0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x58(%rax)
movb -0x21(%rbp), %cl
movq -0x38(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x60(%rax)
movl -0x28(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x64(%rax)
movl -0x2c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
callq 0x3b90
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5820
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
addl $0x1, %eax
shll $0x2, %eax
movslq %eax, %rdi
callq 0x3450
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x6ddb
jmp 0x6ea7
cmpq $0x0, -0x18(%rbp)
je 0x6e3f
movq -0x20(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3450
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x58(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x6e18
jmp 0x6ea7
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x38(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
shlq $0x2, %rdx
callq 0x31e0
jmp 0x6e4b
movq -0x38(%rbp), %rax
movq $0x0, 0x50(%rax)
movl $0x20, %edi
callq 0x3b30
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x6e70
jmp 0x6ea7
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
movq -0x40(%rbp), %rsi
callq 0x3d30
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6ebd
movq -0x38(%rbp), %rdi
callq 0x3a90
callq 0x30e0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)