// File: /workspace/github_c_makefile_star2_O1/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 0xa320
movq %rdx, %r15
cmpq $0x0, (%rdx)
je 0xa320
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 0xa332
movq %rax, %r12
movq %r13, %rdi
callq 0x2270
movq $0x0, 0x30(%rsp)
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x21e0
cmpl $-0x1, %eax
je 0xa315
movl %eax, %r14d
cmpl $0xa, %eax
je 0xa16c
testl %ebp, %ebp
jg 0xa118
movq 0x18(%rsp), %rsi
leaq -0x1(%rsi), %rax
cmpq %rax, %rbx
jne 0xa163
addq $0x1000, %rsi           # imm = 0x1000
movq %r12, %rdi
movq %rsi, 0x18(%rsp)
callq 0x23b0
movq %rax, %r12
testq %rax, %rax
je 0xa410
movb %r14b, (%r12,%rbx)
incq %rbx
jmp 0xa118
testl %ebp, %ebp
jg 0xa30e
movl $0x1, %ebx
movq %r12, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0xa18a
testl %ecx, %ecx
jne 0xa18c
jmp 0xa191
incl %ebx
incq %rax
jmp 0xa17c
movq %r15, 0x40(%rsp)
movq %r13, 0x38(%rsp)
movslq %ebx, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x20e0
movq %rax, %r15
movq %r14, %rdi
callq 0x20e0
xorl %r13d, %r13d
movq %r15, 0x8(%rsp)
testq %r15, %r15
movq %rax, 0x20(%rsp)
je 0xa370
testq %rax, %rax
je 0xa370
movl %ebp, 0x2c(%rsp)
testl %ebx, %ebx
jle 0xa2b0
xorl %r15d, %r15d
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %r12, 0x10(%rsp)
movzbl (%r12,%rbp), %eax
testl %eax, %eax
je 0xa252
cmpl $0x9, %eax
je 0xa252
cmpl $0x3a, %eax
jne 0xa2a4
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 0xa36b
movq 0x10(%rsp), %rax
leaq (%rax,%r15), %rsi
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r12
callq 0x2410
addq %rbp, %r14
subq %r15, %r14
movb $0x0, (%r14)
incq %rbp
jmp 0xa2a1
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 0xa36b
movq 0x10(%rsp), %rax
leaq (%rax,%r15), %rsi
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r12
callq 0x2410
addq %rbp, %r14
subq %r15, %r14
movb $0x0, (%r14)
incq %rbp
incl %r13d
movq %rbp, %r15
incq %rbp
cmpl %ebx, %r13d
jl 0xa1ed
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 0xa118
decl %ebp
jmp 0xa118
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x2190
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %r12d, %r12d
movq 0x6ca6(%rip), %rax      # 0x10fe8
movq (%rax), %rdi
cmpl $-0x3, %r14d
je 0xa358
cmpl $-0x2, %r14d
jne 0xa35f
callq 0x26a4
jmp 0xa364
callq 0x267f
jmp 0xa364
callq 0x26b9
testq %r12, %r12
jne 0xa318
jmp 0xa320
movq 0x10(%rsp), %r12
movq 0x6c71(%rip), %rax      # 0x10fe8
movq (%rax), %r14
callq 0x2340
movl (%rax), %edi
callq 0x2240
leaq 0x1e62(%rip), %rsi      # 0xc1ef
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23f0
cmpq $0x0, 0x8(%rsp)
movq 0x20(%rsp), %r15
je 0xa3d5
testl %r13d, %r13d
js 0xa3cb
movl %r13d, %ebx
incq %rbx
movq 0x8(%rsp), %rax
movq -0x8(%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0xa3c6
callq 0x2190
decq %rbx
jg 0xa3b2
movq 0x8(%rsp), %rdi
callq 0x2190
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
testq %r15, %r15
je 0xa33b
testl %r13d, %r13d
js 0xa403
movl %r13d, %ebx
incq %rbx
movq -0x8(%r15,%rbx,8), %rdi
testq %rdi, %rdi
je 0xa3fe
callq 0x2190
decq %rbx
jg 0xa3ef
movq %r15, %rdi
callq 0x2190
jmp 0xa33b
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
jmp 0xa338