// File: /workspace/github_c_makefile_star2_O3/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
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0xa136
movq %rdx, %r15
cmpq $0x0, (%rdx)
je 0xa136
movl %esi, %ebp
movq %rdi, %r13
movl $0x1000, %eax           # imm = 0x1000
movq %rax, 0x18(%rsp)
movl $0x1000, %edi           # imm = 0x1000
callq 0x20e0
testq %rax, %rax
je 0xa148
movq %rax, %r12
movq %r13, %rdi
callq 0x2270
movq $0x0, 0x30(%rsp)
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x21e0
cmpl $-0x1, %eax
je 0xa12b
movl %eax, %r14d
cmpl $0xa, %eax
je 0x9f77
testl %ebp, %ebp
jg 0x9f23
movq 0x18(%rsp), %rsi
leaq -0x1(%rsi), %rax
cmpq %rax, %rbx
jne 0x9f6e
addq $0x1000, %rsi           # imm = 0x1000
movq %r12, %rdi
movq %rsi, 0x18(%rsp)
callq 0x23c0
movq %rax, %r12
testq %rax, %rax
je 0xa21c
movb %r14b, (%r12,%rbx)
incq %rbx
jmp 0x9f23
testl %ebp, %ebp
jg 0xa124
movl $0x1, %ebx
movq %r12, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x9f95
testl %ecx, %ecx
jne 0x9f97
jmp 0x9f9c
incl %ebx
incq %rax
jmp 0x9f87
movq %r13, 0x38(%rsp)
movl %ebp, 0x2c(%rsp)
movq %r15, 0x40(%rsp)
movslq %ebx, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x20e0
movq %rax, %r15
movq %r14, %rdi
callq 0x20e0
testq %rax, %rax
sete %bpl
xorl %r13d, %r13d
movq %r15, 0x8(%rsp)
testq %r15, %r15
sete %r15b
movq %rax, 0x20(%rsp)
je 0xa159
testq %rax, %rax
je 0xa159
testl %ebx, %ebx
jle 0xa0c6
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %r12, 0x10(%rsp)
movzbl (%r12,%rbp), %eax
testl %eax, %eax
je 0xa068
cmpl $0x9, %eax
je 0xa068
cmpl $0x3a, %eax
jne 0xa0ba
movq %rbp, %r12
subq %r15, %r12
leaq 0x1(%r12), %rdi
callq 0x20e0
movq %rax, %r14
movslq %r13d, %rax
movq 0x8(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
testq %r14, %r14
je 0xa14f
movq 0x10(%rsp), %rax
leaq (%rax,%r15), %rsi
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r12
callq 0x2420
addq %rbp, %r14
subq %r15, %r14
movb $0x0, (%r14)
incq %rbp
jmp 0xa0b7
movq %rbp, %r12
subq %r15, %r12
leaq 0x1(%r12), %rdi
callq 0x20e0
movq %rax, %r14
movslq %r13d, %rax
movq 0x20(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
testq %r14, %r14
je 0xa14f
movq 0x10(%rsp), %rax
leaq (%rax,%r15), %rsi
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r12
callq 0x2420
addq %rbp, %r14
subq %r15, %r14
movb $0x0, (%r14)
incq %rbp
incl %r13d
movq %rbp, %r15
incq %rbp
cmpl %ebx, %r13d
jl 0xa003
movq 0x40(%rsp), %r15
movq (%r15), %rax
movq 0x8(%rax), %rax
movq 0x30(%rsp), %r14
movslq %r14d, %r14
movq (%rax,%r14,8), %rax
movl %ebx, (%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq (%r15), %rax
movq 0x8(%rax), %rax
movq (%rax,%r14,8), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq %r12, %rdi
xorl %esi, %esi
movq 0x18(%rsp), %rdx
callq 0x2050
incl %r14d
movq %r14, 0x30(%rsp)
xorl %ebx, %ebx
movl 0x2c(%rsp), %ebp
movq 0x38(%rsp), %r13
jmp 0x9f23
decl %ebp
jmp 0x9f23
movq %r12, %rdi
callq 0x2190
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2610
jmp 0xa136
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x10(%rsp), %r12
movq 0x6e88(%rip), %rbx      # 0x10fe8
movq (%rbx), %r14
callq 0x2340
movl (%rax), %edi
callq 0x2240
leaq 0x2099(%rip), %rsi      # 0xc20f
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2400
testb %r15b, %r15b
jne 0xa1b6
testl %r13d, %r13d
js 0xa1ac
movl %r13d, %r14d
incq %r14
movq 0x8(%rsp), %rax
movq -0x8(%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0xa1a7
callq 0x2190
decq %r14
jg 0xa193
movq 0x8(%rsp), %rdi
callq 0x2190
testb %bpl, %bpl
jne 0xa1e7
testl %r13d, %r13d
movq 0x20(%rsp), %r15
js 0xa1df
movl %r13d, %r14d
incq %r14
movq -0x8(%r15,%r14,8), %rdi
testq %rdi, %rdi
je 0xa1da
callq 0x2190
decq %r14
jg 0xa1cb
movq %r15, %rdi
callq 0x2190
movq (%rbx), %rcx
leaq 0x1fb5(%rip), %rdi      # 0xc1a6
movl $0x3b, %esi
movl $0x1, %edx
callq 0x23b0
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
testq %r12, %r12
je 0xa136
movq %r12, %rdi
callq 0x2190
jmp 0xa136
callq 0x25e4
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jmp 0xa136