// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdi, %rbx
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 0x76d5d
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 0x1a0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movl $0x1, %r15d
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x76d9c
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x76daa
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdi
movq %rdi, 0x30(%rsp,%r15,8)
testq %rdi, %rdi
je 0x76dd0
callq 0x362b0
movq %rax, 0x30(%rsp,%r15,8)
incq %r15
cmpq $0x10, %r15
jne 0x76d83
movl $0x10, %r15d
movq %rbx, %rdi
callq 0x362b0
leaq 0x30(%rsp), %rbx
movq %rax, (%rbx)
movl $0x20, %edi
callq 0x382d1
movq %rax, %r14
xorl %r12d, %r12d
movq %r12, (%rax)
leaq 0x8(,%r15,8), %rax
movabsq $0x7fffffff8, %r15      # imm = 0x7FFFFFFF8
andq %rax, %r15
movq %r15, %rdi
callq 0x382d1
movq %rax, 0x8(%r14)
movq %r12, 0x10(%r14)
movl $0x0, 0x18(%r14)
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x26c50
movq 0x9f8fb(%rip), %rdi     # 0x116730
movq %r14, %rsi
callq 0x2b24b
movq 0x9f8ec(%rip), %rdi     # 0x116730
cmpq $0x101, 0x28(%rdi)      # imm = 0x101
jb 0x76e9a
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x2b3b7
movq %rbx, %rdi
callq 0x2b3d4
testq %rax, %rax
je 0x76e89
movq 0x10(%rax), %r14
testb $0x1, (%r14)
jne 0x76e5b
movq 0x9f8b7(%rip), %rdi     # 0x116730
movq %rax, %rsi
callq 0x2b331
movq %r14, %rdi
callq 0x76ecb
movq 0x9f8a0(%rip), %rax     # 0x116730
cmpq $0x101, 0x28(%rax)      # imm = 0x101
jae 0x76ea9
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x55461(%rip), %rdi     # 0xcc311
leaq 0x55399(%rip), %rsi     # 0xcc250
movl $0x2c5, %edx            # imm = 0x2C5
callq 0x61908
movl $0x1, %edi
callq 0x263c0