// File: /workspace/github_c_makefile_star2_O0/sasairc[P]yasuna/src/libpolyaness/src/polyaness.c
// Function: init_polyaness
int init_polyaness(FILE* fp, int offset, polyaness_t** polyaness)
{
    if (fp == NULL)
        return -1;

    int             i       = 0,
                    j       = 0,
                    code    = 0,
                    recs    = 0;

    short           status  = 0;

    polyaness_t*    pt      = NULL;

    rewind(fp);
    while ((code = fgetc(fp)) != EOF) {
        if (code == LF) {
            if (offset > 0) {
                offset--;
                continue;
            }
            recs++;
        }
    }

    if ((pt = (polyaness_t*)
            malloc(sizeof(polyaness_t))) == NULL) {
        status = -1; goto ERR;
    }
    if ((pt->record = (polyaness_cell**)
            malloc(sizeof(polyaness_cell*) * (recs + 1))) == NULL) {
        status = -2; goto ERR;
    }

    pt->recs = recs;
    j = recs;
    while (i <= j) {
        if ((pt->record[i] = (polyaness_cell*)
                malloc(sizeof(polyaness_cell))) == NULL) {
            status = -3; goto ERR;
        }
        pt->record[i]->key = NULL;
        pt->record[i]->key = NULL;

        if ((pt->record[j] = (polyaness_cell*)
                malloc(sizeof(polyaness_cell))) == NULL) {
            status = -4; goto ERR;
        }
        pt->record[j]->key = NULL;
        pt->record[j]->key = NULL;

        i++;
        j--;
    }
    *polyaness = pt;

    return 0;

ERR:
    switch (status) {
        case    -1:
        case    -2:
        case    -3:
        case    -4:
            fprintf(stderr, "polyaness: init_polyaness(): malloc(): %s\n",
                    strerror(errno));
            break;
    }

    if (pt->record != NULL) {
        while (i >= 0) {
            if (pt->record[i] != NULL) {
                free(pt->record[i]);
                pt->record[i] = NULL;
            }
            i--;
        }
        free(pt->record);
        pt->record = NULL;
    }
    if (pt != NULL) {
        free(pt);
        pt = NULL;
    }

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xf866
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xfae1
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movw $0x0, -0x32(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2250
movq -0x10(%rbp), %rdi
callq 0x21c0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
je 0xf8cc
cmpl $0xa, -0x2c(%rbp)
jne 0xf8ca
cmpl $0x0, -0x14(%rbp)
jle 0xf8c1
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xf899
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xf899
movl $0x10, %edi
callq 0x20e0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0xf8eb
movw $0xffff, -0x32(%rbp)    # imm = 0xFFFF
jmp 0xfa12
movl -0x30(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x20e0
movq -0x40(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0xf916
movw $0xfffe, -0x32(%rbp)    # imm = 0xFFFE
jmp 0xfa12
movl -0x30(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movl -0x30(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jg 0xf9fb
movl $0x18, %edi
callq 0x20e0
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x24(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0xf95c
movw $0xfffd, -0x32(%rbp)    # imm = 0xFFFD
jmp 0xfa12
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
movl $0x18, %edi
callq 0x20e0
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq -0x28(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0xf9b4
movw $0xfffc, -0x32(%rbp)    # imm = 0xFFFC
jmp 0xfa12
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xf925
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xfae1
movswl -0x32(%rbp), %eax
addl $0x4, %eax
subl $0x3, %eax
ja 0xfa4f
jmp 0xfa20
movq 0x65b9(%rip), %rax      # 0x15fe0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x2300
movl (%rax), %edi
callq 0x2220
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x26cf(%rip), %rsi      # 0x12117
movb $0x0, %al
callq 0x23a0
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xfac2
jmp 0xfa5c
cmpl $0x0, -0x24(%rbp)
jl 0xfaa9
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0xfa9e
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2170
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xfa5c
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2170
movq -0x40(%rbp), %rax
movq $0x0, 0x8(%rax)
cmpq $0x0, -0x40(%rbp)
je 0xfada
movq -0x40(%rbp), %rdi
callq 0x2170
movq $0x0, -0x40(%rbp)
movswl -0x32(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)