// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/sentinel.c
// Function: sentinelRunPendingScripts
void sentinelRunPendingScripts(void) {
    listNode *ln;
    listIter li;
    mstime_t now = mstime();

    /* Find jobs that are not running and run them, from the top to the
     * tail of the queue, so we run older jobs first. */
    listRewind(sentinel.scripts_queue,&li);
    while (sentinel.running_scripts < SENTINEL_SCRIPT_MAX_RUNNING &&
           (ln = listNext(&li)) != NULL)
    {
        sentinelScriptJob *sj = ln->value;
        pid_t pid;

        /* Skip if already running. */
        if (sj->flags & SENTINEL_SCRIPT_RUNNING) continue;

        /* Skip if it's a retry, but not enough time has elapsed. */
        if (sj->start_time && sj->start_time > now) continue;

        sj->flags |= SENTINEL_SCRIPT_RUNNING;
        sj->start_time = mstime();
        sj->retry_num++;
        pid = fork();

        if (pid == -1) {
            /* Parent (fork error).
             * We report fork errors as signal 99, in order to unify the
             * reporting with other kind of errors. */
            sentinelEvent(LL_WARNING,"-script-error",NULL,
                          "%s %d %d", sj->argv[0], 99, 0);
            sj->flags &= ~SENTINEL_SCRIPT_RUNNING;
            sj->pid = 0;
        } else if (pid == 0) {
            /* Child */
            execve(sj->argv[0],sj->argv,environ);
            /* If we are here an error occurred. */
            _exit(2); /* Don't retry execution. */
        } else {
            sentinel.running_scripts++;
            sj->pid = pid;
            sentinelEvent(LL_DEBUG,"+script-child",NULL,"%ld",(long)pid);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
callq 0x2ff70
movq %rax, -0x20(%rbp)
movq 0xf7eb8(%rip), %rdi     # 0x18d060
leaq -0x18(%rbp), %rsi
callq 0x27320
xorl %eax, %eax
cmpl $0x10, 0xf7e92(%rip)    # 0x18d04c
movb %al, -0x2d(%rbp)
jge 0x951d6
leaq -0x18(%rbp), %rdi
callq 0x27380
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0x951e2
jmp 0x95310
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x951fe
jmp 0x951b1
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x95219
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x20(%rbp), %rax
jle 0x95219
jmp 0x951b1
movq -0x28(%rbp), %rax
movl (%rax), %ecx
orl $0x1, %ecx
movl %ecx, (%rax)
callq 0x2ff70
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
callq 0x26ab0
movl %eax, -0x2c(%rbp)
cmpl $-0x1, -0x2c(%rbp)
jne 0x9529f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %r8
movl $0x3, %edi
leaq 0xb0df7(%rip), %rsi     # 0x14605d
xorl %eax, %eax
movl %eax, %edx
leaq 0xb1230(%rip), %rcx     # 0x1464a1
movl $0x63, %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
movb $0x0, %al
callq 0x94990
movq -0x28(%rbp), %rax
movl (%rax), %ecx
andl $-0x2, %ecx
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x18(%rax)
jmp 0x9530b
cmpl $0x0, -0x2c(%rbp)
jne 0x952d1
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0xddce9(%rip), %rax     # 0x172fa8
movq (%rax), %rdx
callq 0x26780
movl $0x2, %edi
callq 0x263c0
movl 0xf7d75(%rip), %eax     # 0x18d04c
addl $0x1, %eax
movl %eax, 0xf7d6c(%rip)     # 0x18d04c
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x18(%rax)
movslq -0x2c(%rbp), %r8
xorl %edi, %edi
leaq 0xb0d74(%rip), %rsi     # 0x14606b
xorl %eax, %eax
movl %eax, %edx
leaq 0xa27fc(%rip), %rcx     # 0x137afe
movb $0x0, %al
callq 0x94990
jmp 0x9530b
jmp 0x951b1
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)