// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %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 0x2dd2
btq %rdx, %rax
jb 0x2df8
btq %rdx, %rcx
jb 0x2ddc
cmpl $0x7c, %edx
je 0x2df8
incq %r14
jmp 0x2dbb
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 0x302b
movq %rax, %r13
movslq %r14d, %r14
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2460
movb $0x0, (%r13,%r14)
movq %r13, %rdi
callq 0x2cf2
xorl %edx, %edx
movl $0x1, %eax
movq %r13, %rcx
xorl %esi, %esi
movl %esi, %r8d
movzbl (%rcx), %edi
cmpl $0x27, %edi
je 0x2e4c
testl %edi, %edi
jne 0x2e56
jmp 0x2e81
xorl %esi, %esi
testl %edx, %edx
sete %sil
movl %esi, %edx
xorl %esi, %esi
testl %r8d, %r8d
sete %sil
cmpl $0x22, %edi
cmovnel %r8d, %esi
cmpl $0x1, %edx
je 0x2e7c
cmpl $0x1, %esi
je 0x2e7c
cmpl $0x20, %edi
je 0x2e7a
cmpl $0x9, %edi
jne 0x2e7c
incl %eax
incq %rcx
jmp 0x2e3b
xorl %r12d, %r12d
testl %eax, %eax
jle 0x3072
movl %eax, %eax
movq %rax, 0x28(%rsp)
leaq 0x8(,%rax,8), %rdi
callq 0x20e0
xorl %r14d, %r14d
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3072
movq %r15, 0x18(%rsp)
movl %ebp, (%rsp)
movq %r13, %rdi
callq 0x21b0
movabsq $0x8500000201, %r9      # imm = 0x8500000201
xorl %r11d, %r11d
xorl %r12d, %r12d
xorl %r8d, %r8d
xorl %ecx, %ecx
xorl %r10d, %r10d
movq %r13, 0x10(%rsp)
movq %rax, 0x20(%rsp)
movzbl (%r13,%r12), %esi
xorl %edx, %edx
cmpq $0x27, %rsi
ja 0x2ffe
btq %rsi, %r9
jae 0x2ffe
xorl %edx, %edx
testl %r8d, %r8d
sete %dl
cmpb $0x27, %sil
sete %dil
cmovel %edx, %r8d
andb %dil, %dl
movzbl %dl, %r15d
leaq (%r11,%r15), %rdx
xorl %edi, %edi
testl %r14d, %r14d
sete %dil
cmpb $0x22, %sil
sete %sil
cmovel %edi, %r14d
andb %sil, %dil
movzbl %dil, %ebp
leaq (%rdx,%rbp), %rbx
cmpl $0x1, %r8d
je 0x2f5f
cmpl $0x1, %r14d
je 0x2f5f
cmpl $0x1, %ecx
jne 0x2f69
incq %rbx
xorl %r8d, %r8d
movl $0x1, %edx
xorl %r14d, %r14d
jmp 0x2f61
movl %ecx, %edx
movq %rbx, %r11
jmp 0x2ffe
movq %r11, 0x30(%rsp)
addq %rbp, %rdx
movq %r12, %r13
subq %rdx, %r13
leaq 0x1(%r13), %rdi
movl %r10d, 0x4(%rsp)
callq 0x20e0
movl 0x4(%rsp), %r10d
movq %rax, %r14
movslq %r10d, %rax
movq 0x8(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
testq %r14, %r14
je 0x3033
cmpq %r12, %rbx
jae 0x2fcf
movq 0x30(%rsp), %rsi
addq 0x10(%rsp), %rsi
addq %rbp, %rsi
addq %r15, %rsi
movq %r14, %rdi
movq %r13, %rdx
callq 0x2460
movl 0x4(%rsp), %r10d
movl %r13d, %ecx
movq %r12, %rbx
jmp 0x2fd1
xorl %ecx, %ecx
movq 0x20(%rsp), %rax
movabsq $0x8500000201, %r9      # imm = 0x8500000201
movb $0x0, (%r14,%rcx)
incq %rbx
incl %r10d
xorl %r8d, %r8d
movl $0x1, %edx
xorl %r14d, %r14d
movq %rbx, %r11
movq 0x10(%rsp), %r13
incq %r12
movl %edx, %ecx
cmpq %rax, %r12
jbe 0x2ee3
movq 0x8(%rsp), %rcx
movq 0x28(%rsp), %rax
movq $0x0, (%rcx,%rax,8)
movl (%rsp), %ebp
movq 0x18(%rsp), %r15
xorl %r12d, %r12d
jmp 0x3074
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x3088
xorl %ebx, %ebx
movl (%rsp), %ebp
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r13
xorl %r12d, %r12d
movq 0x8(%rsp), %r14
movq (%r14,%rbx,8), %rdi
testq %rdi, %rdi
je 0x3060
callq 0x21a0
movq $0x0, (%r14,%rbx,8)
incq %rbx
cmpq %rbx, 0x28(%rsp)
jne 0x304a
movq %r14, %rdi
callq 0x21a0
xorl %ecx, %ecx
movq (%r15), %rax
movq %rcx, 0x8(%rax)
movq (%r15), %rax
movl %ebp, (%rax)
movq %r13, %rdi
callq 0x21a0
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq