// File: /workspace/github_c_makefile_star2_O0/sasairc[P]clangsay/src/libbenly/src/file.c
// Function: load_file_to_array
int load_file_to_array(char*** dest, size_t th_x, size_t th_y, FILE* fp)
{
    int     c       = 0,
            status  = 0;

    size_t  x       = 0,
            y       = 0;

    char*   tmp     = NULL,
        **  buf     = NULL;

    if ((tmp = (char*)
                malloc(sizeof(char) * th_x)) == NULL) {
        status = -1; goto ERR;
    } else {
        memset(tmp, '\0', th_x);
    }
    if ((buf = (char**)
                malloc(sizeof(char*) * th_y)) == NULL) {
        status = -2; goto ERR;
    }
    while (1) {
        c = fgetc(fp);
        switch (c) {
            case    '\n':
            case    EOF:
                /* no data */
                if (c == EOF && x == 0 && y == 0) {
                    if (tmp != NULL) {
                        free(tmp);
                        tmp = NULL;
                    }
                    if (buf != NULL) {
                        free(buf);
                        buf = NULL;
                    }
                    return 0;
                }
                if (y >= th_y) {
                    th_y += th_y;
                    if ((buf = (char**)
                                realloc(buf, sizeof(char*) * th_y)) == NULL) {
                        status = -3; goto ERR;
                    }
                }
                if ((*(buf + y) = (char*)
                            malloc(sizeof(char) * (x + 1))) == NULL) {
                    status = -4; goto ERR;
                } else {
                    memcpy(*(buf + y), tmp, x);
                    *(*(buf + y) + x) = '\0';
                    memset(tmp, '\0', th_x);
                }
                if (c == '\n') {
                    x = 0;
                    y++;
                } else if (c == EOF) {
                    goto ENDLOOP;
                }
                break;
            default:
                if (x >= th_x) {
                    th_x += th_x;
                    if ((tmp = (char*)
                                realloc(tmp, sizeof(char) * th_x)) == NULL) {
                        status = -5; goto ERR;
                    }
                }
                *(tmp + x) = c;
                x++;
                break;
        }
    }

ENDLOOP:
    if (tmp != NULL)
        free(tmp);

    *(buf + y) = NULL;
    *dest = buf;

    return y;

ERR:
    switch (status) {
        case    -5:
        case    -4:
        case    -3:
            if (buf != NULL)
        case    -2:
            if (tmp != NULL)
                free(tmp);
        case    -1:
            break;
    }

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x18(%rbp), %rdi
shlq $0x0, %rdi
callq 0x1090
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x1249
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
jmp 0x1457
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rdx
xorl %esi, %esi
callq 0x1050
movq -0x20(%rbp), %rdi
shlq $0x3, %rdi
callq 0x1090
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x127b
movl $0xfffffffe, -0x30(%rbp) # imm = 0xFFFFFFFE
jmp 0x1457
jmp 0x127d
movq -0x28(%rbp), %rdi
callq 0x1060
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x54(%rbp)
subl $-0x1, %eax
je 0x12a4
jmp 0x1296
movl -0x54(%rbp), %eax
subl $0xa, %eax
jne 0x13c6
jmp 0x12a4
cmpl $-0x1, -0x2c(%rbp)
jne 0x12f4
cmpq $0x0, -0x38(%rbp)
jne 0x12f4
cmpq $0x0, -0x40(%rbp)
jne 0x12f4
cmpq $0x0, -0x48(%rbp)
je 0x12d0
movq -0x48(%rbp), %rdi
callq 0x1030
movq $0x0, -0x48(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x12e8
movq -0x50(%rbp), %rdi
callq 0x1030
movq $0x0, -0x50(%rbp)
movl $0x0, -0x4(%rbp)
jmp 0x14a0
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jb 0x1333
movq -0x20(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rsi
shlq $0x3, %rsi
callq 0x10a0
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0x1331
movl $0xfffffffd, -0x30(%rbp) # imm = 0xFFFFFFFD
jmp 0x1457
jmp 0x1333
movq -0x38(%rbp), %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1090
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x1362
movl $0xfffffffc, -0x30(%rbp) # imm = 0xFFFFFFFC
jmp 0x1457
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x1070
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rdx
xorl %esi, %esi
callq 0x1050
cmpl $0xa, -0x2c(%rbp)
jne 0x13ba
movq $0x0, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x13c4
cmpl $-0x1, -0x2c(%rbp)
jne 0x13c2
jmp 0x1423
jmp 0x13c4
jmp 0x141e
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jb 0x1402
movq -0x18(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
shlq $0x0, %rsi
callq 0x10a0
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x1400
movl $0xfffffffb, -0x30(%rbp) # imm = 0xFFFFFFFB
jmp 0x1457
jmp 0x1402
movl -0x2c(%rbp), %eax
movb %al, %dl
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x127d
cmpq $0x0, -0x48(%rbp)
je 0x1433
movq -0x48(%rbp), %rdi
callq 0x1030
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x14a0
movl -0x30(%rbp), %eax
movl %eax, -0x58(%rbp)
addl $0x5, %eax
subl $0x3, %eax
jb 0x147b
jmp 0x1467
movl -0x58(%rbp), %eax
subl $-0x2, %eax
je 0x1484
jmp 0x1471
movl -0x58(%rbp), %eax
subl $-0x1, %eax
je 0x1498
jmp 0x149a
cmpq $0x0, -0x50(%rbp)
je 0x1496
jmp 0x1484
cmpq $0x0, -0x48(%rbp)
je 0x1494
movq -0x48(%rbp), %rdi
callq 0x1030
jmp 0x1496
jmp 0x1498
jmp 0x149a
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)