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

    int     code    = 0,
            recs    = 0;

    short   status  = 0;

    char*   buf     = NULL;

    size_t  len     = 0,
            x_bufl  = BUFLEN;

    if ((buf = (char*)
            malloc(sizeof(char) * x_bufl)) == NULL) {
        status = -1; goto ERR;
    }

    rewind(fp);
    while ((code = fgetc(fp)) != EOF) {
        if (code == LF) {
            if (offset > 0) {
                offset--;
                continue;
            }
            if (add_data_polyaness(recs, count_keys(buf), buf, &polyaness) < 0) {
                status = -2; goto ERR;
            }
            memset(buf, '\0', x_bufl);
            recs++;
            len = 0;
        } else {
            if (offset > 0)
                continue;
            if (len == (x_bufl - 1)) {
                x_bufl += BUFLEN;
                if ((buf = (char*)
                        realloc(buf, sizeof(char) * x_bufl)) == NULL) {
                    status = -3; goto ERR;
                }
            }
            *(buf + len) = code;
            len++;
        }
    }
    free(buf);

    return 0;

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

    if (buf != NULL) {
        free(buf);
        buf = NULL;
    }

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
pushq $-0x1
popq %r14
testq %rdi, %rdi
je 0x94ab
movq %rdx, %rbx
cmpq $0x0, (%rdx)
je 0x94ab
movl %esi, %ebp
movq %rdi, %r12
movl $0x1000, %r13d          # imm = 0x1000
movl $0x1000, %edi           # imm = 0x1000
callq 0x20e0
testq %rax, %rax
je 0x94bd
movq %rax, (%rsp)
movq %r12, %rdi
callq 0x2270
movq $0x0, 0x28(%rsp)
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x21e0
cmpl $-0x1, %eax
je 0x949c
movl %eax, %r14d
cmpl $0xa, %eax
je 0x92ce
testl %ebp, %ebp
jg 0x9283
leaq -0x1(%r13), %rax
cmpq %rax, %r15
jne 0x9481
addq $0x1000, %r13           # imm = 0x1000
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x23c0
testq %rax, %rax
jne 0x9485
jmp 0x9596
testl %ebp, %ebp
jg 0x9495
movq (%rsp), %r15
movq %r15, %rax
pushq $0x1
popq %rdx
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x92ee
testl %ecx, %ecx
jne 0x92f0
jmp 0x92f5
incl %edx
incq %rax
jmp 0x92e0
movq %r13, 0x38(%rsp)
movq %r12, 0x40(%rsp)
movl %ebp, 0x24(%rsp)
movl %edx, 0xc(%rsp)
movslq %edx, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x20e0
movq %rax, %r13
movq %r14, %rdi
callq 0x20e0
testq %rax, %rax
sete %r12b
xorl %ebp, %ebp
movq %r13, 0x10(%rsp)
testq %r13, %r13
sete %r13b
movq %rax, 0x18(%rsp)
je 0x94fb
testq %rax, %rax
je 0x94fb
movq %rbx, 0x30(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %ebx, %ebx
movl 0xc(%rsp), %ecx
cmpl %ecx, %ebp
jge 0x941f
movzbl (%r15,%r13), %eax
movslq %ebp, %r15
testl %eax, %eax
je 0x93c3
cmpl $0x9, %eax
je 0x93c3
cmpl $0x3a, %eax
jne 0x9413
movq %r13, %r12
subq %rbx, %r12
leaq 0x1(%r12), %rdi
callq 0x20e0
movq %rax, %r14
movq 0x10(%rsp), %rax
movq %r14, (%rax,%r15,8)
testq %r14, %r14
je 0x94f1
movq (%rsp), %r15
leaq (%r15,%rbx), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x2420
addq %r13, %r14
subq %rbx, %r14
movb $0x0, (%r14)
incq %r13
jmp 0x940a
movq %r13, %r12
subq %rbx, %r12
leaq 0x1(%r12), %rdi
callq 0x20e0
movq %rax, %r14
movq 0x18(%rsp), %rax
movq %r14, (%rax,%r15,8)
testq %r14, %r14
je 0x94f1
movq (%rsp), %r15
leaq (%r15,%rbx), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x2420
addq %r13, %r14
subq %rbx, %r14
movb $0x0, (%r14)
incq %r13
incl %ebp
movq %r13, %rbx
movl 0xc(%rsp), %ecx
jmp 0x9417
movq (%rsp), %r15
incq %r13
jmp 0x935a
movq 0x30(%rsp), %rbx
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq 0x28(%rsp), %r14
movslq %r14d, %r14
movq (%rax,%r14,8), %rax
movl %ecx, (%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq (%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%r14,8), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %r15, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %r13
movq %r13, %rdx
callq 0x2050
incl %r14d
movq %r14, 0x28(%rsp)
xorl %r15d, %r15d
movl 0x24(%rsp), %ebp
movq 0x40(%rsp), %r12
jmp 0x9283
movq (%rsp), %rax
movq %rax, (%rsp)
movb %r14b, (%rax,%r15)
incq %r15
jmp 0x9283
decl %ebp
jmp 0x9283
xorl %r14d, %r14d
movq (%rsp), %r15
movq %r15, %rdi
callq 0x2190
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x6b24(%rip), %rax      # 0xffe8
movq (%rax), %r14
callq 0x2340
movl (%rax), %edi
callq 0x2240
leaq 0x1c64(%rip), %rsi      # 0xb13e
xorl %r15d, %r15d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2400
pushq $-0x1
jmp 0x958f
xorl %r13d, %r13d
xorl %r12d, %r12d
movq (%rsp), %r15
movq 0x6ae6(%rip), %rbx      # 0xffe8
movq (%rbx), %r14
callq 0x2340
movl (%rax), %edi
callq 0x2240
leaq 0x1cbb(%rip), %rsi      # 0xb1d3
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2400
testb %r13b, %r13b
movq 0x18(%rsp), %r13
jne 0x9557
movl %ebp, %r14d
testl %r14d, %r14d
js 0x954d
movl %r14d, %eax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x2190
decl %r14d
jmp 0x9532
movq 0x10(%rsp), %rdi
callq 0x2190
testb %r12b, %r12b
jne 0x9578
testl %ebp, %ebp
js 0x9570
movl %ebp, %eax
movq (%r13,%rax,8), %rdi
callq 0x2190
decl %ebp
jmp 0x955c
movq %r13, %rdi
callq 0x2190
movq (%rbx), %rcx
leaq 0x1be8(%rip), %rdi      # 0xb16a
pushq $0x3b
popq %rsi
pushq $0x1
popq %rdx
callq 0x23b0
pushq $-0x2
popq %r14
jmp 0x94a3
movq 0x6a4b(%rip), %rax      # 0xffe8
movq (%rax), %r14
callq 0x2340
movl (%rax), %edi
callq 0x2240
leaq 0x1bf3(%rip), %rsi      # 0xb1a6
xorl %r15d, %r15d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2400
pushq $-0x3
jmp 0x958f