// File: /workspace/github_c_makefile_star2_O2/WojciechMula[P]pyahocorasick/src/Automaton_pickle.c
// Function: pickle_dump_save
static int
pickle_dump_save(TrieNode* node, const int depth, void* extra) {
#define self ((PickleData*)extra)
#define NODEID(object) ((NodeID*)((TrieNode*)object)->fail)

    TrieNode* dump;
    TrieNode* tmp;
    Pair* arr;
    unsigned i;
    size_t size;

    size = get_pickled_size(node);
    if (UNLIKELY(self->top + size > self->size)) {
        if (UNLIKELY(!pickle_data__add_next_buffer(self))) {
            self->error = true;
            return 0;
        }
    }

    dump = (TrieNode*)(self->data + self->top);

    // we do not save the last pointer in array
    arr = (Pair*)(self->data + self->top + PICKLE_TRIENODE_SIZE);

    // append the python object to the list
    if (node->eow and self->values) {
        if (PyList_Append(self->values, node->output.object) == -1) {
            self->error = true;
            return 0;
        }
    }

    // save node data
    if (self->values)
        dump->output.integer = 0;
    else
        dump->output.integer = node->output.integer;

    dump->n         = node->n;
    dump->eow       = node->eow;

    tmp = NODEID(node)->fail;
    if (tmp)
        dump->fail  = (TrieNode*)(NODEID(tmp)->id);
    else
        dump->fail  = NULL;

    // save array of pointers
    for (i=0; i < node->n; i++) {
        TrieNode* child = trienode_get_ith_unsafe(node, i);
        ASSERT(child);
        arr[i].child  = (TrieNode*)(NODEID(child)->id);    // save the id of child node
        arr[i].letter = trieletter_get_ith_unsafe(node, i);
    }

    self->top       += size;
    (*self->count)  += 1;
    return 1;
#undef NODEID
#undef self
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
callq 0x7c12
movq %rax, %r15
movq 0x28(%rbx), %r12
addq %r12, %rax
cmpq 0x10(%rbx), %rax
ja 0x7b99
movq 0x18(%rbx), %rbp
cmpb $0x0, 0x14(%r14)
je 0x7af9
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x7af9
movq (%r14), %rsi
callq 0x31a0
cmpl $-0x1, %eax
je 0x7bae
cmpq $0x0, 0x30(%rbx)
je 0x7b04
xorl %eax, %eax
jmp 0x7b07
movq (%r14), %rax
movq %rax, (%rbp,%r12)
movl 0x10(%r14), %r13d
movl %r13d, 0x10(%rbp,%r12)
movb 0x14(%r14), %al
movb %al, 0x14(%rbp,%r12)
movq 0x8(%r14), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x7b34
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
jmp 0x7b36
xorl %eax, %eax
addq %r12, %rbp
addq $0x1c, %rbp
movq %rax, -0x14(%rbp)
xorl %r12d, %r12d
cmpq %r13, %r12
jae 0x7b7c
movq %r14, %rdi
movq %r12, %rsi
callq 0x4c82
testq %rax, %rax
je 0x7bb6
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, (%rbp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x5bef
movl %eax, -0x4(%rbp)
incq %r12
addq $0xc, %rbp
jmp 0x7b44
addq %r15, 0x28(%rbx)
movq 0x20(%rbx), %rax
incq (%rax)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x7c65
testb %al, %al
je 0x7bae
movq 0x28(%rbx), %r12
jmp 0x7ad4
movb $0x1, 0x38(%rbx)
xorl %eax, %eax
jmp 0x7b8a
movq 0x643b(%rip), %rbx      # 0xdff8
movq (%rbx), %rdi
leaq 0x469(%rip), %rsi       # 0x8030
leaq 0x3148(%rip), %rdx      # 0xad16
leaq 0x31fe(%rip), %rcx      # 0xadd3
leaq 0x2aee(%rip), %r9       # 0xa6ca
movl $0xb2, %r8d
xorl %eax, %eax
callq 0x31b0
movq (%rbx), %rdi
callq 0x3230
pushq $0x1
popq %rdi
callq 0x3310