// File: /workspace/github_c_makefile_star2_O0/WojciechMula[P]pyahocorasick/src/custompickle/load/module_automaton_load.c
// Function: automaton_load_impl
static bool
automaton_load_impl(Automaton* automaton, const char* path, PyObject* deserializer) {

    TrieNode* root;
    LoadBuffer input;
    CustompickleHeader header;
    CustompickleFooter footer;
    size_t i;

    if (!loadbuffer_open(&input, path, deserializer)) {
        return false;
    }

    if (!loadbuffer_init(&input, &header, &footer)) {
        goto exception;
    }

    if (header.data.kind == TRIE || header.data.kind == AHOCORASICK) {
        for (i=0; i < input.capacity; i++) {
            if (UNLIKELY(!automaton_load_node(&input))) {
                goto exception;
            }
        }

        root = automaton_load_fixup_pointers(&input);
        if (UNLIKELY(root == NULL)) {
            goto exception;
        }
    } else if (header.data.kind == EMPTY) {

        root = NULL;

    } else {
        PyErr_SetString(PyExc_ValueError, "automaton kind save in file is invalid");
        goto exception;
    }

    loadbuffer_close(&input);

    // setup object
    automaton->kind          = header.data.kind;
    automaton->store         = header.data.store;
    automaton->key_type      = header.data.key_type;
    automaton->count         = header.data.words_count;
    automaton->longest_word  = header.data.longest_word;
    automaton->version       = 0;
    automaton->stats.version = -1;
    automaton->root          = root;

    return true;

exception:
    loadbuffer_close(&input);
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x4a50
cmpl $0x0, %eax
jne 0x5466
movb $0x0, -0x1(%rbp)
jmp 0x55a4
leaq -0x58(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x4d00
cmpl $0x0, %eax
jne 0x5487
jmp 0x5597
cmpl $0x1, -0x78(%rbp)
je 0x5493
cmpl $0x2, -0x78(%rbp)
jne 0x5507
movq $0x0, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x54de
leaq -0x58(%rbp), %rdi
callq 0x5e80
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x54c8
jmp 0x5597
jmp 0x54ca
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x549e
leaq -0x58(%rbp), %rdi
callq 0x6160
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x5505
jmp 0x5597
jmp 0x5531
cmpl $0x0, -0x78(%rbp)
jne 0x5517
movq $0x0, -0x28(%rbp)
jmp 0x552f
movq 0xca6a(%rip), %rax      # 0x11f88
movq (%rax), %rdi
leaq 0x7190(%rip), %rsi      # 0xc6b8
callq 0x3120
jmp 0x5597
jmp 0x5531
leaq -0x58(%rbp), %rdi
callq 0x50f0
movl -0x78(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x74(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x70(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x68(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl -0x60(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x38(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x55a4
leaq -0x58(%rbp), %rdi
callq 0x50f0
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)