// File: /workspace/github_c_makefile_star2_O2/sasairc[P]clangsay/src/msg.c
// Function: read_msg
static
int read_msg(MSG** msg, int argc, int optind, char** argv)
{
    int     status  = 0;

    if ((*msg)->data != NULL) {
        free2d((*msg)->data, (*msg)->lines);
        (*msg)->lines = 0;
        (*msg)->data = NULL;
    }
    if (optind < argc) {    
        if (((*msg)->data = (char**)
                    smalloc(sizeof(char*) * (argc - optind), NULL)) == NULL) {
            status = -1; goto ERR;
        }
        while (optind < argc) {
            if ((*((*msg)->data + (*msg)->lines) = (char*)
                    smalloc(sizeof(char) * (strlen(*(argv + optind)) + 1), NULL)) == NULL) {
                status = -2; goto ERR;
            }
            memcpy(*((*msg)->data + (*msg)->lines),
                    *(argv + optind), strlen(*(argv + optind)) + 1);
            (*msg)->lines++;
            optind++;
        }
    } else {
        if (((*msg)->lines =
                    load_file_to_array(&(*msg)->data, TH_LINES, TH_LENGTH, stdin)) < 0) {
            status = -3; goto ERR;
        }
    }
    /* remove escape sequence */
    strunsecs(msg);

    return 0;

ERR:
    switch (status) {
        case    -1:
        case    -2:
            break;
        case    -3:
            fprintf(stderr, "%s: read_string(): load_file_to_array(): %s\n",
                    PROGNAME, strerror(errno));
            break;
    }

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x9f92
movl 0x8(%rax), %esi
callq 0x448f
movq (%rbx), %rax
andl $0x0, 0x8(%rax)
andq $0x0, (%rax)
movl %ebp, %eax
subl %r14d, %eax
jle 0xa02c
movslq %eax, %rdi
shlq $0x3, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x4294
movq (%rbx), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0xa087
movslq %r14d, %r14
movslq %ebp, %rbp
cmpq %rbp, %r14
jge 0xa08b
movq (%r15,%r14,8), %rdi
callq 0x21b0
leaq 0x1(%rax), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x4294
movq (%rbx), %rcx
movq (%rcx), %rdx
movslq 0x8(%rcx), %rcx
movq %rax, (%rdx,%rcx,8)
testq %rax, %rax
je 0xa0cf
movq (%rbx), %rax
movq (%rax), %rcx
movslq 0x8(%rax), %rax
movq (%rcx,%rax,8), %r12
movq (%r15,%r14,8), %r13
movq %r13, %rdi
callq 0x21b0
leaq 0x1(%rax), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2470
movq (%rbx), %rax
incl 0x8(%rax)
incq %r14
jmp 0x9fc2
movq (%rbx), %rdi
movq 0x6f8a(%rip), %rax      # 0x10fc0
movq (%rax), %rcx
movl $0x100, %esi            # imm = 0x100
movl $0x200, %edx            # imm = 0x200
callq 0x374c
movq (%rbx), %rcx
movl %eax, 0x8(%rcx)
testl %eax, %eax
jns 0xa091
movq 0x6f87(%rip), %rax      # 0x10fe0
movq (%rax), %rbx
callq 0x2390
movl (%rax), %edi
callq 0x2280
leaq 0x1780(%rip), %rsi      # 0xb7ef
leaq 0x11a7(%rip), %rdx      # 0xb21d
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x2450
pushq $-0x3
jmp 0xa0d1
pushq $-0x1
jmp 0xa0d1
movq (%rbx), %rax
movl 0x8(%rax), %eax
movslq %eax, %r14
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq %r14, %r15
jge 0xa0d3
movq (%rbx), %rax
movslq 0x8(%rax), %rcx
cmpq %rcx, %r15
jge 0xa0d3
movq (%rax), %rax
movq (%rax,%r15,8), %rdi
callq 0x54c2
movq (%rbx), %rax
movq (%rax), %rax
movq -0x8(%rax,%r14,8), %rdi
callq 0x54c2
incq %r15
decq %r14
jmp 0xa09a
pushq $-0x2
popq %r12
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq