// File: /workspace/github_c_makefile_star2_O0/sasairc[P]clangsay/src/libbenly/src/typestring.c
// Function: mbrindex
static
int mbrindex(STRING* self, char* const str, size_t pos, size_t* idx)
{
    int     ch      = 0;

    size_t  off     = 0,
            len     = 0;

    char*   p       = NULL;

    if (self->empty(self))
        return (status = ESTRISEMPTY);
    if (str == NULL || idx == NULL)
        return (status = EARGISNULPTR);
    if (!mb_is_in_range(self, pos))
        return (status = EOUTOFRANGE);

    len = strlen(str);
    *idx = self->mblen(self) - 1;
    p = self->c_str(self) + self->size(self) - 1;
    setlocale(LC_CTYPE, T_STRING_LOCALE_VALUE);
    while (off < self->size(self)) {
        while (mblen(p, MB_CUR_MAX) < 0 && p--)
            off++;
        if ((ch = mblen(p, MB_CUR_MAX)) < 0) {
#ifdef  LIBRARY_VERBOSE
            print_error();
/* LIBRARY_VERBOSE */
#endif
            return (status = EINVALIDCHAR);
        }
        if (pos)
            pos--;
        else if (memcmp(p, str, len) == 0)
            return 0;
        off++;
        p--;
        (*idx)--;
    }
    /* not found */
    *idx = 0;

    return (status = ESTRNOTFOUND);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
cmpl $0x0, %eax
je 0xdbf6
leaq 0x9664(%rip), %rax      # 0x17248
movl $0xfffffffc, (%rax)     # imm = 0xFFFFFFFC
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0xddeb
cmpq $0x0, -0x18(%rbp)
je 0xdc04
cmpq $0x0, -0x28(%rbp)
jne 0xdc1d
leaq 0x963d(%rip), %rax      # 0x17248
movl $0xfffffffb, (%rax)     # imm = 0xFFFFFFFB
movl $0xfffffffb, -0x4(%rbp) # imm = 0xFFFFFFFB
jmp 0xddeb
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xf4a0
cmpl $0x0, %eax
jne 0xdc48
leaq 0x9612(%rip), %rax      # 0x17248
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xddeb
movq -0x18(%rbp), %rdi
callq 0x2190
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
subq $0x1, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
movq -0x50(%rbp), %rax
addq %rcx, %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
xorl %edi, %edi
leaq 0x486d(%rip), %rsi      # 0x1251c
callq 0x23d0
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movq %rax, %rcx
movq -0x58(%rbp), %rax
cmpq %rcx, %rax
jae 0xddcc
jmp 0xdcdc
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
callq 0x21b0
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x22e0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x59(%rbp)
jge 0xdd1a
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x48(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0xdd23
jmp 0xdd31
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xdcdc
movq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x21b0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x22e0
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
jge 0xdd6b
leaq 0x94ef(%rip), %rax      # 0x17248
movl $0xfffffffe, (%rax)     # imm = 0xFFFFFFFE
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0xddeb
cmpq $0x0, -0x20(%rbp)
je 0xdd80
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xdda1
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x2380
cmpl $0x0, %eax
jne 0xdd9f
movl $0x0, -0x4(%rbp)
jmp 0xddeb
jmp 0xdda1
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $-0x1, %rcx
movq %rcx, (%rax)
jmp 0xdcb4
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
leaq 0x946a(%rip), %rax      # 0x17248
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
movl $0xfffffffa, -0x4(%rbp) # imm = 0xFFFFFFFA
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)