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

    size_t  i       = 0,
            envc    = 0,
            len     = 0;

    if ((*proc)->envp != NULL) {
        release_env_proc(*proc);
        (*proc)->envp = NULL;
    }

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

    return 0;

ERR:
    switch (status) {
        case    -1:
            break;
        case    -2:
            release_env_proc(*proc);
            (*proc)->envp = NULL;
            break;
    }

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x6a88
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7720
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x10(%rax)
jmp 0x6a8a
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x6aa7
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x6a8a
movq -0x30(%rbp), %rdi
shlq $0x3, %rdi
callq 0x20e0
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0x6ad1
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
jmp 0x6b9d
jmp 0x6ad3
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x6b7d
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2190
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x20e0
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movq -0x28(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x6b29
movl $0xfffffffe, -0x1c(%rbp) # imm = 0xFFFFFFFE
jmp 0x6b9d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x38(%rbp), %rdx
callq 0x2410
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x6ad3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
jmp 0x6bd7
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
subl $-0x2, %eax
je 0x6bb6
jmp 0x6baa
movl -0x3c(%rbp), %eax
subl $-0x1, %eax
jne 0x6bd1
jmp 0x6bb4
jmp 0x6bd1
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7720
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x10(%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq