// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/bio.c
// Function: bioProcessBackgroundJobs
void *bioProcessBackgroundJobs(void *arg) {
    struct bio_job *job;
    unsigned long type = (unsigned long) arg;
    sigset_t sigset;

    /* Check that the type is within the right interval. */
    if (type >= BIO_NUM_OPS) {
        serverLog(LL_WARNING,
            "Warning: bio thread started with wrong type %lu",type);
        return NULL;
    }

    /* Make the thread killable at any time, so that bioKillThreads()
     * can work reliably. */
    pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
    pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

    pthread_mutex_lock(&bio_mutex[type]);
    /* Block SIGALRM so we are sure that only the main thread will
     * receive the watchdog signal. */
    sigemptyset(&sigset);
    sigaddset(&sigset, SIGALRM);
    if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))
        serverLog(LL_WARNING,
            "Warning: can't mask SIGALRM in bio.c thread: %s", strerror(errno));

    while(1) {
        listNode *ln;

        /* The loop always starts with the lock hold. */
        if (listLength(bio_jobs[type]) == 0) {
            pthread_cond_wait(&bio_condvar[type],&bio_mutex[type]);
            continue;
        }
        /* Pop the job from the queue. */
        ln = listFirst(bio_jobs[type]);
        job = ln->value;
        /* It is now possible to unlock the background system as we know have
         * a stand alone job structure to process.*/
        pthread_mutex_unlock(&bio_mutex[type]);

        /* Process the job accordingly to its type. */
        if (type == BIO_CLOSE_FILE) {
            close((long)job->arg1);
        } else if (type == BIO_AOF_FSYNC) {
            aof_fsync((long)job->arg1);
        } else {
            serverPanic("Wrong job type in bioProcessBackgroundJobs().");
        }
        zfree(job);

        /* Lock again before reiterating the loop, if there are no longer
         * jobs to process we'll block again in pthread_cond_wait(). */
        pthread_mutex_lock(&bio_mutex[type]);
        listDelNode(bio_jobs[type],ln);
        bio_pending[type]--;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x2, -0x18(%rbp)
jb 0x8e230
movq -0x18(%rbp), %rdx
movl $0x3, %edi
leaq 0xb6e4a(%rip), %rsi     # 0x145068
movb $0x0, %al
callq 0x2fc60
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbp
retq
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x26050
movl $0x1, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x26620
leaq 0xfecc0(%rip), %rdi     # 0x18cf10
imulq $0x28, -0x18(%rbp), %rax
addq %rax, %rdi
callq 0x26b30
leaq -0x98(%rbp), %rdi
callq 0x26ac0
leaq -0x98(%rbp), %rdi
movl $0xe, %esi
callq 0x268c0
xorl %edi, %edi
leaq -0x98(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x26170
cmpl $0x0, %eax
je 0x8e2b3
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0xb6dec(%rip), %rsi     # 0x145098
movb $0x0, %al
callq 0x2fc60
jmp 0x8e2b5
movq -0x18(%rbp), %rcx
leaq 0xfed00(%rip), %rax     # 0x18cfc0
movq (%rax,%rcx,8), %rax
cmpq $0x0, 0x28(%rax)
jne 0x8e2f0
leaq 0xfec8e(%rip), %rdi     # 0x18cf60
imulq $0x30, -0x18(%rbp), %rax
addq %rax, %rdi
leaq 0xfec2f(%rip), %rsi     # 0x18cf10
imulq $0x28, -0x18(%rbp), %rax
addq %rax, %rsi
callq 0x26990
jmp 0x8e2b5
movq -0x18(%rbp), %rcx
leaq 0xfecc5(%rip), %rax     # 0x18cfc0
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
leaq 0xfebf1(%rip), %rdi     # 0x18cf10
imulq $0x28, -0x18(%rbp), %rax
addq %rax, %rdi
callq 0x26c40
cmpq $0x0, -0x18(%rbp)
jne 0x8e344
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edi
callq 0x26180
jmp 0x8e380
cmpq $0x1, -0x18(%rbp)
jne 0x8e35c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edi
callq 0x26560
jmp 0x8e37e
leaq 0xb6d65(%rip), %rdi     # 0x1450c8
leaq 0xb6d8e(%rip), %rsi     # 0x1450f8
movl $0xbb, %edx
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x8e380
movq -0x10(%rbp), %rdi
callq 0x3afa0
leaq 0xfeb80(%rip), %rdi     # 0x18cf10
imulq $0x28, -0x18(%rbp), %rax
addq %rax, %rdi
callq 0x26b30
movq -0x18(%rbp), %rcx
leaq 0xfec18(%rip), %rax     # 0x18cfc0
movq (%rax,%rcx,8), %rdi
movq -0xa0(%rbp), %rsi
callq 0x271e0
movq -0x18(%rbp), %rcx
leaq 0xfec0d(%rip), %rax     # 0x18cfd0
movq (%rax,%rcx,8), %rdx
addq $-0x1, %rdx
leaq 0xfebfe(%rip), %rax     # 0x18cfd0
movq %rdx, (%rax,%rcx,8)
jmp 0x8e2b5
nopl (%rax,%rax)