// File: /workspace/github_c_makefile_star2_O3/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 0x127b(%rip), %rsi      # 0xc0c1
leaq 0x10(%rsp), %rdi
movl $0x1, %edx
callq 0x2300
testl %eax, %eax
jne 0xaff8
movl 0x8(%r14), %edi
movq (%r14), %rsi
leaq 0x10(%rsp), %rdx
callq 0x6401
movl %eax, %ebx
movl $0x20, %edi
callq 0x20d0
testl %ebx, %ebx
js 0xae8f
leal 0x1(%rbx), %ebp
movl $0x5f, %edi
callq 0x20d0
decl %ebp
jne 0xae81
movl 0x8(%r14), %eax
cmpl $0x1, %eax
jne 0xaedb
movq 0x6151(%rip), %rax      # 0x10ff0
movq (%rax), %rdi
movq (%r14), %rax
movq (%rax), %rdx
leaq 0x19c2(%rip), %rsi      # 0xc871
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x2450
testl %ebx, %ebx
js 0xaecc
incl %ebx
movl $0x2d, %edi
callq 0x20d0
decl %ebx
jne 0xaebe
movl $0xa, %edi
callq 0x20d0
jmp 0xafe4
jl 0xafba
leal 0x1(%rbx), %eax
movl %eax, 0xc(%rsp)
movq 0x6101(%rip), %r13      # 0x10ff0
xorl %r15d, %r15d
movq (%r14), %rax
movq (%rax,%r15,8), %rdi
leaq 0x10(%rsp), %rsi
callq 0x630a
movl %eax, %ebp
testq %r15, %r15
je 0xaf29
movl 0x8(%r14), %eax
decl %eax
movq (%r13), %rdi
movq (%r14), %rcx
movq (%rcx,%r15,8), %rdx
cmpq %rax, %r15
jne 0xaf3c
leaq 0x195a(%rip), %rsi      # 0xc881
jmp 0xaf43
movq (%r13), %rdi
movq (%r14), %rax
movq (%rax), %rdx
leaq 0x1941(%rip), %rsi      # 0xc87b
jmp 0xaf43
leaq 0x1943(%rip), %rsi      # 0xc886
xorl %eax, %eax
callq 0x2450
cmpl %ebp, %ebx
jle 0xaf69
movl 0xc(%rsp), %r12d
subl %ebp, %r12d
movl $0x20, %edi
callq 0x20d0
decl %r12d
cmpl $0x1, %r12d
ja 0xaf56
testq %r15, %r15
je 0xaf95
movl 0x8(%r14), %eax
decl %eax
cmpq %rax, %r15
jne 0xaf9e
movq (%r13), %rcx
movl $0x4, %esi
movl $0x1, %edx
leaq 0x1900(%rip), %rdi      # 0xc88e
callq 0x2410
jmp 0xafaa
leaq 0x18ef(%rip), %rdi      # 0xc88b
jmp 0xafa5
leaq 0x18ee(%rip), %rdi      # 0xc893
callq 0x2080
incq %r15
movslq 0x8(%r14), %rax
cmpq %rax, %r15
jl 0xaef2
testl %ebx, %ebx
js 0xafce
incl %ebx
movl $0x2d, %edi
callq 0x20d0
decl %ebx
jne 0xafc0
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 0x2896
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xafe4