// File: /workspace/github_c_makefile_star2_O0/sasairc[P]yasuna/src/libbenly/src/column.c
// Function: mbstrlen_with_regex
static
int mbstrlen_with_regex(char* src, regex_t* reg)
{
    int         ch      = 0,
                len     = 0;

    char*       p       = src;

#ifdef  WITH_GLIB
    gunichar*   cpoints;
/* WITH_GLIB */
#endif

    regmatch_t  match;

    setlocale(LC_CTYPE, LOCALE);

    while (*p != '\0') {
        /* get string length */
        if ((ch = mblen(p, MB_CUR_MAX)) < 0)
            return 0;

#ifdef  WITH_GLIB
        /*
         * true : multi byte
         * false: ascii
         */
        if (ch > 1) {
            /* get unicode code point */
            cpoints = g_utf8_to_ucs4_fast(p, sizeof(*p), NULL);
            /*
             * # multi byte
             * true : hankaku kana
             * false: other
             */
            if ((*cpoints >= 0xff65 && *cpoints <= 0xff9f) ||
                    *cpoints == 0x001b) {
                len++;
            } else {
                len += 2;
            }
            g_free(cpoints);
        } else {
            len++;
        }
#else
        /*
         * true : multi byte
         * false: ascii
         */
        if (ch > 1) {
            len += 2;
        } else {
            len++;
        }
/* WITH_GLIB */
#endif
        /* seek offset */
        p += ch;
    }

    /* regex match */
    while (regexec(reg, src, 1, &match, 0) != REG_NOMATCH) {
        src += match.rm_eo;
        len -= match.rm_eo - match.rm_so;
    }

    return len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
xorl %edi, %edi
leaq 0xa12(%rip), %rsi       # 0x2011
callq 0x10d0
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x16bc
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
callq 0x1080
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x1050
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jge 0x1641
movl $0x0, -0x4(%rbp)
jmp 0x1703
cmpl $0x1, -0x1c(%rbp)
jle 0x169d
movq -0x28(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x10e0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0xff65, (%rax)         # imm = 0xFF65
jb 0x1675
movq -0x30(%rbp), %rax
cmpl $0xff9f, (%rax)         # imm = 0xFF9F
jbe 0x167e
movq -0x30(%rbp), %rax
cmpl $0x1b, (%rax)
jne 0x1689
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1692
movl -0x20(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1060
jmp 0x16a6
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x28(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x1604
jmp 0x16be
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
leaq -0x38(%rbp), %rcx
xorl %r8d, %r8d
callq 0x10c0
cmpl $0x1, %eax
je 0x16fd
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movl -0x34(%rbp), %ecx
subl -0x38(%rbp), %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
jmp 0x16be
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq