// File: /workspace/github_c_makefile_star2_O0/sasairc[P]clangsay/src/libbenly/src/proc.c
// Function: set_cmd_argv_proc
static
int set_cmd_argv_proc(PROC** proc, char* const argv[])
{
    int     i       = 0,
            status  = 0;

    size_t  len     = 0;

    if ((*proc)->argv != NULL) {
        release_argv_proc(*proc);
        (*proc)->argc = 0;
        (*proc)->argv = NULL;
    }

    while (*(argv + (*proc)->argc) != NULL)
        (*proc)->argc++;

    if (((*proc)->argv = (char**)
            malloc(sizeof(char*) * ((*proc)->argc + 1))) == NULL) {
        status = -1; goto ERR;
    }
    while (i < (*proc)->argc) {
        len = strlen(*(argv + i));
        if ((*((*proc)->argv + i) = (char*)
                    malloc(sizeof(char) * (len + 1))) == NULL) {
            status = -2; goto ERR;
        }
        memcpy(*((*proc)->argv + i), *(argv + i), len);
        *(*((*proc)->argv + i) + len) = '\0';
        i++;
    }
    *((*proc)->argv + (*proc)->argc) = NULL;

    return 0;

ERR:
    switch (status) {
        case    -1:
        case    -2:
            break;
        case    -3:
            release_argv_proc(*proc);
            (*proc)->argc = 0;
            (*proc)->argv = NULL;
            break;
    }

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x689d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x75e0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0x4(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x8(%rax)
jmp 0x689f
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movslq 0x4(%rcx), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x68c7
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
jmp 0x689f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x20e0
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x68fd
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
jmp 0x69d2
jmp 0x68ff
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x69ab
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2190
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x20e0
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x695a
movl $0xfffffffe, -0x20(%rbp) # imm = 0xFFFFFFFE
jmp 0x69d2
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x28(%rbp), %rdx
callq 0x2410
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x68ff
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movslq 0x4(%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
jmp 0x6a1d
movl -0x20(%rbp), %eax
movl %eax, -0x2c(%rbp)
subl $-0x3, %eax
je 0x69ee
jmp 0x69df
movl -0x2c(%rbp), %eax
addl $0x2, %eax
subl $0x1, %eax
ja 0x6a17
jmp 0x69ec
jmp 0x6a17
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x75e0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0x4(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x8(%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)