// File: /workspace/github_c_makefile_star2_O0/sasairc[P]yasuna/src/libbenly/src/string.c
// Function: str_to_args
char** str_to_args(char* str)
{
    /*
     * # note
     *
     *  sx   : current strings array pointer
     *  xt   : temporary string array pointer
     *  ax   : args array pointer (X)
     *  ay   : args array pointer (Y)
     *  elmc : elements counter
     *  dspf : double space flag
     *  sqtf : single quote flag
     *  dqtf : double quote flag
     */
    int     i,
            ax, ay,
            elmc,
            dspf,
            sqtf,
            dqtf;

    size_t  sx, xt;

    char**  args    = NULL;
    
    /* count elements */
    for (i = dspf = sqtf = dqtf = 0, elmc = 1; str[i] != '\0'; i++) {
        if (str[i] == '\'') {
            if (sqtf == 0)
                sqtf = 1;
            else
                sqtf = 0;
        }
        if (str[i] == '\"') {
            if (dqtf == 0)
                dqtf = 1;
            else
                dqtf = 0;
        }
        if (sqtf == 1 || dqtf == 1)
            continue;

        if (str[i] == ' ' || str[i] == '\t') {
            if (dspf == 1)
                continue;
            elmc++;
        } else {
            dspf = 0;
        }
    }
    if (elmc > 0) {
        if ((args = (char**)
                    malloc(sizeof(char*) * (elmc + 1))) == NULL)
            return NULL;
    } else {
        return NULL;
    }

    /* string to args */
    for (dspf = sqtf = dqtf = sx = ay = ax = xt = 0; sx <= strlen(str); sx++) {
        if (str[sx] == ' ' || str[sx] == '\t' || str[sx] == '\0' || str[sx] == '\'' || str[sx] == '\"') {
            if (str[sx] == '\'') {
                if (sqtf == 0) {
                    xt++;
                    sqtf = 1;
                } else {
                    sqtf = 0;
                }
            }
            if (str[sx] == '\"') {
                if (dqtf == 0) {
                    xt++;
                    dqtf = 1;
                } else {
                    dqtf = 0;
                }
            }
            if (sqtf == 1 || dqtf == 1)
                continue;

            if (dspf == 1) {
                xt++;
                continue;
            }
            if ((args[ay] = (char*)
                        malloc(sizeof(char) * (sx - xt + 1))) == NULL)
                goto ERR;

            for (ax = 0; xt < sx; xt++, ax++)
                    args[ay][ax] = str[xt];

            args[ay][ax] = '\0';
            xt++;
            ay++;
            dspf = 1;
        } else {
            dspf = 0;
        }
    }
    /* null-terminated */
    args[elmc] = NULL;

#ifdef  DEBUG
    fprintf(stderr, "DEBUG: str_to_args(): args(%p)\n", args);
    for (i = 0; i <= elmc; i++)
        fprintf(stderr, "DEBUG: str_to_args(): args[%d](%p) = %s\n", i, args[i], args[i]);
/* DEBUG */
#endif

    return args;


ERR:
    for (i = 0; i < elmc; i++) {
        if (args[i] != NULL) {
            free(args[i]);
            args[i] = NULL;
        }
    }
    free(args);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x1, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x1b78
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
jne 0x1af5
cmpl $0x0, -0x28(%rbp)
jne 0x1aec
movl $0x1, -0x28(%rbp)
jmp 0x1af3
movl $0x0, -0x28(%rbp)
jmp 0x1af5
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0x1b1e
cmpl $0x0, -0x2c(%rbp)
jne 0x1b15
movl $0x1, -0x2c(%rbp)
jmp 0x1b1c
movl $0x0, -0x2c(%rbp)
jmp 0x1b1e
cmpl $0x1, -0x28(%rbp)
je 0x1b2a
cmpl $0x1, -0x2c(%rbp)
jne 0x1b2c
jmp 0x1b6a
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
je 0x1b4e
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x9, %eax
jne 0x1b61
cmpl $0x1, -0x24(%rbp)
jne 0x1b56
jmp 0x1b6a
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1b68
movl $0x0, -0x24(%rbp)
jmp 0x1b6a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1ab7
cmpl $0x0, -0x20(%rbp)
jle 0x1ba9
movl -0x20(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1090
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x1ba7
movq $0x0, -0x8(%rbp)
jmp 0x1e2a
jmp 0x1bb6
movq $0x0, -0x8(%rbp)
jmp 0x1e2a
movq $0x0, -0x40(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1070
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
ja 0x1db3
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
je 0x1c63
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x9, %eax
je 0x1c63
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x1c63
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
je 0x1c63
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0x1d99
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
jne 0x1c98
cmpl $0x0, -0x28(%rbp)
jne 0x1c8f
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movl $0x1, -0x28(%rbp)
jmp 0x1c96
movl $0x0, -0x28(%rbp)
jmp 0x1c98
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0x1ccd
cmpl $0x0, -0x2c(%rbp)
jne 0x1cc4
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0x1ccb
movl $0x0, -0x2c(%rbp)
jmp 0x1ccd
cmpl $0x1, -0x28(%rbp)
je 0x1cd9
cmpl $0x1, -0x2c(%rbp)
jne 0x1cde
jmp 0x1da2
cmpl $0x1, -0x24(%rbp)
jne 0x1cf5
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1da2
movq -0x38(%rbp), %rdi
subq -0x40(%rbp), %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1090
movq -0x48(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x1d21
jmp 0x1dcd
movl $0x0, -0x18(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x1d67
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1d28
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl $0x1, -0x24(%rbp)
jmp 0x1da0
movl $0x0, -0x24(%rbp)
jmp 0x1da2
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1be9
movq -0x48(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1e2a
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1e19
movq -0x48(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x1e0c
movq -0x48(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1030
movq -0x48(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x1e0e
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1dd4
movq -0x48(%rbp), %rdi
callq 0x1030
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)