// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xafe0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
addq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
seta %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0xab32
movq -0x20(%rbp), %rdi
callq 0xb120
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0xab30
movq -0x20(%rbp), %rax
movb $0x1, 0x38(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xad12
jmp 0xab32
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
addq 0x28(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
addq 0x28(%rcx), %rax
addq $0x18, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x0, %eax
je 0xaba5
movq -0x20(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xaba5
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x31a0
cmpl $-0x1, %eax
jne 0xaba3
movq -0x20(%rbp), %rax
movb $0x1, 0x38(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xad12
jmp 0xaba5
movq -0x20(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xabbd
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
jmp 0xabcb
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movb 0x14(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x14(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xac13
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xac1f
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0xace9
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, %esi
callq 0x5dd0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xac9b
movq 0x73a2(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x13b0(%rip), %rsi      # 0xc010
leaq 0x4153(%rip), %rdx      # 0xedba
leaq 0x4250(%rip), %rcx      # 0xeebe
movl $0xb2, %r8d
leaq 0x3aa9(%rip), %r9       # 0xe724
movb $0x0, %al
callq 0x31b0
movq 0x736f(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
callq 0x3230
movl $0x1, %edi
callq 0x3310
jmp 0xac9d
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x4(%rax)
movq -0x10(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, %esi
callq 0x7410
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xac26
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)