// File: /workspace/github_c_makefile_star2_O0/WojciechMula[P]pyahocorasick/src/AutomatonSearchIter.c
// Function: automaton_search_iter_set
static PyObject*
automaton_search_iter_set(PyObject* self, PyObject* args) {
    PyObject* object;
    PyObject* flag;
    Py_ssize_t position;
    bool reset;
    struct Input new_input;

    // first argument - required string or buffer
    object = F(PyTuple_GetItem)(args, 0);
    if (object) {
        init_input(&new_input);
        if (!prepare_input((PyObject*)iter->automaton, object, &new_input)) {
            return NULL;
        }
    }
    else
        return NULL;

    // second argument - optional bool
    flag = F(PyTuple_GetItem)(args, 1);
    if (flag) {
        switch (PyObject_IsTrue(flag)) {
            case 0:
                reset = false;
                break;
            case 1:
                reset = true;
                break;
            default:
                return NULL;
        }
    }
    else {
        PyErr_Clear();
        reset = false;
    }

    destroy_input(&iter->input);
    assign_input(&iter->input, &new_input);

    if (!reset) {
        position = iter->index;
#ifdef VARIABLE_LEN_CHARCODES
        if (iter->automaton->key_type == KEY_STRING) {
            position = iter->position;
        }
#endif
        iter->shift += (position >= 0) ? position : 0;
    }

    iter->index     = -1;
    iter->end       = new_input.wordlen;

    if (reset) {
        iter->state  = iter->automaton->root;
        iter->shift  = 0;
        iter->output = NULL;
#ifdef VARIABLE_LEN_CHARCODES
        iter->position = -1;
        iter->expected = pyaho_UCS2_Any;
#endif
    }

    Py_RETURN_NONE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3140
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x9d19
leaq -0x58(%rbp), %rdi
callq 0x3500
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x3530
testb $0x1, %al
jne 0x9d17
movq $0x0, -0x8(%rbp)
jmp 0x9e34
jmp 0x9d26
movq $0x0, -0x8(%rbp)
jmp 0x9e34
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x3140
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x9d78
movq -0x28(%rbp), %rdi
callq 0x3250
movl %eax, %ecx
movl %ecx, -0x5c(%rbp)
testl %eax, %eax
je 0x9d5d
jmp 0x9d53
movl -0x5c(%rbp), %eax
subl $0x1, %eax
je 0x9d63
jmp 0x9d69
movb $0x0, -0x31(%rbp)
jmp 0x9d76
movb $0x1, -0x31(%rbp)
jmp 0x9d76
movq $0x0, -0x8(%rbp)
jmp 0x9e34
jmp 0x9d81
callq 0x3190
movb $0x0, -0x31(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x3a40
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
leaq -0x58(%rbp), %rsi
callq 0x3ad0
testb $0x1, -0x31(%rbp)
jne 0x9dda
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jl 0x9dc2
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x9dca
xorl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0x9dca
movq -0x68(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x58(%rax), %rcx
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rax
movq $-0x1, 0x50(%rax)
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
testb $0x1, -0x31(%rbp)
je 0x9e24
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
movq 0x8195(%rip), %rdi      # 0x11fc0
callq 0x4a30
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nop