// File: /workspace/github_c_makefile_star2_O2/WojciechMula[P]pyahocorasick/src/custompickle/load/loadbuffer.c
// Function: loadbuffer_init
int
loadbuffer_init(LoadBuffer* input, CustompickleHeader* header, CustompickleFooter* footer) {

    long pos;
    int ret;

    ASSERT(input != NULL);
    ASSERT(header != NULL);
    ASSERT(footer != NULL);

    ret = loadbuffer_loadinto(input, header, CustompickleHeader);
    if (UNLIKELY(!ret)) {
        return 0;
    }

    pos = ftell(input->file);
    if (UNLIKELY(pos < 0)) {
        PyErr_SetFromErrno(PyExc_IOError);
        return 0;
    }

    ret = fseek(input->file, -(long int)sizeof(CustompickleFooter), SEEK_END);
    if (UNLIKELY(ret < 0)) {
        PyErr_SetFromErrno(PyExc_IOError);
        return 0;
    }

    ret = loadbuffer_loadinto(input, footer, CustompickleFooter);
    if (UNLIKELY(!ret)) {
        return 0;
    }

    ret = fseek(input->file, pos, SEEK_SET);
    if (UNLIKELY(ret < 0)) {
        PyErr_SetFromErrno(PyExc_IOError);
        return 0;
    }

    if (UNLIKELY(!custompickle_validate_header(header))) {
        PyErr_Format(PyExc_ValueError, "invalid header");
        return 0;
    }

    if (UNLIKELY(!custompickle_validate_footer(footer))) {
        PyErr_Format(PyExc_ValueError, "invalid footer");
        return 0;
    }

    input->store    = header->data.store;
    input->kind     = header->data.kind;
    input->size     = 0;
    input->capacity = footer->nodes_count;
    input->lookup   = (AddressPair*)memory_alloc(sizeof(AddressPair) * input->capacity);
    if (UNLIKELY(input->lookup == NULL)) {
        PyErr_NoMemory();
        return 0;
    }

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x4294
movq %rsi, %r15
testq %rsi, %rsi
je 0x42be
movq %rdx, %r14
testq %rdx, %rdx
je 0x42e8
movq %rdi, %rbx
pushq $0x30
popq %rdx
movq %r15, %rsi
callq 0x40a0
xorl %ebp, %ebp
testl %eax, %eax
je 0x4240
movq 0x8(%rbx), %rdi
callq 0x31c0
testq %rax, %rax
js 0x424b
movq %rax, %r12
movq 0x8(%rbx), %rdi
pushq $-0x18
popq %rsi
pushq $0x2
popq %rdx
callq 0x3260
testl %eax, %eax
js 0x424b
pushq $0x18
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40a0
testl %eax, %eax
je 0x4240
movq 0x8(%rbx), %rdi
xorl %ebp, %ebp
movq %r12, %rsi
xorl %edx, %edx
callq 0x3260
testl %eax, %eax
js 0x424b
movq %r15, %rdi
callq 0x3aad
testl %eax, %eax
je 0x425c
movq %r14, %rdi
callq 0x3b7f
testl %eax, %eax
je 0x426f
movq 0x10(%r15), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0x10(%rbx)
andq $0x0, 0x20(%rbx)
movq (%r14), %rdi
movq %rdi, 0x28(%rbx)
shlq $0x4, %rdi
callq 0x3370
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x428b
pushq $0x1
popq %rbp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x9d4e(%rip), %rax      # 0xdfa0
movq (%rax), %rdi
callq 0x3090
jmp 0x4240
movq 0x9d25(%rip), %rax      # 0xdf88
movq (%rax), %rdi
leaq 0x409a(%rip), %rsi      # 0x8307
jmp 0x4280
movq 0x9d12(%rip), %rax      # 0xdf88
movq (%rax), %rdi
leaq 0x4096(%rip), %rsi      # 0x8316
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3300
jmp 0x4240
callq 0x30e0
xorl %ebp, %ebp
jmp 0x4240
movq 0x9d5d(%rip), %rbx      # 0xdff8
movq (%rbx), %rdi
leaq 0x3d8b(%rip), %rsi      # 0x8030
leaq 0x3fb8(%rip), %rdx      # 0x8264
leaq 0x4044(%rip), %rcx      # 0x82f7
leaq 0x3fdd(%rip), %r9       # 0x8297
pushq $0x35
jmp 0x4310
movq 0x9d33(%rip), %rbx      # 0xdff8
movq (%rbx), %rdi
leaq 0x3d61(%rip), %rsi      # 0x8030
leaq 0x3f8e(%rip), %rdx      # 0x8264
leaq 0x401a(%rip), %rcx      # 0x82f7
leaq 0x3de5(%rip), %r9       # 0x80c9
pushq $0x36
jmp 0x4310
movq 0x9d09(%rip), %rbx      # 0xdff8
movq (%rbx), %rdi
leaq 0x3d37(%rip), %rsi      # 0x8030
leaq 0x3f64(%rip), %rdx      # 0x8264
leaq 0x3ff0(%rip), %rcx      # 0x82f7
leaq 0x3dfb(%rip), %r9       # 0x8109
pushq $0x37
popq %r8
xorl %eax, %eax
callq 0x31b0
movq (%rbx), %rdi
callq 0x3230
pushq $0x1
popq %rdi
callq 0x3310