// File: /workspace/github_c_makefile_star2_O1/sasairc[P]clangsay/src/msg.c
// Function: print_msg
static
int print_msg(MSG* msg)
{
    int         i       = 0,
                j       = 0,
                len     = 0,
                maxlen  = 0;

#ifdef  WITH_REGEX
    int     status      = 0;

    char    errstr[128] = {'\0'};

    regex_t reg;

    /* compile regex */
    if ((status = regcomp(&reg, ANSI_ESCSEQ, REG_EXTENDED)) != 0) {
        fprintf(stdout, "error");
        regerror(status, &reg, errstr, sizeof(errstr));
        fprintf(stderr, "%s: regcomp(): %s\n",
                PROGNAME, errstr);

        return -1;
    }
    /* get max length */
    maxlen = strmax_with_regex(msg->lines, msg->data, &reg);
#else
    maxlen = strmax(msg->lines, msg->data);
/* WITH_REGEX */
#endif

    /*
     * single line
     */
    putchar(' ');
    i = maxlen;
    while (i >= 0) {
        putchar('_');
        i--;
    }
    if (msg->lines == 1) {
        fprintf(stdout, "\n< %s >\n ",
                *(msg->data));

        while (maxlen >= 0) {
            putchar('-');
            maxlen--;
        }
        puts("");

        return 0;
    }

    /*
     * multi line
     */
    i = 0;
    while (i < msg->lines) {
#ifdef  WITH_REGEX
        len = mbstrlen_with_regex(*(msg->data + i), &reg);
#else
        len = mbstrlen(*(msg->data + i));
/* WITH_REGEX */
#endif
        if (i == 0)
            fprintf(stdout, "\n/ %s",
                    *(msg->data + i));
        else if (i == (msg->lines - 1))
            fprintf(stdout, "\\ %s",
                    *(msg->data + i));
        else
            fprintf(stdout, "| %s",
                    *(msg->data + i));

        j = maxlen - len;
        while (j > 0) {
            putchar(' ');
            j--;
        }

        if (i == 0)
            puts(" \\");
        else if (i == (msg->lines - 1))
            fprintf(stdout, " /\n ");
        else
            puts(" |");

        i++;
    }
    while (maxlen >= 0) {
        putchar('-');
        maxlen--;
    }
    puts("");
#ifdef  WITH_REGEX
    regfree(&reg);
/* WITH_REGEX */
#endif

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
leaq 0x1038(%rip), %rsi      # 0xc0c1
leaq 0x10(%rsp), %rdi
movl $0x1, %edx
callq 0x2300
testl %eax, %eax
jne 0xb245
movl 0x8(%r14), %edi
movq (%r14), %rsi
leaq 0x10(%rsp), %rdx
callq 0x6546
movl %eax, %ebx
movl $0x20, %edi
callq 0x20d0
testl %ebx, %ebx
js 0xb0d4
leal 0x1(%rbx), %ebp
movl $0x5f, %edi
callq 0x20d0
decl %ebp
testl %ebp, %ebp
jg 0xb0c4
cmpl $0x1, 0x8(%r14)
jne 0xb120
movq 0x5f0e(%rip), %rax      # 0x10ff0
movq (%rax), %rdi
movq (%r14), %rax
movq (%rax), %rdx
leaq 0x1771(%rip), %rsi      # 0xc863
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2440
testl %ebx, %ebx
js 0xb111
incl %ebx
movl $0x2d, %edi
callq 0x20d0
decl %ebx
testl %ebx, %ebx
jg 0xb101
movl $0xa, %edi
callq 0x20d0
jmp 0xb231
cmpl $0x0, 0x8(%r14)
jle 0xb205
leal 0x1(%rbx), %eax
movl %eax, 0xc(%rsp)
movq 0x5eb7(%rip), %r13      # 0x10ff0
xorl %r15d, %r15d
movq (%r14), %rax
movq (%rax,%r15,8), %rdi
leaq 0x10(%rsp), %rsi
callq 0x644f
movl %eax, %ebp
testq %r15, %r15
je 0xb173
movl 0x8(%r14), %eax
decl %eax
movq (%r13), %rdi
movq (%r14), %rcx
movq (%rcx,%r15,8), %rdx
cmpq %rax, %r15
jne 0xb187
leaq 0x1702(%rip), %rsi      # 0xc873
jmp 0xb18e
movq (%r13), %rdi
movq (%r14), %rax
movq (%rax,%r15,8), %rdx
leaq 0x16e8(%rip), %rsi      # 0xc86d
jmp 0xb18e
leaq 0x16ea(%rip), %rsi      # 0xc878
xorl %eax, %eax
callq 0x2440
cmpl %ebp, %ebx
jle 0xb1b4
movl 0xc(%rsp), %r12d
subl %ebp, %r12d
movl $0x20, %edi
callq 0x20d0
decl %r12d
cmpl $0x1, %r12d
jg 0xb1a1
testq %r15, %r15
je 0xb1e0
movl 0x8(%r14), %eax
decl %eax
cmpq %rax, %r15
jne 0xb1e9
movq (%r13), %rcx
movl $0x4, %esi
movl $0x1, %edx
leaq 0x16a7(%rip), %rdi      # 0xc880
callq 0x2400
jmp 0xb1f5
leaq 0x1696(%rip), %rdi      # 0xc87d
jmp 0xb1f0
leaq 0x1695(%rip), %rdi      # 0xc885
callq 0x2080
incq %r15
movslq 0x8(%r14), %rax
cmpq %rax, %r15
jl 0xb13c
testl %ebx, %ebx
js 0xb21b
incl %ebx
movl $0x2d, %edi
callq 0x20d0
decl %ebx
testl %ebx, %ebx
jg 0xb20b
movl $0xa, %edi
callq 0x20d0
leaq 0x10(%rsp), %rdi
callq 0x23b0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movl %eax, %edi
callq 0x2936
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xb231