// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/sentinel.c
// Function: sentinelScheduleScriptExecution
void sentinelScheduleScriptExecution(char *path, ...) {
    va_list ap;
    char *argv[SENTINEL_SCRIPT_MAX_ARGS+1];
    int argc = 1;
    sentinelScriptJob *sj;

    va_start(ap, path);
    while(argc < SENTINEL_SCRIPT_MAX_ARGS) {
        argv[argc] = va_arg(ap,char*);
        if (!argv[argc]) break;
        argv[argc] = sdsnew(argv[argc]); /* Copy the string. */
        argc++;
    }
    va_end(ap);
    argv[0] = sdsnew(path);

    sj = zmalloc(sizeof(*sj));
    sj->flags = SENTINEL_SCRIPT_NONE;
    sj->retry_num = 0;
    sj->argv = zmalloc(sizeof(char*)*(argc+1));
    sj->start_time = 0;
    sj->pid = 0;
    memcpy(sj->argv,argv,sizeof(char*)*(argc+1));

    listAddNodeTail(sentinel.scripts_queue,sj);

    /* Remove the oldest non running script if we already hit the limit. */
    if (listLength(sentinel.scripts_queue) > SENTINEL_SCRIPT_MAX_QUEUE) {
        listNode *ln;
        listIter li;

        listRewind(sentinel.scripts_queue,&li);
        while ((ln = listNext(&li)) != NULL) {
            sj = ln->value;

            if (sj->flags & SENTINEL_SCRIPT_RUNNING) continue;
            /* The first node is the oldest as we add on tail. */
            listDelNode(sentinel.scripts_queue,ln);
            sentinelReleaseScriptJob(sj);
            break;
        }
        serverAssert(listLength(sentinel.scripts_queue) <=
                    SENTINEL_SCRIPT_MAX_QUEUE);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x170, %rsp            # imm = 0x170
movq %rdi, %r14
leaq 0xc0(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x6aaa4
movaps %xmm0, 0xf0(%rsp)
movaps %xmm1, 0x100(%rsp)
movaps %xmm2, 0x110(%rsp)
movaps %xmm3, 0x120(%rsp)
movaps %xmm4, 0x130(%rsp)
movaps %xmm5, 0x140(%rsp)
movaps %xmm6, 0x150(%rsp)
movaps %xmm7, 0x160(%rsp)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rsp)
leaq 0x190(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
pushq $0x10
popq %rbx
cmpq $0x88, %rbx
je 0x6ab14
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x6aae9
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x6aaf7
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdi
movq %rdi, 0x28(%rsp,%rbx)
testq %rdi, %rdi
je 0x6ab14
callq 0x3115a
movq %rax, 0x28(%rsp,%rbx)
addq $0x8, %rbx
jmp 0x6aac7
movq %r14, %rdi
callq 0x3115a
leaq 0x30(%rsp), %r14
movq %rax, (%r14)
pushq $0x20
popq %rdi
callq 0x327b9
movq %rax, %r15
andq $0x0, (%rax)
movq %rbx, %rdi
callq 0x327b9
movq %rax, 0x8(%r15)
andq $0x0, 0x10(%r15)
andl $0x0, 0x18(%r15)
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x26c50
movq 0xa3bd2(%rip), %rdi     # 0x10e730
movq %r15, %rsi
callq 0x26ecc
movq 0xa3bc3(%rip), %rdi     # 0x10e730
cmpq $0x101, 0x28(%rdi)      # imm = 0x101
jb 0x6abc3
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2702c
movq %rbx, %rdi
callq 0x27046
testq %rax, %rax
je 0x6abb2
movq 0x10(%rax), %r14
testb $0x1, (%r14)
jne 0x6ab84
movq 0xa3b8e(%rip), %rdi     # 0x10e730
movq %rax, %rsi
callq 0x26fa8
movq %r14, %rdi
callq 0x6abf0
movq 0xa3b77(%rip), %rax     # 0x10e730
cmpq $0x101, 0x28(%rax)      # imm = 0x101
jae 0x6abd0
addq $0x170, %rsp            # imm = 0x170
popq %rbx
popq %r14
popq %r15
retq
leaq 0x52386(%rip), %rdi     # 0xbcf5d
leaq 0x522be(%rip), %rsi     # 0xbce9c
movl $0x2c5, %edx            # imm = 0x2C5
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0