// File: /workspace/github_c_makefile_star2_O0/adsr[P]phpspy/pgrep.c
// Function: pgrep_for_pids
static void pgrep_for_pids() {
    FILE *pcmd;
    char *pgrep_cmd;
    char line[64];
    int pid;
    int found;
    struct timespec timeout;
    if (asprintf(&pgrep_cmd, "pgrep %s", opt_pgrep_args) < 0) {
        errno = ENOMEM;
        perror("asprintf");
        exit(1);
    }
    while (!done) {
        if (wait_for_turn('p')) break;
        found = 0;
        if ((pcmd = popen(pgrep_cmd, "r")) != NULL) {
            while (avail_pids_count < opt_num_workers && fgets(line, sizeof(line), pcmd) != NULL) {
                if (strlen(line) < 1 || *line == '\n') continue;
                pid = atoi(line);
                if (is_already_attached(pid)) continue;
                avail_pids[avail_pids_count++] = pid;
                found += 1;
            }
            pclose(pcmd);
        }
        if (found > 0) {
            pthread_cond_broadcast(&can_consume);
        } else {
            clock_gettime(CLOCK_REALTIME, &timeout);
            timeout.tv_sec += 2;
            pthread_cond_timedwait(
                &can_produce,
                &mutex,
                &timeout
            );
        }
        pthread_mutex_unlock(&mutex);
    }
    free(pgrep_cmd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
leaq 0x12511(%rip), %rax     # 0x3c4d0
movq (%rax), %rdx
leaq -0x10(%rbp), %rdi
leaq 0xb0d2(%rip), %rsi      # 0x3509f
movb $0x0, %al
callq 0x6450
cmpl $0x0, %eax
jge 0x29ffa
callq 0x6060
movl $0xc, (%rax)
leaq 0xb621(%rip), %rdi      # 0x3560c
callq 0x6520
movl $0x1, %edi
callq 0x6580
jmp 0x29ffc
leaq 0x12541(%rip), %rax     # 0x3c544
cmpl $0x0, (%rax)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2a014
jmp 0x2a14a
movl $0x70, %edi
callq 0x2a160
cmpl $0x0, %eax
je 0x2a028
jmp 0x2a14a
movl $0x0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xa982(%rip), %rsi      # 0x349bc
callq 0x6500
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
je 0x2a0f7
jmp 0x2a04f
movl 0x1256b(%rip), %ecx     # 0x3c5c0
xorl %eax, %eax
leaq 0x102c6(%rip), %rdx     # 0x3a324
cmpl (%rdx), %ecx
movb %al, -0x69(%rbp)
jge 0x2a081
leaq -0x50(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl $0x40, %esi
callq 0x62c0
cmpq $0x0, %rax
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x2a08a
jmp 0x2a0ee
leaq -0x50(%rbp), %rdi
callq 0x6160
cmpq $0x1, %rax
jb 0x2a0a2
movsbl -0x50(%rbp), %eax
cmpl $0xa, %eax
jne 0x2a0a4
jmp 0x2a04f
leaq -0x50(%rbp), %rdi
callq 0x6570
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %edi
callq 0x2a230
cmpl $0x0, %eax
je 0x2a0bf
jmp 0x2a04f
movl -0x54(%rbp), %edx
movq 0x124ff(%rip), %rax     # 0x3c5c8
movl 0x124f1(%rip), %ecx     # 0x3c5c0
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x124e6(%rip)     # 0x3c5c0
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x2a04f
movq -0x8(%rbp), %rdi
callq 0x61c0
cmpl $0x0, -0x58(%rbp)
jle 0x2a10b
leaq 0x124cc(%rip), %rdi     # 0x3c5d0
callq 0x60a0
jmp 0x2a139
xorl %edi, %edi
leaq -0x68(%rbp), %rsi
callq 0x6110
movq -0x68(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x68(%rbp)
leaq 0x124d7(%rip), %rdi     # 0x3c600
leaq 0x12500(%rip), %rsi     # 0x3c630
leaq -0x68(%rbp), %rdx
callq 0x6490
leaq 0x124f0(%rip), %rdi     # 0x3c630
callq 0x63d0
jmp 0x29ffc
movq -0x10(%rbp), %rdi
callq 0x6050
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)