// File: /workspace/github_c_makefile_star2_O3/sasairc[P]clangsay/src/libbenly/src/cmd.c
// Function: set_cmd_val
int set_cmd_val(char* str, int type, cmd_t** cmd)
{
    int     len = 0;

    char*   tmp = NULL,
        *   bak = str;

    while ( *str != ';'     &&
            *str != '|'     &&
            *str != '&'     &&
            *str != '<'     &&
            *str != '>'     &&
            *str != '\0'    &&
            *str != '\n') {
        str++;
        len++;
    }
    if ((*str == '>' || *str == '<')
            && isdigit(*(str - 1)))
        len--;

    str = bak;
    if ((tmp = (char*)
                malloc(sizeof(char) * (len + 1))) == NULL)
        return -1;

    memcpy(tmp, str, len);
    tmp[len] = '\0';
    trim(tmp);

    (*cmd)->args = str_to_args(tmp);
    (*cmd)->type = type;
    free(tmp);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
xorl %r14d, %r14d
movabsq $0x800004000000401, %rax # imm = 0x800004000000401
movabsq $0x5000000000000000, %rcx # imm = 0x5000000000000000
movzbl (%rbx,%r14), %edx
cmpq $0x3e, %rdx
ja 0x2d67
btq %rdx, %rax
jb 0x2d8d
btq %rdx, %rcx
jb 0x2d71
cmpl $0x7c, %edx
je 0x2d8d
incq %r14
jmp 0x2d50
callq 0x21e0
movq (%rax), %rax
movsbq -0x1(%rbx,%r14), %rcx
movzwl (%rax,%rcx,2), %eax
shll $0x4, %eax
cwtl
sarl $0xf, %eax
addl %eax, %r14d
leal 0x1(%r14), %eax
movslq %eax, %rdi
callq 0x20e0
testq %rax, %rax
je 0x2fe5
movslq %r14d, %r14
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, 0x8(%rsp)
callq 0x2470
movq 0x8(%rsp), %rax
movb $0x0, (%rax,%r14)
movq 0x8(%rsp), %rdi
callq 0x2c7b
movq 0x8(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %eax
movq %rdi, %rcx
xorl %esi, %esi
movl %esi, %r8d
movzbl (%rcx), %r9d
cmpl $0x27, %r9d
je 0x2df1
testl %r9d, %r9d
jne 0x2dfb
jmp 0x2e29
xorl %esi, %esi
testl %edx, %edx
sete %sil
movl %esi, %edx
xorl %esi, %esi
testl %r8d, %r8d
sete %sil
cmpl $0x22, %r9d
cmovnel %r8d, %esi
cmpl $0x1, %edx
je 0x2e24
cmpl $0x1, %esi
je 0x2e24
cmpl $0x20, %r9d
je 0x2e22
cmpl $0x9, %r9d
jne 0x2e24
incl %eax
incq %rcx
jmp 0x2ddd
xorl %ebx, %ebx
testl %eax, %eax
jle 0x2fec
movl %eax, %r12d
leaq 0x8(,%r12,8), %rdi
callq 0x20e0
xorl %r14d, %r14d
testq %rax, %rax
je 0x2ff0
movq %r12, 0x20(%rsp)
movq %rax, 0x18(%rsp)
movq %r15, 0x28(%rsp)
movl %ebp, 0x10(%rsp)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x21b0
movq %rbx, %rdi
movabsq $0x8500000201, %r10     # imm = 0x8500000201
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %r9d, %r9d
xorl %ecx, %ecx
xorl %r11d, %r11d
movq %rax, 0x30(%rsp)
movzbl (%rdi,%r12), %esi
xorl %edx, %edx
cmpq $0x27, %rsi
ja 0x2fb8
btq %rsi, %r10
jae 0x2fb8
xorl %edx, %edx
testl %r9d, %r9d
sete %dl
cmpb $0x27, %sil
sete %r8b
cmovel %edx, %r9d
andb %r8b, %dl
movzbl %dl, %r15d
movq %r13, 0x40(%rsp)
leaq (%r15,%r13), %rbp
xorl %edx, %edx
testl %r14d, %r14d
sete %dl
cmpb $0x22, %sil
sete %sil
cmovel %edx, %r14d
andb %sil, %dl
movzbl %dl, %ebx
leaq (%rbx,%rbp), %r13
cmpl $0x1, %r9d
je 0x2f05
cmpl $0x1, %r14d
je 0x2f05
cmpl $0x1, %ecx
jne 0x2f0c
incq %r13
jmp 0x2fad
movl %ecx, %edx
jmp 0x2fb8
leaq 0x1(%r12), %rdi
addq %rbx, %rbp
movq %rdi, 0x38(%rsp)
subq %rbp, %rdi
movl %r11d, 0x14(%rsp)
callq 0x20e0
movl 0x14(%rsp), %r11d
movq %rax, %r14
movslq %r11d, %rax
movq 0x18(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
testq %r14, %r14
je 0x3019
cmpq %r12, %r13
jae 0x2f8c
movq 0x40(%rsp), %rsi
addq 0x8(%rsp), %rsi
addq %rbx, %rsi
addq %r15, %rsi
movq %r12, %r13
subq %rbp, %r13
movq %r14, %rdi
movq %r13, %rdx
callq 0x2470
movl 0x14(%rsp), %r11d
movq 0x8(%rsp), %rdi
movl %r13d, %ecx
movq 0x30(%rsp), %rax
movabsq $0x8500000201, %r10     # imm = 0x8500000201
movq 0x38(%rsp), %r13
jmp 0x2fa5
incq %r13
xorl %ecx, %ecx
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rax
movabsq $0x8500000201, %r10     # imm = 0x8500000201
movb $0x0, (%r14,%rcx)
incl %r11d
xorl %r9d, %r9d
movl $0x1, %edx
xorl %r14d, %r14d
incq %r12
movl %edx, %ecx
cmpq %rax, %r12
jbe 0x2e8f
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq $0x0, (%rcx,%rax,8)
movl 0x10(%rsp), %ebp
movq 0x28(%rsp), %r15
xorl %ebx, %ebx
jmp 0x2ff7
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3008
xorl %ecx, %ecx
jmp 0x2ff7
xorl %ecx, %ecx
movq 0x8(%rsp), %rdi
movq (%r15), %rax
movq %rcx, 0x8(%rax)
movq (%r15), %rax
movl %ebp, (%rax)
callq 0x21a0
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
movl 0x10(%rsp), %ebp
movq 0x28(%rsp), %r15
movq 0x18(%rsp), %r14
movq 0x20(%rsp), %r12
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x3044
callq 0x21a0
movq $0x0, (%r14,%rbx,8)
incq %rbx
cmpq %rbx, %r12
jne 0x302e
movq %r14, %rdi
callq 0x21a0
xorl %ecx, %ecx
movq 0x8(%rsp), %rdi
jmp 0x2fe1