// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4d67
movq 0xd2d6(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x72e4(%rip), %rsi      # 0xc010
leaq 0x7511(%rip), %rdx      # 0xc244
leaq 0x759d(%rip), %rcx      # 0xc2d7
movl $0x35, %r8d
leaq 0x7530(%rip), %r9       # 0xc277
movb $0x0, %al
callq 0x31b0
movq 0xd2a3(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
callq 0x3230
movl $0x1, %edi
callq 0x3310
jmp 0x4d69
jmp 0x4d6b
cmpq $0x0, -0x18(%rbp)
jne 0x4dbe
movq 0xd27f(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x728d(%rip), %rsi      # 0xc010
leaq 0x74ba(%rip), %rdx      # 0xc244
leaq 0x7546(%rip), %rcx      # 0xc2d7
movl $0x36, %r8d
leaq 0x730b(%rip), %r9       # 0xc0a9
movb $0x0, %al
callq 0x31b0
movq 0xd24c(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
callq 0x3230
movl $0x1, %edi
callq 0x3310
jmp 0x4dc0
jmp 0x4dc2
cmpq $0x0, -0x20(%rbp)
jne 0x4e15
movq 0xd228(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x7236(%rip), %rsi      # 0xc010
leaq 0x7463(%rip), %rdx      # 0xc244
leaq 0x74ef(%rip), %rcx      # 0xc2d7
movl $0x37, %r8d
leaq 0x72f4(%rip), %r9       # 0xc0e9
movb $0x0, %al
callq 0x31b0
movq 0xd1f5(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
callq 0x3230
movl $0x1, %edi
callq 0x3310
jmp 0x4e17
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x30, %edx
callq 0x4bb0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4e4e
movl $0x0, -0x4(%rbp)
jmp 0x505b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x31c0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4e8f
movq 0xd125(%rip), %rax      # 0x11fa0
movq (%rax), %rdi
callq 0x3090
movl $0x0, -0x4(%rbp)
jmp 0x505b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq $-0x18, %rsi
movl $0x2, %edx
callq 0x3260
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4eda
movq 0xd0da(%rip), %rax      # 0x11fa0
movq (%rax), %rdi
callq 0x3090
movl $0x0, -0x4(%rbp)
jmp 0x505b
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x18, %edx
callq 0x4bb0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4f11
movl $0x0, -0x4(%rbp)
jmp 0x505b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0x3260
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4f56
movq 0xd05e(%rip), %rax      # 0x11fa0
movq (%rax), %rdi
callq 0x3090
movl $0x0, -0x4(%rbp)
jmp 0x505b
movq -0x18(%rbp), %rdi
callq 0x4060
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4f98
movq 0xd00d(%rip), %rax      # 0x11f88
movq (%rax), %rdi
leaq 0x7362(%rip), %rsi      # 0xc2e7
movb $0x0, %al
callq 0x3300
movl $0x0, -0x4(%rbp)
jmp 0x505b
movq -0x20(%rbp), %rdi
callq 0x41f0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4fda
movq 0xcfcb(%rip), %rax      # 0x11f88
movq (%rax), %rdi
leaq 0x732f(%rip), %rsi      # 0xc2f6
movb $0x0, %al
callq 0x3300
movl $0x0, -0x4(%rbp)
jmp 0x505b
movq -0x18(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
shlq $0x4, %rdi
callq 0x3450
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x5054
callq 0x30e0
movl $0x0, -0x4(%rbp)
jmp 0x505b
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)