// File: /workspace/github_c_makefile_star2_O0/adsr[P]phpspy/pgrep.c
// Function: run_signal_thread
static void *run_signal_thread(void *arg) {
    int rv, ignore;
    fd_set rfds;
    struct timeval tv;
    struct sigaction sa;

    (void)arg;

    /* Create done_pipe */
    rv = pipe(done_pipe);
    rv = fcntl(done_pipe[1], F_SETFL, O_NONBLOCK);

    /* Install signal handler */
    memset(&sa, 0, sizeof(struct sigaction));
    sa.sa_handler = handle_signal;
    sigaction(SIGINT, &sa, NULL);
    sigaction(SIGTERM, &sa, NULL);
    sigaction(SIGHUP, &sa, NULL);
    sigaction(SIGALRM, &sa, NULL);
    sa.sa_handler = SIG_IGN;
    sigaction(SIGPIPE, &sa, NULL);

    /* Wait for write on done_pipe from write_done_pipe */
    do {
        FD_ZERO(&rfds);
        FD_SET(done_pipe[0], &rfds);
        tv.tv_sec = 1;
        tv.tv_usec = 0;
        rv = select(done_pipe[0]+1, &rfds, NULL, NULL, &tv);
    } while (rv < 1);

    /* Read pipe for fun */
    rv = read(done_pipe[0], &ignore, sizeof(int));

    /* Set done flag; wake up all threads */
    done = 1;
    pthread_mutex_lock(&mutex);
    pthread_cond_broadcast(&can_consume);
    pthread_cond_broadcast(&can_produce);
    pthread_mutex_unlock(&mutex);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
leaq 0x121aa(%rip), %rdi     # 0x3be80
callq 0x6270
movl %eax, -0xc(%rbp)
movl 0x121a0(%rip), %edi     # 0x3be84
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
movb $0x0, %al
callq 0x6100
movl %eax, -0xc(%rbp)
leaq -0x138(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x6230
leaq 0x72e(%rip), %rax       # 0x2a440
movq %rax, -0x138(%rbp)
movl $0x2, %edi
leaq -0x138(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x60d0
movl $0xf, %edi
leaq -0x138(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x60d0
movl $0x1, %edi
leaq -0x138(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x60d0
movl $0xe, %edi
leaq -0x138(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x60d0
movl $0x1, %eax
movq %rax, -0x138(%rbp)
movl $0xd, %edi
leaq -0x138(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x60d0
jmp 0x29d90
leaq -0x90(%rbp), %rax
movq %rax, -0x148(%rbp)
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
cmpq $0x10, %rax
jae 0x29dda
movq -0x148(%rbp), %rax
movl -0x13c(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x29da8
jmp 0x29ddc
movl 0x1209e(%rip), %eax     # 0x3be80
movl $0x40, %ecx
cltd
idivl %ecx
movl %edx, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, %rcx
movl 0x12081(%rip), %eax     # 0x3be80
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x90(%rbp,%rax,8), %rcx
movq %rcx, -0x90(%rbp,%rax,8)
movq $0x1, -0xa0(%rbp)
movq $0x0, -0x98(%rbp)
movl 0x1204b(%rip), %edi     # 0x3be80
addl $0x1, %edi
leaq -0x90(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0xa0(%rbp), %r8
movq %rcx, %rdx
callq 0x6390
movl %eax, -0xc(%rbp)
cmpl $0x1, -0xc(%rbp)
jl 0x29d8e
movl 0x1201b(%rip), %edi     # 0x3be80
leaq -0x10(%rbp), %rsi
movl $0x4, %edx
callq 0x62a0
movl %eax, -0xc(%rbp)
leaq 0x126c7(%rip), %rax     # 0x3c544
movl $0x1, (%rax)
leaq 0x127a6(%rip), %rdi     # 0x3c630
callq 0x6600
leaq 0x1273a(%rip), %rdi     # 0x3c5d0
callq 0x60a0
leaq 0x1275e(%rip), %rdi     # 0x3c600
callq 0x60a0
leaq 0x12782(%rip), %rdi     # 0x3c630
callq 0x63d0
xorl %eax, %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nop